/* ============================================================
   The City That Remembers — URBNDXB / DBF design system
   Light chrome (default) + dark toggle. The MAP canvas stays
   DARK in both themes (dark CARTO basemap). Calm, government-
   grade, analyst tone. Inter body · DM Mono numbers & citations.
   Tokens replicated verbatim from urbandxb-amr/index.html.
   All transitions eased 200–600ms.
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   LIGHT MODE (default)
═══════════════════════════════════════════════════════════ */
:root {
  /* ── Core surfaces ── */
  --bg-page:      #f7f9fc;
  --bg-white:     #ffffff;
  --bg-light:     #f7f9fc;
  --bg-lighter:   #f9fafb;
  --bg-panel:     #ffffff;

  /* ── Borders ── */
  --border:       #e8ecf2;
  --border-2:     #e5e7eb;
  --border-focus: #8b5cf6;

  /* ── Text ── */
  --text-1:       #1a1d23;
  --text-2:       #374151;
  --text-3:       #6b7280;
  --text-4:       #9ca3af;

  /* ── URBNDXB brand purple ── */
  --brand:        #7c5cbf;
  --brand-mid:    #8b5cf6;
  --brand-light:  #ede9fe;
  --brand-border: #c4b5fd;
  --brand-dark:   #5b21b6;

  /* ── Status semantic ── */
  --green:        #15803d;
  --green-bg:     #f0fdf4;
  --green-border: #bbf7d0;
  --amber:        #d97706;
  --amber-bg:     #fffbeb;
  --amber-border: #fde68a;
  --blue:         #1d4ed8;
  --blue-bg:      #eff6ff;
  --blue-border:  #bfdbfe;
  --red:          #dc2626;
  --red-bg:       #fef2f2;
  --red-border:   #fecaca;
  --grey:         #6b7280;
  --grey-bg:      #f9fafb;
  --grey-border:  #e5e7eb;
  --teal:         #0d9488;
  --teal-bg:      #f0fdfa;
  --teal-border:  #99f6e4;

  /* ── Typography ── */
  --f-body:  'Inter', system-ui, sans-serif;
  --f-mono:  'DM Mono', ui-monospace, monospace;

  /* ── Radii ── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* ── Shadows ── */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);

  /* ── Layout ── */
  --rail-w: 32%;
  --ease:   cubic-bezier(0.22, 0.61, 0.36, 1);

  /* ── Toggle (mirrors AMR portable TopBar switch) ── */
  --toggle-on: #0072F6;
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE (toggle) — DM "Digital Blue Foam" token mapping
═══════════════════════════════════════════════════════════ */
body.dark {
  --bg-page:      #151218;
  --bg-white:     #1D1B20;
  --bg-light:     #1D1B20;
  --bg-lighter:   #28242D;
  --bg-panel:     #1D1B20;

  --border:       #49454E;
  --border-2:     #322F37;
  --border-focus: #BC99FF;

  --text-1:       #E7E0E8;
  --text-2:       #CBC4CF;
  --text-3:       #948F99;
  --text-4:       #605D61;

  --brand:        #BC99FF;
  --brand-mid:    #7429FF;
  --brand-light:  rgba(116,41,255,.15);
  --brand-border: rgba(188,153,255,.30);
  --brand-dark:   #D3BBFF;

  --green:        #4ade80;
  --green-bg:     rgba(74,222,128,.10);
  --green-border: rgba(74,222,128,.25);
  --amber:        #fbbf24;
  --amber-bg:     rgba(251,191,36,.10);
  --amber-border: rgba(251,191,36,.25);
  --blue:         #60a5fa;
  --blue-bg:      rgba(96,165,250,.10);
  --blue-border:  rgba(96,165,250,.25);
  --red:          #f87171;
  --red-bg:       rgba(248,113,113,.10);
  --red-border:   rgba(248,113,113,.25);
  --grey:         #948F99;
  --grey-bg:      #28242D;
  --grey-border:  #49454E;
  --teal:         #2dd4bf;
  --teal-bg:      rgba(45,212,191,.10);
  --teal-border:  rgba(45,212,191,.20);

  --shadow-xs: 0 1px 2px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.7), 0 2px 4px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg-page);
  color: var(--text-1);
  font-family: var(--f-body);
  font-weight: 400;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .25s var(--ease), color .25s var(--ease);
}

