/* ═══════════════════════════════════════════════════════════════════════════
   Layout — app shell, sidebar, map surface, and the floating map overlays.
   Component internals live in components.css; breakpoints in responsive.css.
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app { display: flex; height: 100vh; height: 100dvh; width: 100vw; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--accent-line);
  box-shadow: 4px 0 40px var(--accent-glow);
  z-index: 700;
  transition: width .3s ease, min-width .3s ease;
  overflow: hidden;
}
/* Border and glow go with it — a one-pixel line and a shadow left behind is
   a seam where the point was to have no seam. */
#sidebar.collapsed { width: 0; min-width: 0; border-right: 0; box-shadow: none; }

#sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 16px 80px; }
#sidebar-scroll::-webkit-scrollbar { width: 3px; }
#sidebar-scroll::-webkit-scrollbar-thumb { background: var(--accent-line); border-radius: 2px; }

/* ── Logo ───────────────────────────────────────────────────────────────── */
#logo-area {
  padding: 28px 20px 22px;
  border-bottom: 1px solid var(--accent-line);
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
  position: relative;
}
/* Brand logo. Two files rather than a CSS filter so the official artwork is
   used verbatim in each theme — white lettering on dark, black on light.
   Every visibility rule is written at ID specificity: a plain `.logo-light`
   class rule loses to the `#dsoc-logo-light` sizing rule and both would show. */
#dsoc-logo, #dsoc-logo-light {
  width: 100%; max-width: 250px; height: auto; margin-bottom: 8px;
}
#dsoc-logo       { display: block; }   /* dark theme default */
#dsoc-logo-light { display: none; }

:root[data-theme="light"] #dsoc-logo       { display: none; }
:root[data-theme="light"] #dsoc-logo-light { display: block; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) #dsoc-logo       { display: none; }
  :root:not([data-theme="dark"]) #dsoc-logo-light { display: block; }
}

.dsoc-subtitle {
  font-size: 9px; font-weight: 400; letter-spacing: 0.28em; color: var(--muted);
  text-transform: uppercase; text-align: center;
}

/* ── Main / map ─────────────────────────────────────────────────────────── */
/* overflow: CLIP, not hidden.
  
   `hidden` clips the paint but still makes the element a scroll container —
   it only takes the scrollbar away. The browser is then free to scroll it
   programmatically, and it does: anything off to the side that receives focus
   gets scrolled into view.
  
   That is exactly what was happening. The camera stack parks itself off the
   right edge when collapsed (translateX), which leaves #main 304px of hidden
   horizontal overflow. Open the county forecast panel, it focuses its close
   button, the browser scrolls #main by those 304px to "reveal" the panel —
   and every fixed overlay inside shifts left with it, leaving a black band on
   the right where nothing is painted. The panel looked half off-screen with
   a blank strip beside it.
  
   `clip` clips without creating a scrollport, so there is no scroll position
   to move and the bug cannot happen. `hidden` is kept first as the fallback
   for engines without clip — there it stays clipped, just scrollable. */
#main { flex: 1; position: relative; overflow: hidden; overflow: clip; }

/* The map owns its own stacking context.
   Leaflet's panes run 200–700, and this app adds a streamlines pane at 640.
   #map had no position or z-index, so it created no stacking context and
   those pane numbers competed directly with the overlays sitting beside it in
   #main — the status HUD at 400, the zoom tools at 420, the ring pop-out at
   430, the alert menus at 560. Station plots and wind streamlines were
   painting straight over the HUD, which is what the screenshot showed.
   Isolating the map pins every pane below any positioned sibling, so panels
   and menus are above the map no matter what Leaflet does inside it. */
#map { position: relative; z-index: 0; isolation: isolate; width: 100%; height: 100%; }

