/* ── Reset & base ─────────────────────────────────────────────────────────── */

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

:root {
  /* Data-viz palette — used in map/charts only, intentional colour */
  --blue-0: #f0f5fa;
  --blue-1: #c6dbef;
  --blue-2: #6baed6;
  --blue-3: #2171b5;
  --blue-4: #08306b;
  --accent: #ff6700;

  /* UI chrome — neutral, no blue tint */
  --text:   #111827;
  --muted:  #6b7280;
  --bg:     #ffffff;
  --panel:  #ffffff;
  --border: #e5e7eb;
  --border-subtle: #f3f4f6;

  /* Shadows — neutral grey, no blue cast */
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.05), 0 3px 14px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.07), 0 10px 28px rgba(0, 0, 0, 0.10);

  --radius: 12px;
  --radius-sm: 5px;
  --tab-nav-h: 60px;
  --chart-panel-w: 340px;
}

html {
  font-family: "Work Sans", "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Allow window scroll so Scrollama works out of the box */
body { min-height: 100vh; }

/* ── Tab navigation ───────────────────────────────────────────────────────── */

#tab-nav {
  position: sticky;
  top: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0 1.25rem;
  height: var(--tab-nav-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1rem;
  height: 100%;
  border: none;
  border-bottom: 2.5px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: "Work Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  margin-bottom: -1.5px; /* align border-bottom with nav bottom border */
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--text);
  background: transparent;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  background: var(--border-subtle);
  color: var(--muted);
  border-radius: 4px;
  font-family: "Space Mono", monospace;
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.tab-btn.active .badge {
  background: var(--border);
  color: var(--muted);
}

/* ── Layout — two column, window scrolls ─────────────────────────────────── */

#app {
  display: grid;
  grid-template-columns: 42% 58%;
  align-items: start;
}

/* ── Map container — sticky on window scroll ─────────────────────────────── */

#map {
  position: sticky;
  top: var(--tab-nav-h);
  height: calc(100vh - var(--tab-nav-h));
  width: 100%;
  background: #ebebeb;
  order: 2;
}

/* Interactive tool: map takes over viewport below the tab nav (fixed) */
body.is-interactive #map {
  position: fixed;
  top: var(--tab-nav-h);
  left: 0;
  right: var(--chart-panel-w);
  bottom: 0;
  width: auto;
  height: calc(100vh - var(--tab-nav-h));
  z-index: 500;
}

/* Hide but preserve layout so back-navigation doesn't jump */
body.is-interactive .scroll-container {
  visibility: hidden;
}

/* ── Scroll container — no overflow, page scroll drives Scrollama ────────── */

.scroll-container {
  order: 1;
  padding: 40vh 0 60vh;
}

/* ── Step cards ───────────────────────────────────────────────────────────── */

.step {
  padding: 0 2.5rem 5rem;
  opacity: 0.45;
  transition: opacity 0.4s;
}

.step.active { opacity: 1; }

.step-inner {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 2.25rem 2.5rem;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.step.active .step-inner {
  border-top-color: var(--text);
  box-shadow: var(--shadow);
}

.step-inner:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.step-tag {
  display: inline-block;
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: "Space Mono", monospace;
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 1;
}

.step-tag::before { content: "— "; }
.step-tag::after  { content: " —"; }

.step-svg {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}

.step-inner h2 {
  font-family: "Outfit", sans-serif;
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.9rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
  position: relative;
  z-index: 1;
}

.step-inner p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.step-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.step-body p { margin-bottom: 0.5rem; }

.step-body ul {
  margin-top: 0.75rem;
  padding-left: 1.1rem;
}

.step-body li { margin-bottom: 0.55rem; }

.step-inner strong {
  font-weight: 700;
  color: var(--text);
  position: relative;
  z-index: 1;
}

/* ── Ghost step numbers (editorial counter overlay) ─────────────────────── */

.scroll-container { counter-reset: step-counter; }

.step { counter-increment: step-counter; }

.step-inner::after {
  content: counter(step-counter, decimal-leading-zero);
  position: absolute;
  top: 0.25rem;
  right: 1rem;
  font-family: "Outfit", sans-serif;
  font-size: 5.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--blue-4);
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* ── Tool panel (step 6) ──────────────────────────────────────────────────── */

#tool-panel {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow-lg);
  z-index: 600;
  width: 248px;
}