#app {
  display: grid;
  grid-template-columns: 1fr var(--rail-w);
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "map  rail"
    "chat rail";
  height: 100vh;
  width: 100vw;
  transition: grid-template-columns .28s var(--ease);
}

/* Collapsed: rail hidden, map + chat go full-width. */
#app.rail-collapsed {
  grid-template-columns: 1fr 0;
  grid-template-areas:
    "map"
    "chat";
}
#app.rail-collapsed #rail { display: none; }
#app.rail-collapsed .rail-show { display: inline-flex; }

/* ── scrollbars ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════════════════════════════════════════════════════
   MAP PANE — the canvas stays DARK in both themes
═══════════════════════════════════════════════════════════ */
#map-pane { grid-area: map; position: relative; background: #0b0d12; }
#map { position: absolute; inset: 0; background: #0b0d12; }

/* MapLibre controls — kept dark to sit over the dark basemap */
.maplibregl-ctrl-attrib { background: rgba(11,13,18,.7) !important; }
.maplibregl-ctrl-attrib a { color: #9aa0ad !important; }
.maplibregl-ctrl-group { background: #1a1d24 !important; border: 1px solid #2a2e38 !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid #2a2e38 !important; }
.maplibregl-ctrl-group button span { filter: invert(1) brightness(1.4); }

/* ── Cold-open caption (beat 1) — over the dark map, so light text ── */
.overlay-caption {
  position: absolute; left: 28px; bottom: 30px; z-index: 5;
  pointer-events: none;
  opacity: 0; transform: translateY(8px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}
.overlay-caption.show { opacity: 1; transform: translateY(0); }
.overlay-caption.fade { opacity: 0; transform: translateY(-6px); }
.cold-open-title {
  font-size: 30px; font-weight: 600; letter-spacing: -0.01em; color: #fff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.8);
}
.cold-open-sub {
  margin-top: 6px; color: #c9cdd8; font-size: 13px;
  font-family: var(--f-mono); letter-spacing: 0.01em;
}

/* ── Memory ribbon (HUD, beat 5) — glass card over the dark map ── */
.memory-ribbon {
  position: absolute; top: 16px; left: 16px; z-index: 6;
  width: 192px; padding: 12px 14px;
  background: rgba(20,22,30,0.82);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--r-lg);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  font-family: var(--f-mono);
  color: #e6e8ef;
}
.mr-row { display: flex; justify-content: space-between; align-items: baseline; }
.mr-label { font-size: 9.5px; letter-spacing: 0.18em; color: #8a90a0; }
.mr-state {
  font-size: 10.5px; padding: 1px 9px; border-radius: 999px;
  transition: all 400ms var(--ease);
}
.mr-cold { color: #9aa6cf; background: rgba(124,92,191,0.16); border: 1px solid rgba(124,92,191,0.34); }
.mr-warm { color: #fff; background: var(--brand); border: 1px solid var(--brand); font-weight: 500; }
.mr-metric { margin-top: 9px; font-size: 16px; font-weight: 500; color: #fff; }
.mr-metric i { display: block; font-size: 8.5px; font-style: normal; color: #8a90a0; letter-spacing: 0.08em; margin-top: 1px; }
.mr-reuse { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mr-reuse-bar { flex: 1; height: 5px; background: rgba(255,255,255,0.10); border-radius: 999px; overflow: hidden; }
.mr-reuse-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand-mid));
  transition: width 900ms var(--ease);
}
.mr-reuse-pct { font-size: 11.5px; color: var(--brand-border); min-width: 34px; text-align: right; }
.mr-flash {
  margin-top: 8px; font-size: 10.5px; color: var(--brand-border);
  opacity: 0; transform: translateY(-3px);
  transition: opacity 250ms var(--ease), transform 250ms var(--ease);
}
.mr-flash.show { opacity: 1; transform: translateY(0); }

/* ── Solver tag (beat 4) ── */
.solver-tag {
  position: absolute; bottom: 16px; right: 16px; z-index: 6;
  font-family: var(--f-mono); font-size: 10.5px;
  color: #c9cdd8;
  background: rgba(20,22,30,0.82); border: 1px solid rgba(255,255,255,0.10);
  padding: 5px 11px; border-radius: var(--r-sm);
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
}
.solver-tag.show { opacity: 1; transform: translateY(0); }

/* ── Legend ── */
.legend {
  position: absolute; bottom: 16px; left: 16px; z-index: 6;
  background: rgba(20,22,30,0.82); border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--r-md); padding: 10px 12px; backdrop-filter: blur(10px);
  font-family: var(--f-mono); color: #e6e8ef;
}
.legend-title { font-size: 10.5px; color: #c9cdd8; margin-bottom: 6px; }
.legend-ramp {
  width: 150px; height: 8px; border-radius: 999px;
  /* status amber -> red family (low scores alarming), green = healthy */
  background: linear-gradient(90deg, #dc2626, #ef5b3b, #d97706, #a3b54a, #15803d);
}
.legend-scale { display: flex; justify-content: space-between; font-size: 8.5px; color: #8a90a0; margin-top: 3px; }

/* ── Reset button ── */
.reset-btn {
  position: absolute; top: 16px; right: 16px; z-index: 6;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.03em;
  color: #c9cdd8; background: rgba(20,22,30,0.82);
  border: 1px solid rgba(255,255,255,0.12); border-radius: var(--r-sm);
  padding: 7px 12px; cursor: pointer;
  transition: all 250ms var(--ease);
}
.reset-btn:hover { color: #fff; border-color: rgba(255,255,255,0.28); background: rgba(28,31,42,0.92); }

/* ── Rail collapse button (in the rail header) ── */
.rail-collapse {
  flex-shrink: 0;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; color: var(--text-3);
  background: transparent; border: 1px solid var(--border);
  cursor: pointer; transition: all .15s var(--ease);
}
.rail-collapse:hover { color: var(--brand); border-color: var(--brand-border); background: var(--brand-light); }

/* ── Reopen-panel tab (on the map's right edge, only when collapsed) ── */
.rail-show {
  display: none;                       /* shown via #app.rail-collapsed */
  position: absolute; top: 50%; right: 0; transform: translateY(-50%);
  z-index: 6; align-items: center; gap: 5px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.03em;
  color: #c9cdd8; background: rgba(20,22,30,0.82);
  border: 1px solid rgba(255,255,255,0.12); border-right: none;
  border-radius: var(--r-md) 0 0 var(--r-md);
  padding: 12px 10px; cursor: pointer;
  writing-mode: vertical-rl;
  transition: all 200ms var(--ease);
}
.rail-show span { writing-mode: horizontal-tb; font-size: 14px; }
.rail-show:hover { color: #fff; border-color: rgba(255,255,255,0.28); background: rgba(28,31,42,0.92); }

/* ═══════════════════════════════════════════════════════════
   EVIDENCE RAIL — light panel (or dark surface in dark mode)
═══════════════════════════════════════════════════════════ */
#rail {
  grid-area: rail;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.rail-header {
  display: flex; align-items: center; gap: 11px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 10px var(--brand-border);
  flex-shrink: 0;
}
.brand-text { flex: 1; min-width: 0; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-1); }
.brand-sub { font-size: 10.5px; color: var(--text-3); font-family: var(--f-mono); }
.health-pill {
  font-size: 9.5px; font-family: var(--f-mono);
  color: var(--text-3); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--bg-light);
}
.health-pill.ok { color: var(--green); border-color: var(--green-border); background: var(--green-bg); }
.health-pill.mock { color: var(--amber); border-color: var(--amber-border); background: var(--amber-bg); }

/* ── Theme toggle (replica of AMR .dm-toggle) ── */
.dm-toggle-wrap { display: flex; align-items: center; flex-shrink: 0; }
.dm-toggle {
  position: relative; display: inline-block;
  width: 42px; height: 22px; cursor: pointer; flex-shrink: 0;
}
.dm-toggle input { opacity: 0; position: absolute; width: 0; height: 0; }
.dm-track {
  position: absolute; inset: 0;
  background: #b9bfca;
  border-radius: 100px;
  transition: background .2s;
}
.dm-toggle input:checked ~ .dm-track { background: var(--toggle-on); }
.dm-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.dm-toggle input:checked ~ .dm-thumb { transform: translateX(20px); }
body.dark .dm-track { background: #49454E; }

.rail-body {
  flex: 1; overflow-y: auto; padding: 18px;
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}

.rail-empty { color: var(--text-2); font-size: 13.5px; line-height: 1.6; }
.rail-empty .muted { color: var(--text-3); font-size: 12px; }

/* ── Answer block ── */
.answer-block { animation: rise 450ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.answer-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 10px;
  color: var(--text-3); margin-bottom: 12px; flex-wrap: wrap;
}
.answer-meta .lat-warm { color: var(--brand); }
.answer-meta .lat-cold { color: var(--blue); }
.answer-text { font-size: 14px; line-height: 1.62; color: var(--text-2); }
.answer-text strong { font-weight: 600; color: var(--text-1); }

/* ── Inline citations — DM Mono, brand colour (AMR .ai-cite) ── */
.ai-cite {
  color: var(--brand); font-family: var(--f-mono);
  font-size: 0.92em; opacity: 0.85; cursor: pointer;
  white-space: nowrap; transition: opacity .15s var(--ease);
}
.ai-cite:hover { opacity: 1; text-decoration: underline; }

/* ── District name tokens inside answer text (text→map) ── */
.dtoken {
  cursor: pointer; color: var(--text-1); font-weight: 600;
  border-bottom: 1px solid var(--border-2);
  transition: color 200ms var(--ease), border-color 200ms var(--ease), background 200ms var(--ease);
}
.dtoken:hover, .dtoken.flash { color: var(--brand); border-bottom-color: var(--brand); }
.dtoken.flash { animation: tokenflash 900ms var(--ease); }
@keyframes tokenflash {
  0% { background: var(--brand-light); }
  100% { background: transparent; }
}

/* ── Solver pill in rail (beat 4) ── */
.solver-pill {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0; padding: 12px 14px;
  border: 1px solid var(--blue-border); border-radius: var(--r-lg);
  background: var(--blue-bg);
  font-family: var(--f-mono);
}
.solver-pill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 0 0 rgba(29,78,216,0.6);
  animation: pulse 1.4s infinite; flex-shrink: 0;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(124,92,191,0.45); }
  70%  { box-shadow: 0 0 0 12px rgba(124,92,191,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,92,191,0); }
}
.solver-pill .label { font-size: 11.5px; color: var(--blue); letter-spacing: 0.04em; }
.solver-pill .sub { font-size: 10.5px; color: var(--text-3); }
.solver-pill.done { border-color: var(--green-border); background: var(--green-bg); }
.solver-pill.done .dot { background: var(--green); animation: none; box-shadow: 0 0 8px var(--green-border); }
.solver-pill.done .label { color: var(--green); }

/* ── Solver result block ── */
.solve-result { margin-top: 8px; animation: rise 450ms var(--ease); }
.coverage-row { display: flex; align-items: center; gap: 14px; margin: 14px 0; }
.cov-stat { flex: 1; }
.cov-stat .k { font-size: 9.5px; font-family: var(--f-mono); color: var(--text-3); letter-spacing: 0.08em; }
.cov-stat .v { font-size: 26px; font-weight: 500; font-family: var(--f-mono); }
.cov-before .v { color: var(--red); }
.cov-after .v { color: var(--green); }
.cov-arrow { color: var(--text-4); font-size: 20px; }
.solve-note {
  font-family: var(--f-mono); font-size: 10px; color: var(--text-3);
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: 14px;
}

/* ── District card (map→text) ── */
.district-card { animation: rise 400ms var(--ease); }
.dc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dc-name { font-size: 17px; font-weight: 600; color: var(--text-1); }
.dc-arabic { font-size: 14px; color: var(--text-3); direction: rtl; }
.dc-pop { font-family: var(--f-mono); font-size: 11.5px; color: var(--text-3); margin: 6px 0 16px; }
.dc-cats { display: grid; gap: 9px; }
.cat-row { display: grid; grid-template-columns: 120px 1fr 38px; align-items: center; gap: 10px; cursor: default; padding: 3px 5px; border-radius: var(--r-sm); }
.cat-row.clickable { cursor: pointer; transition: background .14s var(--ease); }
.cat-row.clickable:hover { background: var(--brand-light); }
.cat-row.clickable:hover .cat-name { color: var(--brand); }
.cat-name { font-size: 12px; color: var(--text-2); }
.cat-bar { height: 7px; border-radius: 999px; background: var(--border-2); overflow: hidden; }
.cat-bar > i { display: block; height: 100%; border-radius: 999px; transition: width 700ms var(--ease); }
.cat-val { font-family: var(--f-mono); font-size: 12px; color: var(--text-1); text-align: right; }
.cat-row .prov-hint { grid-column: 1 / -1; font-size: 9.5px; font-family: var(--f-mono); color: var(--brand); margin-top: -3px; opacity: 0; transition: opacity .14s var(--ease); }
.cat-row.clickable:hover .prov-hint { opacity: 1; }

.dc-pois { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.dc-pois h4 { margin: 0 0 8px; font-size: 10.5px; letter-spacing: 0.1em; color: var(--text-3); font-family: var(--f-mono); font-weight: 500; }
.poi-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.poi-tag { font-size: 11px; font-family: var(--f-mono); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px 8px; background: var(--bg-light); }

/* ═══════════════════════════════════════════════════════════
   CHAT BAR (bottom)
═══════════════════════════════════════════════════════════ */
#chat-bar {
  grid-area: chat;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.suggestions { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
/* suggestion chips replicate AMR .ai-chip / .chat-sug */
.chip {
  font-size: 11px; font-weight: 500; color: var(--brand);
  background: var(--brand-light); border: 1px solid var(--brand-border);
  border-radius: var(--r-sm); padding: 5px 11px; cursor: pointer;
  transition: all 160ms var(--ease); max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--f-body); line-height: 1.4;
}
.chip:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip:disabled { opacity: 0.45; cursor: default; }
.chip:disabled:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand-border); }

/* chat input — AMR .chat-field + .chat-send */
.chat-form {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 7px 8px 7px 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.chat-form:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,92,191,.1); }
.chat-input {
  flex: 1; border: none; background: transparent;
  font-family: var(--f-body); font-size: 14px; color: var(--text-1);
  outline: none; min-width: 0;
}
.chat-input::placeholder { color: var(--text-4); }
.chat-send {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: var(--brand); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; flex-shrink: 0;
  transition: background .14s var(--ease), transform .12s var(--ease);
}
.chat-send:hover { background: var(--brand-dark); }
.chat-send:active { transform: scale(0.95); }
.chat-send:disabled { background: var(--border-2); color: var(--text-4); cursor: default; }
body.dark .chat-send:disabled { color: var(--text-3); }

/* ── Thinking indicator in rail ── */
.thinking { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 12.5px; font-family: var(--f-mono); }
.thinking .dots span {
  display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%;
  background: var(--brand); opacity: 0.4; animation: blink 1.2s infinite;
}
.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,100%{opacity:0.3;} 50%{opacity:1;} }

/* ═══════════════════════════════════════════════════════════
   EVIDENCE DRAWER (beat 3)
═══════════════════════════════════════════════════════════ */
.evidence-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15,18,28,0.42); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 320ms var(--ease);
}
.evidence-scrim.show { opacity: 1; }

.evidence-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: 440px; max-width: 92vw;
  background: var(--bg-panel); border-left: 1px solid var(--border);
  box-shadow: -24px 0 60px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform 420ms var(--ease);
  display: flex; flex-direction: column;
}
body.dark .evidence-drawer { box-shadow: -24px 0 60px rgba(0,0,0,0.6); }
.evidence-drawer.show { transform: translateX(0); }
.ed-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 22px 16px; border-bottom: 1px solid var(--border);
}
.ed-kicker { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.2em; color: var(--brand); }
.ed-title { font-size: 16px; font-weight: 600; margin-top: 6px; max-width: 320px; color: var(--text-1); }
.ed-close { background: none; border: none; color: var(--text-3); font-size: 26px; line-height: 1; cursor: pointer; transition: color 200ms var(--ease); }
.ed-close:hover { color: var(--text-1); }

