/* GEONIA — design tokens and components.
   Dark is the signature theme; light is a first-class equivalent, not an inversion. */
:root {
  color-scheme: light;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --bg: #e9eef4;
  --surface: #fbfcfd;              /* chart + solid panel surface */
  --panel: rgba(251, 252, 253, 0.90);
  --panel-2: rgba(236, 241, 247, 0.85);
  --line: rgba(15, 32, 55, 0.10);
  --line-strong: rgba(15, 32, 55, 0.20);
  --text: #0b1522;
  --text-2: #44536a;
  --muted: #6b7a8f;
  --accent: #1f6fd1;
  --accent-soft: rgba(31, 111, 209, 0.10);
  --active: #9a5f00;
  --active-soft: rgba(237, 161, 0, 0.16);
  --danger: #c93a3a;
  --good: #006300;
  --shadow: 0 18px 50px rgba(15, 32, 55, 0.16), 0 2px 8px rgba(15, 32, 55, 0.08);
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  /* data palette (dataviz reference instance, light steps) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --seq: #b7d3f6, #9ec5f4, #6da7ec, #3987e5, #256abf, #184f95, #0d366b;
  /* second sequential context (overlays drawn over a blue choropleth): the next categorical hue, orange */
  --seq-2: #fbd9c6, #f7b996, #f29466, #eb6834, #cc4f1f, #a23c15, #75290c;
  --div-neg: #f29c9b, #d03b3b, #8f2626;
  --div-pos: #9ec5f4, #3987e5, #184f95;
  --div-mid: #d6d5ce;
  --ord: #86b6ef, #3987e5, #256abf, #104281;
  --basemap: positron;
  --ocean: #d6dfe9;
  --land: #f2f3f0;

  --radius: 14px;
  --radius-sm: 8px;
  --panel-w: 360px;
  --insight-w: 460px;
}
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

/* dark tokens: declared for the OS setting and for the explicit toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070b11; --surface: #0e141d; --panel: rgba(12, 18, 27, 0.86); --panel-2: rgba(20, 28, 40, 0.80);
    --line: rgba(167, 196, 226, 0.11); --line-strong: rgba(167, 196, 226, 0.22);
    --text: rgba(239, 245, 251, 0.95); --text-2: rgba(190, 206, 222, 0.78); --muted: #8a99ab;
    --accent: #72b7ff; --accent-soft: rgba(114, 183, 255, 0.12); --active: #f3b85b; --active-soft: rgba(243, 184, 91, 0.14);
    --danger: #ff6b66; --good: #0ca30c;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.25);
    --grid: #1f2732; --axis: #36404d;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --seq: #0d366b, #184f95, #256abf, #3987e5, #6da7ec, #9ec5f4, #cde2fb;
  --seq-2: #5a1f08, #86300f, #b34417, #d95926, #ec7f4f, #f4a77f, #fbd3bc;
    --div-neg: #7d2626, #d03b3b, #f29c9b;
    --div-pos: #184f95, #3987e5, #9ec5f4;
    --div-mid: #2f3640;
    --ord: #cde2fb, #86b6ef, #3987e5, #1c5cab;
    --basemap: dark; --attrib-filter: invert(1);
    --ocean: #0a1018; --land: #1a222d;
  }
}
:root[data-theme="dark"] {
  --bg: #070b11; --surface: #0e141d; --panel: rgba(12, 18, 27, 0.86); --panel-2: rgba(20, 28, 40, 0.80);
  --line: rgba(167, 196, 226, 0.11); --line-strong: rgba(167, 196, 226, 0.22);
  --text: rgba(239, 245, 251, 0.95); --text-2: rgba(190, 206, 222, 0.78); --muted: #8a99ab;
  --accent: #72b7ff; --accent-soft: rgba(114, 183, 255, 0.12); --active: #f3b85b; --active-soft: rgba(243, 184, 91, 0.14);
  --danger: #ff6b66; --good: #0ca30c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.25);
  --grid: #1f2732; --axis: #36404d;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --seq: #0d366b, #184f95, #256abf, #3987e5, #6da7ec, #9ec5f4, #cde2fb;
  --seq-2: #5a1f08, #86300f, #b34417, #d95926, #ec7f4f, #f4a77f, #fbd3bc;
  --div-neg: #7d2626, #d03b3b, #f29c9b;
  --div-pos: #184f95, #3987e5, #9ec5f4;
  --div-mid: #2f3640;
  --ord: #cde2fb, #86b6ef, #3987e5, #1c5cab;
  --basemap: dark; --attrib-filter: invert(1);
  --ocean: #0a1018; --land: #1a222d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-nav { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-nav:focus { left: 12px; }
.mono, .kicker { font-family: var(--mono); }
.kicker { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ glass panels */
.glass {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: transparent; cursor: pointer; font-weight: 600; font-size: 13px;
  color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #06121f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #06121f; } }
.btn.ghost { border-color: transparent; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn svg { width: 16px; height: 16px; flex: none; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--text-2);
  white-space: nowrap;
}
.badge.licensed { color: var(--active); border-color: var(--active); background: var(--active-soft); }
.badge.planned { color: var(--muted); border-style: dashed; }
.badge svg { width: 10px; height: 10px; }
select.input, input.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
}
textarea.input { height: auto; padding: 10px; font-family: var(--mono); font-size: 13px; line-height: 1.5; }