#tool-panel.hidden { display: none; }

/* ── Site title in tab nav ───────────────────────────────────────────────── */

#site-title {
  margin-left: auto;
  padding-left: 1.5rem;
  font-family: "Outfit", sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  user-select: none;
}


.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.1rem;
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }

/* ── Modal backdrop ──────────────────────────────────────────────────────── */

#modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 890;
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

#modal-backdrop.hidden { display: none; }

/* ── Control sections ────────────────────────────────────────────────────── */

.ctrl-section {
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
}

.ctrl-section:first-child {
  border-top: none;
  padding-top: 0;
}

.ctrl-section.hidden { display: none; }

.heatmap-ctrl-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0 0.1rem 1.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.heatmap-ctrl-row.hidden { display: none; }
.heatmap-ctrl-label { white-space: nowrap; }
.heatmap-radius-val {
  min-width: 1.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ctrl-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.ctrl-label {
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 400;
}

/* ── Info popup (floating overlay) ──────────────────────────────────────── */

.info-popup {
  display: none;
  position: fixed;
  z-index: 900;
  width: 290px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.info-popup:not(.hidden) { display: block; }

.info-popup p + p { margin-top: 0.45rem; }

.info-popup strong { color: var(--text); }

.curves-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 0.6rem;
  overflow: visible;
}

/* ── Score mode pill toggle ──────────────────────────────────────────────── */

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.mode-btn {
  flex: 1;
  padding: 0.35rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
  line-height: 1;
  border-radius: 0;
}

.mode-btn + .mode-btn {
  border-left: 1px solid var(--border);
}

.mode-btn.active {
  background: var(--text);
  color: #fff;
}

.mode-active-desc {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  margin: 0 0 0.3rem;
}

.mode-active-desc.hidden { display: none; }


/* Scenario rail (Low · Mid · High) — shown in Contextual mode only */
.scenario-rail {
  margin-bottom: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--border-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.scenario-rail.hidden { display: none; }

.scenario-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.scenario-buttons {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}

.scenario-btn {
  flex: 1;
  padding: 0.25rem 0.4rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.scenario-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}


/* Group toggle buttons */
.group-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.group-btn {
  padding: 0.35rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.group-btn:hover,
.group-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* Toggles */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--text);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.toggle-row--disabled {
  opacity: 0.45;
  cursor: default;
}

.toggle-row--disabled input { cursor: default; }

/* ── Narrative image panel (base + scroll-driven layers) ─────────────────── */

#illustration-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: var(--bg);
  animation: stepIlluIn 0.35s ease;
}

#illustration-panel::before,
#illustration-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 22%;
  z-index: 1;
  pointer-events: none;
}

#illustration-panel::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg), transparent);
}

#illustration-panel::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg), transparent);
}

.illu-image-stack {
  position: relative;
  width: 100%;
  height: 100%;
}

.illu-base,
.illu-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.illu-layer {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.illu-layer--active {
  opacity: 1;
}

/* ── Step illustration overlay (map right-side, synced with scroll) ───────── */

@keyframes stepIlluIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#step-illustration {
  position: absolute;
  bottom: 2rem;
  left: 2rem;
  transform: none;
  width: 380px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: stepIlluIn 0.35s ease;
}

/* Hide the standalone legend strip when the combined scatter+legend box is visible */
#map:has(#step-illustration:not(.illu-full)) #legend {
  display: none;
}

/* Fullscreen mode: covers the entire map, map content hidden behind it */
#step-illustration.illu-full {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#step-illustration.illu-full svg {
  width: min(92%, 560px);
  height: auto;
}

#step-illustration svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* ── Legend strip ─────────────────────────────────────────────────────────── */

