:root {
  --bg: #fff; --fg: #111827; --muted: #6b7280; --accent: #2563eb; --card: #ffffffee;
  --shadow: 0 4px 24px #0003; --hdr: 104px; --on-accent: #fff; --focus: #1d4ed8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #111827; --fg: #f3f4f6; --muted: #9ca3af; --accent: #60a5fa; --card: #1f2937ee; --on-accent: #0b1220; --focus: #93c5fd; }
}
:root[data-theme="dark"] { --bg: #111827; --fg: #f3f4f6; --muted: #9ca3af; --accent: #60a5fa; --card: #1f2937ee; --on-accent: #0b1220; --focus: #93c5fd; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--fg); }
header { position: fixed; z-index: 5; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 14px 8px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(8px); }
.brand { font-weight: 700; letter-spacing: .02em; }
#count { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; font: inherit;
  background: none; border: 0; min-height: 44px; padding: 0 6px; cursor: pointer; }
#count::after { content: " \25BE"; }
.chips { flex-basis: 100%; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chip { padding: 3px 10px; border-radius: 999px; background: #8882; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip b { color: var(--fg); }
#drone-list { position: fixed; z-index: 5; top: calc(max(8px, env(safe-area-inset-top)) + var(--hdr));
  left: 8px; right: 8px; max-width: 520px; max-height: 50vh; overflow: auto; padding: 6px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
#drone-list[hidden] { display: none; }
#drone-list ul, #history ul { list-style: none; margin: 0; padding: 0; }
#drone-list p { margin: 10px; }
.muted { color: var(--muted); }
.list-head { display: flex; gap: 6px; align-items: center; position: sticky; top: 0; padding: 2px 2px 6px; background: var(--card); }
#drone-search { flex: 1; min-height: 44px; padding: 0 12px; border: 1px solid #8884; border-radius: 12px;
  background: var(--bg); color: var(--fg); font: inherit; }
.list-close { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; }
.drone-row { justify-content: flex-start; align-items: flex-start; padding: 8px 10px; }
.ic svg { width: 28px; height: 28px; display: block; }
.drone-row .ic { flex: none; margin-top: 2px; }
.drone-row .body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.drone-row .l1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.pill { padding: 1px 8px; border-radius: 999px; background: #8883; color: var(--muted); font-size: 12px; font-weight: 500; }
.verified { color: #15803d; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .verified { color: #4ade80; } }
:root[data-theme="dark"] .verified { color: #4ade80; }
.link { border: 0; background: none; color: var(--accent); font: inherit; padding: 8px 6px; min-height: 44px; cursor: pointer; }
#sheet-title { margin: 0; display: flex; align-items: center; gap: 8px; }
.model-line { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.note { margin: 0 0 10px; font-size: 13px; }
.note[hidden] { display: none; }
@media (max-width: 600px) { /* mobile: the list is a bottom sheet */
  #drone-list { top: auto; left: 0; right: 0; bottom: 0; max-width: none; max-height: 48vh;
    border-radius: 20px 20px 0 0; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
}
.row-btn { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 48px; padding: 6px 10px; border: 0; border-radius: 10px; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer; }
.row-btn:hover, .row-btn:active { background: #8882; }
.row-btn .sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
#map { position: fixed; inset: 0; }
#sheet { max-height: 75vh; overflow: auto; position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); background: var(--card);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
#sheet[hidden] { display: none; }
#sheet h2 { margin: 0 32px 10px 0; font-size: 18px; }
#sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
#sheet dt { color: var(--muted); }
#sheet dd { margin: 0; font-variant-numeric: tabular-nums; }
#sheet-close { position: absolute; top: 10px; right: 14px; border: 0; background: none;
  color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 12px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; min-width: 44px; padding: 6px 4px; border: 1px solid #8884; border-radius: 12px;
  background: none; color: var(--fg); font: inherit; font-size: 12px; cursor: pointer; }
.act svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.act[aria-pressed="true"], .act[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.act.small { flex-direction: row; min-height: 44px; padding: 0 14px; font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
#history { margin-top: 12px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
#history-list { max-height: 30vh; overflow: auto; }

.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.legend[hidden] { display: none; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: #f43f5e; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #0003; }
.legend .bar { width: 18px; height: 4px; border-radius: 2px; background: #2563eb; margin-left: 8px; }
.legend .bar.est { background: repeating-linear-gradient(90deg, #2563eb 0 5px, transparent 5px 9px); opacity: .6; }
.legend .bar.thin { height: 3px; }
.legend .dot.small { width: 6px; height: 6px; border-width: 1px; }

#controls { position: fixed; z-index: 4; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + var(--hdr));
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: calc(100vw - 16px); }
#ctl-toggle { display: flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 14px;
  border: 0; border-radius: 22px; background: var(--card); color: var(--fg); font: inherit; font-weight: 600;
  box-shadow: var(--shadow); backdrop-filter: blur(8px); cursor: pointer; }
#ctl-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ctl-row { display: flex; gap: 8px; align-items: center; }
#menu-toggle { display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0;
  border: 0; border-radius: 22px; background: var(--card); color: var(--fg); font: inherit; font-size: 20px; line-height: 1;
  box-shadow: var(--shadow); backdrop-filter: blur(8px); cursor: pointer; }
#menu-panel { width: 280px; max-width: 100%; max-height: calc(100vh - 190px); overflow: auto; padding: 4px 12px 8px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
#menu-panel[hidden] { display: none; }
#menu-panel .menu-link { min-height: 44px; margin: 0; }
.sect > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; }
.sect { border-bottom: 1px solid #8883; }
#data-note { margin: 8px 0 0; }
#ctl-panel { width: 300px; max-width: 100%; max-height: calc(100vh - 190px); overflow: auto; padding: 8px 12px 12px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
#ctl-panel[hidden], #empty[hidden], #demo-offer[hidden] { display: none; }
#ctl-panel fieldset { border: 0; margin: 6px 0 0; padding: 0; }
#ctl-panel legend { padding: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.seg { display: flex; gap: 6px; margin-top: 4px; }
.opt { flex: 1; min-height: 44px; min-width: 44px; padding: 0 8px; border: 1px solid #8884; border-radius: 12px;
  background: none; color: var(--fg); font: inherit; font-size: 14px; cursor: pointer; }
.opt.wide { width: 100%; margin-top: 4px; }
.opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; min-height: 44px; }
.field select { min-height: 44px; min-width: 140px; border-radius: 12px; border: 1px solid #8884; background: var(--bg);
  color: var(--fg); font: inherit; padding: 0 8px; }
.sw.cov { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid #1d4ed8; opacity: .8; }
.sw.cov.l0 { background: #93c5fd; margin-left: 0; }
.sw.cov.l1 { background: #60a5fa; }
.sw.cov.l2 { background: #2563eb; }
.sw.cov.l3 { background: #1e3a8a; }
#cov-legend { margin: 8px 0 0; }
#legend { margin-top: 10px; }
#legend[hidden] { display: none; }
.ramp { display: flex; height: 10px; border-radius: 5px; overflow: hidden; }
.ramp i { flex: 1; }
.ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.ticks .mark { color: #9333ea; font-weight: 700; }
#legend p { margin: 8px 0 0; font-size: 12px; }
.sw.sus { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #dc2626; vertical-align: -1px; }
#empty, #demo-offer { position: fixed; z-index: 3; left: 8px; right: 8px; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: 420px;
  margin: 0 auto; padding: 14px 16px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(8px); }
#empty p, #demo-offer p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.badge { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; background: #8881; font-size: 14px; }
#sheet-flags { list-style: none; margin: 0 0 10px; padding: 0; }
#sheet-flags li { margin: 0 0 6px; padding: 8px 12px; border-radius: 10px; font-size: 14px; background: #f59e0b22;
  border: 1px solid #f59e0b66; }
#sheet-flags li.sus { background: #dc262622; border-color: #dc2626aa; font-weight: 600; }
#sheet-flags .why { margin: 4px 0 0; font-size: 13px; font-weight: 400; }
#sheet-flags li.info { background: #8881; border-color: #8884; font-weight: 400; color: var(--muted); }
.details-row { margin: 0 0 8px; }
.details-row .link { display: inline-flex; align-items: center; padding: 0; }

/* drone sheet: handle + heard line exist on phones only */
#sheet-handle, #sheet-heard { display: none; }
#sheet-grip { cursor: default; }
@media (max-width: 767px) {
  :root { --hdr: 96px; }
  body.sheet-open { --hdr: 66px; }
  header { padding: 2px 12px 4px; }
  .chips { flex-wrap: nowrap; overflow: hidden; margin-top: 0; padding-bottom: 2px; }
  .chip { padding: 2px 8px; font-size: 12px; }
  body.sheet-open .chips { display: none; }
  #sheet { max-width: none; max-height: 72vh; padding-top: 6px; }
  #sheet[data-state="peek"] { overflow: hidden; }
  #sheet[data-state="peek"] .more, #sheet[data-state="peek"] .note { display: none; }
  #sheet-grip { touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; margin-bottom: 6px; }
  #sheet-handle { display: block; width: 40px; height: 5px; margin: 0 auto 8px; border-radius: 3px; background: #8886; }
  #sheet h2 { margin-right: 36px; font-size: 17px; }
  #sheet-close { top: 14px; }
  #sheet-heard { display: block; margin: 0 0 8px; font-size: 13px; color: var(--muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  #sheet[data-state="expanded"] #sheet-heard { display: none; }
  #sheet.dragging { transition: none; }
}

/* desktop: the card is a side panel docked left, below the header; the map pads itself by its width */
#sheet-collapse { display: none; }
@media (min-width: 768px) {
  #sheet { left: 8px; right: auto; top: calc(max(8px, env(safe-area-inset-top)) + var(--hdr)); bottom: 8px;
    width: 380px; max-width: none; max-height: none; margin: 0; padding: 14px 16px; border-radius: 14px; }
  #sheet-collapse { display: block; position: absolute; top: 10px; right: 46px; border: 0; background: none;
    color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer; }
  #sheet[data-state="collapsed"] { bottom: auto; overflow: hidden; }
  #sheet[data-state="collapsed"] > :not(#sheet-grip):not(#sheet-close):not(#sheet-collapse) { display: none; }
  #sheet[data-state="collapsed"] h2 { margin-bottom: 0; }
}

/* PWA: install button, toasts, standalone polish */
html, body { overscroll-behavior: none; } /* no pull-to-refresh fighting the sheet drag */
#install-btn { display: inline-flex; align-items: center; gap: 2px; }
#install-btn[hidden] { display: none; }
#install-btn button { min-height: 44px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0 8px; }
#install-btn #install-dismiss { color: var(--muted); font-size: 22px; padding: 0 10px; }
.pwa-toast { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center;
  padding: 6px 8px 6px 16px; border-radius: 14px; background: var(--card); color: var(--fg); box-shadow: var(--shadow);
  backdrop-filter: blur(8px); max-width: calc(100vw - 16px); }
.pwa-toast button { min-height: 44px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.alert-toast { bottom: calc(76px + env(safe-area-inset-bottom)); flex-wrap: wrap; justify-content: center; }
.alert-toast a { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; }
@media (display-mode: standalone) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
}
.menu-link { display: flex; align-items: center; text-decoration: none; margin-top: 4px; }
.legal-links { display: flex; gap: 4px 16px; align-items: center; flex-wrap: wrap; margin: 8px 0 0; font-size: 13px; }
.legal-links .link { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
#empty .empty-link { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 0 12px; }
#empty, #demo-offer { padding-right: 52px; }
#demo-start { min-height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: var(--accent); color: var(--on-accent, #fff); font: inherit; font-weight: 600; cursor: pointer; }
#empty-dismiss, #demo-dismiss { position: absolute; top: 4px; right: 4px; min-width: 44px; min-height: 44px; border: 0;
  background: none; color: var(--muted); font-size: 26px; cursor: pointer; }
#empty .empty-link a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }

/* history replay (replay.js): banner under the header, scrub bar at the bottom */
:root { --rbar: 112px; }
#replay-banner, #demo-banner { position: fixed; z-index: 5; left: 8px; right: 8px; max-width: 560px;
  top: calc(max(8px, env(safe-area-inset-top)) + var(--hdr)); display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 2px 8px; padding: 0 6px 0 14px; border-radius: 14px;
  background: #b45309; color: #fff; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); }
#replay-banner[hidden], #demo-banner[hidden], #replay-bar[hidden], #replay-message[hidden] { display: none; }
#replay-title, #demo-title { flex: 1 1 0; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
#replay-exit, #demo-stop { flex: none; min-height: 44px; padding: 0 10px; border: 0; background: none; color: #fff; font: inherit;
  text-decoration: underline; cursor: pointer; }
#replay-message { flex-basis: 100%; margin: 0 0 8px; font-weight: 500; font-size: 13px; }
#replay-bar { position: fixed; z-index: 4; left: 8px; right: 8px; max-width: 560px; height: var(--rbar);
  bottom: calc(8px + env(safe-area-inset-bottom)); padding: 6px 12px 8px; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
#replay-scrub { display: block; width: 100%; height: 44px; margin: 0; accent-color: #b45309; touch-action: none; }
#replay-bar .r-row { display: flex; align-items: center; gap: 8px; }
#replay-bar .seg { margin-top: 0; flex: 1; }
#replay-bar .opt { min-height: 44px; }
#replay-play { flex: none; width: 44px; height: 44px; border: 0; border-radius: 22px; background: #b45309; color: #fff; cursor: pointer; }
#replay-play svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
#replay-play[aria-pressed="true"] .i-play, #replay-play[aria-pressed="false"] .i-pause { display: none; }
#replay-clock { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
body.replaying #controls { top: calc(max(8px, env(safe-area-inset-top)) + var(--hdr) + 52px); }
body.replaying .maplibregl-ctrl-bottom-right { margin-bottom: calc(var(--rbar) + 8px); }
@media (max-width: 767px) { body.replaying.sheet-open #replay-bar { display: none; } } /* the sheet owns the bottom */
@media (min-width: 768px) {
  #sheet:not([hidden]) ~ #replay-bar, #sheet:not([hidden]) ~ #replay-banner { left: 404px; } /* docked panel */
  #replay-clock { display: none; }
}

/* accessibility (WCAG 2.2 AA): focus ring on every control, text-only helpers, reduced motion */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.maplibregl-canvas:focus-visible { outline-offset: -3px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: fixed; z-index: 30; left: 8px; top: 8px; transform: translateY(-200%); min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; }
.skip:focus-visible { transform: none; }
h1.brand { margin: 0; font-size: inherit; }
#sheet:focus { outline: none; }
#sheet-close, #sheet-collapse { min-width: 44px; min-height: 44px; }
#sheet-close { right: 6px; top: 4px; }
@media (min-width: 768px) { #sheet-collapse { right: 44px; top: 4px; } }
@media (max-width: 767px) { #sheet-close { top: 8px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.pill.sus { background: #dc262622; color: #b91c1c; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.sus { color: #fca5a5; } :root:not([data-theme="light"]) .ticks .mark { color: #d8b4fe; } }
:root[data-theme="dark"] .pill.sus { color: #fca5a5; } :root[data-theme="dark"] .ticks .mark { color: #d8b4fe; }

/* map controls: 44 px touch targets; on phones +/- and "my location" ride above the drone sheet */
.maplibregl-ctrl-group button { width: 44px; height: 44px; }
.maplibregl-ctrl-group button svg { width: 24px; height: 24px; display: block; margin: auto; fill: none; stroke: #333; stroke-width: 2; stroke-linecap: round; }
.maplibregl-ctrl-group[hidden] { display: none; }
@media (max-width: 767px) {
  body.sheet-open .maplibregl-ctrl-bottom-right { margin-bottom: calc(var(--sheet-h, 0px) + 4px); }
}
@media (max-width: 600px) { body.list-open .maplibregl-ctrl-bottom-right { margin-bottom: 48vh; } } /* above the list sheet */

/* filters badge, place search, aviation (#71) */
.chip.badge { border: 1px solid var(--accent); background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; min-height: 28px; }
.chip.badge[hidden] { display: none; }
#place-search { box-sizing: border-box; width: 100%; min-height: 44px; margin-top: 4px; padding: 0 12px; border: 1px solid #8884;
  border-radius: 12px; background: var(--bg); color: var(--fg); font: inherit; }
#place-results { list-style: none; margin: 4px 0 0; padding: 0; }
#place-results[hidden] { display: none; }
#place-results button { width: 100%; min-height: 44px; text-align: left; padding: 0 10px; border: 0; border-radius: 10px;
  background: none; color: var(--fg); font: inherit; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#place-results button:hover, #place-results button:focus-visible { background: #8882; }
#place-results .muted { color: var(--muted); font-size: 13px; }

/* Logo mark: /logo.svg#mark, single colour (currentColor), so it follows light and dark */
.logo { flex: none; margin-right: 8px; color: var(--accent); }
h1.brand { display: inline-flex; align-items: center; }