/* ------------------------------------------------------------------ map shell */
.map-page { overflow: hidden; }
#map { position: fixed; inset: 0; }
.topbar {
  position: fixed; top: 14px; left: 14px; right: 14px; z-index: 20; display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; height: 48px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-name { font-weight: 800; letter-spacing: 0.14em; font-size: 15px; }
.brand-tag { font-size: 11px; color: var(--muted); line-height: 1.2; max-width: 170px; }
.search { position: relative; flex: 0 1 420px; height: 48px; display: flex; align-items: center; padding: 0 12px; gap: 8px; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { border: 0; background: transparent; outline: none; width: 100%; height: 100%; font-size: 14px; }
.search-results {
  position: absolute; top: 54px; left: 0; right: 0; max-height: 60vh; overflow: auto; padding: 6px; z-index: 30;
}
.search-results button {
  display: flex; width: 100%; text-align: left; gap: 10px; align-items: baseline; padding: 8px 10px; border: 0;
  background: transparent; border-radius: var(--radius-sm); cursor: pointer;
}
.search-results button[aria-selected="true"], .search-results button:hover { background: var(--accent-soft); }
.search-results .kind { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; width: 64px; flex: none; }
.topbar .spacer { flex: 1; }
.toolbar { display: flex; align-items: center; gap: 4px; padding: 6px; height: 48px; }
.lang-toggle { font-family: var(--mono); font-weight: 600; letter-spacing: 0.08em; }

/* left: questions */
.questions {
  position: fixed; top: 76px; left: 14px; bottom: 14px; width: var(--panel-w); z-index: 15; display: flex; flex-direction: column;
  overflow: hidden; transition: transform 0.25s ease;
}
.questions header { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.questions h2 { margin: 0; font-size: 13px; font-weight: 700; }
.questions .scroll { overflow: auto; padding: 6px 8px 12px; flex: 1; }
.questions .q-head-actions { display: flex; align-items: center; gap: 8px; }
.questions[data-collapsed="true"] { bottom: auto; }
.questions[data-collapsed="true"] .scroll { display: none; }
.questions[data-collapsed="true"] header { border-bottom: 0; }
.direction { border-bottom: 1px solid var(--line); }
.direction:last-child { border-bottom: 0; }
.direction > button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 8px; border: 0; background: transparent;
  cursor: pointer; text-align: left;
}
.direction > button .dir-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.direction > button .dir-icon svg { width: 16px; height: 16px; }
.direction > button .dir-title { font-weight: 700; font-size: 13.5px; flex: 1; }
.direction > button .dir-count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.direction > button .chev { width: 14px; height: 14px; color: var(--muted); transition: transform 0.2s; }
.direction[data-open="true"] > button .chev { transform: rotate(90deg); }
.direction ul { list-style: none; margin: 0 0 8px; padding: 0; display: none; }
.direction[data-open="true"] ul { display: block; }
.q-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer; padding: 9px 10px 9px 48px;
  border-radius: var(--radius-sm); position: relative;
}
.q-item:hover { background: var(--accent-soft); }
.q-item[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.q-item .q-ask { display: block; font-size: 13px; line-height: 1.4; color: var(--text); }
.q-item .q-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.q-item.planned .q-ask { color: var(--muted); }

/* right: insight */
.insight {
  position: fixed; top: 76px; right: 14px; bottom: 14px; width: var(--insight-w); z-index: 15; display: flex; flex-direction: column;
  overflow: hidden; transform: translateX(calc(100% + 24px)); transition: transform 0.28s ease;
}
.insight[data-open="true"] { transform: none; }
.insight .head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.insight .head h2 { margin: 6px 0 4px; font-size: 18px; line-height: 1.3; font-weight: 750; }
.insight .head p { margin: 0; color: var(--text-2); font-size: 13px; }
.insight .head .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.insight .body { overflow: auto; flex: 1; padding: 14px 18px 18px; }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.params label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.params .wide { grid-column: 1 / -1; }
.headline { font-size: 15.5px; line-height: 1.5; font-weight: 600; margin: 0 0 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 12px; }
.tabs button {
  border: 0; background: transparent; padding: 8px 10px; cursor: pointer; font-weight: 600; font-size: 12.5px;
  color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabpanel[hidden] { display: none; }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 380px; }
.notes { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.notes li { font-size: 12.5px; color: var(--text-2); padding-left: 14px; position: relative; }
.notes li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.callout { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; color: var(--text-2); margin-top: 12px; }
.callout strong { color: var(--text); }
.callout.lock { border-color: var(--active); background: var(--active-soft); color: var(--text); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; padding: 24px 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--danger); font-size: 13px; padding: 12px 0; }

/* tables */
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { position: sticky; top: 0; background: var(--surface); font-weight: 700; font-size: 11.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; z-index: 1; }
table.data th[aria-sort="ascending"]::after { content: " ↑"; }
table.data th[aria-sort="descending"]::after { content: " ↓"; }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }
table.data tr:hover td { background: var(--accent-soft); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px 0; color: var(--muted); font-size: 12px; }

/* provenance */
.prov { display: grid; gap: 8px; }
.prov-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; }
.prov-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.prov-item .name { font-weight: 700; }
.prov-item .meta { color: var(--muted); font-family: var(--mono); font-size: 11px; margin-top: 4px; word-break: break-all; }
.cache { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 4px; }
.cache.hit, .cache.local { background: var(--accent-soft); color: var(--accent); }
.cache.miss { background: rgba(12, 163, 12, 0.14); color: var(--good); }
.cache.stale { background: var(--active-soft); color: var(--active); }