#legend {
  position: absolute;
  bottom: 1.5rem;
  left: 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(198, 219, 239, 0.8);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  box-shadow: var(--shadow);
  z-index: 50;
  font-family: "Space Mono", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

#legend .legend-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

#legend .gradient {
  width: 110px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #f7fbff, #6baed6, #08306b);
}

/* ── CTA button (last step card — "Explore the map") ─────────────────────── */

.cta-explore {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: "Outfit", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  position: relative;
  z-index: 1;
}

.cta-explore:hover {
  background: #000000;
}

/* ── Placeholder overlay (Rail / Cycling / Green coming-soon state) ──────── */

#placeholder-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.25rem 1.75rem;
  box-shadow: var(--shadow);
  z-index: 50;
  text-align: center;
  pointer-events: none;
}

#placeholder-overlay p {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Chart panel (right, interactive mode only) ──────────────────────────── */

#chart-panel {
  display: none;
  width: var(--chart-panel-w);
  min-width: 260px;
  max-width: 420px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

#chart-panel:not(.hidden) { display: block; }

body.is-interactive #chart-panel:not(.hidden) {
  position: fixed;
  top: var(--tab-nav-h);
  right: 0;
  bottom: 0;
  width: var(--chart-panel-w);
  min-width: 260px;
  max-width: 520px;
  z-index: 500;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Chart panel drag-resize handle ─────────────────────────────────────── */

#chart-resize-handle { display: none; }

body.is-interactive #chart-resize-handle {
  display: block;
  position: fixed;
  top: var(--tab-nav-h);
  bottom: 0;
  right: var(--chart-panel-w);
  width: 6px;
  cursor: ew-resize;
  z-index: 501;
  background: transparent;
  transition: background 0.15s;
}

body.is-interactive #chart-resize-handle:hover,
body.is-interactive #chart-resize-handle.dragging {
  background: rgba(0, 0, 0, 0.08);
}

.chart-panel-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}

.kpi-cell {
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kpi-cell + .kpi-cell {
  border-left: 1px solid var(--border);
}

.kpi-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.kpi-label {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.3;
}

.chart-block {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.chart-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chart-placeholder {
  padding: 1.5rem 1rem;
  background: var(--border-subtle);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

/* Scatter plot controls */
.scatter-axes-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.scatter-axis-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scatter-sel {
  font-size: 0.72rem;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: white;
  color: var(--text);
  cursor: pointer;
}
.scatter-axis-sep {
  font-size: 0.72rem;
  color: var(--muted);
}
.chart-note {
  font-size: 0.65rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.3rem 0 0;
}

/* ── Score distribution bars ─────────────────────────────────────────────── */

.dist-row {
  display: grid;
  grid-template-columns: 88px 1fr 30px;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.22rem;
}

.dist-label {
  font-size: 0.67rem;
  font-weight: 600;
  /* colour set inline by JS from the divergent palette */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-track {
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.dist-pct {
  font-size: 0.67rem;
  color: var(--muted);
  text-align: right;
}

/* ── Chart subtitle (scatter) ────────────────────────────────────────────── */

.chart-subtitle {
  font-size: 0.68rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 0.4rem;
  line-height: 1.35;
}

/* ── Bus stop / segment popup ────────────────────────────────────────────── */

.popup-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 1px;
}

.popup-header-title {
  font-size: 0.88em;
  font-weight: 600;
  line-height: 1.3;
}

.popup-type-label {
  font-size: 0.7em;
  color: #888;
  margin-bottom: 3px;
}

.popup-category {
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.popup-score-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.76em;
  color: #555;
  margin: 1px 0 3px;
}

.popup-score-mode {
  color: #888;
}

.popup-score-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #222;
}

.popup-hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 3px 0;
}

.popup-score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78em;
  color: #333;
  line-height: 1.6;
}

.popup-score-sub { color: #666; }

/* ── Mini People+Green panel inside popups ───────────────────────────────── */

.popup-pg-mini {
  font-size: 0.75em;
  margin-top: 2px;
}

.popup-pg-col-header {
  display: flex;
  justify-content: space-between;
  color: #888;
  font-size: 0.85em;
  font-family: var(--font-mono);
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid #f0f0f0;
}

.popup-pg-row {
  display: grid;
  grid-template-columns: 62px 1fr 44px 36px;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

.popup-pg-label {
  font-size: 0.9em;
  font-weight: 600;
  white-space: nowrap;
}

.popup-pg-bar-track {
  height: 5px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}

.popup-pg-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.2s;
}

.popup-pg-count {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: #555;
  text-align: right;
}

.popup-pg-green-val {
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 600;
  color: #2e7d32;
  text-align: right;
}

.popup-pg-band {
  color: #aaa;
  font-size: 0.85em;
  font-weight: 400;
}

/* ── Green paths placeholder card ────────────────────────────────────────── */

.chart-block--placeholder {
  border: 1px dashed var(--border);
  background: var(--border-subtle);
  opacity: 0.8;
}

.tag-tbd {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--border);
  color: var(--muted);
}

.placeholder-note {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}

/* ── Population stat (below scatter) ──────────────────────────────────────── */

.pop-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.6rem;
}

