/* Design tokens. Light is the default; [data-theme="dark"] flips them. */
:root {
  color-scheme: light;
  --app-bg: #f5f7fb;
  --panel: #ffffff;
  --surface-input: #f8fafc;
  --surface-2: #f1f5f9;
  --border: #e6ebf2;
  --border-strong: #d4dde8;
  --text: #152033;
  --text-dim: #344256;
  --text-muted: #697789;
  --text-faint: #9aa7b8;
  --on-accent: #ffffff;
  --chip-text: #10141b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --success: #168f53;
  --success-solid: #2bc585;
  --success-bg: #e7f8ef;
  --danger: #d8284a;
  --danger-solid: #f3607c;
  --danger-bg: #fceef0;
  --warning: #b1730a;
  --warning-solid: #f0b53c;
  --warning-bg: #fdf3e2;
}

[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #111318;
  --panel: #1b1e25;
  --surface-input: #14171d;
  --surface-2: #242932;
  --border: #303541;
  --border-strong: #3b414c;
  --text: #edf1f6;
  --text-dim: #bac2ce;
  --text-muted: #8f99a8;
  --text-faint: #747e8d;
  --on-accent: #ffffff;
  --chip-text: #10141b;
  --accent: #5ca4f7;
  --accent-strong: #356fae;
  --success: #62d2aa;
  --success-solid: #62d2aa;
  --success-bg: #1d2a26;
  --danger: #ff5277;
  --danger-solid: #ff7190;
  --danger-bg: #42252c;
  --warning: #ffd28b;
  --warning-solid: #ffd28b;
  --warning-bg: #33291d;
}

:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--app-bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { color: inherit; }

#city-entrance {
  min-height: 100%; margin: 0; overflow-y: auto; background: var(--app-bg);
}
.portal-header {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--border);
  background: var(--surface-input);
}
.portal-brand {
  display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none;
}
.portal-logo { display: block; width: 188px; height: 54px; object-fit: contain; }
.brand-asset-dark { display: none; }
[data-theme="dark"] .brand-asset-light { display: none; }
[data-theme="dark"] .brand-asset-dark { display: block; }
.portal-brand small {
  max-width: 84px; color: var(--text-muted); font-size: 10px; line-height: 1.25;
}
.portal-status {
  display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 11px;
}
.portal-status svg { width: 14px; height: 14px; }
.portal-actions {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.support-link {
  height: 32px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 11px; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 7px; text-decoration: none;
  font-size: 11px; font-weight: 750;
}
.support-link:hover { border-color: rgba(37,99,235,.3); color: var(--accent); }
.support-link svg { width: 14px; height: 14px; color: var(--danger); }
.city-browser {
  width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 58px 0 72px;
}
.city-browser-heading { max-width: 650px; margin-bottom: 28px; }
.city-browser-heading p {
  margin: 0 0 8px; color: var(--success); font-size: 11px; font-weight: 700;
  text-transform: uppercase;
}
.city-browser-heading h1 { margin: 0; font-size: 34px; line-height: 1.12; }
.city-browser-heading > span {
  display: block; margin-top: 10px; color: var(--text-dim); font-size: 15px; line-height: 1.5;
  white-space: normal; overflow-wrap: anywhere;
}
.city-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.city-card {
  min-width: 0; overflow: hidden; color: inherit; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; text-decoration: none;
}
.city-card.available { cursor: pointer; transition: border-color .15s, transform .15s; }
.city-card.available:hover { border-color: var(--success); transform: translateY(-2px); }
.city-card img, .city-placeholder {
  display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover;
}
.city-placeholder {
  display: grid; place-items: center; color: var(--text-faint); background: var(--surface-2);
}
.city-placeholder.cambridge { background: var(--success-bg); }
.city-placeholder.york { background: var(--warning-bg); }
.city-placeholder.edinburgh {
  background: linear-gradient(135deg, #2a3550, #46618c);
  color: rgba(255, 255, 255, .9);
}
.city-placeholder svg { width: 42px; height: 42px; stroke-width: 1.25; }
.city-card.unavailable { opacity: .64; }
.city-card-copy { min-height: 190px; padding: 17px 18px 18px; }
.city-state {
  display: flex; align-items: center; gap: 5px; color: var(--text-muted);
  font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.city-state.ready { color: var(--success); }
.city-state svg { width: 13px; height: 13px; }
.city-card h2 { margin: 10px 0 6px; font-size: 21px; }
.city-card p {
  min-height: 42px; margin: 0; color: var(--text-muted); font-size: 12px; line-height: 1.5;
  white-space: normal; overflow-wrap: anywhere;
}
.open-city {
  display: flex; align-items: center; gap: 6px; margin-top: 22px;
  color: var(--text); font-size: 12px; font-weight: 700;
}
.open-city svg { width: 15px; height: 15px; }

/* --- three-zone app shell: top bar / editor / map / results --- */
#app {
  position: relative; display: grid;
  grid-template-columns: 74px 344px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "rail editor map";
  overflow: hidden;
}
/* collapse the right results column when it has no content (no empty menu) */
#app.results-collapsed { grid-template-columns: 74px 344px minmax(0, 1fr); }
#app.results-collapsed #results-column { display: none; }
/* collapse the left editor column down to just the rail */
#app.editor-collapsed { grid-template-columns: 74px 0 minmax(0, 1fr); }
#app.editor-collapsed.results-collapsed { grid-template-columns: 74px 0 minmax(0, 1fr); }
#app.editor-collapsed #editor-column { display: none; }

#workspace-bar {
  grid-area: bar; position: relative; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: rgba(255,255,255,.98); border-bottom: 1px solid var(--border); z-index: 6;
  box-shadow: 0 2px 18px rgba(30,41,59,.06);
}
[data-theme="dark"] #workspace-bar {
  background: rgba(27,30,37,.96);
  box-shadow: 0 1px 18px rgba(0,0,0,.22);
}
.brand-lockup {
  display: flex; align-items: center; gap: 9px; min-width: 168px; flex-shrink: 0;
}
.back-to-cities {
  display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  color: var(--accent); border: 0; border-radius: 7px; text-decoration: none;
  background: transparent;
}
.back-to-cities:hover { color: var(--accent-strong); background: var(--surface-2); }
.back-to-cities img { width: 31px; height: 31px; object-fit: contain; }
.workspace-title { min-width: 0; }
.workspace-title h1 { margin: 0; color: var(--accent); font-size: 15px; line-height: 1.1; }
.workspace-title p { margin: 1px 0 0; color: var(--text-muted); font-size: 11px; }
h1 { margin: 0; font-size: 17px; letter-spacing: 0; }
.workspace-summary {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 20px;
  margin-left: 10px; color: var(--text-muted); font-size: 12px; overflow: hidden;
}
.workspace-summary span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.workspace-summary svg { width: 14px; height: 14px; color: var(--text-faint); }
.workspace-summary b { color: var(--text); font-size: 13px; font-weight: 700; }
.workspace-summary[hidden] { display: none; }
.top-modebar {
  /* bottom-centre of the MAP window (the left calc offsets the editor column), so the
     tools never collide with the road-type palette or the top chrome */
  position: absolute; left: calc(432px + (100vw - 432px) / 2); top: auto; bottom: 22px;
  transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  /* wrap instead of scrolling horizontally: light rail shows the most tools (4 alignment
     options + stop tools + Undo/Clear/Finish/Cancel) and a scrolled bar just LOOKS like
     the trailing buttons are missing */
  flex-wrap: wrap;
  width: max-content; max-width: min(1040px, calc(100vw - 466px)); padding: 6px 7px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
  box-shadow: 0 10px 32px rgba(15,23,42,.14);
}
#app.editor-collapsed .top-modebar { left: calc(90px + (100vw - 90px) / 2); max-width: calc(100vw - 112px); }
/* dragging captures the visual rect then pins with inline left/top - the centring
   transform must not re-apply on top of that */
.top-modebar.floating-placed { right: auto; bottom: auto; max-width: none; transform: none; }
.top-modebar.is-dragging { cursor: grabbing; }
.top-modebar[hidden] { display: none; }
.top-modebar button[hidden] { display: none; }
.toolbar-drag {
  width: 22px; height: 50px; display: grid; place-items: center; flex: 0 0 auto;
  color: var(--text-faint); border-radius: 5px; cursor: grab;
}
.toolbar-drag:hover { color: var(--text); background: var(--surface-2); }
.top-modebar.is-dragging .toolbar-drag { cursor: grabbing; }
.toolbar-drag svg { width: 15px; height: 15px; }
.top-modebar .toolbar-divider {
  width: 1px; height: 36px; margin: 0 4px; background: var(--border);
  flex: 0 0 auto;
}
.top-modebar .toolbar-divider[hidden] { display: none; }
.top-modebar button {
  position: relative;
  min-width: 58px; width: 58px; height: 50px; display: grid; place-items: center; align-content: center; gap: 4px;
  color: var(--text-muted); background: transparent; border: 1px solid transparent; border-radius: 5px;
  font-size: 9px; cursor: pointer;
}
.top-modebar button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.top-modebar button.active {
  color: var(--accent); background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.2);
}
#finish-road {
  min-width: 76px; width: 76px;
  color: var(--success); background: var(--success-bg); border-color: rgba(22,143,83,.22);
}
#finish-road[hidden] { display: none; }
#finish-road:disabled {
  opacity: .46; cursor: default;
}
#cancel-road {
  min-width: 76px; width: 76px;
  color: var(--text-muted); background: transparent; border-color: var(--border);
}
#cancel-road:hover { color: var(--danger); background: var(--danger-bg); border-color: rgba(216,40,74,.22); }
#cancel-road[hidden] { display: none; }
#clear:hover { color: var(--danger); border-color: rgba(216,40,74,.22); background: var(--danger-bg); }
.top-modebar button[aria-pressed="true"] {
  color: var(--accent); background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.2);
}
.top-modebar button.coming-soon {
  color: var(--text-faint); cursor: default; opacity: .62;
}
.top-modebar button.coming-soon:hover {
  color: var(--text-faint); background: transparent;
}
.top-modebar button.coming-soon:hover::after {
  content: "Coming soon";
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  padding: 5px 7px; color: white; background: #111827; border-radius: 4px;
  font-size: 10px; white-space: nowrap; box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.top-modebar button.coming-soon:hover::before {
  content: ""; position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom-color: #111827;
}
.top-modebar svg { width: 18px; height: 18px; }
.ws-scenario {
  display: flex; align-items: center; gap: 6px; margin-left: auto; padding: 5px 10px; flex-shrink: 0;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size: 12px;
  cursor: pointer;
}
.ws-scenario:hover { border-color: var(--border-strong); background: var(--panel); }
.ws-scenario svg { width: 14px; height: 14px; color: var(--text-muted); }
.issue-popover {
  position: fixed; top: 58px; right: 112px; z-index: 20; width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 80px); overflow-y: auto;
  padding: 12px; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 16px 36px rgba(15,23,42,.16);
}
.issue-popover-head { margin-bottom: 9px; }
.issue-popover-head b { display: block; font-size: 12px; color: var(--text); }
.issue-popover-head small { color: var(--text-muted); font-size: 10px; }
.issue-popover .model-clear { margin: 8px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
#save-state { color: var(--success); font-size: 11px; flex-shrink: 0; font-weight: 700; }
.ws-actions { display: flex; gap: 8px; flex-shrink: 0; }
.donate-link {
  width: auto; padding: 0 10px; gap: 6px; text-decoration: none; font-size: 11px; font-weight: 750;
}
.donate-link svg { width: 14px; height: 14px; color: var(--danger); }
.ghost-button {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
  color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 6px;
  font-size: 12px; cursor: pointer;
}
.ghost-button:hover { background: var(--surface-2); border-color: var(--border); }
.ghost-button.icon-only { width: 32px; padding: 0; justify-content: center; }
.ghost-button svg { width: 15px; }
.units-toggle { width: auto; min-width: 34px; padding: 0 9px; font-size: 11px; font-weight: 700; justify-content: center; }
.speed-field { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.speed-field input { width: 100%; min-width: 0; }
.speed-field small { color: var(--text-faint); font-size: 10px; white-space: nowrap; }

#left-rail {
  grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-width: 0; padding: 22px 10px 16px; background: var(--panel);
  border-right: 1px solid var(--border); z-index: 4;
  overflow: visible;
}
#left-rail button {
  position: relative; width: 48px; height: 48px; display: grid; place-items: center;
  padding: 0; text-align: center;
  color: var(--text-muted); background: transparent; border: 1px solid transparent;
  border-radius: 9px; cursor: pointer; font-size: 11px; line-height: 1.05;
}
#left-rail button:hover { color: var(--text); background: var(--surface-2); }
#left-rail button.active {
  color: white; background: var(--accent); box-shadow: 0 6px 16px rgba(37,99,235,.28);
}
#left-rail svg { width: 19px; height: 19px; }
#left-rail button span {
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translate(-4px, -50%);
  min-width: max-content; max-width: 142px; padding: 7px 9px; border-radius: 8px;
  color: var(--text); background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  opacity: 0; pointer-events: none; white-space: nowrap; transition: opacity .14s ease, transform .14s ease;
}
#left-rail button:hover span,
#left-rail button:focus-visible span {
  opacity: 1; transform: translate(0, -50%);
}
#left-rail .rail-spacer { margin-top: auto; }

#editor-column, #results-column {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--panel); overflow-x: hidden; overflow-y: auto; z-index: 2;
}
#editor-column { grid-area: editor; border-right: 1px solid var(--border); }
#results-column {
  position: absolute; top: 82px; right: 18px; z-index: 5;
  width: min(356px, calc(100vw - 36px)); max-height: calc(100vh - 106px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 18px 48px rgba(15,23,42,.16); backdrop-filter: blur(8px);
}
[data-theme="dark"] #results-column { box-shadow: 0 18px 48px rgba(0,0,0,.35); }
#results-column.floating-placed {
  right: auto; bottom: auto; max-width: none; max-height: none;
}
#results-column.route-overview-collapsed {
  width: min(296px, calc(100vw - 36px)); height: auto !important;
  min-height: 0; overflow: hidden;
}
#results-column .section-heading.compact { cursor: grab; user-select: none; }
#results-column.is-dragging .section-heading.compact { cursor: grabbing; }
#map-shell { grid-area: map; }

.new-route-design {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; margin: 14px 16px 10px; padding: 0 14px;
  color: white; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 7px; box-shadow: 0 8px 18px rgba(37,99,235,.18);
  font-size: 12px; font-weight: 800; cursor: pointer;
}
.new-route-design:hover { background: var(--accent-strong); }
.new-route-design svg { width: 16px; height: 16px; }

/* multi-route: proposed routes list */
.proposed-routes-panel { padding: 10px 14px 12px; border-bottom: 1px solid var(--border); }
.proposed-routes-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.proposed-routes-head b { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.proposed-route-count {
  font-size: 10px; color: var(--text-faint); padding: 1px 7px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.proposed-route-list { display: grid; gap: 6px; }
.proposed-route-list:empty::after { content: "No proposed routes yet."; color: var(--text-faint); font-size: 11px; }
.proposed-route-empty { margin: 4px 2px; color: var(--text-faint); font-size: 11px; line-height: 1.45; }
.proposed-route-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; background: var(--surface-input);
}
.proposed-route-row:hover { border-color: var(--border-strong); }
.proposed-route-row.active { border-color: var(--accent); background: var(--accent-weak); }
.proposed-route-meta { min-width: 0; }
.proposed-route-meta b { display: block; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proposed-route-meta small { color: var(--text-faint); font-size: 11px; }
.proposed-route-delete { width: 26px; height: 26px; }

.back-to-routes-btn {
  display: flex; align-items: center; gap: 5px; margin: 12px 14px 2px; padding: 7px 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-dim); font-size: 12px; font-weight: 600; cursor: pointer; width: fit-content;
}
.back-to-routes-btn:hover { color: var(--text); border-color: var(--border-strong); }
.back-to-routes-btn svg { width: 15px; height: 15px; }
.back-to-routes-btn[hidden] { display: none; }

/* mode hero picker */
.mode-picker { padding: 12px 14px 16px; }
.mode-picker[hidden] { display: none; }
.mode-picker-title { margin: 12px 0 2px; font-size: 16px; }
.mode-picker-sub { margin: 0 0 14px; color: var(--text-faint); font-size: 12px; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 8px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .12s, box-shadow .12s, transform .06s;
}
.mode-card:hover {
  border-color: var(--mode);
  box-shadow: 0 0 0 1px var(--mode), 0 6px 18px rgba(0, 0, 0, .07);
  transform: translateY(-1px);
}
.mode-card[data-mode="bus"] {
  --mode-icon-light: url("assets/icons/light-bus.png");
  --mode-icon-dark: url("assets/icons/dark-bus.png");
}
.mode-card[data-mode="light_rail"] {
  --mode-icon-light: url("assets/icons/light-tram.png");
  --mode-icon-dark: url("assets/icons/dark-tram.png");
}
.mode-card[data-mode="metro"] {
  --mode-icon-light: url("assets/icons/light-metro.png");
  --mode-icon-dark: url("assets/icons/dark-metro.png");
}
.mode-visual {
  display: block; width: 100%; aspect-ratio: 590 / 404; overflow: hidden;
  border-radius: 9px; background-image: var(--mode-icon-light);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.08);
}
[data-theme="dark"] .mode-visual {
  background-image: var(--mode-icon-dark);
}
.mode-card-title { display: block; min-width: 0; padding: 3px 2px 0; }
.mode-card b { font-size: 13px; color: var(--text); }
.mode-card small { color: var(--text-faint); font-size: 11px; line-height: 1.35; padding: 0 2px 2px; }