/* code */
.code-tabs { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.code-tabs button { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 3px 8px; font-family: var(--mono); font-size: 11px; cursor: pointer; color: var(--text-2); }
.code-tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
pre.code {
  margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; line-height: 1.55; overflow: auto; white-space: pre; position: relative;
}
.code-wrap { position: relative; }
.code-wrap .copy { position: absolute; top: 6px; right: 6px; height: 26px; font-size: 11px; padding: 0 8px; background: var(--surface); }

/* map overlays */
.legend {
  position: fixed; left: calc(var(--panel-w) + 28px); bottom: 14px; z-index: 12; padding: 10px 12px; min-width: 220px; max-width: 320px;
}
.legend[hidden] { display: none; }
.legend .title { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.legend .bins { display: flex; gap: 2px; }
.legend .bins span { flex: 1; height: 10px; border-radius: 2px; }
.legend .ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 4px; gap: 4px; }
.legend .cats { display: grid; gap: 4px; }
.legend .cat { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.legend .sizes { margin-top: 8px; }
.legend .size-row { display: flex; align-items: flex-end; gap: 12px; }
.legend .size { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.legend .ring { border-radius: 50%; border: 1.5px solid var(--axis); flex: none; }
.legend .nodata { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend .nodata i { width: 14px; height: 8px; border: 1px solid var(--line-strong); border-radius: 2px; }

.timeline {
  position: fixed; left: calc(var(--panel-w) + 28px); right: calc(var(--insight-w) + 96px); bottom: 14px; z-index: 13;
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; max-width: 620px;
}
.timeline[hidden] { display: none; }
.timeline input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--accent); }
body.has-timeline .legend { bottom: 76px; }
.timeline .year { font-family: var(--mono); font-weight: 600; min-width: 72px; text-align: right; white-space: nowrap; }

.map-nav { position: fixed; right: 14px; bottom: 14px; z-index: 12; display: flex; flex-direction: column; gap: 2px; padding: 4px; transition: right 0.28s ease; }
.insight[data-open="true"] ~ .map-nav { right: calc(var(--insight-w) + 28px); }
.map-nav button { width: 34px; height: 34px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--text); font-family: var(--mono); }
.map-nav button:hover { background: var(--accent-soft); }

.popover { position: fixed; top: 70px; right: 14px; z-index: 40; width: 280px; padding: 14px; display: grid; gap: 14px; }
.popover[hidden] { display: none; }
.popover .group { display: grid; gap: 6px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 0; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.place-panel { position: fixed; top: 76px; left: calc(var(--panel-w) + 28px); z-index: 14; width: 300px; padding: 10px 14px 12px;
  max-height: calc(100vh - 200px); overflow: auto; }
.place-panel[hidden] { display: none; }
.place-panel[data-collapsed="true"] .pp-body { display: none; }
.place-panel[data-collapsed="true"] { width: 240px; }
.pp-top { display: flex; justify-content: space-between; align-items: center; margin: -4px -6px 0 0; }
.pp-crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); }
.pp-crumbs span + span::before { content: "›"; margin-right: 4px; }
.pp-crumbs .current { color: var(--accent); }
.pp-head h3 { margin: 2px 0 2px; font-size: 17px; line-height: 1.25; }
.pp-context { font-size: 12px; color: var(--text-2); }
.pp-rows { margin: 10px 0 0; display: grid; gap: 0; }
.pp-row { display: grid; grid-template-columns: 1fr auto 18px; gap: 8px; align-items: baseline; padding: 6px 0;
  border-top: 1px solid var(--line); }
