/* FT — Flight Tracker. Dark aviation-console default, light mode as a first-class
   peer. Every colour is a variable so the theme switch is a single attribute flip. */

:root {
  --bg: #0b1017;
  --panel: rgba(16, 23, 33, 0.92);
  --panel-solid: #101721;
  --panel-line: rgba(255, 255, 255, 0.10);
  --ink: #e8eef6;
  --ink-dim: #93a3b8;
  --ink-faint: #64748b;
  --accent: #38bdf8;
  --accent-ink: #04141f;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --chip: rgba(255, 255, 255, 0.06);
  --chip-on: rgba(56, 189, 248, 0.18);
  --field: rgba(255, 255, 255, 0.05);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --radius: 12px;
  --topbar-h: 56px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef2f7;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --panel-line: rgba(15, 23, 42, 0.12);
  --ink: #0f172a;
  --ink-dim: #475569;
  --ink-faint: #94a3b8;
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --good: #059669;
  --warn: #b45309;
  --bad: #dc2626;
  --chip: rgba(15, 23, 42, 0.06);
  --chip-on: rgba(2, 132, 199, 0.15);
  --field: rgba(15, 23, 42, 0.04);
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.18);

  color-scheme: light;
}

* { box-sizing: border-box; }

/* Any author `display` beats the UA sheet's `[hidden] { display: none }`, which
   silently leaves panels like .drawer (display:flex) on screen. Restate it. */
[hidden] { display: none !important; }

/* A full-screen map is an app surface, not a document. Pinning the body and
   killing overscroll stops the whole page being panned or rubber-banded around
   underneath the map — which reads as the app sliding off screen. */
html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Gestures over the map belong to MapLibre. Without this the browser claims
   two-finger pans and pinches for itself and drags the page instead. */
#map { touch-action: none; }

/* Panels still scroll, but their scroll must not chain to the document. */
.drawer-body,
.option-list,
.search-results {
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* Removes the double-tap-to-zoom delay and its accidental page zoom. */
button, .chip, .seg-btn, .tb, .btn { touch-action: manipulation; }

.mono { font-family: "Cascadia Mono", ui-monospace, "SF Mono", Consolas, monospace; }
.muted { color: var(--ink-dim); }
.sep { color: var(--ink-faint); margin: 0 2px; }

#map { position: absolute; inset: 0; }

/* MapLibre's own chrome needs to sit under ours. */
.maplibregl-ctrl-bottom-right { margin-bottom: 4px; }
/* The basemap credit line (OpenStreetMap, CARTO, Esri) is a licence
   requirement, so it stays; it just should not be a white box under the
   legend. Themed like the panels, collapsed to its (i) until clicked. */
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib.maplibregl-compact {
  font-size: 10px; opacity: 1;
  background: var(--panel) !important; color: var(--ink-dim);
  border: 1px solid var(--panel-line); border-radius: 10px;
  backdrop-filter: blur(14px);
}
.maplibregl-ctrl-attrib a { color: var(--ink-dim); }
.maplibregl-ctrl-attrib a:hover { color: var(--ink); }
.maplibregl-ctrl-attrib-button { background-color: transparent !important; }
:root:not([data-theme="light"]) .maplibregl-ctrl-attrib-button { filter: invert(1); }
/* The scale bar shares that corner and was the actual white box under the legend. */
.maplibregl-ctrl-scale {
  background: var(--ctl-bg) !important; color: var(--ctl-ink) !important;
  border: 1.5px solid var(--ctl-ring) !important;
  border-radius: 8px; padding: 3px 8px; font-size: 11px; font-weight: 600; line-height: 1.4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.maplibregl-ctrl-top-right { top: calc(var(--topbar-h) + 8px); }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-line);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); fill: none; }
.brand-name { font-weight: 650; letter-spacing: 0.2px; white-space: nowrap; }

/* min-width:0 is load-bearing: a flex item defaults to min-width:auto and
   refuses to shrink below its content, so the search box pushed the topbar
   buttons off the right edge on narrow screens instead of giving up width. */
.search-wrap { position: relative; flex: 1 1 auto; min-width: 0; max-width: 420px; }
#btn-search { display: none; }

#search {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: var(--field);
  color: var(--ink);
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: var(--accent); }
#search::-webkit-search-cancel-button { filter: invert(0.5); }

