/* R1c: the map-first heads-up shell. Phone first; desktop is the same components (the dock a
   vertical rail, the sheet a right-side panel). ONE breakpoint source: app.js sets html.phone
   from a single matchMedia, "(max-width: 600px), (pointer: coarse) and (max-height: 500px)", and
   every phone rule keys on that class. Sizes written at run time (the sheet heights, the dock
   height, the attribution offset) are CSS variables set through CSSOM: the CSP has no
   'unsafe-inline', so there is never a style="" attribute. Every interactive element is at least
   44 x 44 CSS px. */

/* Self-hosted fonts (SIL OFL 1.1; the licences and sha256 sums are in fonts/). Latin subset. */
@font-face {
  font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/bricolage-grotesque/bricolage-grotesque-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/bricolage-grotesque/bricolage-grotesque-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/atkinson-hyperlegible/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/atkinson-hyperlegible/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
}

:root {
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ink: #16181d;
  --muted: #565c68;
  --line: #dfe2e8;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --accent: #1a56c4;
  --focus: #1a56c4;
  --live: #1e9e3e;
  --stale: #c96f00;
  --nodata: #c4001a;
  --replay: #6a3d9a;
  /* The mockup's tier colours (chrome); dark text on yellow and orange, white on red. */
  --tier-yellow: #F2C230;
  --tier-orange: #F07E26;
  --tier-red: #D7263D;
  /* The map's own tier colours (lib/geo.js), for the legend swatches that describe the map. */
  --map-yellow: #ffd000;
  --map-orange: #ff7a00;
  --map-red: #e8001c;
  --shadow: 0 2px 10px rgba(16, 24, 40, 0.18);
  --top-inset: max(10px, env(safe-area-inset-top));
  --dock-h: calc(64px + env(safe-area-inset-bottom));
  --rail-w: 84px;
  --panel-w: 384px;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
}