.pp-row dt { font-size: 12.5px; color: var(--text-2); }
.pp-row dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-period { margin-left: 6px; font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.pp-remove { border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; font-size: 14px; padding: 0; }
.pp-row:hover .pp-remove, .pp-remove:focus-visible { opacity: 1; }
.pp-actions { display: flex; gap: 6px; margin-top: 10px; }
.pp-add { height: 32px; font-size: 12.5px; }
.place-panel .asks { margin-top: 10px; display: grid; }
.place-panel .asks .btn { white-space: normal; height: auto; min-height: 34px; padding: 6px 10px; text-align: left; }
.place-panel .provisional-note { margin: 8px 0 0; }
.place-card { position: fixed; top: 76px; left: calc(var(--panel-w) + 28px); z-index: 14; width: 300px; padding: 14px; }
.place-card[hidden] { display: none; }
.place-card h3 { margin: 4px 0 8px; font-size: 17px; }
.place-card dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 12.5px; }
.place-card dt { color: var(--text-2); }
.place-card dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.place-card .close { position: absolute; top: 8px; right: 8px; }
.place-card .asks { display: grid; gap: 6px; margin-top: 12px; }

/* street level */
.place-panel:has(.st-tabs) { width: 360px; }
.st-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 2px; }
.st-tabs button { border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.st-tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.pp-row.st { grid-template-columns: 1fr auto; }
.pp-row.st dd { white-space: normal; max-width: 180px; }
.st-section { margin-top: 12px; }
.st-section .kicker { margin-bottom: 6px; display: block; }
.st-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.st-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 12.5px; padding: 4px 0;
  border-top: 1px solid var(--line); }
