/* ============================================================
 * Sydney Dive Conditions, dark ocean theme
 * Tokens validated against WCAG/CVD (see README → design notes)
 * ============================================================ */

:root {
  --page: #0a0f16;
  --surface: #121a24;
  --raised: #1a2431;
  --border: rgba(255, 255, 255, 0.10);
  --ink: #f2f6fa;
  --ink-2: #b8c4d0;
  --muted: #8394a5;
  --grid: #223041;
  --axis: #2c3b4e;
  --accent: #3987e5;
  --good: #34c163;
  --fair: #ffc233;
  --poor: #ff9166;
  --nogo: #e85c5c;
  --score-ink: #12242f;
  color-scheme: dark;
  --banner-bg: #3a2a12;
  --banner-ink: #ffd9a0;
  --banner-border: rgba(250, 178, 25, 0.35);
  --warn-tint: rgba(250, 178, 25, 0.16);
  --warn-ink: #ffd27a;
  --wreck-tint: rgba(57, 135, 229, 0.18);
  --wreck-ink: #9ec5f4;
  --danger-tint: rgba(208, 59, 59, 0.12);
  --danger-border: rgba(208, 59, 59, 0.35);
  --danger-ink: #ffb9b9;
  --legend-bg: rgba(10, 15, 22, 0.88);
  --rain-ink: #86b6ef;
  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --score-ink: rgba(15, 26, 36, 0.78);
  --page: #f2f5f8;
  --surface: #ffffff;
  --raised: #e7edf3;
  --border: rgba(16, 32, 46, 0.13);
  --ink: #12222f;
  --ink-2: #3e5468;
  --muted: #5d7386;
  --grid: #dde5ec;
  --axis: #c3cfda;
  --accent: #2a78d6;
  --banner-bg: #fdf1dc;
  --banner-ink: #7a5200;
  --banner-border: rgba(160, 110, 0, 0.3);
  --warn-tint: rgba(250, 178, 25, 0.22);
  --warn-ink: #7a5200;
  --wreck-tint: rgba(42, 120, 214, 0.13);
  --wreck-ink: #1c5cab;
  --danger-tint: rgba(208, 59, 59, 0.08);
  --danger-border: rgba(208, 59, 59, 0.3);
  --danger-ink: #a02222;
  --legend-bg: rgba(255, 255, 255, 0.92);
  --rain-ink: #1c5cab;
}

* { box-sizing: border-box; }
/* dvh tracks the REAL visible viewport on mobile: plain 100% plus a vh-sized
   map row can push the sidebar under Safari's toolbars with no way to scroll
   to it (page doesn't scroll, and swipes over the map pan the map instead) */
html, body { height: 100%; height: 100dvh; }
/* the page never scrolls sideways: without this, the off-canvas drawer
   (translateX 102%) hands phones a strip of phantom width to scroll into */
html, body { overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
  display: flex;
  flex-direction: column;
  /* identical glyph weight in both themes, macOS subpixel smoothing otherwise
     renders light-on-dark heavier, which reads as a tiny layout shift on toggle */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* identical scrollbar geometry in both themes (kills theme-toggle reflow) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--grid);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: var(--grid) transparent; }

/* ---------------- header ---------------- */

header.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--page);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .logo { width: 27px; height: 27px; flex: none; }
.brand h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: 0.2px; }
.brand .tagline { align-self: baseline; padding-top: 4px; }
.brand .tagline { color: var(--muted); font-size: 12.5px; }
.head-spacer { flex: 1; }
.head-stats { display: flex; align-items: center; gap: 12px; }
.head-stat { color: var(--ink-2); font-size: 13px; }
#updated { color: var(--muted); font-size: 12.5px; }
#water-temp:empty, #updated:empty { display: none; }
/* keep the wrapper out of the flow until it has something to show, so the
   header height doesn't settle after load */
.head-stats:not(:has(> :not(:empty))) { display: none; }

.icon-btn {
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--grid); }
/* glyph-only close buttons for the drawer and dialogs */
.glyph-close {
  width: 34px;
  height: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ---------------- toolbar (the one filter row) ---------------- */

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.chip-row { display: flex; gap: 6px; }
.day-chip, .type-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.day-chip, .type-chip { display: inline-flex; align-items: center; }
.day-chip { gap: 6px; }
.type-chip { gap: 5px; }
.day-sub { display: inline-flex; align-items: center; gap: 6px; }
.day-sub:empty { display: none; }
.day-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.day-chip.active, .type-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.day-chip:hover:not(.active), .type-chip:hover:not(.active) { background: var(--raised); }
/* fixed box for the glyph-only header buttons (☀/☾, ↻, ?): the glyphs have
   different font metrics and a content-sized button would change height per
   glyph and shift the whole header */
#theme-toggle, #refresh, #about-open {
  width: 38px;
  height: 30px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.day-star { margin-left: 2px; font-size: 10px; opacity: 0.9; }
.toolbar-sep { width: 1px; align-self: stretch; background: var(--border); flex: none; }

/* ---------------- layout ---------------- */

.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 370px 1fr;
  min-height: 0;
  position: relative;
  transition: opacity 0.25s;
}
body.refreshing .app-main { opacity: 0.6; }