/* metro tunnelling */
.tunnel-fields {
  margin-top: 10px; padding: 10px 11px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
}
.tunnel-hint { margin: 0 0 9px; color: var(--text-faint); font-size: 10px; line-height: 1.4; }
.tunnel-fields[hidden] { display: none; }
.tunnel-method { margin-top: 9px; display: grid; gap: 5px; }
.tunnel-method-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.tunnel-method label { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.tunnel-method input { width: auto; height: auto; margin: 0; }

.route-empty-state {
  display: grid; place-items: center; gap: 8px; margin: 12px 16px; padding: 34px 20px;
  text-align: center; color: var(--text-muted); background: var(--surface-input);
  border: 1px dashed var(--border-strong); border-radius: 8px;
}
.route-empty-state svg { width: 31px; height: 31px; color: var(--accent); }
.route-empty-state b { color: var(--text); font-size: 14px; }
.route-empty-state span { max-width: 240px; font-size: 12px; line-height: 1.45; }
[data-route-editor][hidden], [data-route-results][hidden], #route-summary-tray[hidden] { display: none; }

.overview-panel {
  padding: 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.section-heading.compact {
  margin: 0 0 10px;
}
.section-heading.compact h2 {
  color: var(--text); font-size: 12px; letter-spacing: .04em;
}
.panel-collapse {
  width: 25px; height: 25px; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: transparent; border: 0; border-radius: 4px; cursor: pointer;
}
.panel-collapse:hover { color: var(--text); background: var(--surface-2); }
.panel-collapse svg { width: 14px; height: 14px; transition: transform .15s; }
.overview-panel.collapsed .panel-collapse svg { transform: rotate(180deg); }
.overview-panel.collapsed .overview-metrics { display: none; }
.overview-panel.collapsed { padding-bottom: 12px; border-bottom: 0; }
.overview-panel.collapsed .section-heading.compact { margin-bottom: 0; }
.overview-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; background: transparent;
}
.overview-metrics span {
  min-height: 74px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 7px;
}
.overview-metrics i, .overview-metrics svg { color: var(--accent); }
.overview-metrics b { font-size: 18px; }

/* collapsible accordion sections (editor + results) */
.acc { border-bottom: 1px solid var(--border); }
.acc-head-row { display: flex; align-items: center; gap: 4px; padding-right: 10px; }
.acc-head {
  flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0;
  padding: 13px 14px; background: none; border: 0; color: inherit; cursor: pointer; text-align: left;
}
.acc-head:hover { background: var(--surface-2); }
.acc-head svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-muted); transition: transform .15s; }
.acc-head[aria-expanded="false"] svg { transform: rotate(-90deg); }
.acc-title { min-width: 0; }
.acc-title b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.acc-title small { display: block; margin-top: 2px; color: var(--text-faint); font-size: 11px; }
.acc-body { padding: 2px 16px 15px; }
.acc-body[hidden] { display: none; }
.analytics-header {
  padding: 16px 10px 10px 12px;
}

@media (max-width: 1240px) {
  #app { grid-template-columns: 64px 288px minmax(0, 1fr); }
  .top-modebar { left: 366px; max-width: calc(100vw - 388px); }
  .top-modebar button { width: 56px; }
  #results-column { width: min(336px, calc(100vw - 28px)); }
}

.panel { padding: 14px 18px; border-bottom: 1px solid var(--border); }
label { display: block; color: var(--text-muted); font-size: 11px; }
input {
  display: block; width: 100%; height: 34px; margin-top: 5px; padding: 0 9px;
  color: var(--text); background: var(--surface-input); border: 1px solid var(--border); border-radius: 5px;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(92,164,247,.14); }
select {
  height: 34px; padding: 0 8px; color: var(--text); background: var(--surface-input);
  border: 1px solid var(--border); border-radius: 5px;
}
.field-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; margin-bottom: 11px; }
#route-ref {
  color: white; background: var(--accent); border-color: var(--accent);
  font-weight: 800; text-align: center;
}
.color-field input { width: 84px; padding: 4px; cursor: pointer; }
.route-palette {
  display: flex; align-items: center; gap: 12px; margin-top: 13px; padding-top: 12px;
  border-top: 1px solid var(--surface-2);
}
.route-palette button {
  width: 19px; height: 19px; padding: 0; border-radius: 50%;
  background: var(--swatch); border: 2px solid transparent; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(16,24,40,.08);
}
.route-palette button:hover { border-color: var(--panel); box-shadow: 0 0 0 2px var(--swatch); }
.text-link {
  flex-shrink: 0; padding: 0 4px; color: var(--accent);
  background: transparent; border: 0; font-size: 11px; cursor: pointer;
}
.text-link:hover { color: var(--accent-strong); text-decoration: underline; }
.stop-summary-card {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 10px;
  min-height: 58px; margin-bottom: 10px; padding: 10px 12px;
  color: var(--text); background: rgba(37,99,235,.045);
  border: 1px solid rgba(37,99,235,.22); border-radius: 6px;
}
.stop-summary-card svg { width: 21px; height: 21px; color: var(--accent); }
.stop-summary-card b, .stop-summary-card small { display: block; }
.stop-summary-card b { font-size: 12px; }
.stop-summary-card small { margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.design-infra-summary .acc-body { display: grid; gap: 7px; }
.infra-summary-row {
  width: 100%; min-height: 46px; display: grid; grid-template-columns: 28px minmax(0, 1fr) 16px;
  align-items: center; gap: 9px; padding: 8px 10px; color: var(--text);
  text-align: left; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
}
.infra-summary-row:hover { border-color: rgba(37,99,235,.28); background: rgba(37,99,235,.04); }
.infra-summary-row svg { width: 16px; height: 16px; color: var(--text-muted); }
.infra-summary-row > svg:first-child { color: var(--text-dim); }
.infra-summary-row b, .infra-summary-row small { display: block; }
.infra-summary-row b { font-size: 12px; }
.infra-summary-row small { margin-top: 2px; color: var(--text-muted); font-size: 10px; }
.editor-footer {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px;
  padding: 14px 16px 18px; border-bottom: 1px solid var(--border);
}
.primary-action, .secondary-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 12px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.primary-action { color: white; background: var(--accent); border: 1px solid var(--accent); }
.primary-action:hover { background: var(--accent-strong); }
.secondary-action { color: var(--accent); background: var(--panel); border: 1px solid var(--border-strong); }
.secondary-action:hover { background: rgba(37,99,235,.045); border-color: rgba(37,99,235,.25); }
.danger-action { color: var(--danger); }
.danger-action:hover { background: var(--danger-bg); border-color: rgba(216,40,74,.24); }
.editor-footer > span {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 7px;
  margin-top: 5px; color: var(--success); font-size: 10px; font-weight: 700;
}
.editor-footer svg { width: 13px; height: 13px; }
.editor-footer small { margin-left: 8px; color: var(--text-faint); font-weight: 500; }
.field-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
.field-grid label { position: relative; min-width: 0; }
.field-grid input { min-width: 0; }
.field-grid small { position: absolute; right: 9px; bottom: 9px; color: var(--text-faint); pointer-events: none; }
.field-grid input[type=number] { padding-right: 58px; }
.road-settings {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px;
}
.road-settings select { display: block; width: 100%; margin-top: 5px; }
.road-one-way {
  display: flex; align-items: center; gap: 6px; height: 34px; color: var(--text-dim);
  white-space: nowrap;
}
.road-one-way input { width: auto; height: auto; margin: 0; }
#road-list { margin-top: 10px; }
.road-list-label {
  margin: 13px 0 6px; color: var(--text-muted); font-size: 9px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
}
.infra-cat-empty {
  margin: 6px 4px; color: var(--text-faint); font-size: 10px; line-height: 1.4;
}
.road-type-gallery {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px;
}
.road-type-gallery button {
  min-width: 0; min-height: 96px; display: grid; grid-template-rows: 58px auto;
  gap: 6px; padding: 7px; color: var(--text); text-align: left;
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer;
}
.road-type-gallery button:hover { border-color: rgba(37,99,235,.28); background: rgba(37,99,235,.035); }
.road-type-gallery button.active {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
.road-type-gallery b {
  overflow: hidden; color: var(--text); font-size: 10px; line-height: 1.15;
  text-overflow: ellipsis; white-space: nowrap;
}
.road-type-preview {
  position: relative; overflow: hidden; display: block; height: 58px; border-radius: 7px;
  background: #eef5fb center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.07);
}
.road-type-preview svg {
  display: none;
}
.road-type-preview.suburban { background-image: url("assets/thumbnails/road-suburban.jpg"); }
.road-type-preview.busway { background-image: url("assets/thumbnails/road-busway.jpg"); }
.road-type-preview.distributor { background-image: url("assets/thumbnails/road-main.jpg"); }
.road-type-preview.dual { background-image: url("assets/thumbnails/road-dual.jpg"); }
.road-draw-cta {
  width: 100%; min-height: 48px; display: grid; grid-template-columns: 30px minmax(0, 1fr);
  align-items: center; gap: 9px; margin-top: 10px; padding: 8px 10px;
  color: var(--accent); text-align: left; background: rgba(37,99,235,.08);
  border: 1px solid rgba(37,99,235,.2); border-radius: 6px; cursor: pointer;
}
.road-draw-cta:hover { background: rgba(37,99,235,.13); }
.road-draw-cta svg { width: 18px; height: 18px; }
.road-draw-cta b, .road-draw-cta small { display: block; }
.road-draw-cta b { color: var(--text); font-size: 12px; }
.road-draw-cta small { margin-top: 2px; color: var(--text-muted); font-size: 10px; }
.road-row {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center;
  gap: 8px; min-height: 58px; padding: 7px 8px; margin-top: 7px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel);
}
.road-row.selected {
  background: var(--surface-2);
  box-shadow: inset 2px 0 var(--accent);
}
.road-row.in-progress {
  border-color: rgba(245,158,11,.28); background: rgba(245,158,11,.055);
}
.road-row.track-row {
  grid-template-columns: 14px minmax(0, 1fr);
  border-style: dashed; background: var(--surface-input);
}
.road-swatch {
  width: 10px; height: 22px; border: 1px solid var(--text-faint); border-radius: 2px;
}
.road-copy { min-width: 0; }
.road-copy b {
  display: block; overflow: hidden; color: var(--text); font-size: 11px;
  text-overflow: ellipsis; white-space: nowrap;
}
.road-copy span { display: block; margin-top: 3px; color: var(--text-faint); font-size: 10px; line-height: 1.45; white-space: normal; }
.road-actions { display: flex; gap: 4px; }
.road-actions button {
  width: 26px; height: 26px; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: transparent; border: 0; border-radius: 4px; cursor: pointer;
}
.road-actions button:hover { color: var(--text); background: var(--surface-2); }
.road-actions button.danger:hover { color: var(--danger); }
.road-actions svg { width: 13px; height: 13px; }
#empty-roads { margin-top: 9px; color: var(--text-faint); font-size: 10px; line-height: 1.4; }
.route-search input { margin-top: 6px; }
.existing-route-list { display: grid; gap: 7px; margin-top: 10px; }
.existing-route-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 16px; align-items: center; gap: 10px;
  width: 100%; min-height: 50px; padding: 8px 10px; text-align: left;
  color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer;
}
.existing-route-row:hover { border-color: rgba(37,99,235,.3); background: rgba(37,99,235,.04); }
.existing-route-row > span:nth-child(2) { min-width: 0; }
.existing-route-row b {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px;
}
.existing-route-row small {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 3px; color: var(--text-muted); font-size: 10px;
}
.existing-route-row svg { width: 15px; height: 15px; color: var(--text-faint); }
.route-ref-pill {
  min-width: 34px; height: 23px; display: inline-grid; place-items: center;
  padding: 0 7px; color: white; background: var(--route-color);
  border-radius: 5px; font-size: 11px; font-weight: 800;
}
.panel-placeholder {
  display: grid; gap: 9px; color: var(--text-muted); font-size: 12px; line-height: 1.45;
}
.panel-placeholder > svg { width: 25px; height: 25px; color: var(--accent); }
.network-panel .primary-action { width: 100%; margin-top: 4px; }
.impact-subhead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border);
}
.infra-impact-block { margin-top: 14px; }
.impact-subhead b {
  color: var(--text-dim); font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
}
.impact-subhead small { color: var(--text-faint); font-size: 10px; }
#building-impact-list { display: grid; gap: 6px; margin-top: 8px; }
.building-impact-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center;
  min-height: 42px; padding: 7px 0; border-top: 1px solid var(--surface-2);
}
.building-impact-row.selected {
  background: var(--surface-2);
  box-shadow: inset 2px 0 var(--warning);
}
.building-impact-row.complex {
  box-shadow: inset 2px 0 rgba(255, 210, 139, .55);
}
.building-impact-row.complex.selected {
  box-shadow: inset 2px 0 var(--warning);
}
.building-impact-copy { min-width: 0; }
.building-impact-copy b {
  display: block; overflow: hidden; color: var(--text); font-size: 11px;
  text-overflow: ellipsis; white-space: nowrap;
}
.building-impact-copy span {
  display: block; margin-top: 2px; color: var(--text-faint); font-size: 9px;
}
.impact-state {
  display: inline-flex; align-items: center; gap: 4px; margin-right: 5px;
  color: var(--warning); font-weight: 800; text-transform: uppercase;
}
.impact-state.remove { color: var(--danger-solid); }
.impact-state.keep { color: var(--success); }
.impact-actions { display: flex; gap: 4px; }
.impact-actions button {
  width: 25px; height: 25px; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: transparent; border: 0; border-radius: 4px; cursor: pointer;
}
.impact-actions button:hover { color: var(--text); background: var(--surface-2); }
.impact-actions button.active { color: var(--chip-text); background: var(--warning-solid); }
.impact-actions button[data-state="remove"].active { background: var(--danger-solid); }
.impact-actions button[data-state="keep"].active { background: var(--success-solid); }
.impact-actions svg { width: 13px; height: 13px; }
.impact-actions button[disabled] { opacity: 0.35; cursor: default; }
.impact-actions button[disabled]:hover { color: var(--text-muted); background: transparent; }
.impact-group { margin-top: 10px; }
.impact-group:first-child { margin-top: 4px; }
.impact-group-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 5px;
  font-size: 10px; color: var(--text-muted);
}
.impact-group-head svg { width: 12px; height: 12px; color: var(--text-faint); }
.impact-group-head b { color: var(--text); font-size: 11px; }
.impact-group-head small { margin-left: auto; color: var(--text-faint); font-size: 9px; }
.impact-group .building-impact-row { margin-bottom: 5px; }
.impact-group-more { color: var(--text-faint); font-size: 9px; padding: 2px 0 0 2px; }
.infra-hint { margin: 10px 2px 0; color: var(--text-faint); font-size: 10px; line-height: 1.4; }
/* Floating "Quick view" inspector over the map */
.build-inspector {
  position: absolute; top: 14px; right: 14px; z-index: 6;
  width: 320px; max-height: calc(100% - 96px);
  min-width: var(--float-min-width, 300px); min-height: var(--float-min-height, 240px);
  display: flex; flex-direction: column; gap: 10px; padding: 13px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.20);
  resize: none;
}
.build-inspector[hidden] { display: none; }
.build-inspector.floating-placed {
  right: auto; bottom: auto; max-width: none; max-height: none;
}
.build-inspector .build-inspector-head { display: flex; align-items: center; gap: 8px; width: 100%; cursor: grab; user-select: none; }
.build-inspector.is-dragging .build-inspector-head { cursor: grabbing; }
.build-inspector .build-inspector-head > svg { width: 15px; height: 15px; flex: none; color: var(--text-muted); }
.build-inspector-heading { flex: 1; min-width: 0; }
.build-inspector-heading b { display: block; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-inspector-heading small { color: var(--text-muted); font-size: 10px; }
.build-inspector-body { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
#build-inspector-close {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: transparent; border: 0; border-radius: 5px; cursor: pointer;
}
#build-inspector-close:hover { color: var(--text); background: var(--surface-2); }
#build-inspector-close svg { width: 14px; height: 14px; }
.build-inspector-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.bi-stat {
  display: flex; flex-direction: column; gap: 1px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-input);
}
.bi-stat small { color: var(--text-faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.03em; }
.bi-stat b { color: var(--text); font-size: 12px; }
.build-inspector-impacts { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.build-inspector-impacts .impact-subhead { display: flex; justify-content: space-between; align-items: baseline; }
.build-inspector-impacts .impact-subhead b { font-size: 11px; color: var(--text); }
.build-inspector-impacts .impact-subhead small { color: var(--text-faint); font-size: 9px; }
#build-inspector-impact-list {
  margin-top: 6px; display: grid; gap: 5px; flex: 1; min-height: 120px;
  align-content: start; overflow-y: auto;
}
/* the full grouped impact review lives in the Build sidebar's own category card */
#infra-cat-impacts .infra-cat-body { max-height: 380px; overflow-y: auto; }
#building-impact-badge:empty { display: none; }
.build-inspector-empty { margin-top: 6px; color: var(--text-faint); font-size: 10px; }
.bi-controls { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 8px 10px; }
.bi-controls > label { display: block; font-size: 11px; color: var(--text-muted); }
.bi-controls select { display: block; width: 100%; margin-top: 5px; }
.bi-controls .road-one-way { grid-column: 1 / -1; height: auto; }
.bi-config {
  grid-column: 1 / -1; display: grid; gap: 8px; margin-top: 4px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.lane-stepper {
  display: grid; grid-template-columns: minmax(0, 1fr) 28px 34px 28px; align-items: center; gap: 4px;
  color: var(--text-dim); font-size: 11px;
}
.lane-stepper button {
  width: 28px; height: 26px; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: var(--surface-input); border: 1px solid var(--border);
  border-radius: 5px; cursor: pointer;
}
.lane-stepper button:hover { color: var(--accent); border-color: rgba(37,99,235,.3); }
.lane-stepper b {
  display: grid; place-items: center; height: 26px; color: var(--text);
  background: var(--surface-input); border: 1px solid var(--border); border-radius: 5px;
}
.mini-switch {
  display: grid; grid-template-columns: minmax(0, 1fr) 30px; align-items: center; gap: 10px;
  color: var(--text-dim); font-size: 11px; cursor: pointer;
}
.mini-switch input { display: none; }
.mini-switch i {
  position: relative; width: 30px; height: 17px; border-radius: 999px;
  background: var(--border-strong); transition: background .15s;
}
.mini-switch i::after {
  content: ""; position: absolute; width: 13px; height: 13px; left: 2px; top: 2px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15,23,42,.22);
  transition: transform .15s;
}
.mini-switch input:checked + i { background: var(--accent); }
.mini-switch input:checked + i::after { transform: translateX(13px); }
.bi-draft-hint { margin: 0; color: var(--text-faint); font-size: 11px; line-height: 1.4; }
.bi-draft-actions { display: flex; gap: 8px; }
.bi-primary, .bi-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 12px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.bi-primary { flex: 1; color: #fff; background: var(--accent); border: 1px solid var(--accent); }
.bi-primary[disabled] { opacity: 0.5; cursor: default; }
.bi-ghost { color: var(--text-muted); background: transparent; border: 1px solid var(--border); }
.bi-ghost:hover { color: var(--text); background: var(--surface-2); }
.bi-draft-actions svg { width: 14px; height: 14px; }
.bi-profile { display: flex; flex-direction: column; gap: 4px; }
.bi-section-label { font-size: 10px; color: var(--text-muted); }
.elev-svg {
  width: 100%; height: 70px; display: block;
  background: var(--surface-input); border: 1px solid var(--border); border-radius: 6px;
}
.elev-area { fill: var(--accent); opacity: 0.14; }
.elev-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.elev-tunnel { fill: none; stroke: var(--text-muted); stroke-width: 1.3; stroke-dasharray: 3 3; stroke-linejoin: round; }
.elev-axis { display: flex; justify-content: space-between; font-size: 9px; color: var(--text-faint); }
.building-map-diagnostics {
  margin-top: 7px; color: var(--text-faint); font-size: 9px; line-height: 1.35;
}
#empty-building-impacts { margin-top: 8px; color: var(--text-faint); font-size: 10px; line-height: 1.4; }
.project-health-panel { padding-bottom: 12px; }
.model-health {
  display: flex; align-items: center; gap: 7px; min-height: 28px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 5px; background: var(--surface-input);
  color: var(--text); font-size: 11px; font-weight: 700;
}
.model-health svg { width: 14px; height: 14px; }
.model-health.ok {
  color: var(--success); border-color: rgba(98,210,170,.36);
}
.model-health.warning {
  color: var(--warning); border-color: rgba(255,188,92,.35);
}
.model-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
  margin-top: 8px;
}
.model-stats span {
  min-width: 0; padding: 6px 7px; color: var(--text-muted); background: var(--surface-input);
  border: 1px solid var(--surface-2); border-radius: 4px; font-size: 9px;
}
.model-stats b {
  display: block; color: var(--text); font-size: 13px; line-height: 1.1;
}
.model-issues {
  display: grid; gap: 5px; margin: 8px 0 0; padding: 0; list-style: none;
}
.model-issues li {
  padding: 6px 7px; border-left: 2px solid var(--warning); border-radius: 4px;
  background: var(--surface-input);
}
.model-issues b {
  display: block; color: var(--warning); font-size: 10px; line-height: 1.25;
}
.model-issues span {
  display: block; margin-top: 2px; color: var(--text-faint); font-size: 9px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.routing-explainer[hidden] { display: none; }
.routing-pill {
  display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 5px; color: var(--text);
  background: var(--surface-input); font-size: 11px; font-weight: 700;
}
.routing-pill svg { width: 14px; height: 14px; }
.routing-pill.ok { color: var(--success); border-color: rgba(98,210,170,.36); }
.routing-pill.warn { color: var(--warning); border-color: rgba(255,188,92,.35); }
.routing-pill.neutral { color: var(--text-dim); }
.routing-note { margin: 8px 0 0; color: var(--text-muted); font-size: 10px; line-height: 1.45; }
.routing-subsection { margin-top: 10px; }
.routing-subsection h3 {
  margin: 0 0 6px; color: var(--text-muted); font-size: 9px; letter-spacing: .08em;
  text-transform: uppercase;
}
.routing-snaps {
  display: grid; gap: 4px; margin: 0; padding: 0; list-style: none;
}
.routing-snaps li {
  display: grid; grid-template-columns: 18px minmax(0, auto) minmax(0, 1fr);
  align-items: center; gap: 6px; min-height: 24px;
  color: var(--text); font-size: 10px;
}
.routing-snaps li > span {
  display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%;
  color: white; background: var(--danger); font-weight: 800; font-size: 9px;
}
.routing-snaps b { white-space: nowrap; }
.routing-snaps small {
  min-width: 0; overflow: hidden; color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap;
}
.routing-roads { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.routing-roads li {
  padding: 6px 7px; border-left: 2px solid var(--border-strong); background: var(--surface-input);
  border-radius: 4px;
}
.routing-roads li.used { border-left-color: var(--success); }
.routing-roads b {
  display: block; overflow: hidden; color: var(--text); font-size: 10px;
  text-overflow: ellipsis; white-space: nowrap;
}
.routing-roads span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 9px; line-height: 1.35; }

.changelog-dialog {
  width: min(520px, calc(100vw - 32px)); padding: 0; overflow: hidden;
  color: var(--text); background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 9px; box-shadow: 0 24px 70px rgba(15,23,42,.26);
}
.changelog-dialog::backdrop { background: rgba(15,23,42,.24); backdrop-filter: blur(1px); }
.changelog-dialog form { margin: 0; }
.changelog-dialog header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 20px 0;
}
.release-pill {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px;
  color: var(--accent); background: rgba(37,99,235,.08); border: 1px solid rgba(37,99,235,.18);
  border-radius: 999px; font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase;
}
.changelog-body { padding: 16px 24px 6px; }
.changelog-body h2 { margin: 0 0 10px; font-size: 25px; line-height: 1.1; letter-spacing: 0; }
.changelog-body p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.55; }
.changelog-body ul {
  display: grid; gap: 9px; margin: 18px 0 0; padding: 0; list-style: none;
}
.changelog-body li {
  position: relative; padding-left: 19px; color: var(--text-muted); font-size: 13px; line-height: 1.45;
}
.changelog-body li::before {
  content: ""; position: absolute; left: 0; top: .5em; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
}
.changelog-dialog footer {
  display: flex; justify-content: flex-end; padding: 18px 24px 22px;
  border-top: 1px solid var(--border); background: var(--surface-input);
}