/* ── Alert bar ──────────────────────────────────────────────────────────── */
#alert-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 500; pointer-events: none; }
#alert-inner {
  background: var(--overlay-strong);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-strong);
  width: 100%;
  padding: 7px 28px;
  padding-top: calc(7px + env(safe-area-inset-top));
  padding-left: calc(28px + env(safe-area-inset-left));
  padding-right: calc(28px + env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: center; gap: 0;
  pointer-events: auto;
  /* Six badges plus separators outgrow a laptop-width header, and clipping the
     warning count is the worst possible failure here. Let the row scroll
     instead, and shed the least important parts first at narrow widths. */
  overflow-x: auto;
  scrollbar-width: none;
}
#alert-inner::-webkit-scrollbar { display: none; }
.abadge { display: flex; align-items: center; gap: 9px; padding: 0 24px; flex-shrink: 0; }
.albl {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted2);
}
.aval {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  color: var(--muted2); min-width: 28px; text-align: right;
}
.aval.warn  { color: var(--accent); animation: blink 1.8s ease-in-out infinite; }
.aval.watch { color: var(--amber); }
.aval.adv   { color: var(--blue); }
.asep { width: 1px; height: 18px; background: var(--border-strong); flex-shrink: 0; }

/* ── Header clocks ───────────────────────────────────────────────────────────
   The clocks used to float over the lower-right of the map, where they sat on
   top of the analysis. The header already had the spare width. */
.hdr-clock { gap: 7px; }
.hdr-time {
  font-family: var(--font-mono); font-size: 15px; font-weight: 700;
  color: var(--text); min-width: 74px; text-align: left; letter-spacing: 0.02em;
}
.hdr-time-local { color: var(--faint); }
.hdr-date {
  font-family: var(--font-mono); font-size: 9px; color: var(--muted);
  white-space: nowrap;
}

/* Which zone "Local" means. Sized to sit inside the badge rather than look
   like a form control dropped into the header. */
.tz-select {
  font-family: var(--font-body);
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
  max-width: 92px;
}
.tz-select:hover { color: var(--text); border-color: var(--border-strong); }
.tz-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* New-warning flash (js/map/alerts.js toggles .alerting) */
/* Progressive shedding as the header runs out of room. */
@media (max-width: 1400px) {
  .abadge { padding: 0 16px; }
  .hdr-date { display: none; }
}
@media (max-width: 1180px) {
  .abadge { padding: 0 11px; }
  .hdr-time { font-size: 13px; min-width: 66px; }
  #help-btn { font-size: 0; padding: 4px 7px; }
  #help-btn::before { content: '?'; font-size: 11px; font-weight: 800; }
}
@media (max-width: 1000px) {
  /* Below this the counts alone deserve the space. */
  .hdr-clock { display: none; }
}

#alert-inner.alerting { animation: alert-flash 1s ease-in-out 3; }
@keyframes alert-flash {
  0%, 100% { background: var(--overlay-strong); }
  50%      { background: var(--accent); }
}

/* ── Status HUD (upper left) ────────────────────────────────────────────── */
#status-hud {
  position: absolute; top: calc(42px + env(safe-area-inset-top)); left: 0;
  z-index: 400; display: flex; flex-direction: column; gap: 0;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
/* Folded away to the left, behind the sidebar. translateX rather than display
   so the strips keep ticking and come back where they were. */
#status-hud.collapsed { transform: translateX(-100%); }

