/* FloodTwin NYC. A cartographic, editorial interface: paper-toned panels with hairline
   structure over the 3D city, IBM Plex type (serif for headings and figures, mono for
   readouts), one functional blue for data and interaction, and no decorative effects. */
:root {
  --bg: #0b0d0e;
  --paper: #f4f2ed;
  --paper-2: #ebe8e1;
  --paper-3: #e1ddd4;
  --ink: #1b1d1e;
  --ink-2: #4b5154;
  --ink-3: #82878a;
  --rule: #dad6ce;
  --rule-2: #c4bfb5;
  --blue: #1d5fa6;
  --blue-2: #2f74c0;
  --red: #b5303e;
  --green: #2e7a58;
  --amber: #c68a1e;
  --series-1: #1d5fa6;
  --series-2: #c2622b;
  --series-3: #2e7a58;
  --g2: #7b68c4;
  --g3: #2a9289;
  --g4: #b08d26;
  --grid: #e3dfd8;
  --axis: #c9c4ba;
  --solid: #f4f2ed;
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: var(--ink-3);
  --accent: var(--blue);
  --line: var(--rule);
  --line-2: var(--rule-2);
  --serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --top: 52px;
  --left-w: 316px;
  --right-w: 360px;
  --tl-h: 112px;
  --gap: 10px;
  --r: 5px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.16), 0 10px 28px rgba(0, 0, 0, 0.22);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--ink); text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.muted { color: var(--ink-3); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
svg { flex: none; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#view.drawing { cursor: crosshair; }

/* ---------- masthead ---------- */
.topbar {
  position: fixed; left: 0; right: 0; top: 0; height: var(--top); z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--paper); border-bottom: 1px solid var(--rule-2); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark { width: 20px; height: 20px; flex: none; align-self: center; color: var(--ink); }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.brand-place { color: var(--ink-3); white-space: nowrap; font-size: 13px; }
.transport { display: flex; align-items: center; gap: 4px; }
.topbar-pill { display: flex; align-items: center; gap: 4px; }
.clock { font-family: var(--mono); font-size: 13px; letter-spacing: -0.01em; line-height: 1.2; padding: 0 12px 0 6px; min-width: 214px; color: var(--ink); }
.clock small { display: block; font-family: var(--font); font-size: 11.5px; color: var(--ink-3); letter-spacing: 0; margin-top: 2px; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.perf { color: var(--ink-3); font-size: 11.5px; margin-right: 10px; white-space: nowrap; font-family: var(--mono); }

.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--r); border: 1px solid transparent; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.ghost { border-color: transparent; }
.icon-btn svg { width: 16px; height: 16px; }
.play-wrap { position: relative; width: 40px; height: 40px; display: grid; place-items: center; }
.play-ring { position: absolute; inset: 0; transform: rotate(-90deg); pointer-events: none; }
.play-ring circle { fill: none; stroke-width: 1.5; }
.play-ring .track { stroke: var(--rule); }
.play-ring .bar { stroke: var(--blue); transition: stroke-dashoffset 0.4s ease; }
.icon-btn.play { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--paper); border: none; }
.icon-btn.play:hover { background: #000; color: #fff; }

.btn { height: 30px; padding: 0 11px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--paper); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--paper-2); border-color: var(--ink-3); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: var(--paper-2); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 500; }
.btn.primary:hover { background: #000; color: #fff; }
.btn.accent { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 500; }
.btn.accent:hover { background: var(--blue-2); }
.btn.small { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }

/* segmented controls: a flat bordered group, the chosen segment inked */
.seg { position: relative; display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--paper); overflow: hidden; }
.seg button { position: relative; z-index: 1; height: 26px; padding: 0 10px; border: 0; border-left: 1px solid var(--rule); background: transparent; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; transition: color 0.15s; }
.seg button:first-of-type { border-left: 0; }
.seg button:hover { color: var(--ink); background: var(--paper-2); }
.seg button[aria-pressed="true"] { color: var(--paper); background: transparent; }
.seg .thumb { position: absolute; z-index: 0; top: 0; bottom: 0; left: 0; width: 0; background: var(--ink); pointer-events: none; transition: transform 0.18s ease, width 0.18s ease; }
.seg:not(.ready) .thumb { transition: none; }
.seg.full { display: flex; }
.seg.full button { flex: 1; padding: 0 4px; }
.speed-seg button { padding: 0 8px; font-family: var(--mono); font-size: 12px; }

