:root {
  --ink: #1d2733;
  --ink-2: #55616e;
  --ink-3: #8a949e;
  --line: #e6e9ec;
  --card: rgba(255, 255, 255, 0.96);
  --celeste: #75aadb;
  --sol: #f6b40e;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.08), 0 6px 24px rgba(20, 30, 45, 0.12);
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #d9e0e4; color: var(--ink); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#scene.dragging { cursor: grabbing; }
#scene.hovering { cursor: pointer; }

/* ---------------------------------------------------------------- aircraft labels */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform;
  display: inline-flex; align-items: center; gap: 4px;
  font: 700 11px/1 var(--font); letter-spacing: 0.02em; color: #17202b;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff, 0 0 5px #fff;
  transition: opacity 0.25s;
}
.lbl .l-rt { font-weight: 600; font-size: 10px; color: #3c4d5e; letter-spacing: 0.01em; }
.lbl.parked { font-weight: 500; font-style: italic; color: #44505c; }
.lbl.parked .l-rt { color: #5b6774; }
.lbl.vehicle { font-weight: 600; font-size: 10px; color: #6a5a1c; }
.lbl.selected, .lbl.highlighted { color: #0b5cad; }
.lbl.selected .l-rt, .lbl.highlighted .l-rt { color: #0b5cad; }
.lbl.highlighted { transform-origin: center; font-weight: 800; }
.lbl.hidden { opacity: 0; }
.l-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex: none; vertical-align: 1px; }
.l-dot.go { background: #1fa968; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9); }
.l-dot.urgent { background: #e09612; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9); }
.l-dot.warn { background: #e5484d; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9); }
.l-dot.info { background: #3b82f6; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9); }
.lbl.place {
  font: 600 10px/1.2 var(--font); letter-spacing: 0.12em; text-transform: uppercase; color: rgba(38, 50, 62, 0.72); text-align: center;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.9), 0 0 6px rgba(255, 255, 255, 0.8);
}
.lbl.place.water { color: rgba(255, 248, 235, 0.85); font-style: italic; letter-spacing: 0.3em; text-shadow: 0 1px 3px rgba(60, 40, 20, 0.5); font-size: 12px; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

#panel {
  position: fixed; top: 12px; left: 12px; width: 272px; max-height: calc(100% - 68px); overflow: hidden auto;
  padding: 12px 14px 12px; z-index: 5; transition: opacity 0.4s, transform 0.4s, width 0.2s; scrollbar-width: thin;
}
#panel.wide { width: 328px; }
body.tv #panel, body.tv #controls, body.tv #hud { opacity: 0; pointer-events: none; transform: translateY(-6px); }
body.booting #panel, body.booting #controls, body.booting #hud { opacity: 0; pointer-events: none; }

.p-head { display: flex; align-items: center; gap: 8px; min-height: 26px; margin-bottom: 6px; }
.p-head h1, .p-head h2 { font-size: 15px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-head h1 .tag { display: inline-block; vertical-align: 2px; margin-left: 6px; padding: 1px 5px; border-radius: 4px; font-size: 9px; letter-spacing: 0.08em; font-weight: 700; color: #fff; background: var(--celeste); }
.icon-btn { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: #eef1f4; color: var(--ink); }
.icon-btn.on { background: #e3effa; color: #0b5cad; }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.blurb { color: var(--ink-2); margin: 0 0 8px; }
.blurb a { text-decoration-color: #b9c2ca; text-underline-offset: 2px; }

.rows { margin: 0 -6px; }
.row { display: flex; align-items: center; width: 100%; padding: 6px 6px; border-radius: 7px; text-align: left; gap: 8px; }
.row:hover { background: #f1f4f6; }
.row .grow { flex: 1; }
.row .hint { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.row .chev { width: 14px; height: 14px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.kv span:first-child { color: var(--ink-2); }
.kv span:last-child { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.kv.small span:last-child { font-weight: 500; }
.sect { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-weight: 700; font-size: 12px; }
.sect::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.note { color: var(--ink-2); margin: 8px 0 0; }
.muted { color: var(--ink-3); }
.mono { font: 11px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--ink-2); background: #f3f5f7; border-radius: 7px; padding: 7px 8px; margin: 8px 0 0; word-break: break-word; }
.foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--ink-3); font-size: 11px; }

/* search */
.search { display: flex; align-items: center; gap: 6px; background: #f1f4f6; border-radius: 8px; padding: 0 8px; margin-bottom: 6px; }
.search input { flex: 1; border: 0; background: none; font: inherit; color: inherit; padding: 7px 0; outline: none; min-width: 0; text-transform: uppercase; }
.search input::placeholder { text-transform: none; color: var(--ink-3); }
.result { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 6px; border-radius: 7px; text-align: left; }
.result:hover, .result.active { background: #f1f4f6; }
.result b { font-weight: 700; min-width: 68px; display: inline-flex; align-items: center; gap: 5px; }
.result .sub { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .st { color: var(--ink-3); font-size: 11px; }

/* aircraft view */
.portrait { display: block; width: 100%; height: 132px; object-fit: contain; margin: 2px 0 6px; }
.route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 6px; margin: 2px 0 2px; }
.route .code { font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }
.route .name { font-size: 10.5px; color: var(--ink-3); line-height: 1.25; margin-top: 1px; }
.route .to { text-align: right; }
.route .arrow { color: var(--ink-2); padding-top: 1px; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.state-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: #eef4fa; color: #0b5cad; font-weight: 600; font-size: 11.5px; }
.state-pill.parked { background: #f1f3f5; color: var(--ink-2); }
.state-pill.air { background: #fff4d6; color: #8a5a00; }
.state-pill.b-pill { background: #f1f3f5; color: var(--ink-2); }
.state-pill.b-pill.go { background: #e5f7ee; color: #0f7644; }
.state-pill.b-pill.urgent { background: #fff2d6; color: #9a6000; }
.state-pill.b-pill.warn { background: #fdecec; color: #b42318; }
.state-pill.b-pill.info { background: #e8f2fd; color: #0b5cad; }

/* live flight board */
.b-fresh { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.b-fresh .dot.on { background: #2fb26a; }
.b-fresh .dot.wait { background: var(--sol); }
.b-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #eef1f4; padding: 3px; border-radius: 9px; margin: 4px 0 8px; }
.b-tab { padding: 5px 8px; border-radius: 7px; font-weight: 600; font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.b-tab span { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.b-tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(20, 30, 45, 0.08); }
.b-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.b-stat { background: #f4f6f8; border-radius: 8px; padding: 6px 8px; text-align: left; border: 1px solid transparent; }
.b-stat:hover { background: #edf1f5; }
.b-stat.on { border-color: var(--celeste); background: #eef5fc; }
.b-stat b { display: block; font-size: 15px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.b-stat span { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.b-stat.map b { color: #0b5cad; }
.b-stat.go b { color: #0f7644; }
.b-stat.warn b { color: #b42318; }
.b-filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.b-chip { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--ink-2); background: #f1f4f6; }
.b-chip:hover { background: #e6ebf0; }
.b-chip.on { background: var(--ink); color: #fff; }
.b-search { margin-bottom: 6px; }
.b-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 6px 6px; border-radius: 8px; text-align: left; border-bottom: 1px solid #f0f2f5; }
.b-row:last-of-type { border-bottom: 0; }
.b-row.on-map:hover { background: #eef5fc; }
.b-time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; line-height: 1.2; }
.b-time b { font-size: 12px; font-weight: 700; color: var(--ink); }
.b-time b.strike { text-decoration: line-through; color: var(--ink-3); font-weight: 500; font-size: 11px; }
.b-rev { font-size: 11.5px; font-weight: 700; color: var(--ink); }
.b-rev.late { color: #b42318; }
.b-rev.early { color: #0f7644; }
.b-main { min-width: 0; }
.b-top { display: flex; align-items: center; gap: 5px; }
.b-flt { font-weight: 700; font-size: 12px; color: var(--ink); white-space: nowrap; }
.b-iata { font-size: 10.5px; font-weight: 700; color: var(--ink-2); background: #eef1f4; padding: 0 4px; border-radius: 4px; }
.b-gate { font-size: 10px; font-weight: 700; color: #0b5cad; background: #e5f1fc; padding: 0 4px; border-radius: 4px; }
.b-city { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.b-st { display: inline-block; padding: 2px 6px; border-radius: 5px; font-size: 10.5px; font-weight: 600; background: #f1f3f5; color: var(--ink-2); white-space: nowrap; }
.b-st.go { background: #e5f7ee; color: #0f7644; }
.b-st.urgent { background: #fff2d6; color: #9a6000; }
.b-st.warn { background: #fdecec; color: #b42318; }
.b-st.info { background: #e8f2fd; color: #0b5cad; }
.b-live { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; color: #0f7644; }
.b-live.parked { color: var(--ink-3); font-weight: 600; }
.b-live .dot { width: 5px; height: 5px; }
.b-live .dot.on { background: #2fb26a; }
.b-live .dot.parked { background: #8a949e; }
.b-delta { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.b-delta.late { color: #b42318; }
.b-delta.early { color: #0f7644; }
.hud-btn { cursor: pointer; transition: background 0.15s; }
.hud-btn:hover { background: #fff; color: var(--ink); }
.hud-btn.active { background: #eef5fc; color: #0b5cad; }
.hud-btn .dot.on { background: #2fb26a; }
.hud-btn .dot.wait { background: var(--sol); }

/* collection */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.tile { background: #f4f6f8; border-radius: 9px; padding: 6px 8px 8px; text-align: left; min-width: 0; }
.tile img { display: block; width: 100%; height: 58px; object-fit: contain; }
.tile b { display: block; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile span { display: block; font-size: 10.5px; color: var(--ink-3); }
.tile.unseen img { filter: grayscale(1) brightness(0.2) opacity(0.18); }
.tile.unseen b { color: var(--ink-3); }

/* ---------------------------------------------------------------- hud + controls */
.hud { position: fixed; left: 12px; bottom: 12px; display: flex; gap: 8px; z-index: 4; transition: opacity 0.4s; flex-wrap: wrap; }
.chip { padding: 6px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #b8c0c8; }
.kv .dot { display: inline-block; margin-right: 5px; vertical-align: 1px; }
.kv .dot.on { background: #2fb26a; }
.kv .dot.wait { background: var(--sol); }
.kv .dot.off { background: #e5484d; }
.live .dot { background: #2fb26a; box-shadow: 0 0 0 0 rgba(47, 178, 106, 0.5); animation: pulse 2s infinite; }
.replay .dot { background: var(--sol); }
.error .dot { background: #e5484d; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(47, 178, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 178, 106, 0); } }

.controls { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 4; transition: opacity 0.4s; }
.ctl { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; font-weight: 500; color: var(--ink-2); }
.ctl:hover { color: var(--ink); background: #fff; }
#tv-exit { position: fixed; right: 12px; top: 12px; z-index: 6; opacity: 0.0; transition: opacity 0.4s; }
body.tv #tv-exit { opacity: 0.85; }
#tv-caption { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 6; padding: 8px 16px; font-size: 13px; opacity: 0; transition: opacity 0.6s; pointer-events: none; white-space: nowrap; }
body.tv #tv-caption.show { opacity: 1; }
#tv-caption b { font-weight: 700; color: var(--ink); }

/* ---------------------------------------------------------------- splash */
#splash { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #d5dde2; transition: opacity 1.1s ease 0.1s; }
#splash.done { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
#splash h1 { font-size: clamp(24px, 4vw, 34px); font-weight: 600; letter-spacing: -0.01em; color: #3b4a59; margin: 0 0 6px; text-shadow: 0 0 18px #fff; }
.splash-plane { animation: fly 3.2s ease-in-out infinite; filter: drop-shadow(0 6px 5px rgba(40, 60, 80, 0.2)); }
@keyframes fly { 0% { transform: translate(-70px, 14px); } 50% { transform: translate(70px, -6px); } 100% { transform: translate(-70px, 14px); } }
#splash-note { color: #8a949e; min-height: 1.4em; margin: 10px 0 0; }

@media (max-width: 560px) {
  #panel, #panel.wide { width: auto; right: 12px; max-height: 46%; }
  .hud { bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) { .splash-plane, .live .dot { animation: none; } }