.st-list li b { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-list li span { color: var(--text); }
.st-list li small { grid-column: 1 / -1; color: var(--muted); font-family: var(--mono); font-size: 10.5px; }
.st-bars { display: grid; gap: 2px; }
.st-bar { display: grid; grid-template-columns: 120px 1fr 44px 44px; gap: 6px; align-items: center; border: 0;
  background: transparent; padding: 3px 4px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 11.5px; }
.st-bar:hover, .st-bar[aria-pressed="true"] { background: var(--accent-soft); }
.st-bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.st-bar .track { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.st-bar .track i { display: block; height: 100%; background: var(--series-1); border-radius: 0 3px 3px 0; }
.st-bar[aria-pressed="true"] .lbl { color: var(--text); font-weight: 700; }
.st-bar .val, .st-bar .lq { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--text-2); }
.st-bar .lq.hi { color: var(--good); font-weight: 600; }
.st-bar .lq.lo { color: var(--muted); }
.st-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: 11.5px; color: var(--text-2); }
.st-legend span { display: inline-flex; align-items: center; gap: 6px; }
.st-legend i { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
/* answer panel actions: hide (keeps the map) and close */
.insight-actions { display: inline-flex; gap: 2px; }

/* census units kept underneath the firm-level tabs */
.st-source { margin-bottom: 10px; }
.st-overlay { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.st-census { margin: 2px 0 12px; padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.st-census .un-controls { margin-top: 6px; }
.st-census .legend.pp-legend { margin-top: 6px; }

/* city layers */
.city-list { display: grid; gap: 2px; }
.city-list .check { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: center; font-size: 12.5px; }
.city-list small { font-family: var(--mono); color: var(--muted); font-size: 10.5px; }
.city-list a { color: var(--muted); text-decoration: none; font-size: 11px; }
.city-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0;
  box-shadow: 0 0 0 2px var(--surface); }
.city-dot.mobility { background: var(--series-1); } .city-dot.civic { background: var(--series-2); }
.city-dot.environment { background: var(--series-3); } .city-dot.air-good { background: var(--good); }
.city-dot.air-fair { background: var(--active); } .city-dot.air-poor { background: var(--danger); }

/* Québec census units */
.local-level #legend:not(.gdp), .local-level #timeline { display: none; }
.place-panel:has(.un-controls) { width: 380px; max-height: calc(100vh - 300px); }
.un-controls { display: grid; gap: 6px; margin-top: 8px; }
.un-controls .seg button { font-size: 11.5px; padding: 5px 2px; }
.un-controls select { height: 32px; font-size: 12.5px; }
.legend.pp-legend { position: static; margin-top: 10px; padding: 0; min-width: 0; max-width: none; background: none;
  border: 0; box-shadow: none; backdrop-filter: none; }
.un-dist, .un-hist { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 10.5px;
  font-variant-numeric: tabular-nums; }
.un-dist th, .un-hist th { font-weight: 500; color: var(--muted); text-align: right; padding: 2px 3px; }
.un-dist td, .un-hist td { text-align: right; padding: 3px; border-top: 1px solid var(--line); }
.un-hist th:first-child, .un-hist td:first-child { text-align: left; }
.un-hist { margin-top: 8px; font-size: 11px; }
.un-dist + .un-dist { margin-top: 6px; }
.un-dist th, .un-dist td { width: 20%; }
.un-chart .chart { height: 150px; }
.st-note { font-size: 11.5px; color: var(--text-2); margin: 10px 0 0; line-height: 1.45; }
.st-weather { display: flex; align-items: baseline; gap: 10px; margin: 8px 0; }
.st-weather .temp { font-size: 34px; font-weight: 300; font-variant-numeric: tabular-nums; }

/* map layers: MapLibre globe or d3 Equal Earth */
.map-layer { position: absolute; inset: 0; }
.map-layer[hidden] { display: none; }
.mini-map .legend { z-index: 2; }
.flat-map { width: 100%; height: 100%; display: block; background: var(--bg); cursor: grab; }
.flat-map:active { cursor: grabbing; }
.flat-map path, .flat-map circle { vector-effect: non-scaling-stroke; }
.fm-sphere { fill: var(--ocean); stroke: var(--line-strong); stroke-width: 1; }
.fm-graticule { fill: none; stroke: var(--line); stroke-width: 0.6; }
.fm-country { fill: var(--land); stroke: var(--line-strong); stroke-width: 0.5; cursor: pointer; }
.fm-country.hover { stroke: var(--text); stroke-width: 1.5; }
.fm-a1 { stroke: var(--surface); stroke-width: 0.6; cursor: pointer; }
.fm-hl { fill: none; stroke: var(--active); stroke-width: 2; pointer-events: none; }
.fm-flow { fill: none; stroke-opacity: 0.75; stroke-linecap: round; pointer-events: none; }
.fm-pt { stroke: var(--surface); cursor: pointer; }
.fm-ctx-pt { stroke: var(--surface); opacity: 0.75; cursor: pointer; }
.fm-ctx-pt.ports { fill: var(--text-2); }
.fm-ctx-pt.mines { fill: var(--active); }
.fm-label { fill: var(--muted); font-family: var(--mono); text-anchor: middle; dominant-baseline: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--land); stroke-linejoin: round; letter-spacing: 0.02em; vector-effect: none; }
.fm-popup { position: absolute; z-index: 5; min-width: 180px; max-width: 280px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 26px 10px 12px; }
.fm-popup[hidden] { display: none; }
.fm-popup-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; }