/* ---------- panels ---------- */
.panel {
  position: fixed; top: calc(var(--top) + var(--gap)); bottom: var(--gap); z-index: 15;
  display: flex; flex-direction: column;
  background: rgba(244, 242, 237, 0.97); border: 1px solid rgba(0, 0, 0, 0.14); border-radius: var(--r); box-shadow: var(--shadow);
}
.panel.left { left: var(--gap); width: var(--left-w); }
.panel.right { right: var(--gap); width: var(--right-w); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--rule); }
.panel-title { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; display: inline-flex; align-items: baseline; gap: 8px; }
.panel-title svg { display: none; }
.panel-body { overflow-y: auto; overflow-x: hidden; padding: 0 0 12px; flex: 1; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }

.section { border-bottom: 1px solid var(--rule); }
.section.first { padding: 12px 16px 14px; display: grid; gap: 6px; }
.section-label { color: var(--ink-3); font-size: 12px; }
.group-label { color: var(--ink-3); font-size: 12px; margin-top: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
.group-label:first-of-type { margin-top: 0; }
.section-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: none; border: 0; text-align: left; color: var(--ink); }
.section-head:hover { background: var(--paper-2); }
.section-icon { display: none; }
.section-title { font-weight: 600; flex: 1; }
.section-side { display: inline-flex; align-items: center; gap: 8px; }
.section-head .chev { width: 13px; height: 13px; color: var(--ink-3); transition: transform 0.18s ease; display: block; }
.section.closed .chev { transform: rotate(-90deg); }
.section.closed .section-body { display: none; }
.section-body { padding: 2px 16px 16px; display: grid; gap: 14px; }
.section-note { color: var(--ink-3); font-size: 12px; line-height: 1.55; }
.badge { display: inline-flex; align-items: center; height: 19px; padding: 0 6px; border-radius: 3px; font-size: 11px; color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--rule); white-space: nowrap; font-family: var(--mono); }
.badge.accent { color: #fff; border-color: var(--blue); background: var(--blue); font-family: var(--font); }

/* scenario list: a ruled list with a radio mark, the chosen row marked in ink */
.presets { display: grid; }
.preset { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: start; text-align: left; padding: 8px 8px 8px 6px; margin: 0 -8px 0 -6px; border: 0; border-radius: 3px; background: none; color: var(--ink); }
.preset:hover { background: var(--paper-2); }
.preset::before { content: ''; width: 12px; height: 12px; margin-top: 2px; border-radius: 50%; border: 1px solid var(--ink-3); background: var(--paper); box-sizing: border-box; }
.preset.on::before { border: 4px solid var(--ink); }
.preset-icon { display: none; }
.preset-main { display: grid; gap: 2px; min-width: 0; }
.preset-name { font-weight: 500; }
.preset.on .preset-name { font-weight: 600; }
.preset-tag { color: var(--ink-3); font-size: 11.5px; }
.preset-note { color: var(--ink-2); font-size: 12px; line-height: 1.55; }

/* fields */
.field { display: grid; gap: 7px; }
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-label { color: var(--ink-2); }
.field-value { font-family: var(--mono); font-size: 12px; color: var(--ink); white-space: nowrap; }
.field-value.muted { color: var(--ink-3); font-family: var(--font); }
.field-hint { color: var(--ink-3); font-size: 11.5px; line-height: 1.5; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--ink) var(--p, 50%), var(--rule-2) var(--p, 50%)); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule-2); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; margin-top: -5.5px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
input[type="range"]:hover::-webkit-slider-thumb { background: var(--ink); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-text { display: grid; gap: 1px; }
.switch-text small { color: var(--ink-3); font-size: 11.5px; }
/* layer toggles as plain checkboxes */
.switch { position: relative; width: 15px; height: 15px; flex: none; order: -1; }
.switch-row { justify-content: flex-start; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 3px; border: 1px solid var(--ink-3); background: var(--paper); pointer-events: none; }
.switch span::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--paper); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); opacity: 0; }
.switch input:checked + span { background: var(--ink); border-color: var(--ink); }
.switch input:checked + span::after { opacity: 1; }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.layers { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-btn { height: 26px; padding: 0 9px; border-radius: 3px; border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink-2); font-size: 12.5px; }
.chip-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.chip-btn.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.list { display: grid; border-top: 1px solid var(--rule); }
.list-item { display: grid; gap: 8px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; color: var(--ink); }
.list-item.row { display: flex; align-items: center; gap: 10px; }
.list-item.clickable:hover { background: var(--paper-2); }
.list-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); font-size: 12px; justify-self: start; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.callout { padding: 10px 12px; border-left: 2px solid var(--ink-3); background: var(--paper-2); color: var(--ink-2); font-size: 12px; line-height: 1.55; }
.apply-bar { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--rule-2); background: var(--paper-2); border-radius: 0 0 var(--r) var(--r); }
.apply-text { flex: 1; color: var(--ink-2); font-size: 12px; }