#hud-collapse {
  position: absolute;
  top: calc(46px + env(safe-area-inset-top));
  left: 0;
  z-index: 401;
  width: 15px; height: 34px;
  border-radius: 0 6px 6px 0;
  background: var(--overlay-strong); backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong); border-left: 0;
  color: var(--muted); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: left .28s cubic-bezier(.4, 0, .2, 1), color .15s;
}
#hud-collapse:hover { color: var(--accent); }
#hud-collapse[aria-expanded="false"] span { transform: rotate(180deg); }
.hud-strip {
  display: flex; align-items: center; gap: 9px;
  background: var(--overlay); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  /* Extra room on the left for the collapse tab, which is pinned to the map
     edge so it stays reachable once the strips have slid away. */
  padding: 5px 14px 5px 22px;
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em;
  pointer-events: none;
}
.hud-strip:first-child { border-top: 1px solid var(--border); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot.red   { background: var(--accent); animation: blink 1.2s ease-in-out infinite; }
.dot.amber { background: var(--amber); animation: blink 1.5s ease-in-out infinite; }
.dot.green { background: var(--green); box-shadow: 0 0 5px var(--green); }
.dot.cyan  { background: var(--cyan); box-shadow: 0 0 5px var(--cyan); }

/* Tile refresh countdowns, now the first line of the status stack. */
.hud-countdown { gap: 7px; }
.hud-lbl { color: var(--muted2); }
.hud-val { font-family: var(--font-mono); }
.hud-val.radar { color: var(--accent); }
.hud-val.sat   { color: var(--cyan); }
.hud-sep { width: 1px; height: 12px; background: var(--border-strong); }

/* ── Sidebar toggle ─────────────────────────────────────────────────────────
   Pinned to the map's left edge, as a sibling of the map rather than a child
   of the panel it collapses.

   It used to live inside #sidebar at `right: -14px` — but #sidebar is not a
   positioned element, so that resolved against the viewport and put the
   button at the far RIGHT of the window, fourteen pixels off-screen and
   unclickable. The panel could not be collapsed at all, which is also why the
   header bar was stuck at the width left over beside it.

   Centred vertically to stay clear of the status HUD's own tab at the top of
   the same edge. */
/* The whole-sidebar fold. Same problem the camera tab had: a 15px sliver in
   --muted against the map is easy to miss entirely, and this one is the only
   way to get the sidebar back once it is folded. Wider, taller, and drawn in
   the accent so it reads as a control rather than as an edge artifact. */
#toggle-btn {
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  z-index: 800;
  width: 18px; height: 72px;
  border-radius: 0 7px 7px 0;
  background: var(--overlay-strong); backdrop-filter: blur(8px);
  border: 1px solid var(--accent-line); border-left: 0;
  cursor: pointer; color: var(--accent);
  font-size: 14px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 2px 0 12px var(--accent-glow);
  transition: color .15s, background .15s, box-shadow .15s;
}
#toggle-btn:hover {
  color: var(--text); background: var(--accent);
  box-shadow: 2px 0 18px var(--accent-glow);
}
#toggle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Right-hand stack: stream above cameras ──────────────────────────────────
   One flex column rather than two independently positioned panels. Previously
   each was absolutely positioned at a fixed top offset, so whenever the stream
   was expanded its bottom edge ran under the camera header. Stacking them
   means the layout stays correct at every combination of collapsed/expanded. */
#right-stack {
  position: absolute;
  top: calc(42px + env(safe-area-inset-top));
  right: 12px;
  z-index: 400;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Never run off the bottom of the map; scroll the stack instead. */
  max-height: calc(100% - 96px - env(safe-area-inset-top));
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: none;   /* children opt back in, so the map stays draggable */
}
#right-stack::-webkit-scrollbar { display: none; }
#right-stack > * { pointer-events: auto; flex-shrink: 0; }

/* Folded away to the right, as one. The stream and the cameras are a single
   block of the display — the right-hand column — and wanting the map back
   means wanting both gone, not one and then the other.

   Slid rather than hidden, so it comes back exactly where it was, with the
   carousels still on the frame they were showing. #main clips the overflow,
   so nothing hangs off the page. Visibility follows at the END of the slide
   (and leads on the way back), which takes the panels' buttons out of the
   tab order once they are off-screen rather than leaving focusable controls
   parked outside the window. */
#right-stack {
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s;
}
#right-stack.collapsed {
  transform: translateX(calc(100% + 16px));
  visibility: hidden;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s;
}

/* The tab that does it — the mirror of the status HUD's tab on the left
   edge, at the same height, so the two read as a pair. */
#right-collapse {
  position: absolute;
  top: calc(46px + env(safe-area-inset-top));
  right: 0;
  z-index: 401;
  /* Tall enough to carry its own name. The stack is folded by default, so
     this tab is usually the only thing on screen representing the cameras,
     and it has to say so. */
  width: 17px; min-height: 86px;
  border-radius: 6px 0 0 6px;
  background: var(--overlay-strong); backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong); border-right: 0;
  color: var(--accent); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: -2px 0 12px var(--accent-glow);
  transition: color .15s, background .15s, box-shadow .15s;
}
#right-collapse:hover { color: var(--text); background: var(--accent); }

/* Shared by both edge tabs. It used to be written against #right-collapse
   alone, so the tools tab rendered its name as horizontal 12px text inside a
   17px-wide tab and showed about one letter of it. */
#right-collapse .rc-label,
#zoom-tools-collapse .rc-label {
  writing-mode: vertical-rl;
  font-size: 8px; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase;
}
#right-collapse .rc-chev,
#zoom-tools-collapse .rc-chev { font-size: 12px; }
#right-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Stream thumbnail ────────────────────────────────────────────────────── */
#yt {
  border: 1px solid var(--border-strong); border-radius: 8px;
  overflow: hidden; box-shadow: var(--overlay-shadow);
  display: none;              /* js/ui/stream.js adds .active once a video is set */
}
#yt.active { display: block; }

