/* Plane Spotter — mobile web app. Colours and type from the design canvas. */
:root {
  --ink: #0F1A24; --ink2: #3B4A58; --muted: #5B6B7A;
  --line: #E3E8ED; --line2: #D5DDE5; --surface: #F5F7FA; --ground: #EEF2F5;
  --arr: #1F6FD1; --arr-text: #1556A8; --dep: #B35C00; --other: #8796A5;
  --ok: #177A4B; --ok-text: #136A40; --late: #A15C00;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: calc(64px + var(--safe-bottom) + 12px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill, .plane-svg path { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.link { background: none; border: 0; color: var(--arr); padding: 10px 4px; min-height: 44px; cursor: pointer; font-size: 16px; }
.link.strong { font-weight: 600; }
.distances .link { font-size: 12px; font-weight: 600; min-height: 32px; padding: 6px 0; }

/* Phone only: wide screens get a "open on your phone" card. */
#desktop-gate { display: none; }
@media (min-width: 700px) {
  #app { display: none; }
  body { overflow: auto; }
  #desktop-gate { display: grid; place-items: center; min-height: 100%; padding: 32px; }
}
.gate-card { max-width: 420px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 40px 32px; }
.gate-plane { width: 44px; height: 44px; color: var(--arr); fill: currentColor; stroke: none; }
.gate-card h1 { font-size: 26px; margin: 12px 0 8px; }
.gate-card p { color: var(--ink2); line-height: 1.5; margin: 0 0 16px; }
#gate-qr { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
#gate-qr svg { display: block; width: 168px; height: 168px; }
#gate-qr svg path { fill: #0F1A24; }
.gate-url { font-family: var(--mono); font-size: 13px; word-break: break-all; margin-top: 16px !important; }

/* Screens */
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; overflow: hidden; overflow: clip; } /* clip: can't be scrolled, even by focus */
.screen { isolation: isolate; } /* each screen keeps its layers to itself */
#screen-detail { z-index: 40; }
.screen.page { overflow-y: auto; background: #fff; padding: calc(var(--safe-top) + 16px) 16px calc(var(--tabbar-h) + 24px); }
.map { position: absolute; inset: 0; background: var(--ground); z-index: 0; }
.leaflet-container { font-family: var(--sans); background: var(--ground); }
.leaflet-control-attribution { font-size: 9px; }
.muted-tiles { filter: saturate(.35) brightness(1.06) contrast(.92); }

.top-bar { position: absolute; z-index: 10; left: 16px; right: 16px; top: calc(var(--safe-top) + 8px); display: flex; gap: 8px; }
.chip { flex: 1; min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(255,255,255,.95); text-align: left; cursor: pointer; }
.chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.chip-text .mono { font-size: 15px; }
.chev { width: 14px; height: 14px; margin-left: auto; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; display: inline-block; }
.dot.off { background: var(--late); }
.icon-btn { width: 48px; height: 48px; flex: none; border-radius: 14px; border: 1px solid var(--line2); background: rgba(255,255,255,.95); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }

.floating { position: absolute; z-index: 5; left: 16px; right: 16px; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; transition: top .32s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.floating.dragging { transition: none; }
.legend { display: flex; gap: 12px; align-items: center; height: 44px; padding: 0 12px; border-radius: 10px; background: rgba(255,255,255,.95); border: 1px solid var(--line2); font-size: 12px; color: var(--ink2); white-space: nowrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* The draggable panel */
.sheet { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; top: 50%; background: #fff; border-radius: 24px 24px 0 0; border-top: 1px solid var(--line2); box-shadow: 0 -8px 24px rgba(15,26,36,.08); display: flex; flex-direction: column; transition: top .32s cubic-bezier(.2,.8,.2,1); }
.sheet.dragging { transition: none; }
.sheet-grab { flex: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.handle { display: flex; justify-content: center; align-items: flex-start; width: 100%; height: 26px; padding-top: 8px; border: 0; background: none; cursor: grab; }
.handle span { width: 36px; height: 5px; border-radius: 3px; background: #C5CED7; }
.sheet.dragging .handle span { background: #8A9AA9; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 20px; }
.sheet-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.live .dot { width: 6px; height: 6px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--tabbar-h) + 16px); }
.segmented { margin: 12px 16px 8px; padding: 3px; border-radius: 12px; background: var(--ground); border: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
.segmented.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 8px; }
.segmented button { min-height: 40px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; }
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15,26,36,.15); }
.distances { display: flex; align-items: center; gap: 6px; padding: 0 20px 2px; color: var(--ink2); }
.distances svg { width: 14px; height: 14px; flex: none; }
.distances span { flex: 1; }

.flight-list { list-style: none; margin: 0; padding: 0 8px; }
.flight-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px; border-bottom: 1px solid #EDF1F4; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
.t-main { font-family: var(--mono); font-size: 15px; font-weight: 600; display: block; }
.t-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); display: block; }
.f-city { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.f-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.f-meta .mono { color: var(--ink2); }
.f-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.f-home { font-size: 11px; color: var(--ink2); display: flex; gap: 3px; align-items: center; font-variant-numeric: tabular-nums; }
.f-home svg { width: 10px; height: 10px; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 8px; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; stroke-width: 2.2; }
.pill.info { color: var(--arr-text); background: rgba(90,176,255,.14); }
.pill.ok { color: var(--ok-text); background: rgba(23,122,75,.12); }
.pill.gray { color: var(--ink2); background: #E8EEF4; }
.f-mid .pill { margin-top: 4px; }

/* Map markers */
.plane-marker { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 76px; margin-left: -38px; margin-top: -11px; cursor: pointer; }
.plane-svg { width: 22px; height: 22px; display: block; }
.plane-label { font-family: var(--mono); font-size: 9.5px; line-height: 1.15; text-align: center; background: rgba(238,242,245,.85); border-radius: 3px; padding: 0 3px; }
.plane-label b { display: block; font-weight: 600; }
.plane-label span { color: var(--ink2); }
.home-pin { width: 26px; height: 26px; margin: -26px 0 0 -13px; }
.airport-pin { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--muted); color: #fff; display: grid; place-items: center; }
.airport-pin svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.endpoint { font-family: var(--mono); font-weight: 600; font-size: 12px; display: flex; flex-direction: column; align-items: center; width: 50px; margin: -6px 0 0 -25px; }
.endpoint i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; background: var(--ground); }

/* Tab bar: a floating pill sitting on the white panel */
.tabbar { position: absolute; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 8px); width: min(340px, calc(100% - 32px)); height: 64px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px; border-radius: 32px; background: rgba(255,255,255,.9); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--line2); box-shadow: 0 6px 24px rgba(15,26,36,.12); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 28px; color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: var(--arr); background: rgba(15,26,36,.06); font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; }
.badge-wrap { position: relative; display: flex; }
.badge { position: absolute; top: -4px; right: -12px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #E5484D; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
body.detail-open .tabbar { display: none; }

/* Pages: From home and Settings */
h1.large { font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin: 8px 0 4px; }
.sub { margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.compass-card { padding: 8px 0 4px; margin-bottom: 16px; }
#compass { width: 100%; height: auto; display: block; }
.section { margin: 20px 0 6px; padding: 0 4px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
.section small { font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.room-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px; margin-bottom: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; cursor: pointer; }
.room-row strong { font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-row .small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.late { color: var(--late); font-weight: 600; }
.early { color: var(--ok); font-weight: 600; }
.footnote { font-size: 12px; color: var(--muted); margin: 6px 4px 0; line-height: 1.45; }

.group { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.screen.page .group { background: var(--surface); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 14px; border: 0; border-bottom: 1px solid #EDF1F4; background: none; text-align: left; }
.row:last-child { border-bottom: 0; }
.row.nav { cursor: pointer; }
.row-icon { width: 32px; height: 32px; border-radius: 9px; background: #E8EEF4; display: grid; place-items: center; flex: none; }
.row-icon svg { width: 18px; height: 18px; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.row-text strong { font-size: 15px; }
.row-text .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev-r { width: 16px; height: 16px; color: #9AA8B5; stroke-width: 2.4; flex: none; }
.switch { position: relative; width: 51px; height: 31px; flex: none; border-radius: 16px; border: 0; padding: 0; background: #C5CED7; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(15,26,36,.25); transition: left .2s; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { left: 22px; }
.switch:disabled { opacity: .45; cursor: default; }

/* Plane details */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 12px; }
.detail-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.detail-head p { margin: 2px 0 0; font-size: 13px; }
.detail-body { padding: 4px 16px calc(var(--safe-bottom) + 32px); display: flex; flex-direction: column; gap: 16px; }
.route-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.route-ends { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.code { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1.15; display: block; }
.route-ends .small { font-size: 13px; }
.progress { position: relative; height: 20px; }
.progress .track { position: absolute; top: 9px; left: 0; right: 0; height: 2px; background: var(--line2); border-radius: 1px; }
.progress .done { position: absolute; top: 9px; left: 0; height: 2px; background: var(--arr); border-radius: 1px; }
.progress svg { position: absolute; top: 1px; width: 18px; height: 18px; color: var(--arr); fill: currentColor; stroke: none; transform: rotate(90deg); }
.route-km { text-align: center; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); }
.status-line .dot { width: 6px; height: 6px; }
.home-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.home-box svg { width: 18px; height: 18px; flex: none; }
.home-box .km { font-family: var(--mono); font-size: 17px; font-weight: 600; margin-left: auto; white-space: nowrap; }
.photo { width: 100%; height: 196px; object-fit: cover; border-radius: 18px; display: block; background: var(--surface); }
.photo-ph { height: 196px; border-radius: 18px; border: 1px dashed #C5CED7; background: repeating-linear-gradient(135deg, #F2F5F8 0 12px, #E9EEF2 12px 24px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; text-align: center; padding: 0 16px; }
.photo-ph svg { width: 28px; height: 28px; stroke-width: 1.6; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.grid3 > div { background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.grid3 .lbl { font-size: 11px; color: var(--muted); }
.grid3 .val { font-family: var(--mono); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid3 .hint { font-size: 11px; color: var(--muted); }

/* Modal sheets */
.modal { position: absolute; inset: 0; z-index: 50; background: rgba(15,26,36,.32); display: flex; align-items: flex-end; }
.modal-sheet { width: 100%; height: calc(100% - var(--safe-top) - 12px); background: #fff; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .28s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
.modal-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 12px 0; }
.modal-bar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-bar > :last-child { justify-self: end; }
.modal-body { flex: 1; overflow-y: auto; padding: 4px 16px calc(var(--safe-bottom) + 32px); }
.search { display: flex; align-items: center; gap: 8px; height: 46px; margin: 8px 16px 4px; padding: 0 12px; border-radius: 12px; background: var(--ground); color: var(--muted); }
.modal-body .search { margin: 0 0 8px; }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ink); outline: none; }
.suggestions { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.suggestions:empty { display: none; }
.suggestions button { display: block; width: 100%; min-height: 52px; padding: 6px 14px; border: 0; border-bottom: 1px solid #EDF1F4; background: #fff; text-align: left; cursor: pointer; }
.suggestions strong { display: block; font-size: 15px; font-weight: 500; }
.suggestions .small { color: var(--muted); }
.wide-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); color: var(--arr); font-weight: 600; font-size: 15px; cursor: pointer; margin-bottom: 8px; }
.wide-btn svg { width: 18px; height: 18px; }
.mini-map { height: 150px; border-radius: 14px; border: 1px solid var(--line); overflow: hidden; position: relative; z-index: 0; }
.ap-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 14px; border: 0; border-bottom: 1px solid #EDF1F4; background: #fff; text-align: left; cursor: pointer; }
.ap-row[aria-pressed="true"] { background: rgba(31,111,209,.08); }
.ap-row .row-text b { font-family: var(--mono); font-size: 16px; margin-right: 8px; }
.ap-row .km { font-family: var(--mono); font-size: 13px; color: var(--ink2); }
.ap-row .check { width: 20px; height: 20px; color: var(--arr); stroke-width: 2.6; visibility: hidden; }
.ap-row[aria-pressed="true"] .check { visibility: visible; }
.room-edit { padding: 12px 14px; border-bottom: 1px solid #EDF1F4; }
.room-edit input { width: 100%; border: 0; font: inherit; font-size: 15px; font-weight: 600; background: transparent; padding: 4px 0 8px; outline: none; }
.room-edit .segmented { margin: 0; }
.room-edit .remove { font-size: 12px; min-height: 32px; padding: 6px 0; color: #B3261E; }
.add-room { width: 100%; text-align: left; padding: 14px; color: var(--arr); font-weight: 600; font-size: 15px; background: none; border: 0; cursor: pointer; }