.help-dialog {
  width: min(1380px, calc(100vw - 36px)); padding: 0; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: 9px;
  color: var(--text); background: var(--panel); box-shadow: 0 28px 70px rgba(15,23,42,.24);
}
.help-dialog::backdrop { background: rgba(15,23,42,.22); backdrop-filter: blur(1px); }
.help-dialog form { position: relative; margin: 0; }
.help-dialog header {
  position: absolute; right: 18px; top: 16px; z-index: 5;
  display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 0; border: 0;
}
.help-dialog header > div { display: none; }
.help-dialog header span {
  display: block; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em;
}
.help-dialog h2 { margin: 4px 0 0; font-size: 20px; line-height: 1.15; }
.help-shell {
  display: grid; grid-template-columns: 292px minmax(0, 1fr);
  height: min(820px, calc(100vh - 72px)); min-height: 0; max-height: calc(100vh - 72px);
}
.help-sidebar {
  display: flex; flex-direction: column; gap: 14px; min-height: 0; max-height: 100%; padding: 24px 18px;
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--border); background: linear-gradient(180deg, rgba(248,250,252,.96), var(--panel));
}
/* When the window is shorter than the nav, the sidebar must SCROLL, not squash: flex
   children default to shrink, so each group collapsed and its buttons painted over the
   next section (Road Builder overlapping Metro). Keep every child its natural height. */
.help-sidebar > * { flex-shrink: 0; }
[data-theme="dark"] .help-sidebar { background: linear-gradient(180deg, rgba(30,35,45,.96), var(--panel)); }
.help-sidebar-title {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
}
.help-sidebar-title > svg {
  width: 24px; height: 24px; padding: 4px; color: var(--accent);
  border: 1px solid rgba(37,99,235,.18); border-radius: 50%;
}
.help-sidebar-title b { display: block; color: var(--text); font-size: 16px; line-height: 1.2; }
.help-sidebar-title small { display: block; margin-top: 7px; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
.help-search {
  position: relative; display: block; margin: 2px 0 3px; color: var(--text-muted);
}
.help-search svg {
  position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%);
}
.help-search input {
  height: 36px; margin: 0; padding-left: 34px; border-radius: 7px; font-size: 12px;
}
.help-search-empty {
  margin: -4px 0 0; padding: 9px 10px; color: var(--text-muted); font-size: 11px; line-height: 1.35;
  border: 1px dashed var(--border-strong); border-radius: 7px; background: var(--surface-input);
}
.help-nav-group {
  display: grid; gap: 3px; padding-top: 2px;
}
.help-nav-details {
  display: grid; gap: 5px; min-height: 0;
}
.help-nav-details summary {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) 16px; gap: 8px; align-items: center;
  min-height: 34px; padding: 0 9px; color: var(--text-dim); border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 700; list-style: none;
}
.help-nav-details summary::-webkit-details-marker { display: none; }
.help-nav-details summary:hover { color: var(--accent); background: rgba(37,99,235,.08); }
.help-nav-details summary svg { width: 15px; height: 15px; }
.help-nav-details summary svg:last-child { transition: transform .15s ease; }
.help-nav-details[open] summary svg:last-child { transform: rotate(180deg); }
.help-nav-details .help-nav-group {
  padding: 2px 0 0 10px;
  border-left: 1px solid var(--border);
}
.help-nav-group button {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: center;
  min-height: 32px; padding: 0 9px; color: var(--text-dim); text-align: left;
  background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.help-nav-group button:hover,
.help-nav-group button.active {
  color: var(--accent); background: rgba(37,99,235,.08);
}
.help-nav-group button svg { width: 15px; height: 15px; }
.help-more {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
  margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-input);
}
.help-more svg { width: 22px; height: 22px; color: var(--accent); }
.help-more b { display: block; font-size: 12px; color: var(--text); }
.help-more small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; line-height: 1.35; }
.help-main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
.help-home {
  display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
  flex: 1; align-content: start; padding: 52px 28px 28px; min-height: 0; overflow-y: auto;
}
.help-home.active { display: grid; }
.help-topic-card {
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; align-content: start;
  min-height: 170px; padding: 20px; text-align: left; cursor: pointer;
  color: var(--text); background: var(--surface-input); border: 1px solid var(--border);
  border-radius: 9px;
}
.help-topic-card:hover { border-color: rgba(37,99,235,.36); background: var(--panel); }
.help-topic-card > svg {
  width: 34px; height: 34px; padding: 7px; color: var(--accent);
  background: rgba(37,99,235,.08); border-radius: 8px;
}
.help-topic-card b { display: block; font-size: 18px; line-height: 1.2; }
.help-topic-card small {
  display: block; margin-top: 8px; color: var(--text-muted); font-size: 13px; line-height: 1.45;
}
.help-slide {
  display: none; grid-template-columns: minmax(0, 1.62fr) minmax(290px, .72fr); gap: 28px;
  flex: 1; min-height: 0; padding: 52px 28px 24px; overflow-y: auto;
}
.help-slide.active { display: grid; }
.help-slide.getting-started-page {
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, .85fr); align-items: start;
}
.help-slide[data-help-topic="metrics"],
.help-slide.route-page {
  grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 18px;
  padding: 44px 34px 28px;
}
.help-slide[data-help-topic="metrics"] .help-copy,
.help-slide.route-page .help-copy {
  order: -1; align-self: start; max-width: 1080px;
}
.help-slide[data-help-topic="metrics"] .help-copy p,
.help-slide.route-page .help-copy p {
  max-width: 880px;
}
/* article sub-headings + card titles for the detailed method write-ups */
.help-copy h4 {
  margin: 16px 0 2px; color: var(--accent); font-size: 11.5px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
}
.help-steps li b { display: block; margin-bottom: 3px; color: var(--text); }
.help-slide[data-help-topic="metrics"] .help-steps,
.help-slide.route-page .help-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 1100px;
}
.help-slide[data-help-topic="metrics"] .help-steps li,
.help-slide.route-page .help-steps li {
  min-height: 76px; padding: 15px 16px 15px 36px; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); background: var(--surface-input);
  box-shadow: 0 8px 18px rgba(15,23,42,.04);
}
.help-slide[data-help-topic="metrics"] .help-steps li::before,
.help-slide.route-page .help-steps li::before {
  left: 16px; top: 22px; width: 8px; height: 8px;
}
.help-slide[data-help-topic="metrics"] .guide-stage,
.help-slide.route-page .guide-stage {
  min-height: 380px; aspect-ratio: 16 / 8.4;
}
.guide-stage {
  position: relative; min-height: 430px; overflow: hidden; border: 1px solid var(--border);
  border-radius: 8px; background:
    linear-gradient(90deg, rgba(148,163,184,.18) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(148,163,184,.18) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(135deg, #edf5f9, #f8fafc 55%, #e8f4ef);
}
.guide-video {
  position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%;
  display: block; object-fit: contain; opacity: 0; background: #f8fafc;
  transition: opacity .18s ease;
}
.guide-video.is-ready { opacity: 1; }
.guide-video.is-ready + span,
.guide-video.is-ready ~ span { display: none; }
.app-shot-stage {
  display: grid; place-items: center; padding: 10px; background: #edf3f8;
}
[data-theme="dark"] .app-shot-stage { background: #1d2430; }
.help-app-shot {
  width: 100%; height: 100%; display: block; object-fit: contain; object-position: center;
  border-radius: 6px; background: var(--panel);
  box-shadow: 0 10px 28px rgba(15,23,42,.08);
}
.guide-rail {
  position: absolute; left: 16px; top: 16px; bottom: 16px; width: 44px; border-radius: 8px;
  background: rgba(255,255,255,.84); border: 1px solid var(--border);
}
.guide-sidepanel {
  position: absolute; left: 74px; top: 16px; bottom: 16px; width: 104px; border-radius: 8px;
  background: rgba(255,255,255,.84); border: 1px solid var(--border);
}
.guide-mapline {
  position: absolute; height: 8px; border-radius: 999px; background: #6b7b91; opacity: .45;
}
.guide-mapline.one { left: 210px; right: 36px; top: 96px; transform: rotate(-7deg); }
.guide-mapline.two { left: 230px; right: 70px; top: 162px; transform: rotate(18deg); }
.guide-map-pin {
  position: absolute; left: 64%; top: 45%; width: 24px; height: 24px; border-radius: 50% 50% 50% 6px;
  transform: rotate(-45deg); background: var(--accent); box-shadow: 0 5px 14px rgba(37,99,235,.25);
}
.guide-map-pin::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%; background: white;
}
.guide-line {
  position: absolute; left: 12%; right: 11%; top: 53%; height: 16px; border-radius: 999px;
  background: #0f8796; transform: rotate(-12deg); box-shadow: 0 0 0 4px rgba(15,135,150,.14);
}
.guide-stop {
  position: absolute; width: 28px; height: 28px; border-radius: 50%; background: var(--panel);
  border: 6px solid #2563eb; box-shadow: 0 4px 12px rgba(15,23,42,.15);
}
.guide-stop.one { left: 18%; top: 56%; }
.guide-stop.two { left: 47%; top: 45%; }
.guide-stop.three { right: 18%; top: 34%; }
.guide-cursor {
  position: absolute; width: 22px; height: 28px; left: 14%; top: 66%;
  clip-path: polygon(0 0, 0 100%, 32% 77%, 52% 100%, 70% 91%, 50% 68%, 82% 68%);
  background: #111827; filter: drop-shadow(0 6px 10px rgba(15,23,42,.22));
  animation: guide-cursor-route 4s ease-in-out infinite;
}
.guide-stage-tools {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(135deg, #f8fafc, #edf3ff);
}
.guide-tool {
  width: 118px; height: 92px; display: grid; place-items: center;
  color: var(--text-muted); background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.guide-tool.active { color: var(--accent); border-color: rgba(37,99,235,.28); background: rgba(37,99,235,.08); }
.guide-tool svg { width: 34px; height: 34px; }
.guide-stage-tools .guide-cursor { animation-name: guide-cursor-tools; }
.guide-road {
  position: absolute; left: 7%; right: 7%; top: 50%; height: 18px; border-radius: 999px;
  background: #6b7280; transform: rotate(-17deg); opacity: .76;
}
.guide-track {
  position: absolute; left: 42%; top: 18%; bottom: 14%; width: 12px; border-radius: 999px;
  background: #0f8796; transform: rotate(27deg); box-shadow: 0 0 0 4px rgba(15,135,150,.12);
}
.guide-choice {
  position: absolute; width: 70px; height: 54px; display: grid; place-items: center;
  color: var(--accent); background: rgba(255,255,255,.88); border: 1px solid rgba(37,99,235,.24);
  border-radius: 8px; box-shadow: 0 7px 22px rgba(15,23,42,.08);
}
.guide-choice.one { right: 26px; top: 50px; }
.guide-choice.two { right: 26px; top: 116px; color: var(--text-muted); border-color: var(--border); }
.guide-choice svg { width: 26px; height: 26px; }
.guide-stage-crossing .guide-cursor { animation-name: guide-cursor-crossing; }
.guide-panel {
  position: absolute; inset: 44px 56px; border-radius: 8px; background: rgba(255,255,255,.82);
  border: 1px solid var(--border); box-shadow: 0 10px 28px rgba(15,23,42,.08);
}
.guide-bar {
  position: absolute; left: 76px; height: 14px; border-radius: 999px; background: var(--accent);
}
.guide-bar.one { top: 86px; width: 46%; }
.guide-bar.two { top: 128px; width: 70%; background: var(--success); }
.guide-bar.three { top: 170px; width: 34%; background: var(--warning-solid); }
.guide-stage-analytics .guide-cursor { animation-name: guide-cursor-analytics; }
.guide-card {
  position: absolute; left: 36px; right: 36px; height: 48px; border-radius: 8px;
  background: rgba(255,255,255,.84); border: 1px solid var(--border); box-shadow: 0 8px 20px rgba(15,23,42,.06);
}
.guide-card.one { top: 32px; }
.guide-card.two { top: 94px; }
.guide-card.three { top: 156px; }
.guide-card::before {
  content: ""; position: absolute; left: 18px; top: 15px; width: 36%; height: 10px; border-radius: 999px;
  background: var(--border-strong);
}
.guide-card::after {
  content: ""; position: absolute; right: 18px; top: 13px; width: 82px; height: 14px; border-radius: 999px;
  background: var(--success-bg);
}
.guide-meter {
  position: absolute; left: 58px; right: 58px; bottom: 28px; height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--danger-solid), var(--warning-solid), var(--success-solid));
}
.guide-stage-results .guide-cursor { animation-name: guide-cursor-results; }
.guide-method-card,
.guide-method-note {
  position: absolute; border-radius: 8px; background: rgba(255,255,255,.86);
  border: 1px solid var(--border); box-shadow: 0 8px 20px rgba(15,23,42,.06);
}
.guide-method-card { left: 44px; right: 44px; height: 70px; }
.guide-method-card.one { top: 42px; }
.guide-method-card.two { top: 128px; }
.guide-method-card::before {
  content: ""; position: absolute; left: 18px; top: 17px; width: 42%; height: 11px;
  border-radius: 999px; background: var(--border-strong);
}
.guide-method-card::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: 17px; height: 9px;
  border-radius: 999px; background: var(--surface-2);
}
.guide-method-note {
  left: 70px; right: 70px; bottom: 60px; height: 58px; background: rgba(37,99,235,.08);
  border-color: rgba(37,99,235,.22);
}
.guide-method-meter {
  position: absolute; left: 104px; right: 104px; bottom: 36px; height: 9px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--success-solid));
}
.guide-stage-methodology .guide-cursor { animation-name: guide-cursor-methodology; }
.guide-save,
.guide-folder {
  position: absolute; top: 74px; width: 94px; height: 74px; border-radius: 9px;
  background: rgba(255,255,255,.86); border: 1px solid var(--border); box-shadow: 0 8px 22px rgba(15,23,42,.07);
}
.guide-save { left: 22%; }
.guide-folder { right: 22%; }
.guide-save::before,
.guide-folder::before {
  content: ""; position: absolute; left: 21px; right: 21px; top: 22px; height: 12px;
  border-radius: 999px; background: var(--border-strong);
}
.guide-save::after,
.guide-folder::after {
  content: ""; position: absolute; left: 26px; right: 26px; top: 43px; height: 9px;
  border-radius: 999px; background: var(--surface-2);
}
.guide-heart {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%);
  width: 62px; height: 62px; display: grid; place-items: center; border-radius: 50%;
  color: var(--danger); background: white; border: 1px solid rgba(216,40,74,.18);
  box-shadow: 0 12px 28px rgba(216,40,74,.16);
}
.guide-heart svg { width: 28px; height: 28px; }
.guide-stage-support .guide-cursor { animation-name: guide-cursor-support; }
.help-copy { align-self: center; min-width: 0; }
.help-kicker {
  display: block; margin-bottom: 12px; color: var(--accent); font-size: 12px; font-weight: 850;
  letter-spacing: .08em; text-transform: uppercase;
}
.help-copy h3 { margin: 0 0 12px; font-size: 32px; line-height: 1.08; letter-spacing: 0; }
.help-copy p { margin: 0; color: var(--text-dim); font-size: 17px; line-height: 1.55; }
.help-copy p + p { margin-top: 10px; }
.help-steps {
  display: grid; gap: 9px; margin: 18px 0 0; padding: 0; list-style: none;
}
.help-steps li {
  position: relative; padding-left: 19px; color: var(--text-muted); font-size: 14px; line-height: 1.46;
}
.help-steps li::before {
  content: ""; position: absolute; left: 0; top: .5em; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}
