:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #f6f8fc;
  --muted: #91a0b4;
  --panel: rgba(6, 13, 24, .92);
  --panel-border: rgba(148, 163, 184, .18);
  --blue: #2bb7ff;
  --cyan: #67e8f9;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }
html, body, #map { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: #07101c; color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed; z-index: 50; top: 8px; left: 8px; padding: 8px 12px; border-radius: 8px;
  background: #fff; color: #08111e; transform: translateY(-140%);
}
.skip-link:focus { transform: translateY(0); }

.panel {
  position: absolute; z-index: 5; top: 18px; left: 18px; width: 344px; max-height: calc(100vh - 36px);
  overflow: auto; border: 1px solid var(--panel-border); border-radius: 17px; background: var(--panel);
  box-shadow: 0 22px 58px rgba(0, 0, 0, .48); backdrop-filter: blur(16px); scrollbar-width: thin;
}
.panel__header { padding: 18px 18px 12px; }
.eyebrow { margin: 0 0 7px; color: #55c9ff; font-size: 10px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; line-height: 1.08; }
.subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.status-badge { padding: 5px 8px; border: 1px solid rgba(43, 183, 255, .45); border-radius: 999px; color: #8fe0ff; background: rgba(43, 183, 255, .1); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }

.presentation-button {
  width: calc(100% - 36px); margin: 0 18px 14px; padding: 9px 12px; border: 1px solid rgba(43, 183, 255, .34);
  border-radius: 10px; background: linear-gradient(135deg, rgba(23, 105, 224, .24), rgba(34, 211, 238, .1));
  color: #dff7ff; font-size: 11px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; cursor: pointer;
}
.presentation-button:hover { border-color: rgba(103, 232, 249, .75); background-color: rgba(43, 183, 255, .17); }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 14px; border-top: 1px solid var(--panel-border); border-bottom: 1px solid var(--panel-border); }
.tab { padding: 11px 4px 9px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #738197; font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.tab.is-active { border-bottom-color: var(--blue); color: #e9f8ff; }
.tab-panel { padding: 14px 18px 16px; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { padding: 10px; border: 1px solid var(--panel-border); border-radius: 10px; background: rgba(148, 163, 184, .045); }
.metric span { display: block; margin-bottom: 4px; color: #75849a; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.metric strong { color: #f4f8ff; font-size: 16px; font-variant-numeric: tabular-nums; }
.panel-note { margin: 12px 0 0; color: #8795a9; font-size: 10.5px; line-height: 1.5; }

.control-group { margin: 0; padding: 0; border: 0; }
.control-group + .control-group { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--panel-border); }
.control-group legend { width: 100%; margin-bottom: 8px; color: #738197; font-size: 9px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mode-button { min-height: 32px; padding: 7px; border: 1px solid rgba(148, 163, 184, .18); border-radius: 8px; background: rgba(148, 163, 184, .05); color: #9aa7ba; font-size: 10px; font-weight: 750; cursor: pointer; }
.mode-button.is-active { border-color: rgba(43, 183, 255, .55); background: rgba(43, 183, 255, .14); color: #e7f8ff; }

.legend { display: grid; gap: 8px; margin-top: 13px; padding: 11px 12px; border: 1px solid var(--panel-border); border-radius: 10px; background: rgba(3, 8, 16, .34); }
.legend > div { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; color: #c8d1df; font-size: 11px; }
.legend output { color: #7f8da1; font-size: 10px; font-variant-numeric: tabular-nums; }
.legend.is-muted { opacity: .44; }
.legend-line { width: 28px; height: 4px; border-radius: 999px; }
.legend-line.retained { background: #708096; opacity: .75; }
.legend-line.added { background: #2bb7ff; box-shadow: 0 0 9px rgba(43, 183, 255, .78); }
.legend-line.removed { height: 2px; background: repeating-linear-gradient(90deg, var(--amber) 0 6px, transparent 6px 10px); }

.compact-controls { display: grid; gap: 7px; }
.switch-row { display: flex; align-items: center; gap: 8px; min-height: 26px; color: #cbd5e1; font-size: 11px; cursor: pointer; }
.switch-row input { width: 15px; height: 15px; margin: 0; accent-color: #1da8f5; }
.switch-row span { display: flex; align-items: center; gap: 7px; }
.switch-row output { margin-left: auto; color: #708096; font-size: 10px; font-variant-numeric: tabular-nums; }
.simulation-controls { display: grid; gap: 14px; }
.simulation-row { display: grid; gap: 7px; }
.bus-key { width: 9px; height: 9px; border: 1px solid rgba(255,255,255,.8); border-radius: 3px; }
.bus-key.existing { background: #64748b; }
.bus-key.proposed { background: #198bd8; }
.speed-row { display: grid; grid-template-columns: 46px 1fr 36px; align-items: center; gap: 7px; color: #718096; font-size: 9px; }
.speed-row input { width: 100%; accent-color: #1da8f5; }
.speed-row output { color: #b9c5d4; text-align: right; font-variant-numeric: tabular-nums; }
.panel__footer { min-height: 35px; padding: 10px 18px; border-top: 1px solid var(--panel-border); color: #66758a; font-size: 9.5px; }

.bus-marker { width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.92); border-radius: 50%; color: white; box-shadow: 0 0 0 4px rgba(6,13,24,.58), 0 0 18px currentColor; }
.bus-marker.existing { background: #556274; }
.bus-marker.proposed { background: #168bd3; }
.bus-marker svg { width: 22px; height: 22px; }

.presentation { position: absolute; z-index: 6; inset: 0; pointer-events: none; }
.presentation__close { position: absolute; top: 20px; right: 20px; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(6,13,24,.84); font-size: 25px; line-height: 1; cursor: pointer; pointer-events: auto; }
.presentation-content {
  position: absolute; top: 50%; left: max(24px, 3vw); width: min(520px, calc(100vw - 48px)); max-height: calc(100vh - 170px);
  overflow: auto; padding: 24px 26px; border: 1px solid rgba(148,163,184,.2); border-left: 3px solid var(--blue);
  border-radius: 15px; background: rgba(6,13,24,.9); box-shadow: 0 18px 48px rgba(0,0,0,.42); backdrop-filter: blur(14px);
  opacity: 1; transform: translateY(-50%); transition: opacity 240ms ease, transform 240ms ease; pointer-events: auto; scrollbar-width: thin;
}
.presentation-content.is-changing { opacity: 0; transform: translateY(calc(-50% + 8px)); }
.presentation-content--hero { width: min(500px, calc(100vw - 48px)); padding: 30px 31px; }
.presentation-content--metrics { width: min(550px, calc(100vw - 48px)); }
.presentation-content--narrative { width: min(520px, calc(100vw - 48px)); }
.presentation-content--map-focus { width: min(380px, calc(100vw - 48px)); padding: 20px 22px; }
.presentation-content__eyebrow { margin: 0 0 8px; color: #69d6ff; font-size: 10px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.presentation-content__title { margin: 0; font-size: 29px; line-height: 1.08; letter-spacing: -.035em; text-wrap: balance; }
.presentation-content--hero .presentation-content__title { max-width: 10ch; font-size: clamp(38px, 3.4vw, 52px); }
.presentation-content--map-focus .presentation-content__title { font-size: 25px; }
.presentation-content__subtitle { margin: 8px 0 0; color: #dce8f7; font-size: 17px; font-weight: 650; }
.presentation-content__status { display: inline-block; margin: 14px 0 0; padding: 6px 9px; border: 1px solid rgba(43,183,255,.4); border-radius: 999px; color: #9de6ff; background: rgba(43,183,255,.11); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.presentation-content__narrative { margin-top: 14px; color: #a8b5c7; font-size: 13px; line-height: 1.62; }
.presentation-content__narrative p { margin: 0; }
.presentation-content__narrative p + p { margin-top: 10px; }
.presentation-content--hero .presentation-content__narrative { max-width: 42ch; font-size: 14px; }
.presentation-content--narrative .presentation-content__narrative { color: #c1cad7; font-size: 14px; line-height: 1.7; }
.presentation-content--map-focus .presentation-content__narrative { font-size: 12px; }
.presentation-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 17px; }
.presentation-metric { min-height: 78px; padding: 12px 13px; border: 1px solid rgba(148,163,184,.18); border-radius: 11px; background: rgba(148,163,184,.055); }
.presentation-metric__label { display: block; margin-bottom: 7px; color: #8190a5; font-size: 9px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.presentation-metric__value { display: block; color: #f4f8ff; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.presentation-metric--proposed, .presentation-metric--added { border-color: rgba(43,183,255,.28); }
.presentation-metric--proposed .presentation-metric__value, .presentation-metric--added .presentation-metric__value { color: var(--cyan); }
.presentation-metric--removed { border-color: rgba(245,158,11,.28); }
.presentation-metric--removed .presentation-metric__value { color: #fbbf24; }
.presentation-metric--retained .presentation-metric__value, .presentation-metric--existing .presentation-metric__value { color: #cbd5e1; }
.presentation-callouts { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.presentation-callout { display: grid; gap: 3px; padding: 9px 11px; border-left: 2px solid #64748b; border-radius: 0 8px 8px 0; background: rgba(148,163,184,.055); color: #aab6c7; font-size: 11px; line-height: 1.45; }
.presentation-callout strong { color: #e4ebf4; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.presentation-callout--changed { border-left-color: var(--cyan); }
.presentation-content__source { display: block; margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(148,163,184,.14); color: #748297; font-size: 9px; line-height: 1.45; }
.chapter-nav { position: absolute; bottom: 24px; left: 50%; display: flex; align-items: center; gap: 12px; padding: 7px 9px; border: 1px solid rgba(148,163,184,.2); border-radius: 999px; background: rgba(6,13,24,.9); transform: translateX(-50%); pointer-events: auto; }
.chapter-nav > button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(148,163,184,.09); cursor: pointer; }
.chapter-nav > button:disabled { opacity: .28; cursor: default; }
.chapter-dots { display: flex; align-items: center; gap: 1px; }
.chapter-dot { position: relative; width: 28px; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.chapter-dot::before { content: ''; position: absolute; top: 50%; right: 3px; left: 3px; height: 5px; border-radius: 999px; background: #39475a; transform: translateY(-50%); }
.chapter-dot.is-active::before { background: var(--blue); box-shadow: 0 0 8px rgba(43,183,255,.7); }
body.is-presenting .panel { opacity: 0; transform: translateX(-20px); pointer-events: none; }
body.is-presenting .maplibregl-ctrl-top-right { opacity: .35; }
body.emphasize-pois .maplibregl-map { cursor: default; }

.urban-debug {
  position: absolute; z-index: 8; right: 12px; bottom: 36px; margin: 0; padding: 8px 10px;
  border: 1px solid rgba(103, 232, 249, .3); border-radius: 7px; background: rgba(3, 8, 16, .86);
  color: #b9f3ff; font: 10px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; pointer-events: none;
}

.maplibregl-popup-content { border: 1px solid rgba(148,163,184,.25); border-radius: 10px; background: #0a1422; color: #e7edf6; box-shadow: 0 12px 34px rgba(0,0,0,.42); font: 600 11px/1.45 Inter, ui-sans-serif, system-ui, sans-serif; }
.maplibregl-popup-tip { border-top-color: #0a1422 !important; }
.maplibregl-popup-content a { color: #67d8ff; }

button:focus-visible, input:focus-visible, .maplibregl-ctrl button:focus-visible { outline: 2px solid #67e8f9; outline-offset: 2px; }

@media (max-width: 760px) {
  .panel { top: 10px; left: 10px; width: min(330px, calc(100vw - 20px)); max-height: min(65vh, 590px); }
  .panel__header { padding-top: 15px; }
  h1 { font-size: 21px; }
  .maplibregl-ctrl-top-right { top: 8px; right: 8px; }
  .presentation-content, .presentation-content--hero, .presentation-content--metrics, .presentation-content--narrative, .presentation-content--map-focus {
    top: auto; bottom: 76px; left: 14px; width: calc(100vw - 28px); max-height: calc(100vh - 150px); padding: 18px 19px; transform: none;
  }
  .presentation-content.is-changing { transform: translateY(8px); }
  .presentation-content__title, .presentation-content--map-focus .presentation-content__title { font-size: 24px; }
  .presentation-content--hero .presentation-content__title { font-size: 34px; }
  .chapter-nav { gap: 5px; }
  .chapter-dot { width: 23px; }
}

@media (max-height: 800px) and (min-width: 761px) {
  .presentation-content { max-height: calc(100vh - 140px); padding: 20px 22px; }
  .presentation-content--hero { padding: 24px 26px; }
  .presentation-content--hero .presentation-content__title { font-size: 40px; }
  .presentation-content__title { font-size: 26px; }
  .presentation-content__narrative { margin-top: 11px; line-height: 1.5; }
  .presentation-metrics { margin-top: 13px; }
  .presentation-metric { min-height: 68px; padding: 10px 11px; }
  .presentation-metric__value { font-size: 20px; }
}

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