/* ===========================================================================
   NCMA Urban Growth Explorer — styles
   Colour tokens are the validated values recorded in PALETTE.md. Defined on
   bare :root, then re-declared for dark under both the OS media query and the
   [data-theme] scope so the toggle wins in both directions.
   =========================================================================== */

:root {
  color-scheme: light;

  --plane:       #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f2f1ed;
  --surface-3:   #e9e8e2;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --ink-muted:   #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --border:      rgba(11, 11, 11, .10);
  --border-firm: rgba(11, 11, 11, .18);
  --shadow:      0 1px 2px rgba(11,11,11,.06), 0 8px 24px rgba(11,11,11,.08);
  --accent:      #2a78d6;
  --accent-ink:  #ffffff;
  --wash:        rgba(42, 120, 214, .10);

  /* trajectory — No change, ordinal by the density level held */
  --nc-1: #65c297; --nc-2: #24ab79; --nc-3: #00915f; --nc-4: #00754a;
  /* trajectory — growth, ordinal by intensity */
  --gr-1: #79adf2; --gr-2: #3985e2; --gr-3: #005dbd;
  /* trajectory — singletons */
  --cg:   #cc5728; --undef: #8b8a83;

  /* density / gain — one-hue ordinal ramp */
  --dens-1: #79adf2; --dens-2: #4e90e5; --dens-3: #1f73d4; --dens-4: #0057b7;

  /* built-up epochs (baked into the PNGs — see build_rasters.py) */
  --ep-1991: #982159; --ep-1997: #bf3f77; --ep-2011: #de6494; --ep-2023: #f491b5;

  /* status — fixed, never themed */
  --critical: #d03b3b; --warning: #fab219; --good: #0ca30c;

  --radius: 10px;
  --radius-sm: 6px;
  --pad: 14px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --surface-3: #2c2c2a;
    --ink: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
    --grid: #2c2c2a; --baseline: #383835;
    --border: rgba(255,255,255,.10); --border-firm: rgba(255,255,255,.20);
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 28px rgba(0,0,0,.55);
    --accent: #3987e5; --accent-ink: #0d0d0d; --wash: rgba(57,135,229,.18);
    --nc-1: #00774e; --nc-2: #009364; --nc-3: #1eaf7a; --nc-4: #63c699;
    --gr-1: #0e61bb; --gr-2: #3985e2; --gr-3: #71aaf5;
    --cg:   #ed794d; --undef: #6f6e68;
    --dens-1: #19549b; --dens-2: #2070ce; --dens-3: #4b90e8; --dens-4: #87bafd;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --surface-3: #2c2c2a;
  --ink: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
  --grid: #2c2c2a; --baseline: #383835;
  --border: rgba(255,255,255,.10); --border-firm: rgba(255,255,255,.20);
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 28px rgba(0,0,0,.55);
  --accent: #3987e5; --accent-ink: #0d0d0d; --wash: rgba(57,135,229,.18);
  --nc-1: #00774e; --nc-2: #009364; --nc-3: #1eaf7a; --nc-4: #63c699;
  --gr-1: #0e61bb; --gr-2: #3985e2; --gr-3: #71aaf5;
  --cg:   #ed794d; --undef: #6f6e68;
  --dens-1: #19549b; --dens-2: #2070ce; --dens-3: #4b90e8; --dens-4: #87bafd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--plane); color: var(--ink);
  font-family: var(--font); font-size: 13px; line-height: 1.45;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- app shell */

#app {
  display: grid; height: 100%;
  grid-template-rows: auto 1fr;
  grid-template-columns: 300px 1fr 340px;
  grid-template-areas: "head head head" "side map insights";
}

header {
  grid-area: head; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; height: 60px; overflow: hidden;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand p { margin: 0; font-size: 11px; color: var(--ink-muted); white-space: nowrap; }

.stats { display: flex; gap: 6px; margin-left: auto; overflow: hidden; }
.stat {
  padding: 5px 12px; border-radius: var(--radius-sm); white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border);
}
.stat b { display: block; font-size: 16px; font-weight: 640; letter-spacing: -.02em; line-height: 1.15; }
.stat span { display: block; font-size: 10.5px; color: var(--ink-muted); }
.stat .delta { color: var(--ink-2); font-weight: 500; }