/* ---------- results panel ---------- */
.headline { padding: 14px 16px 12px; display: grid; gap: 10px; border-bottom: 1px solid var(--rule); }
.hl-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hl-name { font-family: var(--serif); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-status { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.hl-status::before { content: ''; width: 7px; height: 7px; background: var(--ink-3); }
.hl-status.s-running::before, .hl-status.s-seeking::before { background: var(--blue); }
.hl-status.s-running, .hl-status.s-seeking { color: var(--blue); }
.hl-status.s-done::before { background: var(--green); }
.hl-progress { height: 2px; background: var(--rule); }
.hl-progress i { display: block; height: 100%; background: var(--ink); transition: width 0.4s ease; }
.hl-progress.live i { background: var(--blue); }
.hl-figures { display: grid; grid-template-columns: 1fr 1.18fr 1fr; }
.hl-fig { display: grid; gap: 1px; min-width: 0; padding: 0 8px; border-left: 1px solid var(--rule); }
.hl-fig:first-child { padding-left: 0; border-left: 0; }
.hl-label { color: var(--ink-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-value { font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -0.015em; white-space: nowrap; font-variant-numeric: tabular-nums lining-nums; }
.tabs { position: relative; display: flex; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--rule); }
.tab { position: relative; height: 38px; padding: 0; border: 0; background: none; color: var(--ink-3); font-size: 13px; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.tabs .thumb { display: none; }
.tabpanel { padding: 16px 16px 0; display: grid; gap: 20px; align-content: start; }
.kpi-hero { display: grid; gap: 4px; }
.kpi-hero .kpi-label { color: var(--ink-2); font-size: 12.5px; }
.kpi-big { font-family: var(--serif); font-size: 40px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.05; font-variant-numeric: tabular-nums lining-nums; }
.kpi-hero.small .kpi-big { font-size: 30px; }
.kpi-hero .kpi-sub { color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); }
.kpis.three { grid-template-columns: 1fr 1fr 1fr; }
.kpi { padding: 10px 12px 11px 0; display: grid; gap: 1px; min-width: 0; align-content: start; border-bottom: 1px solid var(--rule); }
.kpis .kpi:nth-child(2n) { padding-left: 12px; border-left: 1px solid var(--rule); }
.kpis.three .kpi { padding-left: 10px; border-left: 1px solid var(--rule); }
.kpis.three .kpi:first-child { padding-left: 0; border-left: 0; }
.kpis.three .kpi:nth-child(2n) { padding-left: 10px; }
.kpi-label { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: -0.015em; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums lining-nums; }
.kpis.three .kpi-value { font-size: 17px; }
.kpi-sub { color: var(--ink-3); font-size: 11px; line-height: 1.4; }
.kpi-spark { display: none; }
.block { display: grid; gap: 9px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--ink); }
.block-title { font-weight: 600; }
.block-title.big { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.block > .block-title.big { padding-bottom: 0; }
.block-sub { color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0; font-size: 12.5px; margin: 2px 0 0; border-top: 1px solid var(--rule); }
.facts dt, .facts dd { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--ink-3); padding-right: 14px; }
.facts dd { margin: 0; text-align: right; }
.hint { color: var(--ink-2); font-size: 12.5px; line-height: 1.6; }
.hint strong { color: var(--ink); font-weight: 600; }
.rank { display: grid; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(40px, 1fr) auto; align-items: center; gap: 10px; padding: 6px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; color: var(--ink); }
.rank-row:hover { background: var(--paper-2); }
.rank-name { display: grid; min-width: 0; }
.rank-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-name small { color: var(--ink-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 8px; background: var(--paper-3); }
.rank-bar i { display: block; height: 100%; background: var(--red); transition: width 0.4s ease; }
.rank-value { font-family: var(--mono); font-size: 12px; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.routes { display: inline-flex; gap: 3px; flex: none; }
.route { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-style: normal; font-size: 10.5px; font-weight: 600; color: #fff; background: #808183; }
.r-1, .r-2, .r-3 { background: #ee352e; } .r-4, .r-5, .r-6 { background: #00933c; } .r-7 { background: #b933ad; }
.r-A, .r-C, .r-E { background: #0039a6; } .r-B, .r-D, .r-F, .r-M { background: #ff6319; } .r-G { background: #6cbe45; }
.r-J, .r-Z { background: #996633; } .r-L { background: #a7a9ac; } .r-N, .r-Q, .r-R, .r-W { background: #fccc0a; color: #111; } .r-S { background: #808183; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { text-align: right; font-weight: 500; color: var(--ink-3); padding: 6px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.data-table td { text-align: right; padding: 6px; border-bottom: 1px solid var(--rule); white-space: nowrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.data-table td:first-child { font-family: var(--font); }
.data-table th:first-child, .data-table td:first-child { text-align: left; padding-left: 0; }
.data-table th:last-child, .data-table td:last-child { padding-right: 0; }

/* charts */
.chart { position: relative; width: 100%; }
.chart-svg { display: block; width: 100%; overflow: visible; }
.chart-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-ref { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tick { fill: var(--ink-3); font-size: 10.5px; font-family: var(--mono); }
.chart-note { fill: var(--ink-2); font-size: 11px; }
.chart-axis-label { fill: var(--ink-3); font-size: 11px; }
.chart-cross { stroke: var(--ink-3); stroke-width: 1; }
.chart-now { stroke: var(--ink); stroke-width: 1; }
.chart-dot { stroke: var(--paper); stroke-width: 1.5; }
.chart-pt { cursor: default; outline: none; }
.chart-pt:focus-visible .chart-dot { stroke: var(--ink); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; padding: 7px 9px; border-radius: 3px; background: var(--paper); border: 1px solid var(--ink-3); box-shadow: 0 4px 14px rgba(0,0,0,0.14); display: grid; gap: 3px; min-width: 120px; }
.chart-tip-title { color: var(--ink-3); font-size: 11px; }
.chart-tip-row { display: flex; align-items: center; gap: 7px; font-size: 12px; white-space: nowrap; }
.chart-tip-row strong { font-weight: 600; font-family: var(--mono); }
.chart-tip-key { width: 10px; height: 2px; flex: none; }
.chart-tip-name { color: var(--ink-3); }
.legend-row { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-2); font-size: 12px; }
.legend-row .key { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-row .key i { width: 12px; height: 2px; display: inline-block; }
.legend-row .key i.dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- map overlays ---------- */
.overlay-card { background: rgba(244, 242, 237, 0.97); border: 1px solid rgba(0, 0, 0, 0.14); border-radius: var(--r); box-shadow: var(--shadow); }
.viewmodes { position: fixed; top: calc(var(--top) + var(--gap)); left: calc(var(--left-w) + 2 * var(--gap)); right: calc(var(--right-w) + 2 * var(--gap)); z-index: 12; display: flex; justify-content: center; pointer-events: none; }
.viewmodes .seg { pointer-events: auto; box-shadow: var(--shadow); border-color: rgba(0, 0, 0, 0.18); }
.viewmodes .seg button { height: 28px; padding: 0 12px; }
.legend { position: fixed; left: calc(var(--left-w) + 2 * var(--gap)); bottom: calc(var(--tl-h) + 2 * var(--gap) + 34px); z-index: 12; padding: 10px 12px; min-width: 230px; max-width: 290px; display: grid; gap: 7px; }
.legend-title { font-weight: 600; font-size: 12.5px; }
.legend-bar { height: 8px; }
.legend-scale { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 11px; font-family: var(--mono); }
.legend-classes { display: grid; gap: 5px; }
.legend-class { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.legend-class i { width: 12px; height: 12px; }
.legend-class span:last-child { color: var(--ink-3); font-size: 11.5px; }
.legend-note { color: var(--ink-3); font-size: 11.5px; line-height: 1.45; }
.legend-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.legend-chip i { width: 16px; height: 10px; border: 1.5px solid; }
/* scale bar and cursor position, in the map's own furniture style */
.mapinfo { position: fixed; left: calc(var(--left-w) + 2 * var(--gap)); bottom: calc(var(--tl-h) + 2 * var(--gap)); z-index: 12; display: flex; align-items: flex-end; gap: 14px; pointer-events: none;
  color: #f4f2ed; font-size: 11px; font-family: var(--mono); text-shadow: 0 1px 2px rgba(0,0,0,0.85); }
.scalebar { display: grid; gap: 2px; }
.scalebar i { display: block; height: 5px; border: 1.5px solid #f4f2ed; border-top: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.coords { white-space: nowrap; }
.credits { position: fixed; right: calc(var(--right-w) + 2 * var(--gap) + 50px); bottom: calc(var(--tl-h) + 2 * var(--gap)); z-index: 11; color: rgba(244, 242, 237, 0.85); font-size: 10.5px; text-shadow: 0 1px 2px rgba(0,0,0,0.85); pointer-events: none; white-space: nowrap; }
.city-loading { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tl-h) + 2 * var(--gap)); z-index: 12; padding: 6px 11px; display: flex; gap: 9px; align-items: center; font-size: 12px; color: var(--ink-2); }
.camtools { position: fixed; right: calc(var(--right-w) + 2 * var(--gap)); bottom: calc(var(--tl-h) + 2 * var(--gap)); z-index: 12; display: flex; flex-direction: column; align-items: stretch;
  background: rgba(244, 242, 237, 0.97); border: 1px solid rgba(0, 0, 0, 0.14); border-radius: var(--r); box-shadow: var(--shadow); }
.camtools .icon-btn { width: 34px; height: 34px; border-radius: 0; }
.camtools .sep { height: 1px; background: var(--rule); }
.views-menu { position: absolute; right: calc(100% + 6px); bottom: 0; min-width: 236px; padding: 4px 0; display: grid; z-index: 2; }
.menu-title { color: var(--ink-3); font-size: 11.5px; padding: 6px 12px 6px; border-bottom: 1px solid var(--rule); margin-bottom: 2px; }
.views-menu button { text-align: left; padding: 7px 12px; border: 0; background: none; color: var(--ink); }
.views-menu button:hover { background: var(--paper-2); }
.compass { transition: transform 0.08s linear; color: var(--ink-2); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; color: #f6f4ef; text-shadow: 0 1px 2px rgba(0,0,0,0.85), 0 0 10px rgba(0,0,0,0.4); }
.lbl.boro { font-family: var(--serif); font-size: 16px; font-weight: 600; letter-spacing: 0.01em; color: rgba(248, 246, 241, 0.92); }
.lbl.water { font-family: var(--serif); font-size: 12.5px; font-style: italic; color: rgba(205, 225, 238, 0.82); letter-spacing: 0.02em; }
.lbl.nta { font-size: 12px; color: rgba(246, 244, 239, 0.84); }
.lbl.landmark { font-size: 11.5px; color: #f6f4ef; padding-bottom: 7px; }
.lbl.landmark::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 4px; height: 4px; margin-left: -2px; background: #f6f4ef; box-shadow: 0 0 0 1px rgba(0,0,0,0.6); }
/* map callouts: paper tags with a hairline */
.lbl.gauge, .lbl.hwm { text-shadow: none; padding: 2px 6px; border-radius: 2px; font-size: 11px; background: var(--paper); border: 1px solid rgba(0,0,0,0.3); color: var(--ink-2); margin-top: -4px; box-shadow: 0 1px 3px rgba(0,0,0,0.35); font-family: var(--mono); }
.lbl.gauge { font-family: var(--font); }
.lbl.gauge b, .lbl.hwm b { color: var(--ink); font-weight: 600; font-family: var(--mono); }
.lbl.hwm .sim { color: var(--blue); }
.lbl.station { font-size: 11px; color: #f6f4ef; padding-left: 12px; }
.lbl.station::before { content: ''; position: absolute; left: 0; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #f6f4ef; box-shadow: 0 0 0 1px rgba(0,0,0,0.6); }
.lbl.station.wet { color: #ffc2bc; }
.lbl.station.wet::before { background: #e5483f; }

.hovercard { position: fixed; z-index: 30; pointer-events: none; padding: 8px 10px; border-radius: 3px; background: var(--paper); border: 1px solid rgba(0,0,0,0.25); box-shadow: 0 6px 20px rgba(0,0,0,0.25); min-width: 200px; max-width: 290px; display: grid; gap: 3px; font-size: 12px; }
.hovercard-title { font-weight: 600; font-size: 12.5px; padding-bottom: 4px; margin-bottom: 2px; border-bottom: 1px solid var(--rule); }
.hovercard-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-3); }
.hovercard-row b { color: var(--ink); font-weight: 500; font-family: var(--mono); }

/* ---------- timeline ---------- */
.timeline { position: fixed; left: calc(var(--left-w) + 2 * var(--gap)); right: calc(var(--right-w) + 2 * var(--gap)); bottom: var(--gap); height: var(--tl-h); z-index: 12; padding: 9px 13px 7px; display: grid; grid-template-rows: auto 1fr; gap: 5px; }
.timeline-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-2); min-width: 0; }
.timeline-head > div:first-child > div:first-child { font-weight: 600; color: var(--ink); white-space: nowrap; }
.timeline-head .legend-row { font-size: 11.5px; flex-wrap: nowrap; overflow: hidden; }
.timeline svg { width: 100%; height: calc(var(--tl-h) - 42px); display: block; overflow: visible; touch-action: none; cursor: pointer; }
.tl-done { fill: rgba(0, 0, 0, 0.045); }
.tl-head { stroke: var(--ink); stroke-width: 1.5; }
.tl-knob { fill: var(--ink); stroke: var(--paper); stroke-width: 2; }
.tl-snap { stroke: var(--ink-3); stroke-width: 1; }
.tl-rain { fill: var(--series-1); opacity: 0.5; }
.tl-label { fill: var(--ink-3); font-size: 10.5px; font-family: var(--mono); }
.tl-hover { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 2; }
.tl-peak rect { fill: var(--paper); stroke: none; }
.tl-peak text { fill: var(--ink-2); font-size: 11px; font-family: var(--mono); }

/* ---------- loader, welcome, toast ---------- */
#loader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--paper); transition: opacity 0.6s; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-inner { width: min(440px, 86vw); display: grid; gap: 16px; }
.loader-brand { display: flex; align-items: baseline; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.loader-brand .brand-mark { align-self: center; }
.loader-brand .brand-name { font-size: 26px; }
.loader-place { color: var(--ink-3); font-size: 15px; }
.loader-lede { color: var(--ink-2); font-size: 14px; line-height: 1.65; font-family: var(--serif); }
.loader-bar { height: 2px; background: var(--rule); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0%; background: var(--ink); transition: width 0.25s ease; }
.loader-status { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; font-family: var(--mono); }
.loader-error { color: var(--red); line-height: 1.6; }

.scrim { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(10, 12, 13, 0.42); }
.welcome { width: min(600px, 92vw); padding: 26px 28px 22px; border-radius: var(--r); background: var(--paper); border: 1px solid rgba(0,0,0,0.2); box-shadow: 0 24px 60px rgba(0,0,0,0.4); display: grid; gap: 16px; }
.welcome-eyebrow { color: var(--ink-3); font-size: 12.5px; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.welcome h1 { margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.welcome p { margin: 0; color: var(--ink-2); line-height: 1.65; font-size: 14px; }
.welcome-facts { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.welcome-facts div { padding: 12px 12px 12px 0; display: grid; gap: 3px; }
.welcome-facts div + div { padding-left: 12px; border-left: 1px solid var(--rule); }
.welcome-facts b { font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.welcome-facts span { color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.welcome-actions .btn { height: 34px; padding: 0 14px; }
.welcome-foot { color: var(--ink-3); font-size: 12px; line-height: 1.5; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tl-h) + 2 * var(--gap) + 40px); transform: translateX(-50%); z-index: 40; padding: 8px 13px; border-radius: 3px; background: var(--ink); color: var(--paper); font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.busy { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 45; padding: 13px 17px; border-radius: var(--r); background: var(--paper); border: 1px solid rgba(0,0,0,0.2); display: flex; gap: 11px; align-items: center; box-shadow: var(--shadow); }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--rule-2); border-top-color: var(--ink); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.draw-banner { position: fixed; top: calc(var(--top) + 52px); left: 50%; transform: translateX(-50%); z-index: 14; padding: 7px 10px; display: flex; gap: 12px; align-items: center; font-size: 12.5px; }

/* clean frame for stills */
.clean .topbar, .clean .panel, .clean .timeline, .clean .viewmodes, .clean .legend, .clean .camtools, .clean .toast, .clean .city-loading, .clean .mapinfo, .clean .credits { display: none !important; }

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

/* ---------- narrow screens ---------- */
.panel-toggle { display: none; }
@media (max-width: 1380px) {
  :root { --right-w: 336px; --left-w: 292px; }
  .perf, .credits { display: none; }
  .clock { min-width: 196px; }
}
@media (max-width: 1100px) {
  :root { --left-w: 0px; --right-w: 0px; --gap: 8px; }
  .panel { top: auto; bottom: calc(var(--tl-h) + 2 * var(--gap)); height: min(62vh, 560px); width: calc(100vw - 16px) !important; left: 8px; right: 8px; display: none; z-index: 25; }
  .panel.open { display: flex; }
  .panel-toggle { display: inline-flex; }
  .viewmodes { left: 8px; right: 8px; overflow-x: auto; justify-content: flex-start; }
  .clock { min-width: 0; }
  .top-actions .btn span { display: none; }
  .brand-place, .mapinfo .coords { display: none; }
}
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 6px; padding: 0 8px; }
  .speed-seg { display: none; }
  .clock { font-size: 12px; }
  .welcome-facts { grid-template-columns: 1fr; }
  .welcome-facts div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); }
  .legend { display: none; }
}