/* MapLibre */
.maplibregl-popup-content { background: var(--surface) !important; color: var(--text); border-radius: 10px !important; box-shadow: var(--shadow) !important; padding: 10px 12px !important; font-family: var(--font); border: 1px solid var(--line); }
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 16px; }
.pop-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.pop-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-2); }
.pop-row b { color: var(--text); font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.maplibregl-ctrl-attrib { background: var(--panel) !important; color: var(--muted) !important; font-size: 10px; border-radius: 8px !important; }
.maplibregl-ctrl-attrib-button { filter: var(--attrib-filter, none); }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.map-page .maplibregl-ctrl-top-left { top: 70px; left: calc(var(--panel-w) + 22px); }

.mobile-tabs { display: none; }
.provisional-note { font-size: 10px; color: var(--muted); }

/* ------------------------------------------------------------------ content pages */
.page-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: var(--panel); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.page-header nav { display: flex; gap: 2px; margin-left: 12px; flex-wrap: wrap; }
.page-header nav a { padding: 6px 10px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.page-header nav a:hover, .page-header nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
.page h1 { font-size: 30px; line-height: 1.2; margin: 8px 0 10px; letter-spacing: -0.01em; }
.page h2 { font-size: 19px; margin: 34px 0 10px; }
.page h3 { font-size: 15px; margin: 22px 0 8px; }
.page p.lead { font-size: 16px; color: var(--text-2); max-width: 760px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mini-map { height: 360px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); position: relative; }
.mini-map .legend { position: absolute; left: 10px; bottom: 10px; }
.src-table td, .src-table th { font-size: 13px; }
.form { max-width: 380px; margin: 40px auto; display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.form .error { padding: 0; }
.key-reveal { font-family: var(--mono); padding: 10px 12px; border: 1px dashed var(--active); background: var(--active-soft); border-radius: 8px; word-break: break-all; }
.sql-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.schema details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.schema summary { cursor: pointer; font-family: var(--mono); font-size: 13px; font-weight: 600; }
.schema ul { margin: 6px 0 0; padding-left: 16px; font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.endpoint { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.endpoint code { font-family: var(--mono); font-size: 12.5px; }
.method-get { color: var(--good); font-family: var(--mono); font-weight: 600; }
.method-post { color: var(--active); font-family: var(--mono); font-weight: 600; }
.study-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius); background: #000; }
.embeds { display: grid; gap: 6px; }
.embeds a { display: flex; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  :root { --panel-w: 320px; --insight-w: 400px; }
  .brand-tag { display: none; }
}
@media (max-width: 760px) {
  .topbar { top: 10px; left: 10px; right: 10px; gap: 6px; }
  .brand { padding: 6px 10px; height: 44px; }
  .brand-name { display: none; }
  .search { height: 44px; flex: 1; }
  .toolbar { height: 44px; }
  .toolbar .hide-mobile { display: none; }
  .questions, .insight {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; border-radius: 16px 16px 0 0;
    transform: translateY(calc(100% + 10px));
  }
  .questions[data-mobile-open="true"], .insight[data-open="true"] { transform: none; }
  .insight { z-index: 16; }
  .mobile-tabs { display: flex; position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 14; padding: 4px; gap: 4px; }
  .legend { left: 10px; bottom: 70px; min-width: 0; max-width: calc(100vw - 20px); }
  .timeline { left: 10px; right: 10px; bottom: 120px; }
  .map-nav { display: none; }
  .map-page .maplibregl-ctrl-top-left { top: 62px; left: 4px; }
  .place-card { left: 10px; right: 10px; width: auto; top: 64px; }
  .place-panel { left: 10px; right: 10px; width: auto; top: 62px; max-height: 45vh; }
  .params { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .sql-grid { grid-template-columns: 1fr; }
  .page { padding: 20px 16px 60px; }
  .page-header { padding: 10px 16px; flex-wrap: wrap; }
  .page-header nav { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* foresight tab (projection and vulnerability) */
.fs-classes { display: grid; gap: 4px; margin: 8px 0; font-size: 12px; }
.fs-class { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; }
.fs-class i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); }
.fs-class b { font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.fs-formula { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); margin: 6px 0; word-break: break-word; }
.fs-inds { display: grid; gap: 4px; font-size: 12px; }
.fs-inds small { color: var(--muted); }
.st-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.st-table th, .st-table td { text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.st-table th:first-child, .st-table td:first-child { text-align: left; }
.st-table tr.best td { font-weight: 600; }