.search-results {
  position: absolute;
  top: 40px; left: 0; right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 40;
}
.search-results .row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.search-results .row:hover, .search-results .row.on { background: var(--chip); }
.search-results .row b { font-family: "Cascadia Mono", ui-monospace, monospace; }
.search-results .row small { color: var(--ink-dim); margin-left: auto; }
.search-results .empty { padding: 12px; color: var(--ink-dim); text-align: center; }
.search-results .sect { padding: 8px 12px 2px; font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-faint); }
.search-results .row.place b { font-family: inherit; }

.topbar-actions { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }

.tb {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: var(--field);
  color: var(--ink);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tb:hover { border-color: var(--accent); }
.tb[aria-pressed="true"] { background: var(--chip-on); border-color: var(--accent); color: var(--accent); }
.tb svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Mode switch lives in the topbar next to the other controls, so it matches
   their height rather than the taller segmented controls in the panels. */
.mode-seg { flex: 0 0 auto; height: 34px; align-items: center; }
.mode-seg .seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; height: 28px; white-space: nowrap; }
.mode-ico { width: 15px; height: 15px; display: none; fill: currentColor; }

@media (max-width: 900px) {
  .mode-seg .seg-btn { padding: 0 9px; font-size: 11.5px; }
}

.pill {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* Spin, with its speed stepper. The minus and plus are deliberately narrow —
   the topbar is already tight at 360px, so they read as affordances on the
   button rather than as two more buttons competing with it. */
.spin-group { display: flex; align-items: center; flex: 0 0 auto; }
.spin-main { border-radius: 0; }
.spin-step {
  width: 22px; height: 34px;
  border: 1px solid var(--panel-line);
  background: var(--field);
  color: var(--ink-dim);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.spin-step:hover { color: var(--accent); border-color: var(--accent); }
.spin-step:disabled { opacity: 0.35; cursor: default; }
#spin-down { border-radius: 999px 0 0 999px; border-right: 0; }
#spin-up { border-radius: 0 999px 999px 0; border-left: 0; }
.spin-level {
  min-width: 14px; padding: 0 3px;
  font-size: 11px; font-weight: 700;
  color: var(--accent);
}

/* ------------------------------------------------- 2D / 3D map mode switch */

/* Right-hand map controls (zoom, compass, 2D/3D, basemaps): every button is
   its own box, separated by a gap, instead of cells sharing a white strip
   with hairline dividers (asked for 2026-09-04). Dark, the default: black
   box, white text, sky-blue ring; light: white box, ink text, blue ring. The
   active choice fills with the ring colour. */
:root {
  --ctl-bg: #000000; --ctl-bg-hover: #161c26; --ctl-ink: #ffffff;
  --ctl-ring: #38bdf8; --ctl-ring-hover: #7dd3fc; --ctl-on-ink: #04141f;
}
:root[data-theme="light"] {
  --ctl-bg: #ffffff; --ctl-bg-hover: #eaf4fb; --ctl-ink: #0f172a;
  --ctl-ring: #0284c7; --ctl-ring-hover: #0369a1; --ctl-on-ink: #ffffff;
}
.maplibregl-ctrl-top-right .maplibregl-ctrl-group {
  background: transparent; box-shadow: none; border-radius: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.maplibregl-ctrl-top-right .maplibregl-ctrl-group button,
.maplibregl-ctrl-top-right .maplibregl-ctrl-group button + button,
.maplibregl-ctrl-top-right .maplibregl-ctrl-group button:first-child,
.maplibregl-ctrl-top-right .maplibregl-ctrl-group button:last-child {
  width: 32px; height: 32px;
  border: 1.5px solid var(--ctl-ring); border-radius: 8px;
  background: var(--ctl-bg); color: var(--ctl-ink);
  font-size: 11px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.maplibregl-ctrl-top-right .maplibregl-ctrl-group button:hover { background: var(--ctl-bg-hover); border-color: var(--ctl-ring-hover); }
.maplibregl-ctrl-top-right .maplibregl-ctrl-group button.on { background: var(--ctl-ring); color: var(--ctl-on-ink); }
/* MapLibre draws the zoom and compass glyphs as dark SVGs; on a black box they
   need inverting. */
:root:not([data-theme="light"]) .maplibregl-ctrl-top-right .maplibregl-ctrl-icon { filter: invert(1); }
.map-mode { display: flex; overflow: visible; }
/* Four basemaps as a 2x2 block of boxes. */
/* One column of equal boxes; wide enough that "Combo" centres instead of
   overflowing its 50px box (measured: 38px of text in a 34px content box). */
.map-base { display: flex; flex-direction: column; gap: 4px; }
.maplibregl-ctrl-top-right .map-base button,
.maplibregl-ctrl-top-right .map-base button:first-child,
.maplibregl-ctrl-top-right .map-base button:last-child,
.maplibregl-ctrl-top-right .map-base button + button { width: 60px; min-width: 60px; height: 28px; padding: 0 4px; font-size: 10.5px; line-height: 28px; text-align: center; }

/* --------------------------------------------------------------- statusbar */

/* Stacked in a column wrapper rather than each pinned to its own offset: the
   status bar wraps to two lines on narrow screens, and any hardcoded top for
   the panel beneath it then overlaps. */
.hud-left {
  position: absolute;
  top: calc(var(--topbar-h) + 8px); left: 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  z-index: 20;
  pointer-events: none;
}
.hud-left > * { pointer-events: auto; }

.statusbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  font-size: 12px;
  z-index: 20;
  box-shadow: var(--shadow);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint); margin-right: 4px;
  transition: background 0.3s;
}
.dot.live { background: var(--good); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.dot.err  { background: var(--bad);  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18); }

/* ----------------------------------------------------------------- reentries
   Sits directly beneath the status bar and only in satellite mode, where the
   counts above it are satellites rather than aircraft. */

.decaybar {
  width: 232px;
  padding: 9px 12px 10px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.decay-head { display: flex; align-items: center; gap: 8px; }
.decay-title {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--ink-dim); white-space: nowrap;
}
.decay-spark { flex: 1 1 auto; height: 18px; overflow: visible; }
.decay-spark polyline { fill: none; stroke: var(--warn); stroke-width: 1.4; stroke-linejoin: round; }
.decay-spark .base { stroke: var(--panel-line); stroke-width: 1; }

.decay-stats {
  display: flex; justify-content: space-between; gap: 4px;
  margin-top: 7px;
}
.decay-stat { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.decay-stat b {
  font-family: "Cascadia Mono", ui-monospace, monospace;
  font-size: 14px; font-weight: 700; line-height: 1.1;
}
.decay-stat small { font-size: 9.5px; color: var(--ink-faint); margin-top: 1px; }

.decay-note { margin-top: 7px; font-size: 9.5px; line-height: 1.35; color: var(--ink-faint); }

@media (max-width: 640px) {
  .decaybar { width: auto; align-self: stretch; }
}

/* ------------------------------------------------------------------ drawer */

.drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 92vw;
  display: flex; flex-direction: column;
  background: var(--panel-solid);
  border-left: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
  z-index: 60;
  animation: slide-in 0.18s ease-out;
}
/* Rises rather than sliding in from the right: a right-anchored panel animating
   on translateX overflows the viewport for the length of the animation, which
   shows up as phantom horizontal overflow in layout audits. */
@keyframes slide-in { from { transform: translateY(10px); opacity: 0; } }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-line);
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 16px; }
.drawer-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--panel-line);
}