.head-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------------------------------------------------------------- controls */

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

.seg {
  display: flex; gap: 2px; padding: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.seg button {
  flex: 1; padding: 5px 7px; border: 0; background: transparent; cursor: pointer;
  border-radius: 4px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap;
}
.seg button:hover { background: var(--surface-3); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 560; }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 0; margin-top: 2px; }
.switch input {
  appearance: none; margin: 0; width: 30px; height: 17px; flex: none; cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--border-firm); border-radius: 9px;
  position: relative; transition: background .15s;
}
.switch input::after {
  content: ""; position: absolute; top: 1px; left: 1px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s;
}
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(13px); }
.switch span { font-size: 12px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--surface-3); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; margin-top: -5px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-firm);
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--surface-3); border-radius: 2px; }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

.text-input {
  width: 100%; padding: 6px 9px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.text-input::placeholder { color: var(--ink-muted); }
.row-2 { display: flex; gap: 6px; }

.mini-btn {
  padding: 5px 10px; font-size: 11.5px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
}
.mini-btn:hover { background: var(--surface-3); color: var(--ink); }
.mini-btn.wide { width: 100%; }

/* ----------------------------------------------------------------- panels */

.panel { background: var(--surface); overflow: hidden auto; scrollbar-width: thin; }
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; border: 2px solid var(--surface); }

#sidebar { grid-area: side; border-right: 1px solid var(--border); }
#insights { grid-area: insights; border-left: 1px solid var(--border); }

.block { padding: var(--pad); border-bottom: 1px solid var(--border); }
.block:last-child { border-bottom: 0; }

.block-title {
  display: flex; align-items: center; gap: 6px; margin: 0 0 9px;
  font-size: 10.5px; font-weight: 640; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-muted);
}
.block-title .count { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.hint { margin: 7px 0 0; font-size: 11px; color: var(--ink-muted); line-height: 1.4; }
.hint code { font-size: 10.5px; background: var(--surface-2); padding: 0 3px; border-radius: 3px; }

.field { margin-top: 10px; }
.field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--ink-2); margin-bottom: 4px;
}
.field-label b { font-weight: 560; color: var(--ink); font-variant-numeric: tabular-nums; }

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

.legend-group { margin-bottom: 10px; }
.legend-group:last-child { margin-bottom: 0; }
.legend-group > h4 {
  margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.legend-group > h4::after { content: ""; flex: 1; height: 1px; background: var(--grid); }

.legend-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 4px 6px; margin: 1px 0; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); cursor: pointer;
}
.legend-item:hover { background: var(--surface-2); }
.legend-item[aria-pressed="true"] { background: var(--wash); box-shadow: inset 0 0 0 1px var(--accent); }
.legend-item.dimmed { opacity: .42; }
.legend-item.static { cursor: default; }
.legend-item.static:hover { background: transparent; }
.legend-item .sw { width: 14px; height: 14px; flex: none; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--border-firm); }
.legend-item .lbl { flex: 1; font-size: 11.5px; line-height: 1.3; min-width: 0; }
.legend-item .code {
  font-size: 10px; font-weight: 640; color: var(--ink-muted);
  background: var(--surface-2); border-radius: 3px; padding: 0 4px; margin-right: 4px;
}
.legend-item .n { flex: none; font-size: 11px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.legend-ramp { display: flex; gap: 2px; margin-bottom: 5px; }
.legend-ramp > div { flex: 1; height: 11px; border-radius: 2px; }
.legend-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-muted); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips:not(:empty) { margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px 3px 8px;
  border-radius: 20px; font-size: 11px;
  background: var(--wash); border: 1px solid var(--accent); color: var(--ink);
}
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--ink-2); padding: 0 2px; font-size: 13px; line-height: 1; }
.chip button:hover { color: var(--ink); }

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

#map-wrap { grid-area: map; position: relative; background: var(--plane); }
#map { position: absolute; inset: 0; background: var(--plane); }
#map.pointing { cursor: pointer; }

