:root {
  --bg: #f4f5f7;
  --card: rgba(255, 255, 255, 0.62);
  --text: #16181d;
  --muted: #5f6672;
  --line: #dde1e7;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --left: #2563eb;
  --right: #d9480f;
  --now: #0f9d58;
  --passed: #9aa1ab;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.14);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --card: rgba(20, 23, 29, 0.55);
    --text: #eef0f3;
    --muted: #9aa3b0;
    --line: #2d323b;
    --accent: #5b8cff;
    --left: #5b8cff;
    --right: #ff7a3d;
    --now: #34c77b;
    --passed: #6b7380;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --card: rgba(20, 23, 29, 0.55);
  --text: #eef0f3;
  --muted: #9aa3b0;
  --line: #2d323b;
  --accent: #5b8cff;
  --left: #5b8cff;
  --right: #ff7a3d;
  --now: #34c77b;
  --passed: #6b7380;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#map { position: fixed; inset: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.card {
  position: fixed;
  z-index: 2;
  background: var(--card);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Route entry */
.plan { top: 16px; left: 50%; transform: translateX(-50%); width: 360px; padding: 14px; }
.plan.flying { width: auto; min-width: 300px; max-width: calc(100vw - 720px); padding: 10px 16px; text-align: center; }
.plan.flying .brand { justify-content: center; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.brand svg { width: 20px; height: 20px; fill: var(--accent); transform: rotate(45deg); }
.brand .link { margin-left: auto; }
.route { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 8px; align-items: center; }
.route .field:first-child { grid-column: 1; grid-row: 1; }
.route .field:last-child { grid-column: 1; grid-row: 2; }
.route .swap { grid-column: 2; grid-row: 1 / span 2; }
.field { position: relative; display: block; }
.field span { position: absolute; left: 12px; top: 9px; font-size: 12px; color: var(--muted); pointer-events: none; }
.field input {
  width: 100%;
  padding: 8px 12px 8px 52px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: 42px;
  margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 260px; overflow: auto;
  backdrop-filter: blur(10px);
}
.suggest li { display: flex; gap: 10px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.suggest li b { width: 34px; flex: none; }
.suggest li small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest li > div { min-width: 0; }
.suggest li.active, .suggest li:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row .field.flight { flex: 1; min-width: 0; }
.field.flight input { padding-left: 58px; }
.field.flight input::placeholder { color: var(--muted); opacity: 0.8; }
.primary { min-height: 38px; }
.clock .live { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.clock .live[data-status="live"] { color: #2f9e44; font-weight: 600; }
.clock .live[data-status="live"]::before { content: "● "; animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: 0.3; } }
body[data-live="on"] #speed { display: none; }
body[data-live="on"] #scrub { opacity: 0.5; }
.seg { display: flex; flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px 0; border-radius: 8px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-text); }
.primary { border: 0; background: var(--accent); color: var(--accent-text); padding: 0 22px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.icon { border: 1px solid var(--line); background: transparent; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 500; font-size: 13px; }
.error { color: #d93025; margin: 8px 0 0; font-size: 13px; }
.summary { color: var(--muted); font-size: 13px; }
.summary b { color: var(--text); font-size: 15px; }
.plan.flying form { display: none; }
.plan.flying .brand { margin-bottom: 4px; }

/* Landmark list */
.list { top: 16px; width: 300px; max-height: var(--panel-max, 50vh); display: flex; flex-direction: column; }
/* Looking out one window, the other window's panel gets out of the way. */
body[data-look="left"] .list.R, body[data-look="right"] .list.L { display: none; }
.list.L { left: 16px; }
.list.R { right: 16px; }
.list h2 { display: flex; align-items: center; gap: 8px; }
/* Panel header doubles as the collapse toggle */
.list .head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 14px 8px;
  border: 0; background: none; cursor: pointer; text-align: left; border-radius: var(--radius);
}
.list .head h2 { margin: 0 auto 0 0; font-size: 15px; }
.list .head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.now-count { font-size: 11px; font-weight: 600; color: var(--now); }
.chev { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; transition: transform 0.2s; }
.list.collapsed .chev { transform: rotate(-90deg); }
.list.collapsed .scroll { display: none; }
.list.collapsed .head { padding-bottom: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.L { background: var(--left); }
.dot.R { background: var(--right); }
.count { color: var(--muted); font-size: 12px; }
.scroll { overflow: auto; padding: 0 6px 8px; }
.group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 8px 4px; }
.ev { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 9px; cursor: pointer; width: 100%; text-align: left; border: 0; background: none; }
.ev:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ev .side { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.ev .side.L { background: var(--left); }
.ev .side.R { background: var(--right); }
.ev.now .side { background: var(--now); box-shadow: 0 0 0 3px color-mix(in srgb, var(--now) 35%, transparent); }
.ev.passed { opacity: 0.5; }
.ev .name { font-weight: 600; }
.ev .name[title="Must-see"] { color: color-mix(in srgb, var(--text) 80%, #f59f00); }
.ev .meta { color: var(--muted); font-size: 12px; }
.ev .when { margin-left: auto; text-align: right; font-size: 12px; white-space: nowrap; color: var(--muted); }
.ev.now .when { color: var(--now); font-weight: 600; }
.empty { color: var(--muted); padding: 8px 10px 12px; }

/* Playback bar */
.bar {
  left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(1040px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 14px; padding: 10px 14px;
}
.play { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--accent-text); border: 0; }
.time { flex: 1; min-width: 120px; }
.clock { font-variant-numeric: tabular-nums; }
.clock span { color: var(--muted); }
#scrub { width: 100%; accent-color: var(--accent); }
.stats { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.stats div { display: flex; flex-direction: column; min-width: 64px; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
#speed { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: transparent; }
#speed option { background: var(--bg); }
.toggles { display: flex; gap: 6px; align-items: center; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: transparent; cursor: pointer; white-space: nowrap; }
.chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); color: var(--accent); }

/* Plane marker */
.plane { width: 40px; height: 40px; pointer-events: none; }
.plane svg { width: 100%; height: 100%; fill: #111827; stroke: #fff; stroke-width: 1.2; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }

/* View switcher */
.views { flex: none; }
.views button { padding: 5px 10px; white-space: nowrap; }

/* Window view: a cabin window frame around the map */
.window-frame { position: fixed; inset: 0; z-index: 1; pointer-events: none; display: none; }
.window-frame .pane {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 96vw; height: 92vh; /* larger than a real cabin window, so more of the view shows */
  border-radius: 22% / 26%;
  box-shadow: 0 0 0 14px #d7d9dd, 0 0 0 16px #b9bcc2, 0 0 0 200vmax #e8e9ec, inset 0 0 40px rgba(0, 0, 0, 0.25);
}
body[data-view="window"] .window-frame { display: block; }

/* Callouts */
.toasts { position: fixed; z-index: 3; left: 50%; bottom: 110px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 999px;
  padding: 8px 16px; display: flex; gap: 8px; align-items: center; animation: pop 0.25s ease-out;
  backdrop-filter: blur(10px);
}
.toast .side { width: 10px; height: 10px; border-radius: 50%; }
.toast .side.L { background: var(--left); }
.toast .side.R { background: var(--right); }
.toast small { color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 760px) {
  .plan, .plan.flying { left: 12px; right: 12px; width: auto; min-width: 0; max-width: none; transform: none; top: 12px; padding: 10px 12px; }
  .plan.flying .brand { font-size: 15px; }
  .summary { font-size: 12px; }
  /* The two window panels sit side by side above the playback bar. */
  /* Panels hang from the top, under the route card; a lone panel (window views) takes the full width. */
  .list { width: calc(50vw - 18px); top: calc(var(--plan-bottom, 90px) + 8px); bottom: auto; max-height: var(--panel-max, 30vh); }
  body[data-look="left"] .list.L, body[data-look="right"] .list.R { width: calc(100vw - 24px); }
  .list.L { left: 12px; }
  .list.R { right: 12px; }
  .list .head h2 { font-size: 13px; }
  .list .head { padding: 8px 10px 6px; gap: 6px; }
  .count { font-size: 11px; }
  .ev .meta { display: none; }
  .ev .name { font-size: 13px; }
  .ev .when { font-size: 11px; }
  .ev { padding: 5px 8px; }
  .bar { bottom: 12px; width: calc(100vw - 24px); flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px; }
  .play { width: 38px; height: 38px; }
  .time { flex-basis: calc(100% - 52px); }
  .stats { gap: 10px; }
  .stats div { min-width: 0; }
  .stats span { font-size: 10px; }
  #speed { padding: 4px; font-size: 13px; }
  .toggles { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .chip { padding: 5px 10px; font-size: 13px; }
  .views { flex: 1; }
  .views button { padding: 4px 6px; font-size: 13px; }
  .toasts { top: auto; bottom: calc(var(--bar-h, 96px) + 20px); width: calc(100vw - 24px); }
  .toast { padding: 6px 12px; font-size: 13px; max-width: 100%; }
  .toast span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Camera views need the screen: a shorter list, one callout, and a window that fits between the panels. */
  body[data-view="cockpit"] .toast ~ .toast, body[data-view="window"] .toast ~ .toast { display: none; }
  .window-frame .pane { top: 50%; width: 97vw; height: 96vh; border-radius: 18% / 12%; }
}
.clock { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) { .clock .live[data-status="live"]::before { animation: none; } }