.icon-btn {
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-dim);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--chip); color: var(--ink); }

.fgroup { padding: 14px 0; border-bottom: 1px solid var(--panel-line); }
.fgroup:last-child { border-bottom: 0; }
.fgroup h3 {
  margin: 0 0 10px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--ink-dim);
}
.hint { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-faint); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: var(--chip);
  color: var(--ink-dim);
  font-size: 12.5px; cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--chip-on); border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* An agency loaded for the current view but not pinned: on, but only while you are here. */
.chip.auto { border-style: dashed; color: var(--ink); }
.chip.off { opacity: 0.55; text-decoration: line-through; }
.chip-sep { flex-basis: 100%; font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.agency-search {
  width: 100%; box-sizing: border-box; margin: 6px 0 8px; padding: 7px 10px;
  border-radius: 8px; border: 1px solid var(--panel-line); background: var(--chip); color: var(--ink); font-size: 13px;
}
.agency-search:focus { outline: none; border-color: var(--accent); }
.chip .sw {
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: baseline;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.chip .sw[hidden] { display: none; }

.legend-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 12px; }
.legend-kinds .lk { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--ink-dim); white-space: nowrap; }
.legend-kinds .lk i { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; }
/* Sea names thirteen ship classes plus chokepoints and ports: three tighter columns. */
#legend-sea.legend-kinds { grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; }
#legend-sea .lk { font-size: 14px; gap: 7px; }
#legend-sea .lk i { width: 12px; height: 12px; }
#legend-sea .lk.muted { grid-column: 1 / -1; white-space: normal; font-size: 12.5px; }