/* Collapse control, matching the camera rail's. */
#yt-collapse {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 5px 10px; cursor: pointer;
  background: var(--overlay-strong); border: none;
  border-bottom: 1px solid var(--border-strong);
  color: var(--muted2); font-family: var(--font-body);
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em;
  transition: color .15s;
}
#yt-collapse:hover { color: var(--accent); }
#yt-collapse-chev { transition: transform .2s ease; font-size: 8px; }
#yt.collapsed #yt-collapse-chev { transform: rotate(180deg); }
#yt.collapsed #yt-collapse { border-bottom: none; }
#yt.collapsed #yt-body { display: none; }
#yt-thumb { position: relative; width: 300px; height: 169px; cursor: pointer; display: block; background: #000; }
#yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#yt-thumb-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35); transition: background .2s;
}
#yt-thumb:hover #yt-thumb-play { background: rgba(0, 0, 0, 0.15); }
#yt-thumb-play svg { width: 54px; height: 38px; }
#yt-live-badge {
  position: absolute; top: 8px; left: 8px; background: var(--accent); color: var(--on-accent);
  font-size: 8px; font-weight: 800; letter-spacing: 0.1em; padding: 2px 6px;
  border-radius: 3px; text-transform: uppercase;
}
#yt-frame { display: block; }

/* ── Camera rail (inside #right-stack) ──────────────────────────────────── */
#right-rail {
  display: flex; flex-direction: column; gap: 8px;
}

/* Collapse control — the camera stack is tall and often in the way. */
#cams-collapse {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 5px 10px; cursor: pointer;
  background: var(--overlay-strong); backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--muted2); font-family: var(--font-body);
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em;
  box-shadow: var(--overlay-shadow); transition: color .15s;
}
#cams-collapse:hover { color: var(--accent); }
#cams-collapse-chev { transition: transform .2s ease; font-size: 8px; }
#right-rail.collapsed #cams-collapse-chev { transform: rotate(180deg); }
#cams-body { display: flex; flex-direction: column; gap: 8px; }
#right-rail.collapsed #cams-body { display: none; }

/* ── Time panel (lower right) ───────────────────────────────────────────── */
#time-panel {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  right: calc(18px + env(safe-area-inset-right));
  z-index: 400; width: 210px;
  background: var(--overlay-strong); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--overlay-shadow);
  transform: scale(0.9); transform-origin: bottom right;
}
.tblock { display: flex; flex-direction: column; gap: 2px; }
.tlbl {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.tlbl svg { width: 11px; height: 11px; flex-shrink: 0; }
.tval  { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--text); line-height: 1.1; }
.tval2 { font-family: var(--font-mono); font-size: 20px; font-weight: 600; color: var(--faint); line-height: 1.1; }
.tdate { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 2px; }
.ttz   { font-size: 9px; color: var(--muted); font-family: var(--font-mono); }
#tdiv  { border-top: 1px solid var(--border); margin: 10px 0; }

/* ── Zoom tools (right edge) ─────────────────────────────────────────────── */
#zoom-tools {
  position: absolute;
  /* Clear of its own tab. The camera column can afford to have the tab
     overlap its edge because it is 300px wide; this stack is 40, and a tab
     laid over it covers the view buttons. */
  right: calc(34px + env(safe-area-inset-right));
  bottom: calc(52px + env(safe-area-inset-bottom));
  z-index: 420;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  padding: 5px;
  background: var(--overlay-strong); backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: var(--overlay-shadow);
}
#zoom-tools button {
  width: 30px; height: 26px; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--text); font-family: var(--font-body);
  font-size: 15px; font-weight: 600; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
#zoom-tools button:disabled { opacity: 0.3; cursor: default; }

/* ── Colour, by what each tool DOES ──────────────────────────────────────────
   The stack was ten grey glyphs, which is a list to be read rather than a set
   of tools to be reached for. Colour groups them so the eye can go straight to
   the right one: navigation is neutral, the drawing tools each keep their own
   hue, and the saved views share the brand red because they are one family.

   The hues are the map's own: the ring tool wears the colour rings are drawn
   in, the crosshair the colour the locator paints. Not decoration — the button
   and the thing it makes on the map match. */