html, body { margin: 0; height: 100%; background: #eef0ee; overflow: hidden; overscroll-behavior: none; }
#map { position: absolute; inset: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button, select, input, a { font: inherit; color: inherit; }
.small { font-size: 13px; color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }

/* ---- Top bar: the status pill (centre) and the avatar (right). ---------------------------- */
#topbar {
  position: fixed; z-index: 4; top: var(--top-inset);
  left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  height: 44px; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.pill {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; max-width: calc(100% - 120px); box-sizing: border-box;
  padding: 0 18px; border: 0; border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 15px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill-text { overflow: hidden; text-overflow: ellipsis; }
.pill-dots { display: inline-flex; gap: 4px; flex: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #9aa0aa; flex: none; }
.dot[data-state="live"] { background: var(--live); }
.dot[data-state="stale"] { background: var(--stale); }
.dot[data-state="nodata"] { background: var(--nodata); }
.dot[data-state="replay"] { background: var(--replay); }
.pill[data-mode="stale"] { background: #fff4e0; color: #5c3200; }
.pill[data-mode="nodata"] { background: #ffe9ec; color: #7a0010; }
.pill[data-mode="replay"] { background: #f1e9fa; color: #3d1f63; }

.avatar {
  position: absolute; right: 0; top: 0; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer; color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
}
.avatar.has-initial { background: var(--ink); color: #fff; }
.avatar.has-initial .avatar-glyph { display: none; }
.avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }

/* ---- Banners, under the top bar. ----------------------------------------------------------- */
/* R2b: the column also holds the alert card and the toasts. On a phone it keeps clear of the map
   controls on the right (zoom and locate, 44 px wide at 10 px from the edge). */
#banners {
  position: fixed; z-index: 6; top: calc(var(--top-inset) + 54px);
  left: max(12px, env(safe-area-inset-left)); right: calc(max(10px, env(safe-area-inset-right)) + 54px);
  max-height: calc(100% - var(--top-inset) - 54px - var(--sheet-now, var(--dock-h)) - 12px); overflow: hidden;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.banner {
  pointer-events: auto; box-sizing: border-box;
  background: #b80016; color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; text-align: center; box-shadow: var(--shadow);
}
#conn-banner button {
  margin-left: 6px; min-height: 44px; min-width: 44px; padding: 0 14px; cursor: pointer;
  border: 0; border-radius: 10px; background: #fff; color: #b80016; font-weight: 700;
}

/* ---- The dock (phone: bottom tabs). -------------------------------------------------------- */
#dock {
  position: fixed; z-index: 7; left: 0; right: 0; bottom: 0;
  height: var(--dock-h); box-sizing: border-box; padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.08);
}
.dock-tab {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; min-width: 44px; min-height: 44px; height: 64px;
  padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 12px; font-weight: 700; letter-spacing: 0.01em;
}
.dock-tab[aria-expanded="true"], .dock-tab[aria-current="page"] { color: var(--accent); }
.dock-tab[aria-expanded="true"]::before, .dock-tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 6px; width: 44px; height: 32px; border-radius: 16px;
  background: rgba(26, 86, 196, 0.12); z-index: -1;
}
.dock-tab svg { margin-top: 4px; }
.count {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px;
  padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: var(--tier-red);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ---- The sheet (phone: a bottom sheet on the dock). ---------------------------------------- */
#sheet {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: var(--dock-h);
  max-width: 640px; margin: 0 auto; height: var(--sheet-half, 50%);
  display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box;
  background: var(--surface); border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 18px rgba(16, 24, 40, 0.22);
  transition: height 0.2s ease-out;
}
#sheet.snap-full { height: var(--sheet-full, 85%); }
#sheet.dragging { height: var(--sheet-full, 85%); transition: none; }
#sheet.settling { height: var(--sheet-drag, 50%); transition: none; }
#sheet-grab {
  position: absolute; z-index: 2; top: 0; left: 50%; transform: translateX(-50%);
  width: 132px; height: 44px; touch-action: none;
}
#sheet-handle {
  display: block; width: 100%; height: 44px; margin: 0; padding: 0; border: 0;
  background: transparent; cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
#sheet-handle::before {
  content: ""; display: block; width: 40px; height: 5px; margin: 0 auto;
  border-radius: 3px; background: #b4b8c0;
}
.pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.pane-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 18px 8px 4px 18px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.pane-head h2 {
  margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 22px;
  letter-spacing: -0.01em;
}
.pane-head h2:focus { outline: none; }
.pane-head h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pane-close {
  width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--surface-2);
  cursor: pointer; font-size: 16px; flex: none;
}
.pane-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 18px 18px;
  touch-action: pan-y; overscroll-behavior: contain;
}
.group { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h3 {
  margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 16px;
}

/* Form controls, all >= 44 px tall. */
.check {
  display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.field { display: block; margin: 8px 0 2px; font-weight: 700; font-size: 14px; }
select {
  display: block; width: 100%; min-height: 44px; box-sizing: border-box; padding: 0 10px;
  border: 1px solid #b8bdc6; border-radius: 10px; background: var(--surface);
}
input[type="range"] {
  display: block; width: 100%; height: 44px; margin: 0; accent-color: var(--accent);
}
#radar-key { margin: 6px 0 2px; }
#radar-key .bar {
  height: 12px; border: 1px solid #999; border-radius: 2px;
  /* A white ground under the key, as under the map: a transparent step shows as the page. */
  background-color: #fff;
}
#radar-key .ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
#radar-note { margin: 2px 0 6px; }

/* M3e playback rows (R3: the scrubber, below; the simple replay row in Layers). */
.play-row { display: flex; align-items: center; gap: 10px; }
.play-row2 { display: flex; align-items: center; gap: 8px; min-height: 44px; flex-wrap: wrap; }

.tiers { list-style: none; padding: 0; margin: 6px 0; }
.tiers li { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-weight: 700; font-size: 13px; }
.swatch { display: inline-block; width: 22px; height: 12px; border-radius: 2px; border: 1.5px solid #222; }
.tier-yellow { background: var(--map-yellow); }
.tier-orange { background: var(--map-orange); }
.tier-red { background: var(--map-red); }
/* M5b: the early-look legend entry; hollow and dashed, like the provisional overlay. */
.swatch.early-swatch { background: transparent; border: 2px dashed #d45a00; border-radius: 6px; }
#legend p { margin: 6px 0; }

/* Radar health rows: the id and short text, then the full text (never hover-only). */
#sites .site {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-weight: 700; font-variant-numeric: tabular-nums;
}
#sites .site b { font-family: var(--font-display); font-size: 16px; }
#sites .site .dot { background: #9aa0aa; }
#sites .site.live .dot { background: var(--live); }
#sites .site.stale .dot { background: var(--stale); }
#sites .site.nodata .dot { background: var(--nodata); }
#sites .site.replay .dot { background: var(--replay); }
#sites .site.stale, #sites .site.nodata { color: var(--nodata); }
#sites .site.replay { color: var(--replay); }
.site-full {
  margin: 2px 0 8px 18px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
}

/* The Me sheet. */
#me-line { margin: 4px 0 10px; font-size: 16px; overflow-wrap: anywhere; }
.button-link, .wide {
  display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px;
  box-sizing: border-box; padding: 0 16px; border-radius: 10px; text-decoration: none;
  border: 1px solid #b8bdc6; background: var(--surface); font-weight: 700; cursor: pointer;
}
.button-link { display: inline-flex; }
.wide { width: 100%; margin-top: 8px; }
.wide:disabled { color: #8a909a; background: var(--surface-2); cursor: default; }
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-weight: 700; }
.switch {
  position: relative; width: 64px; height: 44px; padding: 0; border: 0; background: transparent;
  cursor: pointer; flex: none;
}
.switch span {
  position: absolute; left: 8px; right: 8px; top: 10px; bottom: 10px; border-radius: 12px;
  background: #c3c7cf; transition: background 0.15s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch[aria-checked="true"] span { background: var(--accent); }
.switch[aria-checked="true"] span::after { transform: translateX(24px); }
.disclaimer { font-weight: 700; font-size: 13px; }

/* ---- Alerts (R2b): the cards (map top, sheet head, sheet list), the quiet line, toasts. ---- */
.alert-card {
  margin: 10px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: var(--surface);
}
.alert-card .tier-band, .toast .toast-tier {
  padding: 6px 12px; font-family: var(--font-display); font-weight: 700; font-size: 14px;
  letter-spacing: 0.02em; background: #9aa0aa; color: #111;
}
.alert-card[data-tier="ROTATION"] .tier-band, .toast[data-tier="ROTATION"] .toast-tier { background: var(--tier-yellow); color: #1d1600; }
.alert-card[data-tier="STRONG ROTATION"] .tier-band, .toast[data-tier="STRONG ROTATION"] .toast-tier { background: var(--tier-orange); color: #1f0d00; }
.alert-card[data-tier="DEBRIS CONFIRMED"] .tier-band, .toast[data-tier="DEBRIS CONFIRMED"] .toast-tier { background: var(--tier-red); color: #fff; }
/* An early look is visibly provisional: a dashed border and a hatched band, never merged. */
.alert-card.early, .toast.early { border: 2px dashed #6b7280; }
.alert-card.early .tier-band, .toast.early .toast-tier {
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.35) 0 6px, transparent 6px 12px);
}
.ac-body { padding: 8px 12px 10px; }
.ac-body p { margin: 0 0 4px; }
.ac-sentence { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1.25; }
.ac-where { font-size: 14px; color: var(--muted); }
.ac-eta { font-size: 14px; font-variant-numeric: tabular-nums; }
.ac-detail { font-size: 13px; color: var(--muted); }
.ac-disclaimer { margin: 6px 0 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.alert-card .show-on-map { margin: 8px 0 0; }
.alerts-sub { margin: 14px 0 2px; font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.alerts-empty { margin: 16px 0; color: var(--muted); }
#alerts-head .alert-card { margin-top: 2px; box-shadow: var(--shadow); }

/* The card on the map: compact, under the pill, beside the map controls (never over them). */
#alert-top { pointer-events: none; display: flex; flex-direction: column; gap: 6px; }
html.alerts-open #alert-top, html.sheet-full #alert-top { display: none; }
/* An open map popup that the CARD would cover: the card yields until it closes or moves clear
   (app.js updatePopupYield). visibility, not display, so its rect still measures. Toasts never
   yield (review F1). */
html.popup-yield #alert-top { visibility: hidden; }
#alert-top > * { pointer-events: auto; }
#alert-top-cards { display: flex; flex-direction: column; gap: 6px; }
#alert-top .alert-card { margin: 0; box-shadow: var(--shadow); }
#alert-top .tier-band { padding: 4px 10px; font-size: 12px; }
#alert-top .ac-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 0 10px; }
#alert-top .ac-body { flex: 1 1 auto; min-width: 0; padding: 0; }
#alert-top .ac-sentence { font-size: 15px; }
#alert-top .ac-where { display: none; }
#alert-top .ac-eta { font-size: 13px; margin: 0; }
#alert-top .show-on-map { flex: none; width: auto; margin: 0; padding: 0 12px; font-size: 13px; }
#alert-top .ac-disclaimer { margin: 2px 10px 6px; font-size: 11px; }
.alert-quiet {
  align-self: flex-start; margin: 0; padding: 4px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow);
  font-size: 13px; color: var(--muted);
}

/* "+N more alerts" (re-review R1): pinned at the top of the column, before the toasts, so it is
   never clipped; a 44 px button that opens the Alerts sheet. */
.toast-more {
  pointer-events: auto; flex: none; align-self: flex-start; min-height: 44px; min-width: 44px;
  padding: 0 16px; border: 0; border-radius: 22px; background: var(--ink); color: #fff;
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow); cursor: pointer;
}
/* Toasts: stacked above the cards, most severe first; they slide in unless motion is reduced. */
#toasts { display: flex; flex-direction: column; gap: 6px; }
.toast {
  pointer-events: auto; border-radius: 14px; overflow: hidden; background: var(--surface);
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.3); border: 1px solid var(--line);
  animation: toast-in 0.25s ease-out;
}
.toast p { margin: 0; }
.toast .toast-tier { padding: 4px 10px; font-size: 12px; }
.toast .toast-text { padding: 5px 10px 0; font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.25; }
.toast-row { display: flex; align-items: center; gap: 6px; padding: 2px 6px 6px 10px; }
.toast-meta { flex: 1 1 auto; min-width: 0; }
.toast .toast-kind { font-size: 12px; }
.toast .toast-ended { font-size: 13px; font-weight: 700; color: var(--ink); }
.toast-actions button:disabled { color: #8a909a; cursor: default; }
.toast .ac-disclaimer { margin: 0; font-size: 11px; }
.toast-actions { flex: none; display: flex; gap: 6px; }
.toast-actions button {
  min-height: 44px; min-width: 44px; padding: 0 10px; border: 1px solid #b8bdc6;
  border-radius: 10px; background: var(--surface); font-weight: 700; font-size: 13px; cursor: pointer;
}
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Map popups. */
.maplibregl-popup-content { font-family: var(--font-body); font-size: 14px; line-height: 1.4; max-width: 280px; padding: 12px 40px 12px 12px; }
.maplibregl-popup-close-button { width: 44px; height: 44px; font-size: 22px; }
.popup h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 16px; }
.popup .note { color: var(--muted); font-style: italic; }
.popup ul { margin: 2px 0 0; padding-left: 16px; }
.early-popup .early-label { font-variant-numeric: tabular-nums; }
.early-popup .early-marker { font-weight: 600; color: #b80016; }

/* MapLibre controls: 44 px targets, clear of the top bar; the attribution follows the sheet. */
.maplibregl-ctrl-group button { width: 44px; height: 44px; }
.maplibregl-ctrl-top-right { top: calc(var(--top-inset) + 54px); }
.maplibregl-ctrl-attrib.maplibregl-compact { min-height: 44px; padding: 0 44px 0 0; border-radius: 22px; }
.maplibregl-ctrl-attrib.maplibregl-compact-show { padding: 0 44px 0 10px; }
.maplibregl-ctrl-attrib-button { width: 44px; height: 44px; border-radius: 22px; background-position: center; background-repeat: no-repeat; }
.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner { line-height: 44px; }
.maplibregl-ctrl-attrib.maplibregl-compact-show a { display: inline-block; min-height: 44px; }
.maplibregl-ctrl button.locate-button { font-size: 20px; line-height: 1; color: #333; }
.maplibregl-ctrl button.locate-button.locate-on { color: #1a73e8; background-color: #e8f0fe; }
.maplibregl-ctrl button.locate-button.locate-on.locate-stale { color: #8a8a8a; background-color: #f0f0f0; }
html.phone .maplibregl-ctrl-bottom-right, html.phone .maplibregl-ctrl-bottom-left {
  bottom: var(--sheet-now, 64px); transition: bottom 0.2s ease-out;
}

/* ---- Desktop: the dock is a vertical rail on the left, the sheet a right-side panel. ------- */
html:not(.phone) #dock {
  top: 12px; bottom: auto; left: 12px; right: auto; width: var(--rail-w); height: auto;
  padding: 8px 0; grid-template-columns: 1fr; gap: 4px;
  border: 0; border-radius: 18px; box-shadow: var(--shadow);
}
html:not(.phone) .dock-tab { height: 68px; }
html:not(.phone) #topbar { left: calc(var(--rail-w) + 24px); right: 12px; top: 12px; }
html:not(.phone) .pill { max-width: calc(100% - 140px); }
html:not(.phone) #sheet {
  top: 68px; bottom: 12px; left: auto; right: 12px; width: var(--panel-w); max-width: none;
  height: auto; margin: 0; border-radius: 18px; box-shadow: var(--shadow); transition: none;
}
html:not(.phone) #sheet-grab { display: none; }
html:not(.phone) .maplibregl-ctrl-top-right { top: 56px; }
html:not(.phone).sheet-open .maplibregl-ctrl-top-right,
html:not(.phone).sheet-open .maplibregl-ctrl-bottom-right { right: calc(var(--panel-w) + 12px); }
html:not(.phone) #banners {
  top: 66px; left: calc(var(--rail-w) + 24px); right: auto; width: 340px; max-height: calc(100% - 78px);
}

@media (prefers-reduced-motion: reduce) {
  #sheet, .switch span, .switch span::after,
  html.phone .maplibregl-ctrl-bottom-right, html.phone .maplibregl-ctrl-bottom-left {
    transition: none !important;
  }
  .toast { animation: none !important; }
}

/* ---- R3: the Layers sheet. --------------------------------------------------------------- */
/* Radar on/off: a native checkbox drawn as the switch (role=switch; a 64 x 44 target). */
.switch-row label { cursor: pointer; }
.switch-input {
  appearance: none; -webkit-appearance: none; position: relative; flex: none;
  width: 64px; height: 44px; margin: 0; cursor: pointer; background: transparent;
}
.switch-input::before {
  content: ""; position: absolute; left: 8px; right: 8px; top: 10px; bottom: 10px;
  border-radius: 12px; background: #c3c7cf; transition: background 0.15s;
}
.switch-input::after {
  content: ""; position: absolute; top: 13px; left: 11px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch-input:checked::before { background: var(--accent); }
.switch-input:checked::after { transform: translateX(24px); }

/* The fast-scan badge (M5a sweep image showing). */
.badge {
  display: inline-block; margin: 2px 0 8px; padding: 3px 10px; border-radius: 12px;
  background: #e7f0ff; color: #123a80; font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* The product picker: a radio group of large choices. */
.picker { margin: 4px 0 6px; padding: 0; border: 0; min-width: 0; }
.picker legend { padding: 0; margin-bottom: 6px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; box-sizing: border-box;
  margin: 0 0 6px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: #eef4ff; }
.choice input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.choice-text { display: flex; flex-direction: column; min-width: 0; }
.choice-name { font-weight: 700; font-size: 15px; }
.choice-term { font-size: 12px; color: var(--muted); }
.choice-explain { font-size: 13px; color: var(--ink); margin-top: 2px; }

/* The colour key's plain labels, under the numeric ticks. */
#radar-key .key-labels { position: relative; min-height: 18px; font-size: 12px; font-weight: 700; color: var(--ink); }
#radar-key .key-label { position: absolute; top: 0; white-space: nowrap; }
#radar-key .key-start { left: 0; }
#radar-key .key-end { right: 0; }
#radar-key .key-at { left: var(--at, 50%); transform: translateX(-50%); }
#radar-key .key-at::before {
  content: ""; position: absolute; left: 50%; top: -20px; height: 18px; border-left: 2px solid var(--ink);
}

/* The simple replay (expert off). */
.wide-inline {
  min-height: 44px; min-width: 44px; padding: 0 16px; border: 1px solid #b8bdc6; border-radius: 10px;
  background: var(--surface); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.wide-inline:disabled { color: #8a909a; background: var(--surface-2); cursor: default; }

/* ---- R3 expert mode: the docked scrubber. ------------------------------------------------ */
#scrubber {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: var(--dock-h);
  box-sizing: border-box; padding: 6px 12px 4px; background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.08);
}
html.phone.sheet-open #scrubber { display: none; }
#playback .play-row { display: flex; align-items: center; gap: 8px; }
#playback button {
  flex: none; min-height: 44px; min-width: 44px; padding: 0 12px; cursor: pointer; white-space: nowrap;
  border: 1px solid #b8bdc6; border-radius: 10px; background: var(--surface); font-weight: 700;
}
#playback button:disabled { cursor: default; color: #9aa0aa; }
#play-button { width: 5em; }
#play-slider { flex: 1 1 auto; min-width: 80px; width: 0; }
#play-label {
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums; color: var(--muted); padding-left: 2px;
}
#play-label[data-mode="replay"] { color: var(--replay); font-weight: 700; }
html:not(.phone) #scrubber {
  left: calc(var(--rail-w) + 24px); right: 12px; bottom: 12px; max-width: 760px;
  border: 0; border-radius: 16px; box-shadow: var(--shadow);
}
html:not(.phone).sheet-open #scrubber { right: calc(var(--panel-w) + 24px); }

/* ---- R3 expert mode: the value probe. ---------------------------------------------------- */
.maplibregl-ctrl button.probe-button { font-size: 22px; line-height: 1; color: #333; }
.maplibregl-ctrl button.probe-button.probe-on { color: #fff; background-color: var(--ink); }
html.probe-on .maplibregl-canvas-container.maplibregl-interactive,
html.probe-on .maplibregl-canvas { cursor: crosshair !important; }
#probe-readout {
  position: fixed; z-index: 6; left: 12px; right: 12px;
  bottom: calc(var(--dock-h) + var(--scrub-h, 0px) + 8px);
  display: flex; align-items: center; gap: 8px; box-sizing: border-box;
  padding: 6px 6px 6px 14px; border-radius: 14px; background: var(--ink); color: #fff;
  box-shadow: var(--shadow);
}
html.phone.sheet-open #probe-readout { bottom: calc(var(--sheet-now, var(--dock-h)) + 8px); }
html:not(.phone) #probe-readout {
  left: calc(var(--rail-w) + 24px); right: auto; width: 360px;
  bottom: calc(12px + var(--scrub-h, 0px) + 8px);
}
.probe-text { flex: 1 1 auto; min-width: 0; }
#probe-readout p { margin: 0; }
#probe-main { font-family: var(--font-display); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
#probe-fine { font-size: 12px; color: #c9ced8; }
#probe-close {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 22px; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 16px;
}

/* ---- R3 expert mode: track detail (popup and the Alerts cards' expander). ---------------- */
.facts { margin: 4px 0 6px; display: grid; gap: 2px; font-size: 13px; }
.facts .fact { display: grid; grid-template-columns: 7.5em 1fr; gap: 6px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.ac-more { margin: 6px 0 2px; }
.ac-more summary {
  display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700;
  font-size: 14px; color: var(--accent);
}
@media (prefers-reduced-motion: reduce) {
  .switch-input::before, .switch-input::after { transition: none !important; }
}