.leaflet-container { font-family: var(--font); background: var(--plane); }
.leaflet-bar, .leaflet-bar a {
  background: var(--surface); color: var(--ink-2);
  border-color: var(--border) !important; box-shadow: var(--shadow);
}
.leaflet-bar a:hover { background: var(--surface-2); color: var(--ink); }
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 88%, transparent) !important;
  color: var(--ink-muted); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 10px;
}
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-control-scale-line {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-color: var(--ink-2); color: var(--ink-2); font-size: 10px;
}
.leaflet-top.leaflet-left { top: 8px; left: 8px; }

/* floating widgets */
.map-widget {
  position: absolute; z-index: 700;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
#basemap-picker { top: 12px; right: 12px; padding: 5px; display: flex; gap: 3px; }
#basemap-picker button {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 9px; border-radius: var(--radius-sm); font-size: 11.5px; color: var(--ink-2);
}
#basemap-picker button:hover { background: var(--surface-2); }
#basemap-picker button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 560; }

/* ---------------------------------------------------------------- timeline */

#timeline {
  left: 50%; transform: translateX(-50%); bottom: 16px;
  width: min(620px, calc(100% - 32px)); padding: 11px 16px 13px;
}
.tl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tl-play {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
}
.tl-play svg { width: 13px; height: 13px; }
.tl-title { font-size: 11px; color: var(--ink-muted); }
.tl-title b {
  display: block; font-size: 17px; font-weight: 650; color: var(--ink);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.tl-readout { margin-left: auto; text-align: right; font-size: 11px; color: var(--ink-muted); }
.tl-readout b { display: block; font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.tl-track { position: relative; height: 34px; margin: 0 8px; }
.tl-rail { position: absolute; left: 0; right: 0; top: 7px; height: 3px; background: var(--surface-3); border-radius: 2px; }
.tl-fill { position: absolute; left: 0; top: 7px; height: 3px; border-radius: 2px; background: var(--accent); transition: width .3s ease; }
.tl-stop {
  position: absolute; top: 0; transform: translateX(-50%); padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: transparent; cursor: pointer; color: var(--ink-muted);
}
.tl-stop .dot {
  width: 13px; height: 13px; border-radius: 50%; background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--baseline); transition: box-shadow .15s, transform .15s;
}
.tl-stop .yr { font-size: 10.5px; font-variant-numeric: tabular-nums; }
.tl-stop:hover .dot { transform: scale(1.15); }
.tl-stop[aria-pressed="true"] .dot { box-shadow: inset 0 0 0 4px var(--accent); transform: scale(1.2); }
.tl-stop[aria-pressed="true"] .yr { color: var(--ink); font-weight: 620; }

/* ------------------------------------------------------------------- swipe */

#swipe-handle {
  position: absolute; top: 0; bottom: 0; width: 2px; z-index: 690;
  background: var(--surface); box-shadow: 0 0 0 1px var(--border-firm); cursor: ew-resize;
}
#swipe-handle::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border-firm); box-shadow: var(--shadow);
}
#swipe-handle::after {
  content: "◀ ▶"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 9px; color: var(--ink-2); white-space: nowrap; letter-spacing: -1px;
}
.swipe-tag {
  position: absolute; top: 58px; z-index: 690; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 560; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
#swipe-tag-a { left: 12px; }
#swipe-tag-b { right: 12px; }

/* ----------------------------------------------------------------- tooltip */

#tip {
  position: fixed; z-index: 1200; pointer-events: none; display: none;
  max-width: 250px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 11.5px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--border-firm); box-shadow: var(--shadow);
}
#tip .t-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
#tip .t-title .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
#tip .t-row { color: var(--ink-2); font-variant-numeric: tabular-nums; }
#tip .t-note { margin-top: 3px; opacity: .75; }

/* ------------------------------------------------------------------ charts */