/* ── Population label + inline neighbourhood selector ────────────────────── */

.pop-label-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex-wrap: wrap;
}

.neighbourhood-inline-sel {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  padding: 0 1px;
  outline: none;
}

.neighbourhood-inline-sel:hover,
.neighbourhood-inline-sel:focus {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ── Demographic group bars (population section) ─────────────────────────── */

.demo-bars-section {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.demo-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 34px;
  align-items: center;
  gap: 0.4rem;
}

.demo-bar-label {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--text);
}

.demo-bar-age {
  font-weight: 400;
  color: var(--muted);
}

.demo-bar-track {
  background: var(--border-subtle);
  border-radius: 3px;
  height: 10px;
  overflow: hidden;
}

.demo-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.35s ease;
}

.demo-bar-pct {
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

.age-bar-note {
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 0.3rem;
  font-style: italic;
}

/* People+Green redesign — 70/30 two-column, no divider */
.pg-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.25rem;
}

.pg-row {
  display: grid;
  grid-template-columns: 70% 30%;
  gap: 0;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.pg-row.hidden { display: none; }

.pg-row--stop:not(.hidden) {
  background: var(--border-subtle, #f3f4f6);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 4px 0;
}

.pg-col-people,
.pg-col-green {
  padding: 0 4px;
}

.pg-big-num {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1.1;
}

.pg-big-label {
  font-size: 0.67rem;
  color: var(--muted);
  margin-top: 1px;
}

.pg-stop-num {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--muted);
  line-height: 1.1;
}

.pg-stop-label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pg-stop-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 2px;
  line-height: 1;
}

.pg-groups-header {
  display: flex;
  padding: 0 0 4px 0;
  border-bottom: 1px solid var(--border-subtle, #f3f4f6);
  margin-bottom: 4px;
}

.pg-col-header {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #6b7280);
}

.pg-groups {
  margin-top: 4px;
}

.pg-group-row {
  display: grid;
  grid-template-columns: 70% 30%;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.pg-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 3px;
}

.pg-group-age {
  font-weight: 400;
  color: var(--muted);
}

.pg-group-bar-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pg-group-bar-track {
  position: relative;
  flex: 1;
  height: 5px;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: visible;
}

.pg-group-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: #4caf50;
  transition: width 0.3s ease;
}

.pg-group-pct {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: #2e7d32;
  white-space: nowrap;
}

.pg-group-unc {
  font-size: 0.6rem;
  color: var(--muted);
  white-space: nowrap;
}

.pg-group-green-val {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #2e7d32;
}

.pg-group-green-sub {
  font-size: 0.63rem;
  color: var(--muted);
}