/* loading indicator: one large spinner disc centred over the content */
.loader-pill {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1300;
  width: 58px;
  height: 58px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
body.refreshing .loader-pill { display: inline-flex; }
.spin-ring {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3.5px solid var(--grid);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
/* visually hidden, still announced by screen readers */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.rfx { display: inline-block; }
body.refreshing .rfx { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  body.refreshing .rfx, .spin-ring { animation: none; }
}

#banner {
  background: var(--banner-bg);
  color: var(--banner-ink);
  border-bottom: 1px solid var(--banner-border);
  padding: 7px 16px;
  font-size: 13px;
}

/* ---------------- sidebar ---------------- */

.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* as a grid item, auto min-width would let the search row's intrinsic
     width (large at the 16px mobile font) widen the whole 1fr column past
     the viewport */
  min-width: 0;
  background: var(--page);
}
.sidebar-controls {
  padding: 10px 12px 8px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
#search {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  min-width: 0;
}
#search::placeholder { color: var(--muted); }
#sort, #area {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  border-radius: 8px;
  padding: 7px 22px 7px 8px;
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
/* the area picker leads the toolbar: same control language, a touch bolder */
#area {
  flex: none;
  color: var(--ink);
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 24px 5px 12px;
  cursor: pointer;
  max-width: 220px;
}
/* phone version of the area picker: a pill button that opens the #region
   dialog (shown ≤920px in place of the select) */
.area-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  min-width: 0;
}
.rg-ico { color: var(--accent); font-size: 12px; }
#region-lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-car { color: var(--muted); font-size: 10px; }
#search { appearance: none; -webkit-appearance: none; }
#sort-dir { width: 34px; padding: 7px 0; text-align: center; flex: none; }
#summary { padding: 8px 14px 0; color: var(--muted); font-size: 12.5px; flex: none; }
#daybrief {
  padding: 4px 14px 7px;
  color: var(--ink-2);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
}
#daybrief:empty { display: none; }
.bf-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.bf-group { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.bf-group + .bf-group { border-left: 1px solid var(--border); padding-left: 10px; }
.bf-item { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.bf-ico { color: var(--muted); font-size: 10px; }

.bw-box { margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--border); }
.bw-cap { font-size: 11px; color: var(--muted); }

#site-list {
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 6px 10px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}
.site-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--ink);
  display: block;
  width: 100%;
}
.site-card:hover { background: var(--raised); }
.site-card.selected { border-color: var(--accent); }
.site-card.dim { opacity: 0.72; }
.site-card.dim:hover, .site-card.dim.selected { opacity: 1; }
.sc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sc-name { font-weight: 600; font-size: 13.5px; }
.sc-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.lvl-badge {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 9.5px;
  letter-spacing: 0.4px;
  color: var(--muted);
  vertical-align: 1px;
}
.sc-stats { color: var(--ink-2); font-size: 12px; margin-top: 5px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* rating chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--score-ink);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  flex: none;
}
.chip strong { font-weight: 700; }
.chip-sm { font-size: 11.5px; padding: 2px 8px; }
.chip-empty { background: var(--raised); color: var(--muted); }

/* ---------------- map ---------------- */

#map { min-height: 0; background: var(--page); }