#zoom-tools button { color: var(--muted2); }        /* + and −, plain movement */
/* Written inside #zoom-tools so they outrank `#zoom-tools button` above —
   an id alone loses to an id plus a type selector. */
#zoom-tools #zoom-box     { color: var(--cyan); }
#zoom-tools #zoom-rings   { color: var(--amber); }
#zoom-tools #zoom-measure { color: var(--blue); }
#zoom-tools #zoom-locate  { color: var(--accent); }
/* The map sectors are a set, not a tool — white keeps them reading as one
   group and stops four red buttons competing with the coloured tools above
   them for the eye. */
#zoom-tools .zoom-view { color: var(--brand-white); }

/* Hover keeps each tool's own colour and fills behind it, rather than
   repainting everything the same accent — the colour IS the identification. */
#zoom-tools button:hover:not(:disabled) {
  background: var(--sunken);
  filter: brightness(1.25);
}
#zoom-tools button:focus-visible {
  outline: 2px solid currentColor; outline-offset: -2px;
}

/* The drawn icons follow the button's colour. */
.tool-ico { width: 17px; height: 17px; display: block; }
#zoom-tools .zoom-view { font-size: 9px; font-weight: 800; letter-spacing: 0.08em; height: 22px; }
#zoom-level {
  font-family: var(--font-mono); font-size: 8px; font-weight: 700;
  color: var(--muted); text-align: center; letter-spacing: 0.02em;
}
.zoom-sep { height: 1px; background: var(--border-strong); margin: 2px 0; }

/* Folded away to the right, exactly as the camera column is: slid rather than
   hidden so it returns where it was, #main clips the overflow, and visibility
   follows at the end of the slide so the buttons leave the tab order once they
   are off-screen. */
#zoom-tools {
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s;
}
#zoom-tools.collapsed {
  /* Far enough to clear both its own width and the gap it sits in. */
  transform: translateX(calc(100% + 40px));
  visibility: hidden;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s;
}

/* The tab that does it — the camera tab's twin, on the same edge, lower down. */
#zoom-tools-collapse {
  position: absolute;
  right: 0;
  bottom: calc(52px + env(safe-area-inset-bottom));
  z-index: 421;
  width: 17px; min-height: 76px;
  border-radius: 6px 0 0 6px;
  background: var(--overlay-strong); backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong); border-right: 0;
  color: var(--accent); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: -2px 0 12px var(--accent-glow);
  transition: color .15s, background .15s, box-shadow .15s;
}
#zoom-tools-collapse:hover { color: var(--text); background: var(--accent); }
#zoom-tools-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#zoom-box[aria-pressed="true"] {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}

/* The rubber-band rectangle drawn while selecting a zoom area. */
.zoom-box-rect {
  position: absolute;
  z-index: 800;
  pointer-events: none;
  border: 2px dashed var(--accent);
  background: var(--accent-soft);
}

/* ── Radar dBZ scale (bottom centre, above the radar pill) ──────────────── */
#radar-legend {
  position: absolute;
  bottom: calc(40px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 400;
  width: min(340px, calc(100% - 300px));
  min-width: 200px;
  padding: 6px 12px 4px;
  background: var(--overlay-strong); backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: var(--overlay-shadow);
  /* Annotation, not a control: the map stays draggable underneath it and only
     the dismiss button takes clicks. */
  pointer-events: none;
}
#radar-legend[hidden] { display: none; }
#radar-legend-collapse {
  position: absolute; top: 3px; right: 4px;
  width: 16px; height: 16px; padding: 0; line-height: 1;
  background: none; border: none; cursor: pointer; pointer-events: auto;
  color: var(--muted); font-size: 10px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, color .15s, background .15s;
}
#radar-legend-collapse:hover { color: var(--accent); background: var(--sunken); }
#radar-legend-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Folded, it collapses INTO the bottom edge rather than shrinking in place:
   the card slides down, loses its bottom border and its lower corners, and
   what is left is a docked strip carrying the name. Still a strip and not
   nothing, because with the sidebar checkbox gone this is the only way back —
   and the whole of it is the target, not just the chevron. */