.field {
  width: 100%; height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--panel-line);
  background: var(--field);
  color: var(--ink);
  font-size: 13px; outline: none;
}
.field:focus { border-color: var(--accent); }
.field.small { width: auto; min-width: 92px; height: 30px; }
select.field { cursor: pointer; }

.option-list {
  max-height: 240px; overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
}
.option-list .opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; cursor: pointer; font-size: 13px;
}
.option-list .opt:hover { background: var(--chip); }
.option-list .opt-group {
  position: sticky; top: 0; z-index: 1;
  padding: 6px 10px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--panel-line);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--ink-faint);
}
.option-list .opt.on { background: var(--chip-on); color: var(--accent); }
.option-list .opt code {
  font-family: "Cascadia Mono", ui-monospace, monospace;
  font-size: 11px; color: var(--ink-faint);
  min-width: 30px;
}
.option-list .opt .kind { margin-left: auto; font-size: 10.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.4px; }

.selected-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.selected-list:empty { display: none; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--chip-on);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px; font-weight: 600;
}
.tag button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }

.range-row { display: flex; gap: 12px; flex-wrap: wrap; }
.range-row label, .row-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-dim); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--field); border-radius: 10px; border: 1px solid var(--panel-line); }
.seg-btn {
  padding: 6px 14px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-dim);
  font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.btn {
  height: 34px; padding: 0 16px;
  border-radius: 9px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; text-decoration: none;
}
.btn.ghost { background: transparent; border-color: var(--panel-line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn[aria-pressed="true"] { background: var(--chip-on); border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ detail */

.detail {
  position: absolute;
  left: 12px; bottom: 12px;
  width: 340px; max-width: calc(100vw - 24px);
  padding: 16px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 25;
  animation: slide-in 0.16s ease-out;
}
.detail-close { position: absolute; top: 8px; right: 8px; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; padding-right: 28px; }
.d-callsign { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.d-operator { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }
.d-badge {
  margin-left: auto; padding: 3px 9px;
  border-radius: 999px; background: var(--chip);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--ink-dim); white-space: nowrap;
}

.d-route {
  margin-top: 12px; padding: 9px 11px;
  background: var(--chip);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
}
.d-route-pair { display: flex; align-items: center; gap: 10px; }
.d-chain {
  margin-top: 7px; padding-top: 6px;
  border-top: 1px solid var(--panel-line);
  font-size: 10.5px; color: var(--ink-faint);
  letter-spacing: 0.3px;
}
.d-route-end { flex: 1 1 0; min-width: 0; }
.d-route-end span { display: block; font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.d-route-end small {
  display: block; margin-top: 1px;
  font-size: 11px; color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.d-route-end:last-child { text-align: right; }
.d-route-arrow { color: var(--accent); font-size: 15px; flex: 0 0 auto; }

.d-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 14px; margin: 14px 0 0;
}
.d-grid .wide { grid-column: 1 / -1; }
.d-grid dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-faint); }
.d-grid dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 600; }
.detail-actions { margin-top: 14px; display: flex; gap: 8px; }

/* ------------------------------------------------------------------ legend */

.legend {
  position: absolute;
  /* Above the map attribution in the corner (two lines on satellite basemaps);
     the doubled box used to sit on it. */
  right: 12px; bottom: 64px;
  /* Sized to content rather than fixed: the category key is two columns of
     labels, and a hard width made the right-hand column spill out of the box. */
  /* Twice the original box (asked for on 2026-09-04), text and pictograms
     scaled to match; the minimize button folds it to the title row. */
  min-width: 300px; max-width: 440px;
  padding: 16px 22px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  z-index: 20;
  font-size: 18px;
}
.legend-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.legend-title { color: var(--ink-dim); font-size: 18px; text-transform: uppercase; letter-spacing: 1.1px; cursor: default; }
.legend-toggle {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 9px; border: 1px solid var(--panel-line); background: var(--chip); color: var(--ink-dim);
  font-size: 24px; line-height: 1; padding: 0; cursor: pointer;
}
.legend-toggle:hover { color: var(--ink); border-color: var(--accent); }
.legend.min { min-width: 0; padding: 10px 14px; }
.legend.min #legend-body { display: none; }
.legend.min .legend-title { cursor: pointer; }
.legend.min .legend-title:hover { color: var(--ink); }

/* Reentries panel in the legend's slot (satellite view, desktop): same box,
   same sizes, same fold. */
.decaybar .decay-head { justify-content: space-between; }
.decaybar.min #decay-body { display: none; }
.decaybar.min .decay-title { cursor: pointer; }
.decaybar.corner {
  position: absolute; right: 12px; bottom: 64px; left: auto; top: auto;
  width: 375px; max-width: calc(100vw - 24px);
  padding: 16px 22px; border-radius: 16px; font-size: 18px;
}
.decaybar.corner.min { width: auto; padding: 10px 14px; }
.decaybar.corner .decay-title { font-size: 18px; letter-spacing: 1.1px; }
.decaybar.corner .decay-spark { height: 28px; }
.decaybar.corner .decay-stat b { font-size: 24px; }
.decaybar.corner .decay-stat small { font-size: 14px; }
.decaybar.corner .decay-stats { gap: 14px; margin-top: 10px; }
.legend-bar {
  height: 14px; margin: 12px 0 8px; border-radius: 8px;
  background: linear-gradient(90deg, #22d3ee 0%, #34d399 25%, #facc15 50%, #fb923c 75%, #f472b6 100%);
}
.legend-scale { display: flex; justify-content: space-between; color: var(--ink-faint); font-size: 18px; }

/* ------------------------------------------------------------- scrim/toast */

.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 50; }

.toast {
  position: absolute;
  bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 9px 16px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 70;
}
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* ---------------------------------------------------------------- responsive
   Verified at 1536 / 1366 / 1317 / 1152 (13.8" Surface) and mobile. */

@media (max-width: 1152px) {
  .legend { min-width: 256px; max-width: 400px; }
}

@media (max-width: 900px) {
  .tb-label { display: none; }
  .tb { padding: 0 10px; }
  .search-wrap { max-width: none; }
}

@media (max-width: 640px) {
  :root { --topbar-h: 52px; }
  .topbar { gap: 6px; }

  /* Below this width the search box, the mode switch, the spin stepper and four
     buttons cannot all share one row — the search was being squeezed to zero.
     It becomes an icon that expands over the bar, which is the one element that
     works fine as an overlay. */
  #btn-search { display: inline-flex; }

  /* Every control has to fit one row down to ~360px, so trim the padding
     rather than dropping a feature. */
  .tb { padding: 0 8px; }
  .spin-step { width: 18px; }
  .spin-level { min-width: 10px; padding: 0 2px; font-size: 10px; }
  .mode-seg .seg-btn { padding: 0 8px; }
  .topbar { padding: 0 6px; }

  /* Nine controls will not fit one row on the narrowest phones. The spin
     steppers drop out first because the same setting has a slider in
     Settings, so the capability survives; the Spin toggle and its level
     readout stay. */
  @media (max-width: 400px) {
    .spin-step { display: none; }
    /* A third mode button landed here; everything gets a little tighter so the
       row still fits an iPhone-width viewport with nothing dropped. */
    .topbar { gap: 4px; padding: 0 4px; }
    .tb { padding: 0 6px; }
    .mode-seg { padding: 2px; gap: 2px; }
    .mode-seg .seg-btn { padding: 0 7px; }
    .spin-level { display: none; }
  }

  .search-wrap {
    position: absolute; left: 8px; right: 8px; top: 9px;
    max-width: none; z-index: 35; display: none;
  }
  .topbar.searching .search-wrap { display: block; }
  .topbar.searching .brand,
  .topbar.searching .topbar-actions { visibility: hidden; }
  /* Icons only: the two word labels were the widest thing in the topbar and
     squeezed the search box down to a few unusable pixels. */
  .mode-label { display: none; }
  .mode-ico { display: block; }
  .mode-seg .seg-btn { padding: 0 10px; }
  #search { font-size: 12px; padding: 0 10px; }
  .brand-name { display: none; }
  .hud-left { left: 8px; right: 8px; }
  .statusbar { justify-content: center; font-size: 11px; align-self: stretch; }
  .drawer { width: 100%; max-width: 100%; }
  .legend { display: none; }
  .detail {
    left: 8px; right: 8px; bottom: 8px;
    width: auto;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .d-grid { grid-template-columns: 1fr 1fr; gap: 9px 12px; }
  .topbar { padding: 0 8px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .detail { animation: none; }
}

/* ------------------------------------------------------------------- stats */

.stat-row { display: flex; gap: 10px; }
.stat-big { flex: 1 1 0; min-width: 0; text-align: center; padding: 8px 4px; background: var(--chip); border-radius: 10px; }
.stat-big b {
  display: block;
  font-family: "Cascadia Mono", ui-monospace, monospace;
  font-size: 17px; font-weight: 700; line-height: 1.15;
}
.stat-big small { display: block; margin-top: 2px; font-size: 10px; color: var(--ink-faint); }

.stat-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 2px; }
.stat-table th, .stat-table td { padding: 5px 4px; text-align: right; white-space: nowrap; }
.stat-table thead th {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--ink-faint); border-bottom: 1px solid var(--panel-line); vertical-align: bottom;
}
.stat-table .th-sub { font-weight: 500; letter-spacing: 0; text-transform: none; }
.stat-table tbody th { text-align: left; font-weight: 600; color: var(--ink-dim); }
.stat-table tbody td { font-family: "Cascadia Mono", ui-monospace, monospace; }
.stat-table tbody tr + tr th, .stat-table tbody tr + tr td { border-top: 1px solid var(--panel-line); }
.stat-table.wide-first th:first-child, .stat-table.wide-first td:first-child {
  text-align: left; white-space: normal; width: 40%;
}
.stat-table .sub { display: block; font-size: 10px; color: var(--ink-faint); font-weight: 400; }

.year-bars { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.year-bar { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.year-bar .yr { font-family: "Cascadia Mono", ui-monospace, monospace; color: var(--ink-dim); width: 34px; }
.year-bar .track { flex: 1 1 auto; height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.year-bar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.year-bar .n { font-family: "Cascadia Mono", ui-monospace, monospace; width: 42px; text-align: right; }

input[type="range"].small { width: 96px; min-width: 0; padding: 0; accent-color: var(--accent); }

/* ------------------------------------------------------------------ ground */

/* Agency chips keep the coloured .sw dot; transit-mode chips replace it with the
   pictogram below, so the three filter families still read as one system. */
#agency-chips .chip .sw, #gmode-chips .chip .sw { display: inline-block; }
/* Mode chips, the legend and the detail badge carry the vehicle pictogram
   itself (inline SVG from the same shape data as the map icons), not a dot.
   The drop shadow stands in for the dot's 1px contrast ring on light chips. */
#gmode-chips .chip .sw { width: auto; height: auto; border-radius: 0; box-shadow: none; background: none; vertical-align: -3px; line-height: 0; }
svg.gi { filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.45)); }
.legend-kinds .lk svg.gi { flex: 0 0 auto; }
#d-badge svg.gi { vertical-align: -2px; margin-right: 5px; }
.chip .fly {
  margin-left: 6px; padding: 0 4px;
  border-left: 1px solid var(--panel-line);
  color: var(--ink-dim); font-size: 13px; line-height: 1;
}
.chip .fly:hover { color: var(--accent); }
.chip.on .fly { border-left-color: rgba(56, 189, 248, 0.35); }

/* stats: one body per mode */
.year-bar .yr.wide { width: 104px; flex: 0 0 104px; font-family: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-table td.left { text-align: left; font-family: inherit; }
.stat-table td.left .sub { display: block; }
.stat-table tr.down th, .stat-table tr.down td { color: #f87171; }
.stat-table th svg.gi { width: 11px; height: 11px; vertical-align: -1px; margin-right: 2px; }
.stat-table th.muted { color: var(--ink-faint); font-weight: 500; }

/* earthquakes */
.legend-kinds .lk.muted { color: var(--ink-faint); }

/* Stats is the one drawer that holds tables: give it room (asked 2026-09-05,
   "you can't read the Stats"). Filters and Settings keep the narrow width. */
#stats.drawer { width: 580px; max-width: 96vw; }

/* Right-to-left interface languages: text runs right-to-left inside panels; the
   map and its controls keep their places. */
html.rtl .drawer, html.rtl .detail, html.rtl #legend, html.rtl .statusbar, html.rtl .toast, html.rtl .search-results, html.rtl #search-results { direction: rtl; }
html.rtl .tab { text-align: right; }
html.rtl .tab.on { box-shadow: inset -3px 0 0 var(--accent); }

/* Settings: tabs down the left, the chosen section on the right. */
#settings.drawer { width: 620px; max-width: 96vw; }
.tabs-body { display: flex; padding: 0 !important; overflow: hidden; }
.tabs-nav { flex: 0 0 148px; display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; border-right: 1px solid var(--panel-line); overflow-y: auto; }
.tab { text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-dim); font: inherit; font-size: 13px; cursor: pointer; }
.tab:hover { color: var(--ink); background: var(--field); }
.tab.on { background: var(--field); color: var(--ink); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
.tabs-panes { flex: 1 1 auto; overflow-y: auto; padding: 4px 18px 18px; min-width: 0; }
.tabs-panes .fgroup[data-tab] { display: none; }
.tabs-panes .fgroup[data-tab].on { display: block; }
.changelog .cl { padding: 10px 0 12px; border-bottom: 1px solid var(--panel-line); }
.changelog .cl:last-child { border-bottom: 0; }
.changelog .cl-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.changelog .cl-date { font-family: var(--mono, ui-monospace, monospace); font-size: 12px; color: var(--accent); white-space: nowrap; }
.changelog .cl-title { font-weight: 650; font-size: 13.5px; }
.changelog ul { margin: 0; padding-left: 18px; }
.changelog li { font-size: 12.5px; line-height: 1.45; color: var(--ink-dim); margin: 3px 0; }
@media (max-width: 640px) {
  #settings.drawer { width: 100vw; max-width: 100vw; }
  .tabs-body { flex-direction: column; }
  .tabs-nav { flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--panel-line); padding: 8px; }
  .tab { white-space: nowrap; }
}
#stats .stat-table { font-size: 12.5px; }
#stats .year-bar .yr.wide { width: 170px; flex: 0 0 170px; }
@media (max-width: 640px) { #stats.drawer { width: 100vw; max-width: 100vw; } }

/* Event cards: one line per event, magnitude first in its age colour. */
.ev-list { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.ev { display: flex; align-items: flex-start; gap: 12px; padding: 8px 10px; border-radius: 10px; background: var(--chip); cursor: pointer; }
.ev:hover, .ev:focus-visible { outline: 1px solid var(--accent, #38bdf8); }
.ev-mag { flex: 0 0 58px; font-family: "Cascadia Mono", ui-monospace, monospace; font-size: 15px; font-weight: 700; line-height: 1.25; }
.ev-main { flex: 1 1 auto; min-width: 0; }
.ev-kicker { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); margin-bottom: 1px; }
.ev-title { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.ev-sub { font-size: 11.5px; color: var(--ink-dim); margin-top: 1px; }

/* storms */
.d-badge .sw, .ev-title .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.fcst-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 2px; }
.fcst-table th { text-align: left; font-weight: 600; color: var(--ink-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 4px 2px 0; }
.fcst-table td { padding: 3px 4px 3px 0; color: var(--ink-dim); white-space: nowrap; font-family: "Cascadia Mono", ui-monospace, monospace; }
.fcst-table td .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.ev-title .muted { font-weight: 400; color: var(--ink-faint); }

/* sea */
#ses-chokes tr[data-choke] { cursor: pointer; }
#ses-chokes td.down { color: #f87171; }

/* -------------------------------------------------------------------- surf */

/* The legend's two explanatory lines span both columns and may wrap. */
#legend-surf .lk.note { grid-column: 1 / -1; white-space: normal; font-size: 14px; line-height: 1.3; }
/* Second and third headings inside one filter group. */
.fgroup h3.sub-head { margin-top: 14px; }
/* The surf card carries two small tables; bottom-anchored, it must scroll rather than run off the top. */
.detail:has(#d-surf:not([hidden])) { max-height: calc(100vh - 76px); overflow-y: auto; overflow-x: hidden; }
#d-surf .fcst-table { display: block; max-width: 100%; overflow-x: auto; }
/* Today's table: the current three-hour block stands out. */
.fcst-table tr.now td { color: var(--ink); font-weight: 600; }
/* "13-18ft" is seven characters; the magnitude column was cut for "M7.1". */
.ev-mag.surf { font-size: 13px; letter-spacing: -0.02em; }