.ed-rungs { flex: 1; overflow-y: auto; padding: 14px 22px 30px; }

/* Each provenance rung — a peelable layer */
.rung {
  position: relative; padding: 14px 14px 14px 44px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--bg-light);
  cursor: pointer;
  opacity: 0; transform: translateX(16px);
  transition: opacity 380ms var(--ease), transform 380ms var(--ease),
              border-color 220ms var(--ease), background 220ms var(--ease);
}
.rung.in { opacity: 1; transform: translateX(0); }
.rung:hover, .rung.active {
  border-color: var(--brand-border);
  background: var(--brand-light);
}
.rung::before {
  content: attr(data-step);
  position: absolute; left: 12px; top: 14px;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-mono); font-size: 11px;
  color: var(--brand); background: var(--brand-light);
  border: 1px solid var(--brand-border);
}
.rung::after {
  content: ""; position: absolute; left: 22px; top: 38px; bottom: -10px;
  width: 1px; background: var(--border);
}
.rung:last-child::after { display: none; }
.rung-label { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.14em; color: var(--text-3); text-transform: uppercase; }
.rung-value { font-size: 13.5px; line-height: 1.5; color: var(--text-2); margin-top: 4px; }
.rung-value .em { color: var(--brand); font-weight: 600; font-family: var(--f-mono); }
.rung.geometry .rung-label { color: var(--brand); }