.rl-folded { display: none; }
#radar-legend {
  transition: bottom .25s cubic-bezier(.4, 0, .2, 1),
              padding .25s cubic-bezier(.4, 0, .2, 1),
              border-radius .25s;
}
#radar-legend.collapsed {
  bottom: 0;
  border-radius: 8px 8px 0 0;
  border-bottom: 0;
  padding: 5px 30px calc(5px + env(safe-area-inset-bottom)) 14px;
  pointer-events: auto; cursor: pointer;
}
#radar-legend.collapsed .rl-body { display: none; }
#radar-legend.collapsed .rl-folded {
  display: block;
  font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
}
#radar-legend.collapsed #radar-legend-collapse { top: 50%; transform: translateY(-50%) rotate(180deg); }
#radar-legend.collapsed:hover .rl-folded { color: var(--accent); }
.rl-head {
  font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin-bottom: 4px;
  display: flex; align-items: center; gap: 5px;
}
/* Each scale's own fold. Small, because it sits in an 8px heading — the grab
   area is grown past the paint rather than the paint being made bigger. */
.rl-sect-fold {
  position: relative;
  flex-shrink: 0;
  width: 11px; height: 11px; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px;
  color: var(--muted); background: none; border: none; border-radius: 2px;
  cursor: pointer; pointer-events: auto;   /* the panel itself takes no clicks */
  transition: color .15s, background .15s;
}
.rl-sect-fold::before { content: ""; position: absolute; inset: -6px; }
.rl-sect-fold:hover { color: var(--accent); background: var(--sunken); }
.rl-sect-fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rl-pal { color: var(--faint); }
.rl-unit { color: var(--cyan); }
.rl-bar {
  height: 9px; border-radius: 2px;
  border: 1px solid var(--border-strong);
}
.rl-ticks {
  position: relative; height: 11px; margin-top: 1px;
}
.rl-tick {
  position: absolute; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 8px; color: var(--muted2);
}

/* Two scales, stacked: reflectivity, then the streamline wash when there is
   one. The panel widens rather than squeezing both into one column, because
   the stain bar carries its own ticks from 0 to 60+. */
#radar-legend.rl-wide { width: min(460px, calc(100% - 300px)); }
.rl-sep {
  height: 1px; margin: 7px 0 6px;
  background: var(--border-strong);
}
.rl-stain .stream-bar { height: 9px; }
.rl-stain .stream-ticks { font-size: 8px; margin-top: 1px; }
.rl-stain .adv-key { margin: 0 0 1px; }

/* ── SPC legend (lower left) ────────────────────────────────────────────── */
#spc-legend {
  position: absolute;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: calc(18px + env(safe-area-inset-left));
  z-index: 400;
  background: var(--overlay-strong); backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 12px; min-width: 136px; box-shadow: var(--overlay-shadow);
  /* The panel itself ignores clicks so the map stays draggable underneath;
     only the dismiss button opts back in. */
  pointer-events: none;
}
#spc-legend[hidden] { display: none; }
#spc-legend-close {
  position: absolute; top: 4px; right: 5px;
  width: 16px; height: 16px; padding: 0; line-height: 1;
  background: none; border: none; cursor: pointer; pointer-events: auto;
  color: var(--muted); font-size: 10px; border-radius: 3px;
}
#spc-legend-close:hover { color: var(--accent); background: var(--sunken); }

/* ── Leaflet overrides ──────────────────────────────────────────────────── */
.leaflet-container { background: var(--map-bg) !important; }
/* The plain basemap sets its own ground colour inline; let it win, and drop
   the attribution strip's tint so the field really is flat. */
.leaflet-container.basemap-plain { background: #ffffff !important; }
.basemap-plain .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.75) !important; color: #555 !important;
}
.basemap-plain .leaflet-control-attribution a { color: #555 !important; }
.leaflet-control-zoom { display: none !important; }
.leaflet-control-attribution {
  font-size: 7px !important;
  background: var(--overlay) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.station-icon { background: transparent !important; border: none !important; }

.leaflet-popup-content-wrapper {
  background: var(--raised) !important; color: var(--text) !important;
  border: 1px solid var(--border-strong) !important; border-radius: 8px !important;
  box-shadow: var(--overlay-shadow) !important;
}
.leaflet-popup-tip { background: var(--raised) !important; }
.leaflet-popup-content { font-size: 11px !important; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.ptitle { font-weight: 700; font-size: 12px; margin-bottom: 5px; }
.prow { font-size: 10px; color: var(--muted2); margin: 2px 0; }
.prow b { color: var(--text); }