.help-callout {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: center;
  margin-top: 16px; padding: 12px; border-radius: 8px; background: var(--danger-bg);
  color: var(--text-dim); border: 1px solid rgba(216,40,74,.16); font-size: 12.5px; line-height: 1.42;
}
.help-callout svg { width: 20px; height: 20px; color: var(--danger); }
.help-mini-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px;
}
.help-mini-grid span {
  min-width: 0; padding: 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-input);
}
.help-mini-grid b { display: block; color: var(--text); font-size: 12px; }
.help-mini-grid small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 10.5px; line-height: 1.35; }
.help-start-gallery {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start;
  gap: 12px; min-height: 0; aspect-ratio: auto; padding: 14px;
  background: linear-gradient(135deg, #edf4f8, #f8fafc);
}
.help-slide.getting-started-page .guide-stage {
  min-height: 0;
}
.help-screenshot-card {
  min-width: 0; margin: 0;
  overflow: hidden; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); box-shadow: 0 8px 18px rgba(15,23,42,.05);
}
.help-screenshot-card img {
  display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: center;
  border-bottom: 1px solid var(--border);
}
.help-screenshot-card figcaption {
  display: block; padding: 9px 10px; color: var(--text-dim); font-size: 12px; font-weight: 750;
}
.metric-visual {
  background:
    radial-gradient(circle at 18% 22%, rgba(37,99,235,.10), transparent 24%),
    linear-gradient(135deg, #f8fbff, #edf4f8 56%, #f7fafc);
}
[data-theme="dark"] .metric-visual {
  background:
    radial-gradient(circle at 18% 22%, rgba(96,165,250,.16), transparent 24%),
    linear-gradient(135deg, #202734, #1d222b 56%, #232832);
}
.metric-map-grid {
  position: absolute; inset: 34px; border-radius: 10px; opacity: .75;
  background:
    linear-gradient(90deg, rgba(148,163,184,.22) 1px, transparent 1px) 0 0 / 58px 58px,
    linear-gradient(0deg, rgba(148,163,184,.20) 1px, transparent 1px) 0 0 / 58px 58px,
    linear-gradient(135deg, rgba(255,255,255,.58), rgba(226,232,240,.55));
  border: 1px solid var(--border);
}
.metric-line,
.metric-arc {
  position: absolute; z-index: 2; height: 12px; border-radius: 999px;
  background: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.10);
}
.metric-line.journey-main { left: 18%; right: 24%; top: 52%; transform: rotate(-18deg); }
.metric-line.journey-alt { left: 24%; right: 34%; top: 40%; height: 7px; background: var(--success-solid); transform: rotate(16deg); }
.metric-line.metro-a { left: 14%; right: 12%; top: 54%; height: 16px; background: #e8590c; transform: rotate(-18deg); }
.metric-line.metro-b { left: 38%; right: 34%; top: 30%; height: 12px; background: #0f8796; transform: rotate(55deg); }
.metric-line.demand-heavy { left: 12%; right: 18%; top: 56%; height: 22px; background: #0f8796; transform: rotate(-10deg); }
.metric-line.demand-light { left: 18%; right: 42%; top: 34%; height: 8px; background: var(--accent); transform: rotate(21deg); }
.metric-line.freq-one { left: 14%; right: 16%; top: 48%; background: var(--success-solid); }
.metric-line.freq-two { left: 20%; right: 30%; top: 62%; height: 7px; background: var(--accent); }
.metric-line.sim-line { left: 12%; right: 12%; top: 51%; height: 13px; background: #0f8796; transform: rotate(-8deg); }
.metric-pin,
.metric-node,
.metric-stop {
  position: absolute; z-index: 3; width: 24px; height: 24px; border-radius: 50%;
  background: var(--panel); border: 6px solid var(--accent); box-shadow: 0 6px 14px rgba(15,23,42,.16);
}
.journey-origin { left: 18%; top: 56%; border-color: var(--success-solid); }
.journey-destination { right: 22%; top: 33%; border-color: var(--danger-solid); }
.reach-origin { left: 48%; top: 48%; }
.metro-one { left: 21%; top: 58%; border-color: #e8590c; }
.metro-two { left: 52%; top: 46%; border-color: #e8590c; }
.metro-three { right: 18%; top: 30%; border-color: #0f8796; }
.stop-a { left: 18%; top: 58%; border-color: #0f8796; }
.stop-b { left: 48%; top: 49%; border-color: #0f8796; }
.stop-c { right: 20%; top: 42%; border-color: #0f8796; }
.metric-iso {
  position: absolute; border-radius: 50%; border: 2px solid rgba(37,99,235,.22);
  background: rgba(37,99,235,.08);
}
.iso-one { width: 130px; height: 130px; left: calc(50% - 65px); top: calc(50% - 65px); }
.iso-two { width: 230px; height: 230px; left: calc(50% - 115px); top: calc(50% - 115px); border-color: rgba(22,163,74,.22); background: rgba(22,163,74,.08); }
.iso-three { width: 330px; height: 330px; left: calc(50% - 165px); top: calc(50% - 165px); border-color: rgba(245,158,11,.24); background: rgba(245,158,11,.07); }
.metric-panel,
.metric-card,
.metric-kpi,
.metric-column {
  position: absolute; z-index: 4; border: 1px solid var(--border); border-radius: 9px;
  background: rgba(255,255,255,.90); box-shadow: 0 12px 26px rgba(15,23,42,.08);
}
[data-theme="dark"] .metric-panel,
[data-theme="dark"] .metric-card,
[data-theme="dark"] .metric-kpi,
[data-theme="dark"] .metric-column { background: rgba(30,35,45,.90); }
.metric-panel { display: grid; gap: 8px; width: 178px; padding: 14px; }
.metric-panel b, .metric-card b, .metric-kpi b, .metric-column b { color: var(--text); font-size: 13px; line-height: 1.2; }
.metric-panel small, .metric-card small, .metric-kpi small, .metric-column small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 10.5px; line-height: 1.3; }
.metric-panel-right { right: 38px; top: 48px; }
.metric-panel-left { left: 42px; top: 46px; }
.metric-card { width: 190px; padding: 14px; }
.metric-card-a { left: 44px; top: 42px; }
.metric-card-b { right: 44px; bottom: 42px; }
.metric-raster {
  position: absolute; inset: 64px 54px 92px; border-radius: 14px; opacity: .92;
  background: linear-gradient(120deg, #ef4444, #f59e0b 35%, #a3e635 66%, #16a34a);
  filter: saturate(.94);
}
.metric-scale {
  position: absolute; left: 70px; right: 70px; bottom: 58px; height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #a3e635, #16a34a);
}
.metric-kpi.big { left: 50px; top: 54px; width: 210px; padding: 18px; }
.metric-kpi.big b { font-size: 34px; letter-spacing: 0; }
.metric-bar {
  position: absolute; left: 70px; right: 70px; height: 18px; border-radius: 999px; background: var(--surface-2);
}
.metric-bar.benefit { top: 210px; background: linear-gradient(90deg, var(--success-solid) 72%, var(--surface-2) 72%); }
.metric-bar.cost { top: 250px; background: linear-gradient(90deg, var(--danger-solid) 34%, var(--surface-2) 34%); }
.metric-agent-grid {
  position: absolute; left: 54px; right: 54px; bottom: 110px; height: 90px;
  background:
    radial-gradient(circle, var(--success-solid) 0 4px, transparent 5px) 0 0 / 28px 28px,
    radial-gradient(circle, var(--danger-solid) 0 3px, transparent 4px) 12px 13px / 42px 34px;
  opacity: .82;
}
.metric-column {
  bottom: 86px; width: 128px; display: grid; align-content: end; padding: 13px;
}
.metric-column.one { left: 86px; height: 150px; }
.metric-column.two { left: calc(50% - 64px); height: 230px; border-color: rgba(22,163,74,.24); }
.metric-column.three { right: 86px; height: 190px; }
.metric-matrix {
  position: absolute; inset: 58px 82px; border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 18px, rgba(255,255,255,.82) 18px 20px, transparent 20px) 0 0 / 34px 34px,
    linear-gradient(0deg, transparent 18px, rgba(255,255,255,.82) 18px 20px, transparent 20px) 0 0 / 34px 34px,
    radial-gradient(circle at 72% 44%, rgba(22,163,74,.72) 0 18px, transparent 19px),
    radial-gradient(circle at 28% 18%, rgba(22,163,74,.48) 0 14px, transparent 15px),
    #edf2f7;
  border: 1px solid var(--border);
}
.metric-slider {
  position: absolute; left: 64px; right: 64px; top: 96px; height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 44%, var(--surface-2) 44%);
}
.metric-slider::after {
  content: ""; position: absolute; left: 42%; top: 50%; width: 26px; height: 26px;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--panel);
  border: 6px solid var(--accent); box-shadow: 0 7px 18px rgba(15,23,42,.16);
}
.metric-arc {
  height: 8px; transform-origin: left center; background: #c2410c;
}
.arc-one { left: 26%; right: 30%; top: 44%; transform: rotate(-34deg); }
.arc-two { left: 32%; right: 18%; top: 58%; transform: rotate(16deg); background: #0f8796; }
.arc-three { left: 20%; right: 46%; top: 68%; transform: rotate(-8deg); background: #c2410c; }
.metric-vehicle {
  position: absolute; z-index: 5; width: 34px; height: 18px; border-radius: 999px;
  background: var(--route-color, #e83f6f); border: 2px solid rgba(15,23,42,.35);
}
.v-one { left: 32%; top: 49%; transform: rotate(-8deg); }
.v-two { right: 28%; top: 42%; transform: rotate(-8deg); }
.metric-method-list {
  position: absolute; left: 78px; right: 78px; bottom: 72px; height: 92px;
  border-radius: 10px; background:
    linear-gradient(var(--surface-2) 0 12px, transparent 12px 26px) 0 0 / 100% 28px;
  border: 1px solid var(--border);
}
.help-dialog footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; border-top: 1px solid var(--border);
}
.help-dots { display: flex; align-items: center; gap: 7px; }
.help-dots button {
  width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: var(--border-strong);
  cursor: pointer;
}
.help-dots button.active { width: 22px; border-radius: 999px; background: var(--accent); }
.primary-action.small {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 13px; font-size: 12px; border-radius: 7px;
}
@keyframes guide-cursor-route {
  0%, 14% { left: 13%; top: 66%; }
  38%, 52% { left: 45%; top: 48%; }
  78%, 100% { left: 73%; top: 36%; }
}
@keyframes guide-cursor-crossing {
  0%, 18% { left: 18%; top: 72%; }
  45%, 58% { left: 46%; top: 48%; }
  84%, 100% { left: 78%; top: 28%; }
}
@keyframes guide-cursor-tools {
  0%, 20% { left: 24%; top: 66%; }
  45%, 60% { left: 48%; top: 44%; }
  84%, 100% { left: 64%; top: 58%; }
}
@keyframes guide-cursor-analytics {
  0%, 18% { left: 18%; top: 72%; }
  48%, 62% { left: 57%; top: 48%; }
  86%, 100% { left: 73%; top: 33%; }
}
@keyframes guide-cursor-results {
  0%, 18% { left: 18%; top: 70%; }
  48%, 62% { left: 72%; top: 38%; }
  86%, 100% { left: 62%; top: 82%; }
}
@keyframes guide-cursor-methodology {
  0%, 18% { left: 20%; top: 72%; }
  42%, 58% { left: 72%; top: 34%; }
  82%, 100% { left: 68%; top: 66%; }
}
@keyframes guide-cursor-support {
  0%, 18% { left: 25%; top: 68%; }
  48%, 62% { left: 68%; top: 48%; }
  86%, 100% { left: 50%; top: 76%; }
}

.relation-dialog {
  position: fixed; inset: 76px 18px auto auto;
  width: min(460px, calc(100vw - 28px)); max-height: calc(100vh - 100px);
  margin: 0; padding: 0; overflow-y: auto; overflow-x: hidden; color: var(--text);
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 7px;
  box-shadow: 0 15px 45px rgba(0,0,0,.55);
}
.relation-dialog::backdrop { background: rgba(5,7,10,.08); }
.relation-dialog form { padding: 15px; min-width: 0; box-sizing: border-box; }
.relation-dialog header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.relation-dialog header > div { min-width: 0; }
.relation-dialog header span {
  color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.relation-dialog h2 { margin: 4px 0 0; font-size: 16px; line-height: 1.2; overflow-wrap: anywhere; }
.relation-dialog > form > p { margin: 9px 0 15px; color: var(--text-muted); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.dialog-close {
  width: 30px; height: 30px; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: transparent; border: 0; border-radius: 4px; cursor: pointer;
}
.dialog-close:hover { color: white; background: var(--surface-2); }
.dialog-close svg { width: 16px; }
.relation-preview {
  position: relative; height: 150px; margin: -5px 0 12px; overflow: hidden;
  background: var(--app-bg); border: 1px solid var(--border); border-radius: 5px;
}
.relation-svg { width: 100%; height: 100%; display: block; }
.relation-svg .rp-existing { stroke: var(--text-faint); stroke-width: 9; stroke-linecap: round; opacity: 0.7; }
.relation-svg .rp-new { stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }
.relation-svg .rp-node { fill: var(--accent); stroke: var(--panel); stroke-width: 2.5; }
.relation-preview span { position: absolute; left: 50%; top: 50%; display: block; }
.preview-existing {
  width: 130%; height: 7px; background: var(--text-faint);
  transform: translate(-50%,-50%) rotate(-18deg);
  box-shadow: 0 0 0 2px var(--surface-input);
}
.preview-proposed {
  width: 120%; height: 6px; background: var(--accent);
  transform: translate(-50%,-50%) rotate(26deg);
  box-shadow: 0 0 0 2px var(--surface-input);
}
.preview-node {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--warning-solid); border: 2px solid white;
  transform: translate(-50%,-50%);
}
.relation-dialog[data-relation="roundabout"] .preview-node {
  width: 24px; height: 24px; background: var(--success-bg);
  border: 5px solid var(--text-faint); box-shadow: 0 0 0 2px var(--surface-input);
}
.relation-dialog[data-relation="bridge"] .preview-proposed {
  z-index: 3; box-shadow: 0 0 0 3px var(--text), 0 0 0 5px var(--surface-input);
}
.relation-dialog[data-relation="underpass"] .preview-existing,
.relation-dialog[data-relation="none"] .preview-existing {
  z-index: 3; box-shadow: 0 0 0 3px var(--surface-input);
}
.relation-dialog[data-relation="none"] .preview-node {
  background: var(--danger-solid);
}
.relation-options { display: grid; grid-template-columns: 1fr; gap: 6px; }
/* Line profile: load between stops + board/alight per stop */
.flow-profile-picker,
.line-profile-card {
  margin-top: 10px; padding: 10px 11px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface-2);
}
.flow-profile-picker-head {
  display: grid; gap: 3px; margin-bottom: 8px;
}
.flow-profile-picker-head b,
.line-profile-head b {
  color: var(--text); font-size: 12px;
}
.flow-profile-picker-head span,
.line-profile-head span,
.flow-profile-picker p {
  color: var(--text-dim); font-size: 10.5px; line-height: 1.4;
}
.flow-profile-picker p { margin: 7px 0 0; }
.flow-route-list {
  display: grid; gap: 5px; max-height: 170px; overflow-y: auto; padding-right: 2px;
}
.flow-route-option {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--panel); color: var(--text); text-align: left; cursor: pointer;
}
.flow-route-option:hover,
.flow-route-option.active {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.flow-route-option span {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11.5px; font-weight: 700;
}
.flow-route-option strong {
  color: var(--text-dim); font-size: 10px; font-weight: 700; white-space: nowrap;
}
.flow-route-option.active strong { color: var(--accent); }
.flow-route-option.no-flow {
  color: var(--text-dim);
}
.flow-route-option.no-flow strong {
  color: var(--text-faint);
}
.flow-map-all {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; margin-top: 7px; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--panel); color: var(--text); cursor: pointer;
  font-size: 10.5px; font-weight: 700;
}
.flow-map-all:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}
.flow-map-all svg { width: 14px; height: 14px; color: var(--accent); }
.line-profile-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px;
}
.line-profile-head span { text-align: right; }
.line-profile-legend {
  display: flex; flex-wrap: wrap; gap: 7px 12px; margin-bottom: 8px;
  color: var(--text-dim); font-size: 10px;
}
.line-profile-legend span { display: inline-flex; align-items: center; gap: 4px; }
.line-profile-legend i { width: 12px; height: 7px; border-radius: 3px; display: inline-block; }
.lp-load-swatch { background: #2a78d6; }
.lp-diagram {
  margin: 8px 0 9px; padding: 8px 9px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel);
}
.lp-diagram svg {
  display: block; width: 100%; height: auto; max-height: 128px; overflow: visible;
}
.lp-diagram text {
  fill: var(--text-dim); font-size: 11px; font-weight: 700;
}
.lp-diagram-key {
  display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 3px;
  color: var(--text-dim); font-size: 10px;
}
.lp-diagram-key span { display: inline-flex; align-items: center; gap: 4px; }
.lp-diagram-key i { width: 12px; height: 7px; border-radius: 3px; display: inline-block; }
.lp-table {
  display: grid; gap: 2px; margin-top: 7px; min-width: 0;
}
.lp-table-head,
.lp-table-row {
  display: grid; grid-template-columns: minmax(150px, 1.4fr) minmax(70px, .55fr) minmax(70px, .55fr) minmax(130px, 1fr);
  align-items: center; gap: 8px; min-width: 0;
}
.lp-table-head {
  padding: 0 8px 3px; color: var(--text-dim); font-size: 9px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
}
.lp-table-row {
  padding: 6px 8px; border-radius: 7px; background: color-mix(in srgb, var(--panel) 74%, transparent);
}
.lp-stop-cell {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-size: 10.5px; font-weight: 800;
}
.lp-on { background: #1baf7a; }
.lp-off { background: #9aa5b1; }
.lp-count {
  display: grid; grid-template-columns: minmax(30px, 1fr) auto; align-items: center; gap: 5px;
  min-width: 0; color: var(--text-dim); font-size: 10px; font-variant-numeric: tabular-nums;
}
.lp-count i,
.lp-load-meter {
  display: block; min-width: 0; height: 8px; border-radius: 4px;
  background: color-mix(in srgb, var(--border) 42%, var(--panel));
}
.lp-count i {
  min-width: 1px;
}
.lp-count.board i { background: #1baf7a; }
.lp-count.alight i { background: #9aa5b1; }
.lp-count.board b { color: #14885f; }
.lp-count.alight b { color: var(--text-dim); }
.lp-count b,
.lp-load-cell b {
  font: inherit; font-weight: 800; white-space: nowrap;
}
.lp-load-cell {
  display: grid; grid-template-columns: minmax(54px, 1fr) auto; align-items: center; gap: 7px;
  min-width: 0; font-size: 10px; color: var(--text); font-variant-numeric: tabular-nums;
}
.lp-load-meter {
  background: color-mix(in srgb, #2a78d6 10%, var(--panel));
}
.lp-load-meter i {
  display: block; height: 8px; border-radius: 4px; background: #2a78d6; min-width: 2px;
}
.lp-load-cell em {
  grid-column: 1 / -1; color: var(--text-dim); font-size: 9.5px; font-style: normal;
}
@media (max-width: 760px) {
  .lp-table-head,
  .lp-table-row {
    grid-template-columns: minmax(120px, 1fr) minmax(58px, .5fr) minmax(58px, .5fr);
  }
  .lp-table-head span:last-child,
  .lp-load-cell {
    grid-column: 1 / -1;
  }
}

/* Exchequer view */
.ap-exch { margin-bottom: 14px; border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; background: var(--surface-2); }
.ap-exch-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); padding: 2.5px 0; }
.ap-exch-row b { color: #16a34a; font-variant-numeric: tabular-nums; }
.ap-exch-row.neg b { color: #dc2626; }
.ap-exch-row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 5px; }
.ap-exch-row.total span { color: var(--text); font-weight: 600; }
.ap-exch-row.total b { color: var(--text); }

/* Corridor finder */
.cor-section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 10px 2px 3px; color: var(--text); font-size: 11px; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
}
.cor-section-title small {
  color: var(--text-faint); font-size: 9px; font-weight: 700; letter-spacing: 0; text-transform: none;
}
.cor-row { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.cor-row > b { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: #c2410c; color: #fff; font-size: 10.5px; }
.cor-row.underserved > b { background: #7c3aed; }
.cor-row.remove > b { background: #dc2626; }
.cor-tag { font-style: normal; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #0e7490; background: #0e749018; padding: 1px 5px; border-radius: 5px; margin-left: 4px; }
.cor-row:has(.cor-apply) { grid-template-columns: 24px 1fr auto; }
.cor-apply { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; font-size: 11px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 7px; cursor: pointer; }
.cor-apply:hover { border-color: var(--accent); color: var(--accent); }
.cor-apply svg { width: 11px; height: 11px; }
.cor-manual { font-size: 9.5px; color: var(--text-faint); white-space: nowrap; cursor: help; }
.cor-copy span { display: block; font-size: 12px; color: var(--text); }
.cor-copy small { font-size: 10.5px; color: var(--text-dim); }

/* Sensitivity tornado */
#ap-tornado .eq-title { display: flex; justify-content: space-between; }
.tor-central { font-weight: 500; color: var(--text-dim); }
.tor-row { display: grid; grid-template-columns: 88px 1fr auto; align-items: center; gap: 7px; margin-bottom: 4px; }
.tor-label { font-size: 10px; color: var(--text-dim); }
.tor-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 4px; }
.tor-bar { position: absolute; top: 2px; bottom: 2px; background: #2a78d6; border-radius: 3px; opacity: 0.85; }
.tor-mid { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--text); border-radius: 1px; }
.tor-val { font-size: 9.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Calibration readout */
.ap-cal-out { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.5; }
.ap-cal-out small { color: var(--text-faint); }
#ap-calibrate { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; }
#ap-calibrate svg { width: 12px; height: 12px; }

/* Printable appraisal report */
.ap-actions { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.ap-actions .ghost-button { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.ap-actions .ghost-button svg { width: 12px; height: 12px; }
#print-sheet { display: none; }
@media print {
  body.printing > *:not(#print-sheet) { display: none !important; }
  body.printing #print-sheet {
    display: block; width: auto; padding: 8mm;
    background: #ffffff; color: #111827;
    --surface: #ffffff; --surface-2: #f3f4f6; --panel: #ffffff;
    --border: #d1d5db; --text: #111827; --text-dim: #4b5563;
    --text-muted: #4b5563; --text-faint: #6b7280;
  }
  body.printing #print-sheet .print-head { border-bottom: 2px solid #111827; margin-bottom: 10px; padding-bottom: 6px; font-size: 16px; }
  body.printing #print-sheet .print-head small { display: block; font-size: 10px; color: #4b5563; font-weight: 400; margin-top: 2px; }
  body.printing #print-sheet .ap-tiles { break-inside: avoid; }
  body.printing #print-sheet details summary { list-style: none; }
}

/* Skim matrix  -  wide panel, readable cells with the minutes printed in them */
.analytics-result-panel.wide { width: min(680px, 96vw); }
.analytics-result-panel.wide[data-tool="skim"] {
  width: fit-content;
  min-width: min(560px, 96vw);
  max-width: min(760px, calc(100vw - 28px));
}
.analytics-result-panel.wide[data-tool="skim"] .analytics-panel-body {
  width: fit-content;
  max-width: 100%;
}
.analytics-result-panel.wide[data-tool="skim"] .planner-note,
.analytics-result-panel.wide[data-tool="skim"] .iso-source {
  width: min(640px, calc(100vw - 84px));
  max-width: 100%;
}
.sk-wrap { overflow-x: auto; margin: 0 auto 8px; width: fit-content; max-width: 100%; }
.sk-table { border-collapse: collapse; width: max-content; }
.sk-table th { font-size: 9px; color: var(--text-dim); font-weight: 600; padding: 2px 4px; text-align: right; white-space: nowrap; }
.sk-table thead th { text-align: center; }
.sk-table tbody th small { font-weight: 400; }
.sk-table td {
  width: 25px; height: 22px; min-width: 25px; border: 1px solid var(--surface); border-radius: 3px;
  text-align: center; font-size: 8.5px; font-variant-numeric: tabular-nums; color: var(--text-dim);
}
.sk-table td.sk-dark { color: #ffffff; }
.sk-table td.sk-self { background: var(--surface-2); }

/* Scenario comparison: KPI delta table */
.cmp-head { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.cmp-head b { color: var(--text); }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 8px; }
.cmp-table th { text-align: right; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); padding: 4px 6px; border-bottom: 1px solid var(--border); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-table th:first-child { text-align: left; }
.cmp-table td { padding: 5px 6px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); border-bottom: 1px solid var(--border); }
.cmp-table td:first-child { text-align: left; color: var(--text-dim); }
.cmp-table td.cmp-better { color: #16a34a; font-weight: 600; }
.cmp-table td.cmp-worse { color: #dc2626; font-weight: 600; }

/* Scenarios workspace: named save/load manager */
.scenario-save-row { display: flex; gap: 7px; margin-bottom: 10px; }
.scenario-save-row input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 12.5px; }
.scenario-save-row .primary-action { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.scenario-panel-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.scenario-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.scenario-row > svg { width: 14px; height: 14px; color: var(--text-dim); }
.scenario-row-copy { min-width: 0; }
.scenario-row-copy b { display: block; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-row-copy span { font-size: 10.5px; color: var(--text-dim); }
.scenario-row button { width: 26px; height: 26px; display: grid; place-items: center; padding: 0; background: transparent; border: 0; border-radius: 6px; color: var(--text-muted); cursor: pointer; }
.scenario-row button:hover { background: var(--surface); color: var(--text); }
.scenario-row button.danger:hover { color: #dc2626; }
.scenario-row button svg { width: 13px; height: 13px; }
.scenario-file-row { display: flex; gap: 7px; }
.scenario-file-row .secondary-action { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.scenario-import-label { cursor: pointer; }

.relation-apply-all {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px;
  width: 100%; min-width: 0; box-sizing: border-box; margin-top: 10px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; line-height: 1.35; color: var(--text); cursor: pointer;
}
.relation-apply-all input[type="checkbox"] {
  display: block; width: 16px; height: 16px; min-width: 16px; margin: 1px 0 0; padding: 0;
  accent-color: #2a78d6; border-radius: 4px;
}
.relation-apply-all span { min-width: 0; overflow-wrap: anywhere; }
.relation-apply-all b { font-weight: 600; }
/* show only the options that make sense for this kind of encounter */
.relation-dialog[data-encounter="crossing"] [data-relation="merge"] { display: none; }
.relation-dialog[data-encounter="endpoint"] [data-relation="intersection"],
.relation-dialog[data-encounter="endpoint"] [data-relation="roundabout"],
.relation-dialog[data-encounter="endpoint"] [data-relation="none"] { display: none; }
.relation-dialog[data-encounter="water"] [data-relation="merge"],
.relation-dialog[data-encounter="water"] [data-relation="intersection"],
.relation-dialog[data-encounter="water"] [data-relation="roundabout"] { display: none; }
/* level-crossing + connect are guideway-only; hide them on road encounters */
.relation-dialog:not([data-encounter^="guideway"]) [data-relation="level_crossing"],
.relation-dialog:not([data-encounter^="guideway"]) [data-relation="connect"] { display: none; }
/* guideway encounters never offer road junctions */
.relation-dialog[data-encounter^="guideway"] [data-relation="merge"],
.relation-dialog[data-encounter^="guideway"] [data-relation="intersection"],
.relation-dialog[data-encounter^="guideway"] [data-relation="roundabout"] { display: none; }
/* guideway crosses water: bridge or tunnel only */
.relation-dialog[data-encounter="guideway-water"] [data-relation="none"],
.relation-dialog[data-encounter="guideway-water"] [data-relation="level_crossing"],
.relation-dialog[data-encounter="guideway-water"] [data-relation="connect"] { display: none; }
/* guideway crosses a road: level crossing / bridge / tunnel / cross-only */
.relation-dialog[data-encounter="guideway-road"] [data-relation="connect"] { display: none; }
/* guideway meets an existing tram line: connect into it, or cross over */
.relation-dialog[data-encounter="guideway-rail"] [data-relation="bridge"],
.relation-dialog[data-encounter="guideway-rail"] [data-relation="underpass"],
.relation-dialog[data-encounter="guideway-rail"] [data-relation="level_crossing"] { display: none; }
/* encounter preview scene */
.relation-svg .rp-water { fill: var(--water, #c9e3f7); stroke: none; opacity: 0.9; }
.relation-svg .rp-building { fill: var(--text-faint); stroke: none; opacity: 0.35; }
.relation-svg .rp-road { fill: none; stroke: var(--border); stroke-width: 5; stroke-linecap: round; opacity: 0.9; }
.relation-svg .rp-new { stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }
.relation-svg .rp-label { fill: var(--text-muted); font-size: 8px; text-anchor: middle; }
/* structure depictions */
.relation-svg .rp-bridge-shadow { fill: rgba(0, 0, 0, 0.22); }
.relation-svg .rp-bridge-deck { fill: var(--panel); stroke: var(--border); stroke-width: 1; }
.relation-svg .rp-bridge-edge { stroke: var(--text); stroke-width: 1.7; stroke-linecap: round; }
.relation-svg .rp-bridge-abut { stroke: var(--text-muted); stroke-width: 3.2; stroke-linecap: round; }
.relation-svg .rp-tunnel-cover { fill: var(--surface-2); opacity: 0.92; }
.relation-svg .rp-tunnel-dash { stroke-width: 5; stroke-dasharray: 3.5 3.5; opacity: 0.5; stroke-linecap: round; }
.relation-svg .rp-portal { fill: none; stroke: var(--text); stroke-width: 2.6; }
.relation-svg .rp-roundabout-ring { fill: none; stroke: var(--accent); stroke-width: 3.6; }
.relation-svg .rp-roundabout-island { fill: var(--surface-2); stroke: var(--accent); stroke-width: 1.3; }
.relation-svg .rp-junction { fill: var(--accent); stroke: var(--panel); stroke-width: 1.6; }
.relation-svg .rp-junction-dot { fill: var(--panel); }
.relation-svg .rp-none-badge { fill: var(--panel); stroke: var(--danger-solid); stroke-width: 1.7; }
.relation-svg .rp-none-x line { stroke: var(--danger-solid); stroke-width: 2.8; stroke-linecap: round; }
.relation-svg .rp-deadend-bar { fill: var(--text); }
.relation-svg .rp-bridge-span-casing { fill: none; stroke: #171a21; stroke-width: 13; stroke-linecap: butt; }
.relation-svg .rp-bridge-span-deck { fill: none; stroke: #eef2f7; stroke-width: 8.5; stroke-linecap: butt; }
.relation-svg .rp-tunnel-span { fill: none; stroke-width: 7.5; stroke-dasharray: 6 5; opacity: 0.6; stroke-linecap: round; }
.relation-options button {
  min-height: 48px; display: grid; grid-template-columns: 26px minmax(0,1fr);
  align-items: center; gap: 8px; min-width: 0; padding: 7px 9px; color: var(--text); text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; cursor: pointer;
}
.relation-options button:hover { background: var(--surface-2); border-color: var(--text-faint); }
.relation-options svg { width: 19px; color: var(--accent); }
.relation-options button > span { min-width: 0; overflow-wrap: anywhere; }
.relation-options b, .relation-options small { display: block; }
.relation-options b { font-size: 12px; }
.relation-options small { margin-top: 2px; color: var(--text-faint); font-size: 10px; line-height: 1.3; }
.relation-options button.current {
  background: var(--accent-strong); border-color: var(--accent);
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: 12px; text-transform: uppercase; color: var(--text-dim); }
.section-heading > div span { display: block; color: var(--text-faint); font-size: 11px; margin-top: 2px; }
.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { display: none; }
.switch span {
  position: relative; width: 28px; height: 16px; border-radius: 8px; background: var(--border-strong);
}
.switch span::after {
  content: ""; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px;
  border-radius: 50%; background: white; transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.days label { text-align: center; cursor: pointer; }
.days input { display: none; }
.days label {
  padding: 6px 0; border: 1px solid var(--border); border-radius: 4px; color: var(--text-faint);
}
.days label:has(input:checked) { color: var(--text); border-color: var(--accent); background: var(--accent-strong); }

.evaluator { padding-bottom: 12px; }
.evaluator-heading { margin-bottom: 11px; }
.section-toggle {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0;
  color: inherit; text-align: left; background: transparent; border: 0; cursor: pointer;
}
.section-toggle svg { width: 16px; height: 16px; color: var(--text-muted); transition: transform .15s; }
.section-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.section-toggle span { min-width: 0; }
.section-toggle b {
  display: block; color: var(--text-dim); font-size: 12px; text-transform: uppercase;
}
.section-toggle small { display: block; margin-top: 2px; color: var(--text-faint); font-size: 11px; }
#journey-panel[hidden] { display: none; }
#clear-journey[hidden] { display: none; }
.journey-inputs {
  display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 7px;
}
.place-field { position: relative; min-width: 0; grid-column: 1; }
.place-field label {
  display: block; margin: 0 0 5px; color: var(--text-muted); font-size: 10px;
}
.place-field input { margin: 0; padding-left: 34px; }
.place-label {
  position: absolute; z-index: 2; left: 8px; top: 25px;
  width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%;
  color: var(--chip-text); background: var(--success-solid); font-size: 9px; font-weight: 800;
  pointer-events: none;
}
.place-label.to { color: white; background: var(--danger); }
.journey-inputs button { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.place-suggestions {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 20;
  display: none; max-height: 210px; overflow-y: auto; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 5px; box-shadow: 0 8px 22px rgba(0,0,0,.45);
}
.place-suggestion { padding: 7px 9px; cursor: pointer; color: var(--text); font-size: 11px; }
.place-suggestion + .place-suggestion { border-top: 1px solid var(--surface-2); }
.place-suggestion:hover, .place-suggestion.selected { background: var(--border); }
.place-suggestion small { display: block; margin-top: 2px; color: var(--text-muted); }
.journey-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 7px; margin-top: 8px;
}
.journey-options input { margin: 0; }
.journey-options select,
.journey-options input {
  width: 100%; min-width: 0;
}
.journey-options select,
.journey-options input {
  min-height: 36px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px;
}
/* Every picker in these tool menus stretches across the full menu width and stacks,
   rather than some sitting in narrow auto-fit columns beside the full-width buttons
   (which read as an awkward half-and-half split). */
.journey-options select,
.journey-options > input { grid-column: 1 / -1; }
.journey-options select:focus,
.journey-options input:focus { outline: none; border-color: var(--accent); }
.journey-options input:disabled,
.journey-options select:disabled {
  opacity: 0.48; cursor: default;
}
.journey-options button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer;
  grid-column: 1 / -1; min-width: 0; min-height: 38px; height: auto; padding: 9px 12px;
  white-space: normal; line-height: 1.15; text-align: center; transition: filter .12s, background .12s;
}
.journey-options button:hover { filter: brightness(1.07); }
/* secondary / diagnostic actions read as outlined, not a second primary */
.journey-options button.secondary {
  background: var(--surface); color: var(--accent); border-color: var(--border);
}
.journey-options button.secondary:hover { border-color: var(--accent); filter: none; }
.journey-options svg { width: 15px; height: 15px; flex: none; }
.planner-note {
  display: flex; align-items: flex-start; gap: 8px; margin: 10px 0 0; padding: 9px 11px;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; font-size: 10.5px; line-height: 1.45; max-width: 100%; overflow-wrap: break-word;
}
.planner-note svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }
#evaluation-result { margin-top: 9px; }
.clear-journey-button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 34px; margin-top: 9px; color: var(--text-muted);
  background: transparent; border: 1px solid var(--border); border-radius: 5px; cursor: pointer;
}
.clear-journey-button:hover { color: var(--text); border-color: var(--danger); }
.clear-journey-button svg { width: 14px; height: 14px; }
.comparison-summary { margin-bottom: 7px; color: var(--success); font-size: 12px; font-weight: 700; }
.comparison-summary.none { color: var(--text-muted); }
/* Journey comparison cards  -  matched to the main Norwich map planner (.jcard) */
.jcard { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 10px 9px 13px; margin-top: 8px; cursor: pointer; }
.jcard.active { border-color: var(--danger); }
.jcard:not(.active):hover { border-color: var(--border-strong); }
/* a coloured left bar + label tint tells the card TYPES apart at a glance (the headline
   "best with proposed" reads as the recommendation; "later departure" recedes) */
.jcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 8px 0 0 8px; background: var(--border-strong); }
.jcard-proposed::before { background: var(--accent); }
.jcard-existing::before { background: var(--text-muted); }
.jcard-fewest::before   { background: #0d9488; }
.jcard-later::before    { background: var(--border); }
.jcard-proposed { background: color-mix(in srgb, var(--accent) 5%, var(--panel)); }
.jcard-proposed .jlabel { color: var(--accent); font-weight: 700; }
.jcard-fewest .jlabel   { color: #0d9488; }
/* Later departures are secondary: lighter, tighter, clearly below the headline options. */
.jcard-later { margin-top: 6px; }
.jcard-later .jlabel { opacity: .75; }
.jcard-later .jtimes { font-size: 13px; font-weight: 500; }
/* a little more air before the first "later departure" separates the two groups */
.jcard-fewest + .jcard-later, .jcard-existing + .jcard-later, .jcard-proposed + .jcard-later { margin-top: 13px; }
.jlabel { display: flex; justify-content: space-between; align-items: baseline; font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px; }
.jhead { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.jtimes { font-size: 14px; white-space: nowrap; }
.jstrip { flex: 1; display: flex; align-items: center; gap: 3px; flex-wrap: wrap; min-width: 0; }
.s-sep { color: var(--text-faint); font-size: 11px; }
.s-walk { font-size: 12px; }
.jtime { margin-left: auto; color: var(--danger); font-size: 15px; flex-shrink: 0; }
.save { color: var(--success); font-weight: 600; font-size: 11px; text-transform: none; letter-spacing: 0; }
.jdetail { margin-top: 9px; border-top: 1px solid var(--border); padding-top: 9px; }
.jcard:not(.active) .jdetail { display: none; }
.tlrow { display: flex; }
.tlt { width: 38px; flex-shrink: 0; font-size: 11px; color: var(--text-muted); text-align: right; padding-right: 2px; line-height: 1.7; }
.tlc { width: 16px; flex-shrink: 0; position: relative; }
.tlc::before { content: ""; position: absolute; left: 6px; top: 2px; bottom: -2px; width: 4px; background: var(--c, var(--text-faint)); border-radius: 2px; }
.tlc.walk::before { width: 0; border-left: 3px dotted var(--text-faint); background: none; left: 7px; }
.tlc.dot::after { content: ""; position: absolute; left: 3px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--on-accent); border: 2px solid var(--c, var(--text-faint)); }
.tlc.end::before { bottom: auto; height: 8px; }
.tlb { flex: 1; min-width: 0; padding: 0 0 13px 8px; font-size: 12px; line-height: 1.45; }
.tlrow:last-child .tlb { padding-bottom: 2px; }
.tlmeta { color: var(--text-muted); }
.refbadge { display: inline-block; color: var(--app-bg); font-weight: 700; border-radius: 4px; padding: 0 6px; }
.impact-legs { color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.impact-error { color: var(--danger); font-size: 11px; line-height: 1.4; }

.journey-endpoint {
  position: relative; z-index: 10;
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  color: var(--chip-text); background: var(--success-solid); border: 2px solid var(--on-accent); font-size: 10px; font-weight: 800;
  box-shadow: 0 1px 5px rgba(0,0,0,.65);
}
.journey-endpoint.destination { background: var(--danger); color: var(--on-accent); }

.stops-section { flex: none; min-height: 160px; padding: 14px 12px 10px 18px; }
#stop-list { list-style: none; margin: 0; padding: 0 6px 0 0; }
.stop-row {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) 28px; align-items: center;
  min-height: 44px; border-bottom: 1px solid var(--surface-2);
}
.stop-index {
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text); font-size: 10px; font-weight: 700;
}
.stop-copy { min-width: 0; padding: 7px 8px; }
.stop-copy b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.stop-copy span { color: var(--text-faint); font-size: 10px; }
.stop-row button { opacity: 0; }
.stop-row:hover button { opacity: 1; }
#empty-stops { color: var(--text-faint); font-size: 12px; line-height: 1.5; padding: 12px 2px; }

.icon-button {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface-2); cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-button.danger:hover { color: var(--danger); border-color: var(--danger-bg); }
.icon-button svg { width: 16px; height: 16px; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px 18px 15px; }
.route-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 11px; }
.route-stats span { color: var(--text-faint); font-size: 10px; }
.route-stats b { display: block; color: var(--text); font-size: 14px; margin-bottom: 1px; }
.footer-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.footer-actions button {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-width: 0;
  height: 34px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 5px; cursor: pointer;
}
.footer-actions button:hover { background: var(--surface-2); }
.footer-actions svg { width: 15px; }

#map-shell { position: relative; min-width: 0; }
/* isolate the map's stacking context: maplibre depth-sorts HTML markers with large
   inline z-indexes, which otherwise float ABOVE the panels overlaid on the map */
#map { position: absolute; inset: 0; z-index: 0; isolation: isolate; }
#map-shell::before,
#map-shell::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  transition: opacity .15s;
}
#map-shell.show-builder-grid::before {
  opacity: .45;
  background-image:
    linear-gradient(rgba(37,99,235,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.18) 1px, transparent 1px);
  background-size: 44px 44px;
}
#map-shell.show-builder-guides::after {
  opacity: .7;
  background:
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(37,99,235,.25) 50%, transparent calc(50% + .5px)),
    linear-gradient(transparent calc(50% - .5px), rgba(37,99,235,.25) 50%, transparent calc(50% + .5px));
}
.builder-palette {
  /* top-centre of the map; the build tools bar sits at the bottom, so the two can
     never collide regardless of how many tools the bar wraps to */
  position: absolute; left: 50%; right: auto; top: 20px; bottom: auto;
  transform: translateX(-50%); z-index: 5;
  display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: stretch; gap: 14px;
  width: min(820px, calc(100% - 40px)); min-height: 106px; padding: 12px 14px;
  background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 16px 40px rgba(15,23,42,.14);
  backdrop-filter: blur(8px);
}
[data-theme="dark"] .builder-palette { background: rgba(27,30,37,.95); }
.builder-palette[hidden] { display: none; }
.builder-palette-label {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  color: var(--text-muted);
}
.builder-palette-label b { color: var(--text); font-size: 12px; }
.builder-palette-label small { font-size: 10px; line-height: 1.35; }
.builder-palette .road-type-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.builder-palette .road-type-gallery button { min-height: 82px; }
.builder-hud {
  position: absolute; left: 50%; bottom: 76px; z-index: 5; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); overflow: hidden;
  min-width: min(720px, calc(100% - 64px));
  background: rgba(255,255,255,.97); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 14px 38px rgba(15,23,42,.16); backdrop-filter: blur(8px);
}
#map-shell.inspector-open .builder-hud {
  left: calc((100% - 348px) / 2);
  min-width: min(720px, calc(100% - 420px));
}
[data-theme="dark"] .builder-hud { background: rgba(27,30,37,.95); }
.builder-hud[hidden] { display: none; }
.builder-hud span {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); grid-template-rows: auto auto;
  gap: 2px 8px; min-width: 0; min-height: 58px; padding: 11px 16px; border-right: 1px solid var(--border);
}
.builder-hud span:last-child { border-right: 0; }
.builder-hud svg { grid-row: 1 / span 2; align-self: center; width: 16px; height: 16px; color: var(--accent); }
.builder-hud small {
  overflow: hidden; color: var(--text-faint); font-size: 9px; text-overflow: ellipsis;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.builder-hud b { overflow: hidden; color: var(--text); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.builder-options {
  position: absolute; left: 50%; bottom: 24px; z-index: 5; transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px; min-height: 38px; padding: 0 16px;
  color: var(--text-muted); background: rgba(255,255,255,.96);
  border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 12px 30px rgba(15,23,42,.14);
  backdrop-filter: blur(8px); font-size: 11px;
}
#map-shell.inspector-open .builder-options { left: calc((100% - 348px) / 2); }
[data-theme="dark"] .builder-options { background: rgba(27,30,37,.95); }
.builder-options[hidden] { display: none; }
.builder-options span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.builder-options svg { width: 14px; height: 14px; color: var(--accent); }
.builder-options b { color: var(--accent); }
.structure-choice-group {
  display: grid; gap: 8px; margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.structure-choice-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 9px; background: var(--surface-input); border: 1px solid var(--border); border-radius: 7px;
}
.structure-choice-copy b { display: block; color: var(--text); font-size: 12px; }
.structure-choice-copy span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 10px; }
.structure-choice-actions { display: flex; gap: 5px; }
.structure-choice-actions button {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px;
  color: var(--text-muted); background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  font-size: 10px; font-weight: 700; cursor: pointer;
}
.structure-choice-actions button.active {
  color: var(--accent); background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.28);
}
.structure-choice-actions svg { width: 13px; height: 13px; }
.infra-category-list {
  display: grid; gap: 8px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.infra-cat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px; overflow: hidden;
}
.infra-cat.coming-soon { width: 100%; padding: 0; text-align: left; cursor: default; opacity: .62; }
.infra-cat-head {
  width: 100%; display: grid; grid-template-columns: 14px 22px minmax(0, 1fr) auto; gap: 10px;
  align-items: center; min-height: 48px; padding: 9px 10px; cursor: pointer;
  list-style: none; color: var(--text-muted);
}
.infra-cat-head::-webkit-details-marker { display: none; }
.infra-cat-head:hover { background: rgba(37,99,235,.04); }
.infra-cat.coming-soon .infra-cat-head { cursor: default; }
.infra-cat[open] > .infra-cat-head {
  color: var(--accent); background: rgba(37,99,235,.06);
  border-bottom: 1px solid var(--border);
}
.infra-cat-chevron {
  width: 14px; height: 14px; flex: none; color: var(--text-muted); transition: transform .15s ease;
}
.infra-cat[open] > .infra-cat-head .infra-cat-chevron { transform: rotate(90deg); }
.infra-cat-chevron.is-static { opacity: .4; }
.infra-category-list svg { width: 18px; height: 18px; }
.infra-cat-chevron { width: 14px; height: 14px; }
.infra-category-list b { display: block; color: var(--text); font-size: 11px; }
.infra-category-list small { display: block; margin-top: 2px; color: var(--text-faint); font-size: 9px; }
.infra-category-list em {
  min-width: 22px; height: 22px; display: grid; place-items: center; font-style: normal;
  color: var(--text-muted); background: var(--surface-2); border-radius: 999px; font-size: 10px; font-weight: 700;
}
.infra-cat-body { padding: 7px 8px 9px; display: flex; flex-direction: column; gap: 6px; }
.map-toolbar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 7px; padding: 5px; background: rgba(255,255,255,.96);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 28px rgba(20,30,48,.15);
  z-index: 3;
}
[data-theme="dark"] .map-toolbar {
  background: rgba(24,27,33,.96);
  box-shadow: 0 8px 28px rgba(0,0,0,.34);
}
.segmented { display: flex; }
.segmented button {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
  border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer;
}
.segmented button:first-child { border-radius: 4px 0 0 4px; }
.segmented button:last-child { border-right: 0; border-radius: 0 4px 4px 0; }
.segmented button:hover { color: var(--text); background: var(--surface-2); }
.segmented button.active { color: white; background: var(--accent-strong); }
.segmented svg { width: 15px; }
.toolbar-toggle {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px;
  color: var(--text-muted); background: transparent; border: 1px solid var(--border-strong);
  border-radius: 5px; cursor: pointer;
}
.toolbar-toggle:hover { color: var(--text); background: var(--surface-2); }
.toolbar-toggle[aria-pressed="true"] {
  color: white; background: var(--accent-strong); border-color: var(--accent);
}
.toolbar-toggle svg { width: 15px; height: 15px; }
.toolbar-toggle[hidden] { display: none; }
#map-status, #routing-state {
  position: absolute; bottom: 170px; left: 50%; transform: translateX(-50%);
  padding: 7px 11px; border-radius: 5px; background: rgba(24,27,33,.94);
  color: white; border: 1px solid rgba(255,255,255,.16); font-size: 11px;
  z-index: 4;
}
#map-status { display: none !important; }
#map-shell.builder-active #map-status { bottom: 148px; }
#map-shell.inspector-open #map-status { left: calc((100% - 348px) / 2); }
#routing-state { bottom: 210px; display: flex; align-items: center; gap: 7px; }
#routing-state[hidden] { display: none; }
#routing-state span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse .8s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }

#route-summary-tray {
  position: absolute; left: 24px; right: 24px; bottom: 24px; z-index: 3;
  min-height: 132px; overflow: hidden; background: rgba(255,255,255,.96);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 35px rgba(20,30,48,.16);
  backdrop-filter: blur(10px);
}
[data-theme="dark"] #route-summary-tray {
  background: rgba(27,30,37,.94);
  box-shadow: 0 10px 35px rgba(0,0,0,.35);
}
.summary-tabs {
  display: flex; align-items: center; gap: 22px; min-height: 44px; padding: 0 22px;
  border-bottom: 1px solid var(--border);
}
.summary-tabs button {
  position: relative;
  height: 44px; padding: 0; color: var(--text-faint); background: transparent; border: 0;
  border-bottom: 2px solid transparent; font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.summary-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.summary-tabs button.coming-soon { cursor: default; opacity: .65; }
.summary-tabs button.coming-soon:hover::after {
  content: "Coming soon";
  position: absolute; top: -31px; left: 50%; transform: translateX(-50%);
  padding: 5px 7px; color: white; background: #111827; border-radius: 4px;
  font-size: 10px; white-space: nowrap; text-transform: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.summary-tabs button.coming-soon:hover::before {
  content: ""; position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #111827;
}
.summary-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px;
  background: var(--border);
}
.summary-metrics span {
  min-width: 0; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 7px;
  align-items: center; min-height: 76px; padding: 14px 16px; background: var(--panel);
}
.summary-metrics i, .summary-metrics svg {
  grid-row: 1 / span 2; align-self: center; width: 16px; height: 16px; color: var(--text-muted);
}
.summary-metrics small {
  grid-column: 2; display: block; overflow: hidden; color: var(--text-faint); font-size: 10px;
  text-overflow: ellipsis; white-space: nowrap;
}
.summary-metrics b {
  grid-column: 2; display: block; min-width: 0; margin-top: 4px; color: var(--text);
  font-size: clamp(16px, 1.5vw, 18px); font-weight: 700; white-space: nowrap;
}
.summary-metrics em { font-style: normal; }

.editor-marker {
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  background: var(--route-color); color: var(--on-accent); border: 2px solid var(--on-accent);
  box-shadow: 0 2px 7px rgba(0,0,0,.55); font-size: 10px; font-weight: 800; cursor: grab;
}
.editor-marker.shape {
  width: 14px; height: 14px; color: transparent; border-width: 2px; background: var(--surface-input);
  border-color: var(--route-color);
}
/* a guideway point tied into the existing tram/light-rail network */
.editor-marker.tram-connection {
  box-shadow: 0 0 0 3px #8b5cf6, 0 2px 7px rgba(0,0,0,.55);
}
.road-control {
  width: 16px; height: 16px; padding: 0; border-radius: 50%;
  border: 2px solid #ffffff; background: var(--accent);
  box-shadow: 0 2px 0 rgba(15,23,42,.24), 0 0 0 3px rgba(37,99,235,.22); cursor: grab;
}
.road-control.endpoint {
  width: 18px; height: 18px; background: var(--accent); border-color: var(--on-accent);
}
.road-control:active { cursor: grabbing; }
.maplibregl-popup-content { color: var(--surface-2); font-size: 12px; }

@media (max-width: 760px) {
  .relation-dialog {
    inset: auto 10px 10px 10px; width: auto; max-height: 48vh;
  }
  .help-dialog { width: calc(100vw - 20px); }
  .help-dialog header { right: 14px; top: 14px; padding: 0; }
  .help-shell { grid-template-columns: 1fr; height: min(760px, calc(100vh - 20px)); min-height: 0; max-height: calc(100vh - 20px); }
  .help-sidebar { max-height: 230px; overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .help-home { grid-template-columns: 1fr; padding: 48px 15px 15px; min-height: 0; }
  .help-topic-card { min-height: 120px; padding: 15px; }
  .help-slide { grid-template-columns: 1fr; padding: 48px 15px 15px; }
  .help-slide.getting-started-page { grid-template-columns: 1fr; }
  .help-slide[data-help-topic="metrics"],
  .help-slide.route-page { padding: 48px 15px 15px; }
  .help-slide[data-help-topic="metrics"] .help-steps,
  .help-slide.route-page .help-steps { grid-template-columns: 1fr; }
  .guide-stage { min-height: 190px; }
  .help-copy h3 { font-size: 23px; }
  .help-copy p { font-size: 15px; }
  .help-steps li { font-size: 13.5px; }
  .help-start-gallery { grid-template-columns: 1fr; }
  .help-dialog footer { padding: 12px 15px; }
  .portal-header { height: 60px; padding: 0 16px; }
  .portal-logo { width: 154px; height: 48px; }
  .portal-brand small { display: none; }
  .portal-status { display: none; }
  .city-browser { width: min(100% - 28px, 560px); padding: 34px 0 48px; }
  .city-browser-heading { margin-bottom: 20px; }
  .city-browser-heading h1 { font-size: 27px; }
  .city-browser-heading > span { font-size: 13px; }
  .city-grid { grid-template-columns: 1fr; }
  .city-card-copy { min-height: 0; }
  .city-card p { min-height: 0; }
  .open-city { margin-top: 17px; }
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 56px minmax(0, 44%) minmax(0, 56%);
    grid-template-areas: "bar" "map" "editor";
  }
  #left-rail, #results-column, .ws-scenario { display: none; }
  #workspace-bar { gap: 8px; padding: 0 10px; }
  .brand-lockup { min-width: 0; }
  .top-modebar {
    left: 10px; right: 10px; bottom: 10px; transform: none;
    width: auto; max-width: none; min-width: 0; overflow-x: auto;
    flex-wrap: nowrap; justify-content: flex-start; padding: 4px; border-radius: 6px;
  }
  .top-modebar button { min-width: 48px; width: 48px; height: 42px; font-size: 0; }
  .top-modebar svg { width: 18px; height: 18px; }
  .ws-actions .ghost-button:not(.theme-toggle):not(.units-toggle) { display: none; }
  #editor-column {
    border-right: 0; border-top: 1px solid var(--border);
  }
  .stops-section { flex: none; min-height: 150px; }
  .panel { padding: 10px 14px; }
  .days { overflow-x: auto; padding-bottom: 2px; }
  .days label { min-width: 40px; }
  .footer-actions { gap: 5px; }
  .footer-actions button { padding: 0 4px; font-size: 12px; }
  .map-toolbar { max-width: calc(100vw - 20px); }
  .segmented button { font-size: 0; padding: 0 12px; }
  .segmented svg { width: 18px; height: 18px; }
  .toolbar-toggle span { display: none; }
  .toolbar-toggle { width: 32px; padding: 0; justify-content: center; }
  #route-summary-tray { display: none; }
  #map-status { bottom: 14px; }
  #routing-state { bottom: 52px; }
}

/* Full-screen loading overlay while the designer loads routes + building impacts.
   Lives inside #app, so it only covers the workspace (not the city-picker portal),
   and #app's `hidden` attribute keeps it out of the way until a city is opened. */
#app-loading {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
  transition: opacity 0.4s ease;
}
#app-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.app-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.app-loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: app-loading-spin 0.8s linear infinite;
}
@keyframes app-loading-spin { to { transform: rotate(360deg); } }
.app-loading-text {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Undo toast  -  surfaces "Undo" after actions (e.g. deleting a route) done from views
   where the editing toolbar (which holds the Undo button) is hidden. */
.undo-toast {
  position: absolute;   /* inside #map-shell, like #map-status, so it centres on the map */
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 14px 11px 18px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.30);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.undo-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
/* shift with the map like #map-status when the inspector panel is open */
#map-shell.inspector-open .undo-toast { left: calc((100% - 348px) / 2); }
.undo-toast-action {
  background: none;
  border: none;
  cursor: pointer;
  color: #7dd3fc;
  font-weight: 700;
  font-size: 13.5px;
  padding: 2px 4px;
}
.undo-toast-action:hover { text-decoration: underline; }

/* Timetable popup shown when an existing route line is clicked. */
.route-timetable .maplibregl-popup-content {
  padding: 0; border-radius: 10px; overflow: hidden;
  background: var(--panel); color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,.28); border: 1px solid var(--border);
}
.route-timetable-popup { min-width: 240px; }
.rt-head {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px;
  background: color-mix(in srgb, var(--rt, #4f9cf5) 16%, var(--panel));
  border-bottom: 1px solid var(--border);
}
.rt-ref {
  flex: none; font-weight: 800; font-size: 13px; color: #fff; background: var(--rt, #4f9cf5);
  padding: 2px 9px; border-radius: 6px; letter-spacing: .3px;
}
.rt-desc { font-weight: 600; font-size: 12.5px; color: var(--text); }
.rt-meta { padding: 9px 14px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.rt-empty { margin: 0; padding: 12px 14px; font-size: 12.5px; color: var(--text-muted); }
.rt-stop { padding: 9px 14px 4px; font-size: 11.5px; color: var(--text-muted); }
.rt-times {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 14px 13px;
  max-height: 168px; overflow-y: auto;
}
.rt-times span {
  font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--text-dim);
  background: var(--surface-2); border-radius: 5px; padding: 2px 6px;
}

/* Day tabs above the grid when per-day GTFS timetables are available. */
.rt-day-tabs { display: flex; gap: 6px; padding: 8px 14px 0; }
.rt-day-tab {
  font: inherit; font-size: 11px; font-weight: 600; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 10px; cursor: pointer;
}
.rt-day-tab.active { color: #fff; background: var(--accent, #4f9cf5); border-color: transparent; }
.rt-day-tab[disabled] { opacity: .45; cursor: default; }

/* Full timetable grid inside the route popup (stops as rows, trips as columns).
   Kept deliberately calm: zebra rows instead of per-cell rules, a faint separator when
   the hour turns over, key stops by default with an expand toggle. */
.rt-dir {
  display: flex; align-items: baseline; gap: 7px;
  padding: 12px 14px 6px; font-size: 12px; font-weight: 700; color: var(--text);
}
.rt-dir-arrow { color: var(--text-dim); font-weight: 400; }
.rt-dir-meta { font-size: 11px; font-weight: 500; color: var(--text-dim); margin-left: auto; white-space: nowrap; }
.rt-grid-wrap { max-height: 300px; max-width: 460px; overflow: auto; margin: 0 8px 4px; border: 1px solid var(--border); border-radius: 7px; }
.rt-grid { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.rt-grid th, .rt-grid td { padding: 4px 9px; font-size: 11px; white-space: nowrap; border: none; }
.rt-grid tr:nth-child(even) th, .rt-grid tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.rt-grid th {
  position: sticky; left: 0; z-index: 1; text-align: left; font-weight: 600;
  color: var(--text-dim); background: var(--panel); max-width: 168px; overflow: hidden; text-overflow: ellipsis;
}
.rt-grid tr:nth-child(even) th { background: var(--surface-2); }
.rt-grid td { color: var(--text); text-align: center; }
.rt-grid td.hr { border-left: 1px solid var(--border); }
.rt-grid tr.rt-gap th { position: sticky; }
.rt-grid tr.rt-gap th::before { content: "⋮  "; color: var(--text-dim); font-weight: 400; }
.rt-expand {
  display: block; margin: 0 14px 12px; padding: 3px 10px;
  font: inherit; font-size: 11px; font-weight: 600; color: var(--text-dim);
  background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.rt-expand:hover { color: var(--text); }

/* Right-hand timetable panel (opened by clicking an existing route line). */
#timetable-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 430px; max-width: 92vw;
  min-width: var(--float-min-width, 360px); min-height: var(--float-min-height, 260px);
  z-index: 7; background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: -10px 0 34px rgba(0,0,0,.20);
  transform: translateX(100%); transition: transform .26s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
#timetable-panel.open { transform: translateX(0); }
#timetable-panel.floating-placed {
  right: auto; bottom: auto; max-width: none; max-height: none;
  border: 1px solid var(--border); border-radius: 12px;
  transform: none; transition: none;
}
#timetable-panel.floating-placed.open { transform: none; }
#timetable-panel[hidden] { display: none; }
.timetable-panel-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.timetable-panel-close:hover { background: var(--surface-input); color: var(--text); }
#timetable-panel-body { overflow-y: auto; height: 100%; }
#timetable-panel-body .route-timetable-popup { min-width: 0; }
#timetable-panel-body .rt-head { padding-right: 52px; cursor: grab; user-select: none; }
#timetable-panel.is-dragging #timetable-panel-body .rt-head { cursor: grabbing; }
#timetable-panel-body .rt-grid-wrap { max-width: none; max-height: 60vh; margin: 0 12px 12px; }

.panel-resize-handle {
  position: absolute; right: 4px; bottom: 4px; z-index: 4;
  width: 18px; height: 18px; cursor: nwse-resize;
  border-radius: 5px; opacity: .55;
}
.panel-resize-handle::before {
  content: ""; position: absolute; right: 4px; bottom: 4px;
  width: 9px; height: 9px;
  background:
    linear-gradient(135deg, transparent 0 42%, var(--text-faint) 43% 48%, transparent 49%),
    linear-gradient(135deg, transparent 0 63%, var(--text-faint) 64% 69%, transparent 70%);
}
.panel-resize-handle:hover,
.is-resizing .panel-resize-handle { opacity: 1; background: color-mix(in srgb, var(--surface-2) 80%, transparent); }

/* Reachability isochrones */
.iso-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; font-size: 12.5px; color: var(--text);
}
.iso-row .save { margin-left: auto; }
.iso-chip { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; opacity: .75; }

/* Analytics: cards in the sidebar, tools in a right-hand panel like the timetable's */
/* compact tile grid  -  twelve tools fit without a scroll; the long description
   lives in the hover tooltip (wired from the hidden span at setup) */
.analytics-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.analytics-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
  padding: 11px 6px 9px; font: inherit; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
}
.analytics-card svg { width: 19px; height: 19px; color: var(--accent); flex: none; }
.analytics-card b { font-size: 11.5px; line-height: 1.25; font-weight: 600; }
.analytics-card span { display: none; }
.analytics-card:hover:not([disabled]) { border-color: var(--accent); }
.analytics-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.analytics-card[disabled] { opacity: .55; cursor: default; }

/* A FITTED floating result window (top-right), height sized to content, not full-height */
.analytics-result-panel {
  position: absolute; top: 14px; right: 14px; width: 360px; max-width: min(760px, 92vw);
  min-width: var(--float-min-width, 320px); min-height: var(--float-min-height, 190px);
  max-height: calc(100% - 28px);
  z-index: 7; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  transform: translateX(calc(100% + 20px)); opacity: 0;
  transition: transform .24s ease, opacity .24s ease, width .18s ease, height .18s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
.analytics-result-panel.open { transform: translateX(0); opacity: 1; }
.analytics-result-panel.floating-placed {
  right: auto; bottom: auto; max-width: none; max-height: none;
  transform: none; transition: opacity .16s ease, width .18s ease, height .18s ease;
}
.analytics-result-panel.is-dragging,
.analytics-result-panel.is-resizing,
#timetable-panel.is-dragging,
#timetable-panel.is-resizing,
#results-column.is-dragging,
#results-column.is-resizing,
.build-inspector.is-dragging,
.build-inspector.is-resizing {
  transition: none !important;
  user-select: none;
}
.analytics-result-panel.floating-placed.open { transform: none; }
.analytics-result-panel[hidden] { display: none; }
.analytics-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text);
  cursor: grab; user-select: none;
}
.analytics-result-panel.is-dragging .analytics-panel-head { cursor: grabbing; }
.analytics-panel-title { flex: 1; }
.analytics-panel-head .timetable-panel-close { position: static; }
.analytics-panel-body { flex: 1; overflow-y: auto; padding: 12px 14px; min-height: 0; scrollbar-gutter: stable; }
/* keep the scrollbar visible on overlay-scrollbar OSes so long reports read as scrollable */
.analytics-panel-body::-webkit-scrollbar { width: 9px; }
.analytics-panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9px; border: 2px solid var(--panel); }
.analytics-panel-body::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.analytics-panel-body .journey-inputs { margin-top: 0; }
.iso-source {
  margin: 10px 2px 0; font-size: 10.5px; line-height: 1.5; color: var(--text-dim);
  border-top: 1px solid var(--border); padding-top: 8px;
}

/* Appraisal + simulation panel bits */
.bcr-headline {
  display: flex; align-items: baseline; gap: 10px;
  margin: 4px 0 10px; padding: 12px 14px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.bcr-headline span { font-size: 11px; font-weight: 700; color: var(--text-dim); }
.bcr-headline b { font-size: 26px; }
.bcr-headline small { color: var(--text-dim); margin-left: auto; text-align: right; }
.bcr-headline.good b { color: #16a34a; }
.bcr-headline.ok b { color: #d97706; }
.bcr-headline.poor b { color: #dc2626; }
#sim-time { width: 100%; margin: 10px 0 4px; }
.sim-readout { display: flex; align-items: baseline; gap: 6px; font-size: 13px; padding: 2px 2px 6px; }
.sim-readout span { color: var(--text-dim); font-size: 11.5px; }
.save-zero { color: var(--text-dim); font-size: 11px; margin-left: auto; white-space: nowrap; }

/* Reachability stat tiles */
.iso-tile {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.iso-tile-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em;
}
.iso-tile-hero { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 2px; }
.iso-tile-sub { font-size: 11.5px; color: var(--text-dim); }
.iso-delta-pill {
  display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  background: color-mix(in srgb, var(--border) 40%, transparent);
}
.iso-delta-pill.gain { color: #14532d; background: #bbf7d0; }

/* Equity mini-chart: newly reached residents by deprivation decile */
.eq-chart { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.eq-title { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.eq-row { display: grid; grid-template-columns: 16px 1fr 52px; align-items: center; gap: 7px; margin: 3px 0; }
.eq-label { font-size: 10.5px; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
.eq-bar { height: 8px; background: color-mix(in srgb, var(--border) 45%, transparent); border-radius: 4px; overflow: hidden; }
.eq-bar span { display: block; height: 100%; background: #3b82f6; border-radius: 4px; }
.eq-val { font-size: 10.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.eq-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 4px; }
.access-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 8px 2px; font-size: 10.5px; color: var(--text-dim); }
.access-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* Overlay layer manager chips (bottom-left of the map) */
#overlay-chips {
  position: absolute; left: 12px; bottom: 34px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.overlay-chip {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.12); width: fit-content;
}
.overlay-chip i { width: 10px; height: 10px; border-radius: 3px; }
.overlay-chip.off { opacity: .55; }
.overlay-chip button {
  font: inherit; background: none; border: 0; cursor: pointer; color: var(--text-dim);
  padding: 0 2px; font-size: 12px; line-height: 1;
}
.overlay-chip button:hover { color: var(--text); }

/* Scenario bar in the workspace header */
.scenario-bar {
  display: flex; align-items: center; gap: 6px; margin-right: 10px;
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2);
}
.scenario-bar > svg { width: 14px; color: var(--text-dim); }
.scenario-bar input[type="text"], #scenario-name {
  width: 130px; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 12px; outline: none;
}
.scenario-bar select {
  max-width: 90px; font-size: 11.5px; border: 0; background: none; color: var(--text-dim);
}
.scenario-bar .ghost-button { padding: 2px 8px; font-size: 11.5px; }

/* ============ Appraisal report card (visual, not a text dump) ============ */
.ap-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
}
.ap-hero-num { font-size: 46px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ap-hero[data-status="good"] .ap-hero-num { color: #16a34a; }
.ap-hero[data-status="ok"]   .ap-hero-num { color: #d97706; }
.ap-hero[data-status="poor"] .ap-hero-num { color: #dc2626; }
.ap-hero-side { flex: 1; min-width: 0; }
.ap-verdict { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 7px; }
.ap-verdict > span::first-letter { text-transform: uppercase; }
.ap-verdict svg { width: 14px; height: 14px; }
.ap-hero[data-status="good"] .ap-verdict svg { color: #16a34a; }
.ap-hero[data-status="ok"]   .ap-verdict svg { color: #d97706; }
.ap-hero[data-status="poor"] .ap-verdict svg { color: #dc2626; }
/* value-for-money meter: tinted TAG bands + a needle + a sensitivity range */
.ap-meter { position: relative; height: 9px; border-radius: 5px; overflow: hidden; display: flex; }
.ap-band { height: 100%; }
.ap-band.poor { flex: 1;   background: #fecaca; }
.ap-band.low  { flex: .5;  background: #fed7aa; }
.ap-band.med  { flex: .5;  background: #fde68a; }
.ap-band.high { flex: 2;   background: #bbf7d0; }
.ap-range { position: absolute; top: 0; height: 100%; background: rgba(15,23,42,.16); }
.ap-needle { position: absolute; top: -2px; width: 2px; height: 13px; background: var(--text); border-radius: 2px; transform: translateX(-1px); box-shadow: 0 0 0 1px var(--panel); }
.ap-meter-scale { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--text-dim); margin-top: 3px; font-variant-numeric: tabular-nums; }

.ap-section-title { display: flex; align-items: baseline; gap: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 4px 0 8px; }
.ap-section-title span { margin-left: auto; font-weight: 500; text-transform: none; letter-spacing: 0; }

.ap-case { margin-bottom: 14px; }
.ap-case-row { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 8px; }
.ap-case-key { font-size: 11px; color: var(--text-dim); }
.ap-bar-track { position: relative; height: 20px; background: color-mix(in srgb, var(--border) 40%, transparent); border-radius: 5px; }
.ap-bar-fill { display: flex; gap: 2px; height: 100%; border-radius: 5px; overflow: hidden; min-width: 2px; }
.ap-seg { display: block; height: 100%; }
.ap-cost-line { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.ap-cost-line span { position: absolute; top: -13px; right: 3px; font-size: 9px; color: var(--text-dim); white-space: nowrap; }
.ap-case-val { grid-column: 2; justify-self: end; font-size: 11.5px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 3px; }
.ap-npv { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px 11px; border-radius: 8px; font-size: 12px; }
.ap-npv span { color: var(--text-dim); }
.ap-npv b { margin-left: auto; font-size: 15px; font-variant-numeric: tabular-nums; }
.ap-npv.pos { background: color-mix(in srgb, #16a34a 12%, transparent); } .ap-npv.pos b { color: #16a34a; }
.ap-npv.neg { background: color-mix(in srgb, #dc2626 12%, transparent); } .ap-npv.neg b { color: #dc2626; }
.ap-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 9px; font-size: 10.5px; color: var(--text-dim); }
.ap-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: 0; margin-right: 4px; }
.ap-legend .ap-cost-key { width: 2px; height: 10px; border-radius: 0; background: var(--text); vertical-align: -1px; }

.ap-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.ap-tile { padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.ap-tile-label { display: block; font-size: 10.5px; color: var(--text-dim); }
.ap-tile-value { display: block; font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.ap-tile-sub { display: block; font-size: 10px; color: var(--text-dim); }

.ap-assumptions { border-top: 1px solid var(--border); padding-top: 8px; }
.ap-assumptions summary { cursor: pointer; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); list-style-position: inside; }
.ap-assumptions summary span { font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.ap-assumptions dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 10.5px; }
.ap-assumptions dt { color: var(--text); font-weight: 600; white-space: nowrap; }
.ap-assumptions dd { margin: 0; color: var(--text-dim); }
.ap-costnote { margin-top: 6px; font-size: 9.5px; color: var(--text-dim); }

/* Agent model: hero uses text colour (surplus is a money figure, not a status), and the
   distributional chart is horizontal bars, one per deprivation decile */
.abm-hero-num { font-size: 34px; color: var(--text) !important; }
.abm-hero-note { font-size: 10.5px; color: var(--text-dim); margin-top: 4px; }
.abm-dist { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.abm-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; }
.abm-row-key { font-size: 10.5px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.abm-row-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.abm-row-fill { height: 100%; border-radius: 4px; min-width: 3px; transition: width .3s ease; }
.abm-row-val { font-size: 10.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; min-width: 42px; }
.abm-dist-axis { display: flex; justify-content: space-between; font-size: 9px; color: var(--text-dim); margin-top: 4px; padding: 0 34px 0 34px; }

/* diverging net-surplus bars (green gain / red loss from a centre baseline) */
.abm-drow { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; margin-bottom: 5px; }
.abm-drow-track { position: relative; height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.abm-drow-center { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border); z-index: 1; }
.abm-drow-fill { position: absolute; top: 0; bottom: 0; border-radius: 3px; min-width: 2px; transition: width .3s ease; }
.abm-row-val.neg { color: #d73027; }

/* #7 saving decomposition + #5 crowding: single-hue / status rows */
.abm-comp, .abm-loads { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.abm-crow { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 8px; }
.abm-crow-key { font-size: 10.5px; color: var(--text-dim); }
.abm-crow-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.abm-crow-fill { height: 100%; background: #1baf7a; border-radius: 4px; min-width: 2px; transition: width .3s ease; }
.abm-crow-val { font-size: 10.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.abm-load { display: grid; grid-template-columns: auto 1fr 40px; align-items: center; gap: 8px; }
.abm-load-ref { font-size: 10.5px; font-weight: 700; color: var(--text); }
.abm-load-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.abm-load-fill { height: 100%; border-radius: 4px; min-width: 2px; transition: width .3s ease; }
.abm-load[data-st="good"] .abm-load-fill { background: #1a9850; }
.abm-load[data-st="warning"] .abm-load-fill { background: #f0a51e; }
.abm-load[data-st="critical"] .abm-load-fill { background: #d73027; }
.abm-load-val { font-size: 10.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* Editable appraisal assumptions */
.ap-editor { margin: 8px 0 4px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.ap-editor > summary { cursor: pointer; padding: 9px 12px; font-size: 12px; font-weight: 700; color: var(--text); list-style-position: inside; }
.ap-editor > summary span { font-weight: 500; color: var(--text-dim); margin-left: 6px; font-size: 11px; }
.ap-ed-group { padding: 4px 12px 8px; }
.ap-ed-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 6px 0 5px; }
.ap-ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.ap-ed-field { display: flex; flex-direction: column; gap: 2px; }
.ap-ed-field span { font-size: 10.5px; color: var(--text-dim); }
.ap-ed-field em { font-style: normal; opacity: .7; }
.ap-ed-field input { width: 100%; box-sizing: border-box; padding: 4px 6px; font: inherit; font-size: 12px; font-variant-numeric: tabular-nums; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); }
.ap-ed-actions { padding: 4px 12px 10px; }
.ap-ed-actions .ghost-button { font-size: 11px; padding: 4px 10px; }

/* Opportunity access continuous legend */
.access-scale { margin: 8px 2px 4px; }
.access-gradient { height: 10px; border-radius: 5px; border: 1px solid var(--border); }
.access-scale-labels { display: flex; justify-content: space-between; margin-top: 3px; font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Appraisal split: left config view with a Back link */
.tool-config { display: flex; flex-direction: column; gap: 0; }
.tool-config,
.tool-config > * { min-width: 0; }
.tool-config .journey-inputs, .tool-config .journey-options { margin-top: 10px; }
/* consistent, professional menu header: back control + tool icon + name + purpose */
.tool-config-head {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 9px;
  padding-bottom: 11px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
}
.tool-config-back {
  width: 28px; height: 28px; display: grid; place-items: center; padding: 0;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; cursor: pointer; transition: color .12s, border-color .12s;
}
.tool-config-back:hover { color: var(--text); border-color: var(--text-faint); }
.tool-config-back svg { width: 15px; height: 15px; }
.tool-config-icon { width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(37,99,235,.10); color: var(--accent); }
.tool-config-icon svg { width: 16px; height: 16px; }
.tool-config-heading { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tool-config-heading b { font-size: 13.5px; color: var(--text); line-height: 1.2; }
.tool-config-heading small { font-size: 10.5px; color: var(--text-dim); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* the old inline back link is replaced by the header's back control */
.analytics-back { display: none; }

/* appraisal: adjusted-BCR note under the meter + wider-impacts-only warning */
.ap-hero-adjusted { margin-top: 7px; color: var(--text-muted); font-size: 11px; line-height: 1.4; }
.ap-hero-adjusted b { color: var(--text); }
.ap-warning {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start;
  margin: 10px 0 2px; padding: 10px 12px; font-size: 11.5px; line-height: 1.5;
  color: var(--text-dim); background: rgba(217,119,6,.08);
  border: 1px solid rgba(217,119,6,.35); border-radius: 8px;
}
.ap-warning svg { width: 16px; height: 16px; margin-top: 2px; color: #d97706; }
.ap-npv small { font-weight: 500; color: var(--text-muted); }

/* appraisal benefit ladder: cumulative BCR tiers, each stating what it adds */
.ap-ladder {
  margin: 10px 0 2px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-input); overflow: hidden;
}
.ap-ladder-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 72px 110px; gap: 8px; align-items: center;
  padding: 7px 11px; font-size: 11.5px; color: var(--text-dim);
}
.ap-ladder-row + .ap-ladder-row { border-top: 1px solid var(--border); }
.ap-ladder-row i { font-style: normal; text-align: right; color: var(--text-muted); }
.ap-ladder-row b { text-align: right; color: var(--text); font-size: 13px; }
.ap-ladder-row b em { font-style: normal; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ap-ladder-row.headline { background: rgba(37,99,235,.07); }
.ap-ladder-row.headline b { color: var(--accent); }
.ap-ladder-note { padding: 7px 11px; font-size: 10.5px; line-height: 1.45; color: var(--text-muted); border-top: 1px dashed var(--border); }