/* Solver pin ring pulse (markers created in map.js) */
@keyframes pinring {
  0%   { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.4); opacity: 0; }
}
.maplibregl-popup-content {
  background: var(--brand) !important;
  border-radius: var(--r-sm) !important;
  padding: 6px 10px !important;
}
.maplibregl-popup-tip { border-top-color: var(--brand) !important; border-bottom-color: var(--brand) !important; }

/* ═══════════════════════════════════════════════════════════
   CITY SWITCHER (top-centre, glass over the dark map)
═══════════════════════════════════════════════════════════ */
/* Tucked into the top-right corner, below the Reset button; dimmed until hover
   so it stays unobtrusive (not a centre-stage control). */
.city-switch {
  position: absolute; top: 52px; right: 16px;
  z-index: 7; display: flex; gap: 2px;
  padding: 2px; border-radius: 999px;
  background: rgba(20,22,30,0.70);
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  opacity: 0.7; transition: opacity 200ms var(--ease);
}
.city-switch:hover { opacity: 1; }
.city-btn {
  font-family: var(--f-body); font-size: 11px; font-weight: 500;
  letter-spacing: 0.01em; color: #c9cdd8;
  background: transparent; border: none; cursor: pointer;
  padding: 4px 11px; border-radius: 999px;
  transition: all 180ms var(--ease); white-space: nowrap;
}
.city-btn:hover { color: #fff; }
.city-btn.active {
  color: #fff; background: var(--brand);
  box-shadow: 0 1px 6px rgba(0,0,0,0.35);
}

/* ═══════════════════════════════════════════════════════════
   SYDNEY THEME — NSW Government design language.
   No purple: NSW Brand Blue (#002664) + Waratah red accent,
   Public Sans body. Map canvas stays dark in both themes.
   Light tokens scoped to :not(.dark); dark tokens to .dark so
   the theme toggle still works per city.
═══════════════════════════════════════════════════════════ */
body.city-sydney { --f-body: 'Public Sans', system-ui, sans-serif; }

body.city-sydney:not(.dark) {
  --brand:        #002664;   /* NSW Brand Blue */
  --brand-mid:    #2e5299;
  --brand-light:  #e9edf5;
  --brand-border: #b9c5dc;
  --brand-dark:   #001a47;
  --border-focus: #002664;
  --toggle-on:    #002664;
}
body.city-sydney.dark {
  --brand:        #8ab4e8;   /* legible NSW blue on dark surfaces */
  --brand-mid:    #4f8bd0;
  --brand-light:  rgba(138,180,232,.15);
  --brand-border: rgba(138,180,232,.32);
  --brand-dark:   #c2d9f4;
  --border-focus: #8ab4e8;
}

/* Waratah-red accent for the brand mark + cold-open, the one place NSW red
   reads as identity rather than as a low-score alarm on the choropleth. */
body.city-sydney .brand-dot { background: #d7153a; box-shadow: 0 0 10px rgba(215,21,58,.5); }
body.city-sydney .cold-open-title { border-left: 4px solid #d7153a; padding-left: 12px; }
body.city-sydney .chat-form:focus-within { box-shadow: 0 0 0 3px rgba(0,38,100,.12); }
body.city-sydney.dark .chat-form:focus-within { box-shadow: 0 0 0 3px rgba(138,180,232,.18); }

@media (max-width: 1100px) {
  :root { --rail-w: 38%; }
  .cold-open-title { font-size: 24px; }
}

/* ═══════════════════════════════════════════════════════════
   SITE ANALYSIS — panel, zone toggle, compass popup, rail card
═══════════════════════════════════════════════════════════ */

/* Floating panel on the map-pane (bottom-left) */
.site-panel {
  position: absolute;
  bottom: 76px;
  left: 16px;
  z-index: 20;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 10px 12px 12px;
  min-width: 300px;
  max-width: 380px;
  font-family: var(--f-body);
}
.dark .site-panel {
  background: #1a1f2e;
  border-color: #2d3348;
  box-shadow: 0 4px 20px rgba(0,0,0,.45);
}

.site-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.site-panel-address {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
  line-height: 1.35;
  flex: 1;
}
.dark .site-panel-address { color: #c4cad8; }
.site-panel-close {
  background: none;
  border: none;
  color: var(--text-4);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.site-panel-close:hover { color: var(--text-1); }

/* Zone type toggle */
.zone-toggle {
  display: flex;
  gap: 4px;
}
.zone-btn {
  flex: 1;
  padding: 5px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 160ms, color 160ms, border-color 160ms;
}
.zone-btn:hover {
  background: var(--bg-light);
  color: var(--text-1);
}
.zone-btn.active {
  background: var(--brand-light);
  border-color: var(--brand-border);
  color: var(--brand-dark);
}
.dark .zone-btn { border-color: #2d3348; color: #8892a4; }
.dark .zone-btn:hover { background: #252b3b; color: #c4cad8; }
.dark .zone-btn.active {
  background: rgba(139,92,246,.18);
  border-color: rgba(139,92,246,.45);
  color: #c4b5fd;
}

/* Amenity arc legend chips inside the site panel */
.compass-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.cl-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-family: var(--f-mono);
  letter-spacing: 0.04em;
  color: var(--text-3);
}
.cl-swatch {
  width: 18px;
  height: 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.dark .cl-chip { color: #6b7280; }
.dark .compass-legend { border-color: #2d3348; }

/* Structured property analysis in the rail */
.prop-district {
  font-size: 10px;
  font-family: var(--f-mono);
  color: var(--text-4);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.dark .prop-district { color: #4b5563; border-color: #252b3b; }

.prop-section { margin-bottom: 14px; }

.prop-section-title {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 6px;
  font-family: var(--f-mono);
}
.dark .prop-section-title { color: #4b5563; }

.prop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--f-mono);
}
.prop-table th {
  text-align: left;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-4);
  border-bottom: 1px solid var(--border);
  padding: 0 4px 4px 0;
}
.prop-table td {
  padding: 5px 4px 5px 0;
  color: var(--text-2);
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
.prop-gap {
  text-align: right !important;
  color: var(--red) !important;
  font-weight: 600;
}
.dark .prop-table th { color: #4b5563; border-color: #252b3b; }
.dark .prop-table td { color: #c4cad8; border-color: #2d3348; }
.dark .prop-gap { color: #fca5a5 !important; }

.prop-bullets {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.75;
}
.prop-bullets strong {
  color: var(--text-1);
  font-weight: 600;
}
.dark .prop-bullets { color: #c4cad8; }
.dark .prop-bullets strong { color: #e7e0e8; }

.prop-analysis { font-size: 11px; line-height: 1.65; }