.mk-wrap { background: none; border: none; }
.mk {
  width: 30px; height: 30px;
  color: var(--score-ink);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.mk-boat { border-radius: 8px; }
.mk-wreck { border-radius: 7px; transform: rotate(45deg); }
.mk-wreck .mk-num { transform: rotate(-45deg); display: block; }

/* hovered-in-list marker: faint accent ring */
.mk-hover {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent), 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* selected marker: crisp accent ring, same language as the selected card */
.mk-sel {
  border-color: #fff;
  box-shadow: 0 0 0 2.5px var(--accent), 0 1px 6px rgba(0, 0, 0, 0.5);
}

.basemap-toggle { display: flex; overflow: hidden; border-radius: 6px; }
.bm-btn {
  background: var(--surface);
  color: var(--ink-2);
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.bm-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

.map-legend {
  background: var(--legend-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.lg-row { display: flex; align-items: center; gap: 7px; margin: 2px 0; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lg-div { height: 1px; background: var(--border); margin: 5px 0; }
.lg-shape {
  width: 10px; height: 10px; flex: none;
  background: var(--muted);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.lg-shore { border-radius: 50%; }
.lg-boat { border-radius: 3px; }
.lg-wreck { border-radius: 2px; transform: rotate(45deg); }
.lg-shapes { display: flex; flex-direction: column; }
.lg-note { color: var(--muted); margin-top: 5px; font-size: 10.5px; }

/* leaflet chrome on dark */
.leaflet-bar a {
  background: var(--surface);
  color: var(--ink);
  border-bottom-color: var(--border);
}
.leaflet-bar a:hover { background: var(--raised); }
.leaflet-container .leaflet-control-attribution {
  background: var(--legend-bg);
  color: var(--muted);
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-tooltip {
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.leaflet-tooltip-top:before { border-top-color: var(--raised); }

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

#drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100%;
  background: var(--page);
  border-left: 1px solid var(--border);
  transform: translateX(102%);
  transition: transform 0.22s ease;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.45);
}
#drawer.open { transform: translateX(0); }
.drawer-bar {
  display: flex;
  justify-content: flex-end;
  padding: 8px 10px 0;
}
#drawer-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  padding: 0 18px calc(26px + env(safe-area-inset-bottom, 0px));
  min-height: 0;
}

.dd-head { margin-bottom: 4px; }
.dd-name { font-size: 19px; margin: 2px 0 4px; }
.dd-meta { color: var(--muted); font-size: 12.5px; }
.dd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tag {
  background: var(--raised);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 2.5px 9px;
  font-size: 11.5px;
}
.tag-warn { background: var(--warn-tint); color: var(--warn-ink); }
.tag-wreck { background: var(--wreck-tint); color: var(--wreck-ink); }
.tag-season { background: rgba(52, 193, 99, 0.15); color: var(--good); }
:root[data-theme="light"] .tag-season { color: #1e8a44; }

.dd-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
}
.hero-score { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.hero-num { font-size: 46px; font-weight: 650; line-height: 1; }
.hero-level { font-size: 16px; font-weight: 700; }
.hero-when { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.hero-now { color: var(--muted); font-size: 12px; margin-top: 2px; }

.meter-row { margin: 9px 0; }
.meter-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.meter-label { color: var(--ink-2); }
.meter-val { color: var(--muted); }
.meter-track {
  height: 6px;
  background: var(--raised);
  border-radius: 4px;
  overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 4px; }

.dd-section { margin-top: 20px; }
.dd-h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 9px;
  font-weight: 600;
}

.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.ds-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 3px 6px;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ds-cell:hover { background: var(--raised); }
.ds-cell.active { border-color: var(--accent); }
.ds-day { font-size: 11px; color: var(--ink-2); font-weight: 600; }
.ds-cell .chip-sm { padding: 1px 6px; font-size: 10.5px; gap: 3px; }
.ds-cell .chip-sm span { display: none; }         /* number + colour + word is too much at this size; word lives in the big chip */
.ds-stat { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ds-rain { color: var(--rain-ink); }

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.tile-label { color: var(--muted); font-size: 11.5px; display: flex; align-items: baseline; gap: 7px; }
.tile-ico { font-size: 14.5px; opacity: 0.9; color: var(--ink-2); }
.tile-value { font-size: 19px; font-weight: 650; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }

.chart-box { position: relative; }
.chart-wrap { position: relative; outline-offset: 4px; }
.chart-panel { margin-bottom: 8px; }
.chart-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.chart-title { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chart-sub { font-size: 11px; color: var(--muted); }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-svg text { font-family: var(--sans); }
.tnum { font-variant-numeric: tabular-nums; }

.chart-tip {
  position: absolute;
  top: 8px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  min-width: 110px;
}
.tip-time { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 2px 0; }
.tip-row strong { color: var(--ink); font-weight: 700; }
.tip-lab { color: var(--muted); font-size: 11px; }
.tip-key { width: 14px; height: 3px; border-radius: 2px; flex: none; }

.tide-note {
  background: var(--warn-tint);
  border: 1px solid var(--banner-border);
  color: var(--warn-ink);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  margin: 0 0 8px;
}
.tide-events { color: var(--ink-2); font-size: 12px; margin-top: 2px; }

.dd-blurb { color: var(--ink-2); font-size: 13.5px; margin: 0 0 10px; }
.dd-dl { display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; margin: 0; font-size: 12.5px; }
.dd-dl dt { color: var(--muted); }
.dd-dl dd { margin: 0; color: var(--ink-2); }
.dd-links { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
}
.link-ico { color: var(--muted); font-size: 15px; line-height: 1; }
.link-btn:hover { background: var(--grid); }

/* ---------------- about dialog ---------------- */

dialog#about {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 620px;
  width: calc(100vw - 48px);
  padding: 22px 24px;
}
dialog#about::backdrop { background: rgba(4, 8, 13, 0.7); }
.about-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
#about h2 { margin: 0; font-size: 18px; }
#about h3 { font-size: 13px; margin: 16px 0 6px; color: var(--ink-2); }
#about p, #about li { color: var(--ink-2); font-size: 13.5px; }
.model-detail { margin: 10px 0 4px; }
.model-detail summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.model-detail ul { margin-top: 8px; }
.model-detail li { margin-bottom: 6px; }
#about .disclaimer {
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--danger-ink);
}

/* ---------------- region picker dialog (phone) ---------------- */

dialog#region {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(340px, calc(100vw - 40px));
  padding: 14px;
}
dialog#region::backdrop { background: rgba(4, 8, 13, 0.7); }
.region-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.region-head h2 { margin: 0; font-size: 15px; }
#region-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 70dvh;
  overflow-y: auto;
}
/* bottom fade while more rows are below (class toggled by app.js) */
#region-list::after {
  content: '';
  position: sticky;
  bottom: 0;
  height: 30px;
  margin-top: -30px;
  flex: none;
  background: linear-gradient(transparent, var(--surface));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#region-list.more-below::after { opacity: 1; }
.region-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 11px;
  color: var(--ink);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  flex: none;
}
.region-row:hover { background: var(--raised); }
.region-row.active { border-color: var(--accent); background: var(--raised); }
.rr-n { color: var(--muted); font-size: 11.5px; flex: none; }

#boot-errors { display: none; }

/* ---------------- responsive ---------------- */

@media (max-width: 920px) {
  /* phones scroll as ONE page: the map keeps a 42svh window at the top and
     the full site list flows below it, instead of the list living in
     whatever two-card sliver of shell height the map left over */
  html, body { height: auto; }
  body { min-height: 100vh; min-height: 100dvh; }
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: 44vh auto;
    grid-template-rows: minmax(180px, 42svh) auto;
  }
  .sidebar { order: 2; border-right: none; border-top: 1px solid var(--border); }
  /* at least a viewport tall: otherwise filtering the list while typing can
     shrink the page under the current scroll position and the view jumps
     back up to the map */
  .sidebar { min-height: 100vh; min-height: 100dvh; }
  #site-list { overflow: visible; flex: none; }
  #map { order: 1; }
  #drawer { position: fixed; width: 100%; }
  .loader-pill { position: fixed; }
  .brand .tagline { display: none; }

  header.app-header { gap: 8px 10px; padding-left: 12px; padding-right: 12px; }

  /* toolbar: three full-width rows with one rhythm — region pill field,
     7-day calendar strip, then the type filters as equal segments */
  .toolbar { flex-wrap: wrap; padding: 8px 12px; row-gap: 7px; }
  .toolbar-sep, #area { display: none; }
  .area-btn { display: flex; flex: 0 0 100%; order: -1; padding: 6px 12px; }
  #region-lab { flex: 1; text-align: left; }
  #day-chips {
    flex: 0 0 100%;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .day-chip {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 4px 1px;
    font-size: 10.5px;
    min-width: 0;
    border-radius: 9px;
  }
  .day-sub { gap: 4px; }
  #type-chips {
    flex: 0 0 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .tc-ico { display: none; }
  .type-chip { padding: 4px 2px; font-size: 12px; justify-content: center; min-width: 0; }

  /* 16px stops iOS zooming the whole page when the search field gets focus */
  #search { font-size: 16px; }

  /* legend: same vertical stack as desktop, smaller, colours + words only */
  .map-legend { padding: 5px 8px; font-size: 10px; }
  .map-legend .lg-row { gap: 5px; margin: 1.5px 0; }
  .map-legend .lg-dot, .map-legend .lg-shape { width: 8px; height: 8px; }
  .map-legend .lg-div { margin: 4px 0; }
  .lg-range { display: none; }
}

/* phones: brand + the three glyph buttons share row one (zero-basis brand
   grows into the leftover space and truncates rather than pushing a button
   onto the wrap line), stats drop to a full-width second row */
@media (max-width: 700px) {
  header.app-header { gap: 8px; }
  .head-spacer { display: none; }
  .brand { flex: 1 1 0; min-width: 0; }
  .brand .logo { width: 24px; height: 24px; }
  .brand h1 {
    font-size: 14.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .head-stats { flex: 1 0 100%; order: 5; min-width: 0; }
}