.pg-group-raw {
  font-size: 0.7rem;
  color: var(--muted, #6b7280);
  margin-top: 1px;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.pg-group-district-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--text, #111827);
  opacity: 0.35;
  border-radius: 1px;
  pointer-events: none;
}

.pg-group-district-marker.hidden { display: none; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  #tab-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 0.15rem;
    padding: 0 0.5rem;
  }
  #app {
    grid-template-columns: 1fr;
  }
  #map {
    order: 1;
    height: calc(50vh - var(--tab-nav-h));
  }
  .scroll-container {
    order: 2;
    padding: 2rem 0 4rem;
  }
  #step-illustration { width: calc(100vw - 2rem); left: 1rem; transform: none; bottom: 1rem; }
}

/* ── Floating mode toggle ─────────────────────────────────────────────────── */
#mode-toggle-float {
  position: fixed;
  top: calc(var(--tab-nav-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

#mode-toggle-float.hidden { display: none; }

#mode-toggle-float .mode-toggle {
  display: flex;
  gap: 0;
  margin: 0;
  border: none;
  padding: 0;
}

#mode-toggle-float .mode-btn {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}

#mode-toggle-float .mode-btn.active {
  background: var(--text);
  color: #fff;
}

#mode-toggle-float .mode-btn + .mode-btn {
  border-left: 1px solid var(--border);
  border-radius: 999px;
}

/* ── Left panel collapse ──────────────────────────────────────────────────── */
#tool-panel {
  transition: max-width 0.2s ease, padding 0.2s ease, width 0.2s ease;
}

#tool-panel.collapsed {
  width: 44px;
  max-width: 44px;
  padding: 8px 6px;
}

#tool-panel.collapsed #tool-panel-body {
  display: none;
}

#tool-panel-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.6rem;
}

#tool-panel.collapsed #tool-panel-header {
  justify-content: center;
  margin-bottom: 0;
}

#tool-panel-collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

#tool-panel-collapse:hover {
  color: var(--text);
  border-color: #9ca3af;
  background: var(--border-subtle);
}

/* Expanded state: show '<' arrow, hide hamburger */
#tool-panel-collapse .icon-collapse-closed { display: none; }
#tool-panel-collapse .icon-collapse-open  { display: block; }

/* Collapsed state: show hamburger, hide '<' arrow */
#tool-panel.collapsed #tool-panel-collapse .icon-collapse-closed { display: block; }
#tool-panel.collapsed #tool-panel-collapse .icon-collapse-open  { display: none; }

/* ── People + Green block ─────────────────────────────────────────────────── */
.pg-kpi-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.pg-kpi-row.hidden { display: none; }

.pg-kpi-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex: 1 1 45%;
}

.pg-kpi-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.pg-kpi-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.pg-kpi-label {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.2;
}

.pg-kpi-nb {
  font-size: 0.78rem;
  color: #a35c00;
  border-left: 2px solid #ff6700;
  padding-left: 6px;
  margin-left: 4px;
  gap: 4px;
}

.pg-nb-name {
  font-weight: 600;
  margin-right: 4px;
}

.pg-sep { color: var(--muted); }

.pg-kpi-stop {
  font-size: 0.78rem;
  color: var(--text);
  background: var(--border-subtle);
  border-radius: 4px;
  padding: 4px 8px;
  margin: 4px 0;
  gap: 6px;
}

.pg-stop-name {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pg-stop-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  margin-left: auto;
}

.demo-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 34px 44px;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
}

.demo-bar-green {
  font-size: 0.7rem;
  color: #2e7d32;
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.demo-bar-track { position: relative; }

.demo-bar-nb-tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #ff6700;
  border-radius: 1px;
  opacity: 0.8;
}

.demo-bar-nb-tick.hidden { display: none; }

.neighbourhood-panel-sel {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0 1.2rem 0 0;
  cursor: pointer;
  appearance: auto;
  flex: 1;
  outline: none;
  letter-spacing: 0.01em;
}

.neighbourhood-panel-sel:hover {
  border-bottom-color: var(--border);
}

/* ── Distribution neighbourhood tick ─────────────────────────────────────── */
.dist-nb-tick {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: #ff6700;
  border-radius: 1px;
  opacity: 0.9;
  pointer-events: none;
}
.dist-nr-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #111827;
  border-radius: 1px;
  pointer-events: none;
}