.chart-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.chart-head h3 { margin: 0; font-size: 12.5px; font-weight: 600; }
.chart-sub { margin: 0 0 8px; font-size: 11px; color: var(--ink-muted); line-height: 1.4; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg text { font-family: var(--font); }
.axis-label { fill: var(--ink-muted); font-size: 10px; }
.value-label { fill: var(--ink-2); font-size: 10px; font-weight: 560; }
.value-label-strong { fill: var(--ink); font-size: 11px; font-weight: 620; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1; }
.mark { transition: opacity .12s; }
.mark:hover { opacity: .82; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; font-size: 11.5px; }
.bar-row .bar-lbl { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar-row .bar-lbl .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.bar-row .bar-lbl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-val { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar-fill { height: 100%; border-radius: 4px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 11px; color: var(--ink-2); }
.chart-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px var(--border); }

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

.detail-empty { color: var(--ink-muted); font-size: 12px; padding: 18px 0; text-align: center; line-height: 1.6; }
.detail-title { margin: 0 0 2px; font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
.detail-sub { margin: 0 0 10px; font-size: 11.5px; color: var(--ink-muted); }
.family-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 560; background: var(--surface-2); border: 1px solid var(--border);
}
.family-chip .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 10px 0 0; font-size: 11.5px; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.detail-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ------------------------------------------------------------------ tables */

table.data { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
table.data caption { text-align: left; font-size: 11px; color: var(--ink-muted); padding-bottom: 6px; }
table.data th, table.data td { padding: 4px 6px; border-bottom: 1px solid var(--grid); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { color: var(--ink-muted); font-weight: 560; border-bottom: 1px solid var(--baseline); }
table.data tbody tr:hover { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------ search list */

.results { margin-top: 8px; max-height: 210px; overflow-y: auto; }
.result {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 5px 7px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink);
}
.result:hover { background: var(--surface-2); }
.result b { display: block; font-size: 11.5px; font-weight: 560; }
.result span { font-size: 10.5px; color: var(--ink-muted); }

/* -------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; padding: 8px var(--pad) 0; border-bottom: 1px solid var(--border); }
.tabs button {
  border: 0; background: transparent; cursor: pointer; padding: 7px 10px; font-size: 12px;
  color: var(--ink-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

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

dialog {
  border: 1px solid var(--border-firm); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--ink); max-width: 560px; width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { display: flex; align-items: center; padding: 14px var(--pad); border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; font-size: 14px; font-weight: 640; }
.dlg-head button { margin-left: auto; }
.dlg-body { padding: var(--pad); max-height: 60vh; overflow-y: auto; font-size: 12px; line-height: 1.55; color: var(--ink-2); }
.dlg-body h3 { font-size: 12px; color: var(--ink); margin: 14px 0 4px; }
.dlg-body h3:first-child { margin-top: 0; }
.dlg-body ul { margin: 4px 0; padding-left: 18px; }
.dlg-body code { font-size: 11px; background: var(--surface-2); padding: 0 3px; border-radius: 3px; }
.dlg-body kbd {
  font: inherit; font-size: 10.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-3); border: 1px solid var(--border-firm);
}

/* ----------------------------------------------------------------- splash */

#splash {
  position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center;
  background: var(--plane); transition: opacity .35s;
}
#splash.gone { opacity: 0; pointer-events: none; }
#splash .box { text-align: center; }
#splash h1 { font-size: 17px; margin: 0 0 6px; font-weight: 640; }
#splash p { margin: 0 0 16px; color: var(--ink-muted); font-size: 12px; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto; border-radius: 50%;
  border: 2px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

#panel-toggles { display: none; }

@media (max-width: 1180px) {
  #app { grid-template-columns: 270px 1fr 300px; }
  .stats .stat:nth-child(n+4) { display: none; }
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr; grid-template-rows: auto 1fr;
    grid-template-areas: "head" "map";
  }
  #sidebar, #insights {
    position: fixed; z-index: 1000; top: 60px; bottom: 0; width: min(330px, 88vw);
    grid-area: unset; border: 0; box-shadow: var(--shadow);
    transform: translateX(-105%); transition: transform .22s ease;
  }
  #sidebar { left: 0; border-right: 1px solid var(--border); }
  #insights { right: 0; left: auto; transform: translateX(105%); border-left: 1px solid var(--border); }
  #sidebar.open, #insights.open { transform: none; }
  #panel-toggles { display: flex; gap: 6px; }
  .stats { display: none; }
  #timeline { bottom: 12px; padding: 9px 12px 11px; }
  .tl-readout { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
