/* BenjiRoute — Benjiverse colours, dark always, Sora (self-hosted at fonts/). Mobile first. */

:root {
  /* Benjiverse tokens (match benjiverse.app) */
  --void: #070f26;
  --color-bg-top: #0b1736;
  --color-bg-mid: #0b2244;
  --color-bg-bottom: #0a3340;
  --surface: rgba(19, 34, 67, 0.78);
  --surface-hover: #1b2f5a;
  --border: #28406e;
  --ink: #f4f6fb;
  --muted: #9fb2d4;
  --accent-soft: #5eead4;
  --blue: #0e7490;
  --blue-bright: #22b8cf;
  --accent-gradient: linear-gradient(135deg, #5eead4 0%, #0e7490 100%);
  --ui-gradient: linear-gradient(135deg, #5eead4 0%, #22b8cf 100%); /* brand gradient ending at --blue-bright so dark text keeps AA (7:1) */
  --navy-glow: #1d4f91;
  --nebula-violet: #5b3fd0;
  --nebula-magenta: #b0409a;
  --starlight: #ffe9c4;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --sans: "Sora", system-ui, sans-serif;
  --mono: var(--sans);          /* numbers use Sora with tabular figures, no mono face */

  /* app aliases */
  --bg: #0b1736;
  --panel: #0f1d3f;            /* solid stand-in for --surface over the page gradient */
  --raise: #162a54;            /* inputs / chips on a panel */
  --text: var(--ink);
  --line: var(--border);
  --accent: var(--accent-soft);
  --on-accent: #06202b;
  --focus: var(--accent-soft);
  --good: #4ade80;
  --bad: #ff8d93;
  --amber: #fbbf24;
  --c-ok: #3ddc84;
  --c-slow: #ffb020;
  --c-heavy: #ff4d5a;
  --c-closed: #1b1030;
  --c-minor: #8499bf;
  --halo: #070f26;
  --gutter: 14px;
  --tap: 44px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--void);
  color: var(--ink);
  font: 400 16px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
}
body { background-image: linear-gradient(180deg, var(--color-bg-top) 0%, var(--color-bg-mid) 45%, var(--color-bg-bottom) 100%); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
h1, h2 { margin: 0; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; text-wrap: balance; }
h1 em { font-style: normal; color: var(--accent-soft); }
p { margin: 0; }
a { color: var(--accent-soft); }

/* ---------- shared controls (16px inputs: no iOS focus zoom) ---------- */
input[type="text"], input[type="password"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--void);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}
input[type="text"]:focus-visible, input[type="password"]:focus-visible { border-color: var(--accent-soft); outline-offset: 1px; }
input::placeholder { color: var(--muted); opacity: 1; }
.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 23, 54, 0.45);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.3s var(--ease), background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: default; }
.btn-primary {
  background: var(--ui-gradient); border-color: transparent; color: var(--on-accent);
  box-shadow: 0 8px 30px -8px rgba(94, 234, 212, 0.45);
}
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 0 12px; }
.btn-small { min-height: var(--tap); font-size: 0.875rem; padding: 0 14px; }
.btn-danger { color: var(--bad); }
.icon-btn {
  flex: none;
  display: grid; place-items: center;
  width: var(--tap); height: var(--tap);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(11, 23, 54, 0.45);
  color: var(--accent-soft);
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s, transform 0.3s var(--ease);
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) {
  .btn:hover { background: var(--surface-hover); border-color: var(--blue-bright); }
  .btn[aria-disabled="true"]:hover, .btn:disabled:hover { background: rgba(11, 23, 54, 0.45); border-color: var(--line); }
  .btn-primary:hover { background: var(--ui-gradient); box-shadow: 0 10px 36px -6px rgba(94, 234, 212, 0.65); transform: translateY(-2px); }
  .btn-quiet:hover { background: var(--surface-hover); border-color: transparent; color: var(--ink); }
  .icon-btn:hover { background: var(--surface-hover); border-color: var(--blue-bright); }
}
.form-error { color: var(--bad); font-weight: 600; font-size: 0.9375rem; }
.form-error:empty { display: none; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); }
.login-card {
  position: relative;
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 28px 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6);
}
.login-card::before {
  content: ""; position: absolute; left: 24px; right: 24px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
}
.login-card h1 { font-size: clamp(2rem, 9vw, 2.5rem); }
.login-lead { color: var(--muted); margin-bottom: 10px; font: 600 0.75rem/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.login-card label { font-weight: 600; font-size: 0.9375rem; margin-top: 6px; color: var(--ink); }
.login-card .btn { margin-top: 14px; min-height: 48px; }
.login-card .btn + .btn { margin-top: 0; }
.login-text { color: var(--ink); font-size: 1rem; line-height: 1.45; }
.login-alt { text-align: center; font-size: 0.9375rem; margin-top: 6px; }
.login-card .btn:not(.btn-primary):not(.btn-quiet) { border-color: var(--muted); }   /* ≥3:1 against the card */
@media (hover: hover) { .login-card .btn:not(.btn-primary):not(.btn-quiet):hover { border-color: var(--blue-bright); } }
.login-alt a { display: inline-block; min-height: 44px; box-sizing: border-box; padding: 13px 10px; color: var(--accent-soft); text-underline-offset: 3px; }   /* 44px+ touch target */
.login-alt a:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; border-radius: 4px; }
@media (max-height: 420px) {
  .login { align-items: start; padding-top: 12px; padding-bottom: 12px; }
  .login-card { padding: 14px 20px 12px; gap: 4px; }
  .login-card h1 { font-size: 1.5rem; }
  .login-lead { display: none; }
  .login-card .btn { min-height: 44px; margin-top: 8px; }
  .login-alt { margin-top: 0; }
  .login-alt a { padding: 11px 10px; min-height: 44px; }
}

/* ---------- app layout: phone = top / map fills the rest / collapsed sheet ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;   /* collapsed sheet is only as tall as its handle row (+ a peek once a journey exists) */
  grid-template-areas: "top" "map" "sheet";
  height: 100dvh;
}
.app.sheet-open { grid-template-rows: auto 18dvh minmax(0, 1fr); }

.top {
  grid-area: top;
  padding: 6px max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  padding-top: max(6px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  z-index: 800;                 /* suggestion lists overlay the map */
}
.top-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.top-row h1 { font-size: 1.375rem; font-weight: 800; }
.status { flex: 1; min-width: 0; font: 600 0.6875rem/1.3 var(--mono); letter-spacing: 0.01em; color: var(--muted); text-align: right; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; margin: 0 calc(var(--gutter) * -1); padding-inline: var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 23, 54, 0.45);
  color: var(--ink);
  font: inherit; font-size: 0.9375rem; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.25s, border-color 0.25s, color 0.25s;
}
.chip[aria-pressed="true"], .fchip[aria-pressed="true"] { background: var(--ui-gradient); border-color: transparent; color: var(--on-accent); }
.chip-manage { background: transparent; color: var(--muted); }
@media (hover: hover) {
  .chip:hover, .fchip:hover { background: var(--surface-hover); border-color: var(--blue-bright); }
  .chip[aria-pressed="true"]:hover, .fchip[aria-pressed="true"]:hover { background: var(--ui-gradient); filter: brightness(1.08); }
}

.search { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; gap: 8px; align-items: flex-start; }
.combo { position: relative; flex: 1; min-width: 0; }
.combo-btn { position: absolute; right: 0; top: 0; border: 0; background: transparent; }
.combo input.combo-input { padding-right: calc(var(--tap) + 6px); text-overflow: ellipsis; min-width: 0; }
.field > .icon-btn, .field > .go-btn { flex: none; }
.go-btn { min-width: var(--tap); width: var(--tap); height: var(--tap); padding: 0; position: relative; }
.go-btn.is-busy { color: transparent; }
.dots { display: none; }
.go-btn.is-busy .dots { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4px; color: var(--on-accent); }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: dot-bounce 1s var(--ease) infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce { 0%, 70%, 100% { transform: translateY(0); opacity: 0.45; } 35% { transform: translateY(-4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: 1; } }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 900;
  list-style: none; margin: 0; padding: 6px;
  max-height: 42dvh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.7);
}
.combo-list li { display: flex; flex-direction: column; min-height: var(--tap); justify-content: center; padding: 4px 12px; border-radius: 10px; cursor: pointer; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--surface-hover); outline: 2px solid var(--accent-soft); outline-offset: -2px; }
.opt-name { font-weight: 600; }
.opt-sub { font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-msg { font-size: 0.875rem; color: var(--bad); font-weight: 600; }
.search-msg:empty { display: none; }

/* ---------- map ---------- */
.map-wrap { grid-area: map; position: relative; min-height: 0; isolation: isolate; }
.map { position: absolute; inset: 0; background: var(--void); -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }   /* a long-press drops a pin: no iOS callout or text selection on the map */
.map .leaflet-popup-content { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.map-btn {
  position: absolute; left: 10px; top: 80px; z-index: 500;
  min-height: var(--tap); width: var(--tap); padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(11, 23, 54, 0.9); color: var(--accent-soft);
  font: 600 0.6875rem/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer;
}
.map-pill { width: auto; padding: 0 16px; border-radius: 999px; left: auto; white-space: nowrap; }
/* Right edge, stacked from the top of the map (the bottom corners belong to the attribution and the sheet): Check road, Pin centre, then Re-centre. */
.map-road { left: auto; right: 10px; top: 10px; }
.map-pin { left: auto; right: 10px; top: 64px; }
.map-recentre { right: 10px; top: 118px; }
.map-road svg, .map-pin svg { width: 22px; height: 22px; display: block; margin: auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Unavailable ("zoom in first", no signal): dashed outline and muted icon, but never faded, so the button still has 3:1 contrast against the map and can be found. */
.map-road[aria-disabled="true"]:not([data-flash]) { border-style: dashed; border-color: var(--muted); color: var(--muted); }
/* Visible tooltip, to the left of the button: on hover (mouse), keyboard focus, and while a flashed message shows. Not for screen readers (aria-label carries the words). */
.map-tip {
  position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%); z-index: 1;
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(11, 23, 54, 0.95); color: var(--ink);
  font: 600 0.75rem/1.2 var(--mono); letter-spacing: 0.02em; text-transform: none; white-space: nowrap; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity 0.15s;
}
.map-btn:focus-visible { border-radius: 50%; }
.map-pill:focus-visible { border-radius: 999px; }
.map-btn:focus-visible .map-tip, .map-btn[data-flash] .map-tip { opacity: 1; visibility: visible; }
@media (hover: hover) { .map-btn:hover .map-tip { opacity: 1; visibility: visible; } }
@media (prefers-reduced-motion: reduce) { .map-tip { transition: none; } }
.road-cross { position: absolute; left: 50%; top: 50%; z-index: 480; width: 28px; height: 28px; margin: -14px 0 0 -14px; pointer-events: none;
  background: linear-gradient(var(--accent-soft), var(--accent-soft)) center / 2px 100% no-repeat, linear-gradient(var(--accent-soft), var(--accent-soft)) center / 100% 2px no-repeat; filter: drop-shadow(0 0 2px var(--void)); }
.road-cross[hidden] { display: none; }
@media (hover: hover) { .map-btn:hover { background: var(--surface-hover); border-color: var(--blue-bright); } }
.legend {
  /* Top-left, stacked under the zoom and Fit buttons: the bottom corners belong to the map attribution and the sheet. */
  position: absolute; left: 10px; top: 134px; z-index: 500;
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 10px; border-radius: 12px;
  background: rgba(11, 23, 54, 0.88);
  border: 1px solid var(--line);
  font: 600 0.625rem/1.2 var(--mono); letter-spacing: 0.01em; color: var(--ink);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend[hidden] { display: none; }
.lg { display: inline-block; width: 16px; height: 5px; border-radius: 3px; }
.lg-ok { background: var(--c-ok); }
.lg-slow { background: var(--c-slow); }
.lg-heavy { background: var(--c-heavy); }
.lg-closed { background: repeating-linear-gradient(90deg, #f4f6fb 0 3px, #1b1030 3px 6px); border: 1px solid #f4f6fb; height: 7px; }

/* ---------- sheet ---------- */
.sheet {
  grid-area: sheet;
  min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  margin-top: -10px;
  padding-bottom: env(safe-area-inset-bottom);   /* collapsed: the handle row sits above the home indicator */
  position: relative; z-index: 600;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}
.sheet-handle {
  flex: none;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap);
  border: 0; background: transparent; color: var(--muted);
  font: 600 0.6875rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; touch-action: manipulation;
}
@media (hover: hover) { .sheet-handle:hover { color: var(--ink); } }
.grip { width: 36px; height: 5px; border-radius: 3px; background: var(--border); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-chev { width: 8px; height: 8px; margin-left: 2px; border: solid currentColor; border-width: 2px 0 0 2px; transform: translateY(2px) rotate(45deg); }   /* points up: "more" */
.sheet-handle[aria-expanded="true"] .sheet-chev { transform: translateY(-2px) rotate(225deg); }   /* points down: "less" */
.sheet-handle:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -4px; border-radius: 12px; }
@media (prefers-reduced-motion: no-preference) { .sheet-chev { transition: transform 0.25s var(--ease); } }

/* Phone: collapsed = handle row only (home) or a short peek of the summary (journey). Expanded = the full sheet. */
@media (max-width: 799.98px) {
  .app { --sheet-lap: 10px; }
  .app:not(.sheet-open) .sheet-body { display: none; }
  .app:not(.sheet-open).has-route .sheet-body { display: block; flex: none; max-height: min(24dvh, 220px); }
  .leaflet-bottom { margin-bottom: var(--sheet-lap, 0px); }   /* the sheet overlaps the map by its 10px lip: keep the attribution above it */
}

.banners { display: flex; flex-direction: column; }
.banner { padding: 9px var(--gutter); font-size: 0.8125rem; line-height: 1.35; font-weight: 600; border-left: 4px solid transparent; }
.banner-hint { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner-demo { background: #2c2268; color: var(--starlight); border-left-color: var(--nebula-violet); }
.banner-warn { background: #3d2c05; color: #ffe2a0; border-left-color: var(--amber); }
.banner-error { background: #4a1220; color: #ffd6db; border-left-color: var(--c-heavy); }

.summary { padding: 10px var(--gutter) 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 4px; align-items: center; border-bottom: 1px solid var(--line); }
.summary-text { display: contents; }
.summary-head { grid-column: 1; font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
.summary-actions { grid-column: 2; }
/* With the 2.7 start button the actions need a full row: button first and full width, then Save etc. */
.summary-actions:has(.nav-start) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.summary-actions .nav-start { order: -1; flex: 1 1 100%; }
.trip-main { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; font-family: var(--sans); font-weight: 800; font-size: 1.875rem; line-height: 1.15; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.trip-time.d-ok, .delay-pill.d-ok { color: #3ddc84; }
.trip-time.d-slow, .delay-pill.d-slow { color: #ffb020; }
.trip-time.d-bad, .delay-pill.d-bad { color: #ff4d5a; }
.trip-arrive { color: var(--ink); white-space: nowrap; }
.trip-arrive small { display: inline-block; margin-right: 6px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); vertical-align: middle; }
.trip-delay { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.delay-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1.5px solid currentColor; background: rgba(7, 15, 38, 0.55); font-weight: 800; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.trip-norm { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.trip-count { grid-column: 1; justify-self: start; min-height: 32px; padding: 0; border: 0; background: none; color: var(--ink); font: 600 0.9375rem/1.3 var(--sans); text-align: left; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 4px; cursor: pointer; }
.trip-count:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (max-width: 380px) { .trip-main { font-size: 1.625rem; } }
/* v2.6 trip brief: calm plain-English line under the journey time. 1rem, muted, capped at 3 lines on phones so options stay in view. */
.trip-brief { grid-column: 1 / -1; margin: 0; max-width: 62ch; font-size: 1rem; font-weight: 400; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.trip-brief:empty { display: none; }
@media (max-width: 799px) { .trip-brief { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; } }
.trip-brief strong, .trip-brief b { font-weight: 600; color: var(--ink); }

.count { display: inline-block; min-width: 1.6em; margin-left: 2px; padding: 0 7px; border-radius: 999px; background: var(--void); border: 1px solid var(--line); font: 600 0.6875rem/1.6 var(--mono); text-align: center; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 8px var(--gutter); scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(11, 23, 54, 0.45); color: var(--ink);
  font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: background-color 0.25s, border-color 0.25s;
}


/* ---------- incident cards ---------- */
.cards { list-style: none; margin: 0; padding: 0; }
.card { border-bottom: 1px solid var(--line); padding: 2px 0 6px; }
.card-main {
  display: flex; gap: 12px; width: 100%; min-height: var(--tap);
  padding: 10px var(--gutter) 4px;
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
/* a problem you have already driven past: greyed, still readable */
.card-passed .card-main, .card-passed .card-meta, .card-passed .card-toggle { opacity: 0.7; filter: grayscale(1); }
.card-main[aria-current="true"] { background: var(--surface-hover); }
@media (hover: hover) { .card-main:hover { background: var(--surface-hover); } }
.card-icon {
  position: relative; flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-minor); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line);
}
.card-icon svg, .inc-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--void); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sev-heavy.card-icon, .sev-heavy.inc-icon { background: var(--c-heavy); }
.sev-slow.card-icon, .sev-slow.inc-icon { background: var(--c-slow); }
.sev-closed.card-icon, .sev-closed.inc-icon { background: var(--c-closed); }
.sev-closed svg { stroke: #fff; }
.sev-closed.card-icon { box-shadow: 0 0 0 1px #f4f6fb; }
.icon-q {
  position: absolute; right: -4px; top: -4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); color: var(--void); border: 1px solid var(--void); font: 700 11px/14px var(--sans); text-align: center;
}
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.card-where { font: 600 0.6875rem/1.4 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-soft); }
.card-partial { font: 500 0.6875rem/1.4 var(--mono); color: var(--muted); }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.card-facts { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 0.875rem; color: var(--muted); }
.delay { font-weight: 600; font-size: 0.8125rem; color: var(--amber); }
.delay-unknown { color: var(--muted); }
.delay-closed { color: var(--bad); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--gutter) 0 calc(var(--gutter) + 48px); }
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--void);
  font: 600 0.6875rem/1.6 var(--mono); letter-spacing: 0; color: var(--muted);
}
.badge.trend-worse { color: var(--bad); border-color: var(--bad); }
.badge.trend-better { color: var(--good); border-color: var(--good); }
.badge.confirmed { color: var(--good); border-color: var(--good); }
.badge.warn { color: var(--amber); border-color: var(--amber); }
.card-toggle {
  display: flex; align-items: center; gap: 6px;
  min-height: var(--tap); margin-left: calc(var(--gutter) + 36px); padding: 0 12px;
  border: 0; background: transparent; color: var(--accent-soft); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer;
}
.chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.card-toggle[aria-expanded="true"] .chev { transform: rotate(225deg); }
.timeline { padding: 0 var(--gutter) 8px calc(var(--gutter) + 48px); font-size: 0.875rem; }
.tl { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--blue); }
.tl li { padding: 3px 0 3px 8px; display: flex; gap: 8px; }
.tl-time { flex: none; font-weight: 600; font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--accent-soft); }
.tl-empty, .tl-end, .tl-detail { color: var(--muted); margin-top: 4px; }

.empty { padding: 20px var(--gutter); color: var(--muted); }
.empty-good { color: var(--good); font-weight: 600; }
.note { padding: 10px var(--gutter); font-size: 0.8125rem; color: var(--muted); }
#tripStore .btn { display: flex; width: fit-content; margin-top: 6px; }
.credit { padding: 8px var(--gutter) 12px; border-top: 1px solid var(--line); font-size: 0.75rem; color: var(--muted); }
.noscript { padding: var(--gutter); }

/* ---------- desktop mouse drag + wheel on horizontal scrollers (app.js enableDragScroll) ---------- */
.drag-x.can-drag, .drag-x.can-drag * { cursor: grab; }
.drag-x.is-dragging, .drag-x.is-dragging * { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.drag-x.is-dragging, .drag-x.is-wheeling { scroll-snap-type: none; scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce) { .drag-x { scroll-behavior: auto; } }

/* ---------- incident card: bottom sheet on phones, right-hand panel from 800px ---------- */
.inc-card {
  position: fixed; inset: auto 0 0 0; margin: 0;
  width: 100%; max-width: none; height: auto; max-height: 50dvh;   /* non-modal: the zoomed incident stays visible above it */
  z-index: 1200;                 /* non-modal dialogs are not in the top layer: sit above Leaflet controls (z 1000) */
  padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  overscroll-behavior: contain;
}
.inc-card[open] { display: flex; flex-direction: column; animation: inc-up 0.28s var(--ease); will-change: transform, opacity; /* iOS Safari: avoid a stale frame */ }
/* While the card is open, keep the map's own controls and attribution clear of it. */
.app.card-open .map-recentre, .app.card-open .map-road, .app.card-open .map-pin { right: calc(10px + var(--card-r, 0px)); }
.app.card-open .road-cross { display: none; }
.btn-start { align-self: flex-start; }
.pop-btn { margin-top: 8px; }
.app.card-open .leaflet-bottom.leaflet-right { margin-right: var(--card-r, 0px); margin-bottom: calc(var(--sheet-lap, 0px) + var(--card-b, 0px)); }
@keyframes inc-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes inc-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.inc-card-head {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 14px max(6px, env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.inc-card-icon {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--c-minor); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line);
}
.inc-card-icon:empty { display: none; }
.inc-card-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--void); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.inc-card-icon.sev-heavy { background: var(--c-heavy); }
.inc-card-icon.sev-slow { background: var(--c-slow); }
.inc-card-icon.sev-closed { background: var(--c-closed); box-shadow: 0 0 0 1px #f4f6fb; }
.inc-card-icon.sev-closed svg { stroke: #fff; }
.inc-card-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.inc-card-head h2:focus { outline: none; }
.inc-card-head h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.inc-card-close {
  flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%;
  background: transparent; color: var(--ink); font: 400 1.75rem/1 var(--sans); cursor: pointer;
}
@media (hover: hover) { .inc-card-close:hover { background: var(--surface-hover); } }

.inc-card-body {
  container: incbody / inline-size;
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 14px max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 20px;     /* rhythm between sections; tighter (6px) inside one */
  font-size: 1rem; line-height: 1.5;
}
.inc-card-body > * { margin: 0; }

.inc-sev {
  display: inline-block; align-self: flex-start; padding: 2px 12px; border-radius: 999px;
  border: 1.5px solid currentColor; font-size: 0.875rem; font-weight: 700; line-height: 1.5; color: var(--muted);
}
.inc-sev-1 { color: var(--c-minor); }
.inc-sev-2 { color: var(--amber); }
.inc-sev-3 { color: var(--c-heavy); }
.inc-sev-4 { color: var(--bad); background: var(--c-closed); }

.inc-facts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }   /* always one row; fewer facts = fewer tiles */
.inc-fact { min-width: 0; padding: 10px 8px 10px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--raise); }
.inc-fact-label { display: block; font-size: 0.75rem; font-weight: 600; line-height: 1.3; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.inc-fact .inc-fact-sub { display: block; margin-top: 4px; font-size: 0.8125rem; font-weight: 500; line-height: 1.3; }
.inc-fact-value { display: block; margin-top: 2px; font: 800 1.3125rem/1.15 var(--sans); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }   /* 1.3125rem keeps '+10 min' on one line in a phone-width tile; 1.5rem from 400px up */
@media (min-width: 400px) { .inc-fact-value { font-size: 1.5rem; } }
.inc-fact-value.delay-low { color: var(--c-ok); }
.inc-fact-value.delay-mid { color: var(--c-slow); }
.inc-fact-value.delay-high { color: var(--c-heavy); }

.inc-section { display: flex; flex-direction: column; gap: 6px; }
.inc-section h3 { margin: 0; font-size: 0.8125rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-soft); }
.inc-section p { margin: 0; overflow-wrap: anywhere; }
.inc-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.inc-events li { padding-left: 16px; position: relative; overflow-wrap: anywhere; }
.inc-events li::before { content: ""; position: absolute; left: 0; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft); }
.inc-note { color: var(--ink); }
.inc-warn { padding: 10px 12px; border-left: 4px solid var(--amber); border-radius: 0 10px 10px 0; background: var(--raise); }
.inc-note[hidden] { display: none; }
.inc-gone { padding: 12px 14px; border: 1px solid var(--bad); border-radius: 12px; background: #4a1220; color: #ffd6db; font-weight: 600; }
.inc-meta { font-size: 0.875rem; color: var(--muted); }
.inc-card .tl { font-size: 1rem; }
.inc-card .tl li { flex-direction: column; gap: 0; padding-block: 5px; }
.inc-card .tl-time { font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.inc-card .tl-text { color: var(--ink); }
.inc-card .tl-empty, .inc-card .tl-end, .inc-card .tl-detail { font-size: 0.875rem; }
/* Optional hooks (need card.js classes): .inc-where-main = junction line; .inc-secondary = small muted detail line */
.inc-note.inc-where-main { font-size: 1.125rem; font-weight: 600; line-height: 1.35; }
.inc-note.inc-secondary { font-size: 0.875rem; color: var(--muted); }

.inc-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.inc-links a {
  display: flex; align-items: center; min-height: var(--tap); padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--raise);
  color: var(--accent-soft); font-weight: 600; text-decoration: none; overflow-wrap: anywhere;
}
@media (hover: hover) { .inc-links a:hover { background: var(--surface-hover); border-color: var(--blue-bright); } }
.inc-showmap {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px; background: var(--ui-gradient); color: var(--on-accent);
  font: 700 1rem/1 var(--sans); cursor: pointer;
  position: sticky; bottom: 0; z-index: 1;
  margin-bottom: calc(14px + env(safe-area-inset-bottom));
  /* solid panel colour round it (and a soft fade above) so scrolling content never shows through the gap */
  box-shadow: 0 0 0 14px var(--panel), 0 calc(14px + env(safe-area-inset-bottom)) 0 14px var(--panel), 0 -18px 14px 2px var(--panel);
}

@media (min-width: 800px) {
  .inc-card {
    inset: 0 0 0 auto; width: min(420px, 100vw); height: 100dvh; max-height: none;
    border: 0; border-left: 1px solid var(--line); border-radius: 0;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  }
  .inc-card[open] { animation-name: inc-in; }
}
@media (prefers-reduced-motion: reduce) { .inc-card[open] { animation: none; will-change: auto; } }

/* ---------- dialogs ---------- */
.dialog {
  width: min(92vw, 420px); padding: 24px 22px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
  overscroll-behavior: contain;
}
.dialog::backdrop { background: rgba(7, 15, 38, 0.72); }
.dialog h2 { font-size: 1.375rem; margin-bottom: 14px; }
.dialog label { display: block; font-weight: 600; margin-bottom: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.manage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.manage-row { display: flex; gap: 6px; align-items: center; }
.manage-row input { flex: 1; min-width: 0; }

/* ---------- desktop: left panel 380px, map right ---------- */
@media (min-width: 800px) {
  .app, .app.sheet-open {
    grid-template-columns: 380px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top map" "sheet map";
  }
  .top { border-right: 1px solid var(--line); }
  .sheet { margin-top: 0; border-radius: 0; border-top: 0; border-right: 1px solid var(--line); box-shadow: none; z-index: 1; }
  .sheet-handle { display: none; }
  .map-wrap { z-index: 0; }
}

/* ---------- map elements ---------- */
.j-pill {
  background: var(--void); color: var(--accent-soft);
  border: 1.5px solid var(--accent-soft); border-radius: 999px;
  font: 600 10px/16px var(--mono); letter-spacing: 0;
  text-align: center; white-space: nowrap; box-shadow: 0 0 10px rgba(7, 15, 38, 0.9);
}
.inc-icon { display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--ink); background: var(--c-minor); box-shadow: 0 0 0 2px var(--halo), 0 2px 6px rgba(0, 0, 0, 0.6); }
.pin { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); font: 800 13px/22px var(--sans); text-align: center; box-shadow: 0 0 0 2px var(--halo), 0 2px 6px rgba(0, 0, 0, 0.6); }
.pin-start { background: var(--accent-soft); color: var(--on-accent); }
.pin-end { background: var(--void); color: var(--ink); }
.pin-drop { background: var(--amber); border-color: var(--void); box-shadow: 0 0 0 2px var(--amber), 0 2px 6px rgba(0, 0, 0, 0.6); }   /* amber: not the route's teal start or dark end pin */
.pin-drop::after { content: ""; display: block; width: 8px; height: 8px; margin: 6px auto 0; border-radius: 50%; background: var(--void); }
.pin-note:empty { display: none; }
.app.pin-open .map-road, .app.pin-open .map-pin, .app.pin-open .map-recentre { visibility: hidden; }
@media (forced-colors: active) { .pin-drop { forced-color-adjust: none; background: Highlight; border-color: HighlightText; box-shadow: 0 0 0 2px Highlight; } .pin-drop::after { background: HighlightText; } }
/* Speed camera icon (2.11.0): a round badge in a plain unclassed marker root, like .pin. Amber for a camera, teal for a device of an average-speed section. */
.cam { width: 26px; height: 26px; box-sizing: border-box; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--void); background: var(--amber); box-shadow: 0 0 0 2px var(--ink), 0 2px 6px rgba(0, 0, 0, 0.6); }
.cam-avg { background: var(--accent-soft); }
.cam svg { width: 16px; height: 16px; fill: none; stroke: var(--void); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (forced-colors: active) { .cam { forced-color-adjust: none; background: Canvas; border-color: CanvasText; box-shadow: 0 0 0 2px Canvas; } .cam svg { stroke: CanvasText; } }

/* you: pulsing dot + accuracy circle (+ heading arrow); static under reduced motion */
.me-icon { position: relative; }
.me-pulse { position: absolute; inset: 8px; border-radius: 50%; background: rgba(56, 189, 248, 0.5); animation: me-pulse 2s ease-out infinite; }
.me-dot { position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; border-radius: 50%; background: #38bdf8; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--halo), 0 2px 8px rgba(0, 0, 0, 0.6); }
.me-head { position: absolute; inset: 0; transform-origin: 50% 50%; }
.me-head::before { content: ""; position: absolute; left: 15px; top: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 11px solid #fff; filter: drop-shadow(0 0 2px var(--halo)); }
@keyframes me-pulse { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(2.2); opacity: 0; } }

/* tiles: invert the light OSM raster into the dark theme; roads and names stay legible */
/* The filter goes on each tile, not the pane: filtering the whole scaled pane left 1px black seams along tile edges. */
.leaflet-tile-pane .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(1.08) contrast(0.95) saturate(0.6); }
.leaflet-container { font: inherit; background: var(--void); }
.leaflet-container a.leaflet-popup-close-button { width: 44px; height: 44px; font-size: 22px; line-height: 44px; color: var(--muted); }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--ink); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6); }
.leaflet-popup-content-wrapper { border-radius: 16px; }
.leaflet-popup-content p { margin: 0; }
.leaflet-popup-content { margin: 12px 44px 12px 14px; font-size: 0.9375rem; line-height: 1.4; }
.leaflet-popup-content .pop-dir { margin: 0 0 2px; font: 600 0.6875rem/1.4 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-soft); }
.pop-title { margin: 0; font-weight: 600; }
.leaflet-popup-content .pop-meta { margin: 2px 0 0; color: var(--muted); font-size: 0.875rem; }
.leaflet-popup-content .pop-delay { margin: 4px 0 0; font: 600 0.8125rem/1.4 var(--mono); color: var(--amber); }
.leaflet-control-attribution { background: rgba(7, 15, 38, 0.85) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--accent-soft) !important; }
.leaflet-bar { border: 1px solid var(--line) !important; border-radius: 22px !important; overflow: hidden; box-shadow: none !important; }
.leaflet-bar a { background: rgba(11, 23, 54, 0.92); color: var(--accent-soft); border-bottom-color: var(--line); }
.leaflet-bar a:hover, .leaflet-bar a:focus-visible { background: var(--surface-hover); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .leaflet-fade-anim .leaflet-popup, .leaflet-zoom-anim .leaflet-zoom-animated { transition: none !important; }
  * { scroll-behavior: auto !important; transition: none !important; }
  .btn:active, .icon-btn:active, .btn-primary:hover { transform: none; }
  .me-pulse { animation: none; opacity: 0.35; transform: scale(1.2); }
}

/* v2.6 incident story: three plain-English parts at the top of the card body */
.story { display: flex; flex-direction: column; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--raise); }
.story > *, .story-part { margin: 0; min-width: 0; }
.story-part { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.story h3 { margin: 0; font-size: 0.8125rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-soft); }
.story p { margin: 0; font-size: 1.0625rem; line-height: 1.5; color: var(--ink); overflow-wrap: anywhere; }
.story > :first-child p, .story > h3:first-child + p { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
/* confidence chip: word + dot glyph + coloured border, so never colour alone; text stays --ink for AA */
.conf { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; min-height: 32px; padding: 2px 12px; border: 2px solid var(--conf, var(--muted)); border-radius: 999px; background: var(--void); color: var(--ink); font-size: 0.9375rem; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.conf::before { content: var(--conf-dots, "\25CB\25CB\25CB") / ""; color: var(--conf, var(--muted)); letter-spacing: 0.08em; font-size: 0.8125rem; }
.conf-high { --conf: var(--good); --conf-dots: "\25CF\25CF\25CF"; }
.conf-medium { --conf: var(--amber); --conf-dots: "\25CF\25CF\25CB"; }
.conf-low { --conf: var(--bad); --conf-dots: "\25CF\25CB\25CB"; }
@media (forced-colors: active) { .story { border-color: CanvasText; } .story h3 { color: CanvasText; } .conf { border: 2px solid CanvasText; background: Canvas; color: CanvasText; forced-color-adjust: none; } .conf::before { color: CanvasText; } .conf-low { border-style: dashed; } .conf-medium { border-style: double; border-width: 4px; } }
/* forced-colors: let the system palette win, keep focus and borders visible */
@media (forced-colors: active) {
  .btn-primary, .chip[aria-pressed="true"], .fchip[aria-pressed="true"] { border: 1px solid ButtonText; forced-color-adjust: auto; }
  .banner { border: 1px solid CanvasText; }
  .btn-quiet { border: 1px solid ButtonText; }
}

/* Leaflet draws a focus rectangle round a clicked vector path: hide it (the hit-area lines are invisible by design). */
.leaflet-interactive:focus, .leaflet-overlay-pane svg path:focus { outline: none; }

/* ---------- brand mark ---------- */
.brand-mark { width: auto; height: 1.4em; display: inline-block; vertical-align: -0.3em; margin-right: 0.35em; }
.login-card h1 { text-align: center; }
.login-card h1:focus, #status:focus { outline: none; }   /* programmatic focus targets, not controls */
.login-card .brand-mark { height: 1.15em; vertical-align: -0.2em; }

/* heading receives programmatic focus on open; no ring for that */
#incTitle:focus { outline: none; }

/* ---------- route options (v2.4): one compact card per alternative route ---------- */
.route-options { min-width: 0; margin: 0; padding: 8px 0 4px; border: 0; }
.route-options[hidden] { display: none; }
.route-options legend { float: left; width: 100%; padding: 0 var(--gutter) 6px; font-size: 0.8125rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-soft); }
.route-options legend + * { clear: both; }
.opt-scroller {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px var(--gutter) 10px;   /* room for the 3px+2px focus ring, which the scroller would otherwise clip */
  scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.opt-scroller::-webkit-scrollbar { display: none; }
.opt-card {
  position: relative; flex: none; box-sizing: border-box; width: 9.5rem; min-height: var(--tap); max-height: 10rem; overflow: hidden;
  display: flex; flex-wrap: wrap; align-content: flex-start; align-items: baseline; column-gap: 6px; row-gap: 1px;
  padding: 6px 10px 7px; scroll-snap-align: start;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--raise); color: var(--ink);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: border-color 0.2s, background-color 0.2s;
}
.opt-card > * { min-width: 0; }
.opt-card input { position: absolute; inline-size: 1px; block-size: 1px; margin: 0; opacity: 0; overflow: hidden; pointer-events: none; }
.opt-card:has(input:checked) { border-color: var(--accent-soft); background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.opt-card:has(input:checked)::after {
  content: ""; position: absolute; top: 8px; right: 8px; inline-size: 1.125rem; block-size: 1.125rem; border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.8 2.8L12 5.6' fill='none' stroke='%2306202b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.opt-card:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) { .opt-card:hover { border-color: var(--blue-bright); } .opt-card:has(input:checked):hover { border-color: var(--accent-soft); } }

.opt-tags { display: flex; flex: 0 0 100%; flex-wrap: wrap; gap: 4px; overflow: hidden; padding-inline-end: 1.375rem; }   /* room for the check mark */
.opt-tag {
  flex: none; padding: 1px 7px; border: 1px solid currentColor; border-radius: 999px; background: rgba(11, 23, 54, 0.45);
  font-size: 0.6875rem; font-weight: 700; line-height: 1.4; white-space: nowrap; color: var(--muted);
}
.opt-tag-fastest { color: var(--accent-soft); }
.opt-tag-efficient { color: var(--c-ok); }
.opt-tag-fewest_problems, .opt-tag-least_traffic { color: var(--blue-bright); }
.opt-tag-no_motorway, .opt-tag-shortest, .opt-tag-alternative { color: var(--muted); }

.opt-time { font-size: 1.1875rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.opt-time.delay-low { color: var(--c-ok); }
.opt-time.delay-mid { color: var(--c-slow); }
.opt-time.delay-high { color: var(--c-heavy); }
.opt-delay { font-size: 0.6875rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
/* miles and problems share a row; via and the worst problem get a full line each */
.opt-meta, .opt-worst { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; font-weight: 500; line-height: 1.3; color: var(--muted); }
.opt-via, .opt-worst { flex: 0 0 100%; order: 1; }
.opt-worst { order: 2; }
.opt-via { overflow: hidden; text-overflow: ellipsis; }
.opt-worst { color: var(--ink); }
.opt-partial { flex: 0 0 100%; white-space: normal; }   /* wrap, don't truncate: the warning must be readable in full */
.opt-single { margin: 0; padding: 4px var(--gutter); font-size: 0.875rem; color: var(--muted); }
.opt-note { margin: 0; padding: 2px var(--gutter) 0; font-size: 0.75rem; line-height: 1.4; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .opt-card { transition: none; } .opt-scroller { scroll-behavior: auto; } }
@media (forced-colors: active) { .opt-card { border-color: CanvasText; } .opt-card:has(input:checked) { border-color: Highlight; border-width: 3px; } .opt-card:has(input:checked)::after { background-color: Highlight; } }
/* keep the selected check mark clear of the tag chips */
.opt-card:has(input:checked) .opt-tags { padding-right: 20px; }

/* Selected incident (its card is open): golden marker ring and glow, and a golden edge on its list row. */
.inc-icon.is-selected { border-color: #ffc83d; box-shadow: 0 0 0 3px #ffc83d, 0 0 14px 4px rgba(255, 200, 61, 0.65); animation: inc-pulse 1.8s ease-in-out 3; }   /* 3 pulses (~5s) then holds the static glow */
/* Never scale/transform the marker element itself: Leaflet positions it with transform, and a scale would multiply that offset. Enlarge the inside instead. */
.inc-icon.is-selected > div { scale: 1.15; display: grid; place-items: center; }
@keyframes inc-pulse { 50% { box-shadow: 0 0 0 3px #ffc83d, 0 0 20px 8px rgba(255, 200, 61, 0.3); } }
/* Drawn as an overlay: an inset shadow on .card sat UNDER .card-main's selected background, so only the lower half showed. */
.card.is-selected { position: relative; }
.card.is-selected::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: #ffc83d; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .inc-icon.is-selected { animation: none; } }
@media (forced-colors: active) { .inc-icon.is-selected { outline: 4px solid Highlight; outline-offset: 2px; } .card.is-selected { border-inline-start: 4px solid Highlight; } }

/* ======================================================================
   v2.5: evidence, source badges, NH record, weather, planned works
   Classes: .src-badge .src-confirmed .prov .ev-* .nh-* .wx-* .planned*
   ====================================================================== */
:root {
  --wx-yellow: #ffd43b; --wx-amber: #ff922b; --wx-red: #e03131;
  --wx-ink: #1a1300;             /* dark text on yellow/amber: > 9:1 */
  --quote-bg: #0a1530;           /* a shade under --panel so verbatim text reads as "quoted" */
}

/* source badges (small pills: text always carries the meaning, colour is a hint) */
.src-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--void);
  font: 600 0.75rem/1.6 var(--sans); color: var(--muted); white-space: nowrap;
}
.src-badge.src-tomtom { border-color: #6f87b8; color: #c7d4ee; }
.src-badge.src-nh { border-color: #5eead4; color: var(--accent-soft); }
.src-badge.src-here { border-color: #8f84e8; color: #d0cbff; }
.src-badge.src-metoffice { border-color: #7cc0ff; color: #bfe0ff; }
.src-confirmed, .badge.src-confirmed {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 999px;
  border: 1px solid var(--good); background: var(--void); color: var(--good);
  font: 700 0.75rem/1.6 var(--sans);
}
.src-confirmed::before { content: "\2713" / ""; font-weight: 800; }

/* provenance sub-lines: small, muted, always under the fact they explain */
.prov, .inc-prov, .ev-prov { display: block; margin-top: 2px; font-size: 0.875rem; font-weight: 400; line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- evidence ---------- */
.ev-section { display: flex; flex-direction: column; gap: 12px; }
.ev-block { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--raise); min-width: 0; }
.ev-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.ev-title, .inc-section .ev-title { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.3; letter-spacing: 0; text-transform: none; color: var(--ink); overflow-wrap: anywhere; }   /* h3 in NH/HERE records: beats .inc-section h3 */
.ev-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0; padding: 0; }
.ev-row { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ev-list dt { font-size: 0.8125rem; font-weight: 600; line-height: 1.3; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ev-list dd { margin: 0; font-size: 1rem; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
@container incbody (min-width: 30rem) {          /* about 520px viewport minus gutters */
  .ev-list { grid-template-columns: minmax(7.5rem, max-content) minmax(0, 1fr); gap: 8px 16px; align-items: baseline; }
  .ev-row { display: contents; }
}
.ev-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

/* verbatim quotes (NH/HERE comments): set apart, never restyled to look like our own words */
.ev-quote, .nh-quote {
  margin: 0; padding: 10px 12px 10px 14px; border-left: 4px solid var(--accent-soft); border-radius: 0 10px 10px 0;
  background: var(--quote-bg); color: var(--ink); font-size: 1rem; line-height: 1.5;
  white-space: pre-line; overflow-wrap: anywhere;
}
.ev-quote-cite, .nh-quote-cite { display: block; margin-top: 6px; font-size: 0.8125rem; font-style: normal; color: var(--muted); white-space: normal; }

/* ---------- National Highways record ---------- */
.nh-record { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.nh-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.nh-where { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.nh-meta { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
.nh-flags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.nh-flags li { padding: 1px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--void); font-size: 0.8125rem; font-weight: 600; color: var(--ink); }

/* status chips: a word plus a distinct leading mark per state, so colour is never the only cue */
.nh-status, .nh-chip {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 2px 12px; border-radius: 999px;
  border: 1.5px solid currentColor; background: var(--void); color: var(--muted);
  font: 700 0.875rem/1.5 var(--sans);
}
.nh-status::before, .nh-chip::before { content: "\25CB" / ""; }                 /* hollow circle: default/planned */
.nh-status.is-active, .nh-status-active, .nh-chip.is-active { color: var(--good); }
.nh-status.is-active::before, .nh-status-active::before, .nh-chip.is-active::before { content: "\25CF" / ""; }   /* solid dot: in force */
.nh-status.is-booked, .nh-status-booked, .nh-chip.is-booked { color: var(--amber); border-style: dashed; }
.nh-status.is-booked::before, .nh-status-booked::before, .nh-chip.is-booked::before { content: "\25D0" / ""; }   /* half dot: booked, not confirmed */
.nh-status.is-planned, .nh-status-planned, .nh-chip.is-planned { color: #b9c8e6; }

/* ---------- weather warnings: coloured chip + words ("Amber warning"), never colour alone ---------- */
.wx-warning { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-left-width: 6px; border-radius: 14px; background: var(--raise); }
.wx-warning.wx-yellow { border-left-color: var(--wx-yellow); }
.wx-warning.wx-amber { border-left-color: var(--wx-amber); border-left-style: double; }
.wx-warning.wx-red { border-left-color: var(--wx-red); border-left-style: solid; }
.wx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.wx-level {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 2px 12px; border-radius: 999px;
  border: 2px solid transparent; font: 800 0.9375rem/1.5 var(--sans); background: var(--wx-yellow); color: var(--wx-ink);
}
.wx-level::before { content: "\25B2" / ""; font-size: 0.8em; }                  /* triangle on every level */
.wx-level.wx-yellow { background: var(--wx-yellow); color: var(--wx-ink); }
.wx-level.wx-amber { background: var(--wx-amber); color: var(--wx-ink); }
.wx-level.wx-amber::before { content: "\25B2\25B2" / ""; letter-spacing: -0.1em; }
.wx-level.wx-red { background: var(--wx-red); color: #fff; border-color: #fff; }
.wx-level.wx-red::before { content: "\25B2\25B2\25B2" / ""; letter-spacing: -0.15em; }
.wx-types { font-size: 1rem; font-weight: 600; text-transform: capitalize; }
.wx-headline { margin: 0; font-size: 1.125rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.wx-when, .wx-areas, .wx-issued { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
.wx-expect { margin: 0; padding: 0 0 0 1.1em; display: flex; flex-direction: column; gap: 4px; font-size: 1rem; }
.wx-link { display: flex; align-items: center; min-height: var(--tap); padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--void); color: var(--accent-soft); font-weight: 600; text-decoration: none; }
@media (hover: hover) { .wx-link:hover { background: var(--surface-hover); border-color: var(--blue-bright); } }
/* the same chip in the route list rows */
.card .wx-level { font-size: 0.75rem; padding: 0 9px; }

/* ---------- planned works (collapsed details in the list) ---------- */
.planned { margin: 6px 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.planned > summary {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px var(--gutter);
  cursor: pointer; list-style: none; font-weight: 700; font-size: 0.9375rem; color: var(--accent-soft);
}
.planned > summary::-webkit-details-marker { display: none; }
.planned > summary::before { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.2s var(--ease); }
.planned[open] > summary::before { transform: rotate(45deg); }
.planned-count { margin-left: auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--void); font-size: 0.8125rem; color: var(--muted); }
.planned > summary:focus-visible { outline-offset: -3px; }
@media (hover: hover) { .planned > summary:hover { background: var(--surface-hover); } }
.planned-note { padding: 0 var(--gutter) 8px; font-size: 0.8125rem; color: var(--muted); }
.planned-list { list-style: none; margin: 0; padding: 0; }
.planned-item { border-top: 1px solid var(--line); }
.planned-item > button { display: flex; flex-direction: column; gap: 2px; width: 100%; min-height: var(--tap); padding: 10px var(--gutter); border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
@media (hover: hover) { .planned-item > button:hover { background: var(--surface-hover); } }
.planned-when { font: 700 0.8125rem/1.4 var(--sans); color: var(--amber); }
.planned-title { font-weight: 600; overflow-wrap: anywhere; }
.planned-where { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }

.credit { font-size: 0.8125rem; }
.credit p { line-height: 1.5; }
.planned > summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

@media (prefers-reduced-motion: reduce) { .planned > summary::before { transition: none; } }
@media (forced-colors: active) {
  .src-badge, .src-confirmed, .nh-status, .nh-chip, .nh-flags li, .planned-count { border: 1px solid CanvasText; }
  .wx-level { border: 2px solid CanvasText; forced-color-adjust: none; }   /* keep the level colour; the word and triangles still carry it */
  .wx-warning { border-left: 6px solid Highlight; }
  .ev-quote, .nh-quote { border-left: 4px solid CanvasText; }
  .ev-block { border: 1px solid CanvasText; }
  .planned > summary::before { border-color: CanvasText; }
}

/* v2.5 card: one collapsed <details> per source (reuses .planned summary styles) */
.src-details { margin: 6px 0 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.src-details > summary { flex-wrap: wrap; gap: 2px 10px; min-height: 48px; padding: 8px 14px; font-size: 0.9375rem; }
.src-details > summary::before { align-self: center; }
.src-sum-main { font-weight: 700; flex: 1 1 0; min-width: 0; }
.src-sum-sub { flex-basis: 100%; margin: 0 0 0 18px; font-weight: 400; }
.src-details-body { padding: 4px 14px 12px; }
.src-details-body > .ev-block { border: 0; padding: 0; margin: 0; background: none; box-shadow: none; }
.ev-section > .src-details + .src-details { margin-top: 6px; }
.trip-brief.is-expanded { -webkit-line-clamp: unset; line-clamp: unset; display: block; overflow: visible; }
.trip-brief-more { grid-column: 1 / -1; justify-self: start; }
.trip-brief-more[hidden] { display: none; }

/* ======================================================================
   2.7.0 navigation UI
   State hook: .app.nav-on (set by app.js while navigating).
   Layout hooks inside .map-wrap: .nav-top (banner + warnings), .nav-bottom
   (.nav-controls + .nav-bar). Glanceable at arm's length: huge distance and arrow,
   56px+ targets, safe-area aware, portrait and landscape.
   ====================================================================== */
:root {
  --nav-tap: 56px;
  --nav-bg: rgba(6, 16, 40, 0.97);        /* near-void navy, slight blue bias */
  --nav-bg-raise: #12254d;
  --nav-ink: #ffffff;
  --nav-sub: #c4d2ee;                      /* 10:1 on --nav-bg */
  --nav-go: #5eead4;
  --nav-edge: rgba(255, 255, 255, 0.3);    /* panel outline that still separates from a pale map in glare */
  --nav-stop: #ff8d93;
  --nav-r: 28px;                           /* big panels: banner, bar, arrival */
  --nav-r-sm: 20px;                        /* lanes, warnings, traffic strip */
  --nav-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.28);
  --nav-pad-l: max(var(--gutter), env(safe-area-inset-left));
  --nav-pad-r: max(var(--gutter), env(safe-area-inset-right));
}

/* ---- navigating: map takes the screen, search header and sheet get out of the way ---- */
.app.nav-on { grid-template-rows: 0 minmax(0, 1fr) 0; }
.app.nav-on .top, .app.nav-on .sheet { display: none; }
.app.nav-on .map-wrap { overflow: hidden; }
.app.nav-on .map { z-index: 0; }            /* contain Leaflet pane z-indexes below the nav layer */
.app.nav-on #fitBtn, .app.nav-on .map-road, .app.nav-on .map-pin, .app.nav-on .road-cross, .app.nav-on .legend,
.app.nav-on .leaflet-control-zoom { display: none; }
@media (min-width: 800px) {
  .app.nav-on { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "map"; }
}

.nav-top, .nav-bottom { position: absolute; z-index: 520; left: 0; right: 0; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.nav-top > *, .nav-bottom > * { pointer-events: auto; }
.nav-top { top: 0; padding: max(8px, env(safe-area-inset-top)) var(--nav-pad-r) 0 var(--nav-pad-l); }
.nav-bottom { bottom: 0; padding: 0 var(--nav-pad-r) max(10px, env(safe-area-inset-bottom)) var(--nav-pad-l); }

/* ---- next-manoeuvre banner ---- */
.nav-banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 14px; row-gap: 0;
  padding: 14px 18px 14px 14px;
  background: var(--nav-bg); color: var(--nav-ink);
  border: 1px solid var(--nav-edge); border-radius: var(--nav-r);
  box-shadow: var(--nav-shadow); overflow: hidden;
}
.nav-arrow { grid-row: 1 / span 2; width: clamp(80px, 24vw, 112px); aspect-ratio: 1; color: var(--nav-go); display: grid; place-items: center; }
.nav-arrow svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-arrow .nav-fill, .nav-then-arrow .nav-fill { fill: currentColor; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; }   /* the stroke rounds the arrowhead corners */
.nav-dist { font-weight: 800; font-size: clamp(3.25rem, 15vw, 5rem); line-height: 1; letter-spacing: -0.04em; white-space: nowrap; align-self: end; }
.nav-dist-num { font-variant-numeric: tabular-nums; }
.nav-dist-unit { font-size: 0.4em; font-weight: 700; letter-spacing: 0; margin-left: 0.15em; color: var(--nav-sub); }
.nav-road {
  align-self: start; margin-top: 6px;
  font-weight: 700; font-size: clamp(1.25rem, 5.6vw, 1.75rem); line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere;
}
.nav-road-num { display: inline-block; padding: 0 9px; border-radius: 10px; background: var(--blue); color: #fff; margin-right: 6px; font-weight: 800; }
.nav-then {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 12px -18px -14px -14px; padding: 12px 18px 12px 16px;
  background: var(--nav-bg-raise); color: var(--nav-sub); font-size: 1.125rem; font-weight: 600; line-height: 1.2;
}
.nav-then:empty { display: none; }
.nav-then.is-status { color: var(--nav-ink); }
.nav-then.is-status .nav-then-text { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }   /* off-route / status hints wrap instead of being cut off */
.nav-then-label { font: 700 0.75rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--nav-sub); }
.nav-then-arrow { flex: none; width: 32px; height: 32px; color: var(--nav-ink); }
.nav-then-arrow svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-then-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--nav-ink); }

/* ---- lane hints ---- */
.nav-lanes { margin-inline: auto; display: flex; background: var(--nav-bg); border: 1px solid var(--nav-edge); border-radius: var(--nav-r-sm); overflow: hidden; box-shadow: var(--nav-shadow); }
.nav-lanes:empty { display: none; }
.nav-lane { width: 48px; height: 56px; display: grid; place-items: center; color: var(--nav-sub); opacity: 0.65; border-left: 2px dashed var(--nav-edge); }
.nav-lane:first-child { border-left: 0; }
.nav-lane svg { width: 34px; height: 40px; fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-lane.is-follow { opacity: 1; color: var(--on-accent); background: var(--nav-go); }

/* ---- compass: the row under the banner holds the lane strip (centred) and the compass (right). Indicator only: it never takes taps.
   The dial turns with --nav-rot (set on .map-wrap by map.js; absent in north-up = 0), the same unwrapped angle and glide as the map, so north stays true on screen. ---- */
.nav-sub { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: 8px; pointer-events: none; }
.nav-sub > * { pointer-events: auto; }
.nav-sub > .nav-compass { pointer-events: none; }
.nav-compass {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 14px 3px 3px; border-radius: 999px;
  background: var(--nav-bg); color: var(--nav-ink); border: 1px solid var(--nav-edge); box-shadow: var(--nav-shadow);
  user-select: none; -webkit-user-select: none;
}
.nav-dial { flex: none; width: 44px; height: 44px; display: block; transform: rotate(var(--nav-rot, 0deg)); transition: transform var(--nav-glide, 0.4s) linear; will-change: transform; }
.nav-rot-snap .nav-dial { transition: none; }
.nav-dial svg { display: block; width: 100%; height: 100%; }
.nav-dial-ring { fill: none; stroke: var(--nav-sub); stroke-width: 1.5; opacity: 0.7; }
.nav-dial-n { fill: var(--nav-stop); font: 800 9px/1 var(--sans); }
.nav-dial-north { fill: var(--nav-stop); }
.nav-dial-south { fill: var(--nav-sub); opacity: 0.8; }
.nav-compass-text { min-width: 2ch; text-align: center; font: 800 1.375rem/1 var(--sans); letter-spacing: 0; font-variant-numeric: tabular-nums; }

/* ---- warnings (background, weak GPS, wake lock, voice) ---- */
.nav-warns { display: flex; flex-direction: column; gap: 8px; }   /* polite live region: warnings are rare and discrete */
.nav-warns:empty { display: none; }
.nav-warn {
  display: flex; align-items: center; gap: 12px; min-height: var(--nav-tap); padding: 10px 16px; border-radius: var(--nav-r-sm); box-shadow: var(--nav-shadow);
  background: #3d2c05; color: #ffe9b0; border: 1px solid var(--amber); font-size: 1rem; font-weight: 600; line-height: 1.3;
}
.nav-warn > button { flex: none; min-width: var(--nav-tap); min-height: var(--nav-tap); margin: -6px -6px -6px 0; padding: 0 18px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.nav-warn-bg { background: #4a1220; color: #ffe0e4; border-color: var(--c-heavy); }   /* "Guidance stopped while BenjiRoute was in the background" */
.nav-note.is-ok { color: var(--nav-go); }
.nav-note { align-self: center; padding: 6px 14px; border-radius: 999px; background: var(--nav-bg); color: var(--nav-sub); border: 1px solid var(--line); font-size: 0.875rem; font-weight: 600; }
.nav-demo { align-self: flex-start; padding: 4px 12px; border-radius: 999px; background: #2c2268; color: var(--starlight); font-size: 0.8125rem; font-weight: 700; }

/* ---- controls ---- */
.nav-controls { display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; }
/* Speed limit sign: a real-world UK roundel (white disc, red ring, black numerals), so it keeps those colours in every theme. Portrait: bottom-left above the bar. */
.nav-limit {
  --d: clamp(52px, 14vw, 64px);
  position: relative; flex: none; margin-inline-end: auto; box-sizing: border-box; width: var(--d); height: var(--d); display: grid; place-items: center;
  border-radius: 50%; background: #fff; border: calc(var(--d) * 0.12) solid #c8102e; color: #000;
  box-shadow: 0 0 0 2px var(--nav-bg), 0 8px 20px -8px rgba(0, 0, 0, 0.65);
  pointer-events: none; user-select: none; -webkit-user-select: none;
}
.nav-limit[hidden] { display: none; }
.nav-limit-num { font: 800 calc(var(--d) * 0.42)/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
/* Speed camera chip (2.11.0), beside the speed sign: icon, a short title and the distance. Amber outline; inside an average-speed section it fills amber. */
.nav-signs { display: flex; align-items: flex-end; gap: 10px; margin-inline-end: auto; pointer-events: none; }
.nav-signs .nav-limit { margin-inline-end: 0; }
.nav-cam {
  box-sizing: border-box; display: flex; align-items: center; gap: 8px; min-height: 44px; max-width: 15rem; padding: 6px 12px 6px 9px; border-radius: 14px;
  background: var(--nav-bg); color: var(--nav-ink); border: 2px solid var(--amber); box-shadow: 0 0 0 2px var(--nav-bg), 0 8px 20px -8px rgba(0, 0, 0, 0.65);
  user-select: none; -webkit-user-select: none; animation: nav-cam-in 0.25s var(--ease);
}
.nav-cam[hidden] { display: none; }
.nav-cam-ico { flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-cam-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-cam-title { font: 800 0.9375rem/1.1 var(--sans); }
.nav-cam-detail { white-space: nowrap; font: 700 0.8125rem/1.1 var(--sans); font-variant-numeric: tabular-nums; color: var(--nav-sub); }
.nav-cam[data-kind="zone"] { background: var(--amber); color: #1a1300; border-color: #1a1300; }
.nav-cam[data-kind="zone"] .nav-cam-detail { color: #1a1300; }
@keyframes nav-cam-in { from { opacity: 0; } }
/* Over the limit (JS sets .is-over + data-over on the sign): red halo outside the roundel, two pulses on entry then steady, and a red pill with the current speed at the lower right.
   The pill is absolutely positioned on the sign, so it adds nothing to the controls' height; the sign has no overflow clipping and sits well inside .map-wrap. */
.nav-limit.is-over {
  box-shadow: 0 0 0 2px var(--nav-bg), 0 0 0 6px #c8102e, 0 8px 20px -8px rgba(0, 0, 0, 0.65);
  will-change: transform; animation: nav-over-pulse 0.6s var(--ease) 2;
}
@keyframes nav-over-pulse { 50% { transform: scale(1.08); } }
.nav-speed {
  position: absolute; right: calc(var(--d) * -0.22); bottom: calc(var(--d) * -0.14); z-index: 1;
  display: flex; align-items: baseline; gap: 2px; padding: 3px 8px 3px 7px; border-radius: 999px;
  background: #c8102e; color: #fff; border: 2px solid #fff; white-space: nowrap;
  font: 800 0.9375rem/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  box-shadow: 0 0 0 2px var(--nav-bg), 0 4px 10px -4px rgba(0, 0, 0, 0.7);
}
.nav-speed[hidden] { display: none; }
.nav-speed-unit { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.nav-btn {
  flex: none; display: inline-grid; place-items: center; grid-auto-flow: column; gap: 8px;
  min-width: var(--nav-tap); min-height: var(--nav-tap); padding: 0; border-radius: 50%;
  border: 2px solid var(--nav-edge); background: var(--nav-bg); color: var(--nav-go);
  font: 700 1.0625rem/1 var(--sans); cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.nav-btn:active { transform: scale(0.95); }
.nav-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn .nav-ico-off { display: none; }
.nav-btn[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }   /* Mute: pressed = muted */
.nav-btn[aria-pressed="true"] .nav-ico-on { display: none; }
.nav-btn[aria-pressed="true"] .nav-ico-off { display: block; }
.nav-btn-view, .nav-btn-overview { position: relative; color: var(--nav-ink); }
.nav-btn-overview[aria-pressed="true"] { border-color: var(--nav-go); color: var(--nav-go); }   /* the whole route ahead is showing */
/* "3D" badge while the tilted view is showing: text, not a glyph, so it reads at 56px (the arrow alone does not change between views). */
.nav-btn-view[data-mode="3d"]::after { content: "3D"; position: absolute; right: 5px; bottom: 6px; font: 800 0.625rem/1 var(--sans); letter-spacing: 0.02em; color: var(--nav-go); }
.nav-btn-end { width: auto; border-radius: 999px; padding: 0 22px; color: var(--nav-stop); border-color: var(--nav-stop); }
.nav-btn-end.is-armed { background: #b3202e; border-color: #ffd6db; color: #fff; }  /* first tap arms, second (within 4 s) ends */
.nav-btn:focus-visible, .nav-warn > button:focus-visible, .nav-start:focus-visible { outline: 4px solid var(--nav-ink); outline-offset: 3px; border-radius: 999px; }
/* Navigating: Re-centre floats just above the bottom block (the controls row), right-aligned, so it never covers the middle of the map. app.js moves the button into .nav-bottom while navigating. */
.app.nav-on .map-recentre {
  top: auto; bottom: 100%; margin-bottom: 8px; right: var(--nav-pad-r); transform: none; z-index: 1; min-height: var(--nav-tap); padding: 0 26px; border-radius: 999px; box-shadow: var(--nav-shadow);
  font: 700 1.0625rem/1 var(--sans); letter-spacing: 0; text-transform: none; background: var(--nav-go); color: var(--on-accent); border-color: transparent;
}

/* ---- bottom bar ---- */
.nav-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 12px 12px 20px;
  background: var(--nav-bg); color: var(--nav-ink); border: 1px solid var(--nav-edge); border-radius: var(--nav-r);
  box-shadow: var(--nav-shadow);
}
.nav-stats { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px clamp(12px, 4vw, 22px); }
.nav-stat { display: flex; flex-direction: column; gap: 3px; flex: none; }
.nav-stat-val { font-weight: 800; font-size: clamp(1.25rem, 6vw, 1.625rem); line-height: 1; letter-spacing: -0.02em; white-space: nowrap; }
.nav-stat-label { font: 700 0.75rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--nav-sub); }
.nav-traffic { order: -1; flex: 1 0 100%; display: flex; align-items: center; min-height: 44px; margin: 0 8px 0 -8px; padding: 0 14px; border-radius: var(--nav-r-sm); background: var(--nav-bg-raise); border: 2px solid var(--c-slow); color: var(--nav-ink); font-size: 0.9375rem; font-weight: 700; line-height: 1.15; overflow: hidden; }
.nav-traffic:empty { display: none; }
.nav-traffic.is-heavy, .nav-traffic.is-closed { border-color: var(--c-heavy); }
.nav-attrib { align-self: flex-end; padding: 3px 10px; border-radius: 999px; background: rgba(7, 15, 38, 0.85); color: var(--nav-sub); font-size: 0.75rem; line-height: 1.3; }
.nav-attrib a { color: inherit; }

/* ---- start button (in #summaryActions) ---- */
.nav-start { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--nav-tap); padding: 0 26px; font-size: 1.125rem; font-weight: 800; }
.nav-start svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-start-note { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }

/* ---- safety disclaimer / pre-start sheet (a .dialog) ---- */
.dialog.nav-dialog { width: min(94vw, 480px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.nav-dialog h2 { font-size: 1.5rem; }
.nav-dialog p, .nav-dialog li { font-size: 1.0625rem; line-height: 1.5; }
.nav-dialog p + p, .nav-dialog ul { margin-top: 12px; }
.nav-dialog ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }
.nav-dialog .nav-dialog-warn { padding: 12px 14px; border-radius: 14px; background: #3d2c05; color: #ffe9b0; border-left: 4px solid var(--amber); font-weight: 600; }
/* "Speed camera alerts" switch in the pre-start sheet: a native checkbox (role switch) drawn as a track and knob; 44 px tall touch target. */
.nav-switch-row { margin-top: 14px; }
.dialog .nav-switch { display: flex; margin-bottom: 0; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-size: 1.0625rem; font-weight: 700; }
.nav-switch input { appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0; width: 52px; height: 32px; border-radius: 999px; background: var(--raise); border: 2px solid var(--border); cursor: pointer; transition: background-color 0.15s; }
.nav-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background-color 0.15s; }
.nav-switch input:checked { background: var(--accent-soft); border-color: var(--accent-soft); }
.nav-switch input:checked::after { transform: translateX(20px); background: var(--void); }
.nav-switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.nav-dialog .nav-switch-hint { margin-top: 2px; font-size: 0.9375rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .nav-switch input, .nav-switch input::after { transition: none; } }
@media (forced-colors: active) { .nav-switch input { forced-color-adjust: none; background: Canvas; border-color: CanvasText; } .nav-switch input::after { background: CanvasText; } .nav-switch input:checked { background: Highlight; border-color: Highlight; } .nav-switch input:checked::after { background: HighlightText; } }
.nav-dialog .dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; position: sticky; bottom: calc(-1 * max(20px, env(safe-area-inset-bottom))); padding-block: 10px; background: var(--panel); }   /* Start stays reachable when landscape makes the sheet scroll */
.nav-dialog .dialog-actions .btn { min-height: var(--nav-tap); font-size: 1.0625rem; }

/* ---- arrival ---- */
.nav-arrived {
  position: absolute; z-index: 530; left: var(--nav-pad-l); right: var(--nav-pad-r); top: 50%; transform: translateY(-50%); max-width: 420px; margin-inline: auto;
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 20px; text-align: center;
  background: var(--nav-bg); border: 2px solid var(--nav-go); border-radius: var(--nav-r); box-shadow: var(--nav-shadow); color: var(--nav-ink);
}
.nav-arrived h2 { font-size: 2rem; }
.nav-arrived .btn { min-height: var(--nav-tap); min-width: 160px; font-size: 1.125rem; }

/* ---- heading-up rotation (in-house; no plugin) ----
   Set on .map-wrap: .nav-headingup. JS sets --nav-d (px, side of the enlarged square),
   --nav-rot (deg, cumulative so it never spins the long way round), --nav-counter (-rot),
   --nav-cy (centre y within .map-wrap, default 70% so the car sits low). */
.nav-headingup .map {
  inset: auto; left: 50%; top: var(--nav-cy, 70%);
  width: var(--nav-d, 150vmax); height: var(--nav-d, 150vmax);
  transform: translate(-50%, -50%) rotate(var(--nav-rot, 0deg));
  transition: transform var(--nav-glide, 0.4s) linear; will-change: transform;
  pointer-events: none; touch-action: none;
}
.nav-headingup .leaflet-control-attribution { display: none; }
.app.nav-on .leaflet-control-attribution { display: none; }   /* navigating: the app's own .nav-attrib carries the OpenStreetMap licence line (two overlapped at the bottom) */
/* Keep icons upright. NEVER put rotate/scale on a Leaflet-positioned root (.leaflet-marker-icon, .inc-icon): they compose outside Leaflet's translate3d and the marker orbits.
   Only inner children are turned: .inc-icon's inner div, and .pin / .j-pill / .cam, which sit inside a plain unclassed marker root. */
.nav-headingup .inc-icon > div, .nav-headingup .pin, .nav-headingup .j-pill, .nav-headingup .cam { rotate: var(--nav-counter, 0deg); transform-origin: 50% 50%; }
/* ---- 3D driving view: .nav-pov on .map-wrap, on top of heading-up. JS sets --nav-pitch, --nav-persp (px), --nav-unpitch (1/cos pitch)
   and --nav-fade (height of the haze at the top). The camera sits at the car (perspective-origin = --nav-cy), so the car does not move. ---- */
.nav-pov { perspective: var(--nav-persp, 800px); perspective-origin: 50% var(--nav-cy, 70%); }
.nav-headingup.nav-pov .map { transform: translate(-50%, -50%) rotateX(var(--nav-pitch, 0deg)) rotate(var(--nav-rot, 0deg)); }
.nav-pov::before { content: ""; position: absolute; z-index: 500; left: 0; right: 0; top: 0; height: var(--nav-fade, 10%); background: linear-gradient(var(--void) 30%, transparent); pointer-events: none; }
/* The tilt squashes upright icons by cos(pitch): stretch them back (scale runs inside rotate, so it is along the icon's own up). */
.nav-headingup.nav-pov .inc-icon > div, .nav-headingup.nav-pov .pin, .nav-headingup.nav-pov .j-pill, .nav-headingup.nav-pov .cam { scale: 1 var(--nav-unpitch, 1); }
.nav-headingup.nav-pov .inc-icon.is-selected > div { scale: 1.15 calc(1.15 * var(--nav-unpitch, 1)); }   /* keeps the selected icon's 1.15 grow */
@media (forced-colors: active) {
  .nav-pov::before { display: none; }                                    /* the haze is a painted colour: the system palette wins */
  .nav-btn-view[data-mode="3d"]::after { color: ButtonText; forced-color-adjust: none; }
}
.nav-explore { position: absolute; inset: 0; z-index: 510; border: 0; padding: 0; background: transparent; cursor: grab; }
.nav-explore:focus-visible { outline: 4px solid var(--nav-go); outline-offset: -4px; border-radius: 0; }

/* ---- car marker (Leaflet divIcon className "nav-car", 48x48): a rounded arrowhead (inline SVG, round joins) with a white outline, soft lift shadow and a faint accuracy halo.
   It lies flat on the map plane, so in the 3D view it tilts with the road. The rotating element stays .nav-car-body (--car-rot). ---- */
.nav-car { width: 48px; height: 48px; filter: drop-shadow(0 2px 3px rgba(2, 8, 24, 0.55)) drop-shadow(0 4px 9px rgba(2, 8, 24, 0.4)); }
.nav-car-body { position: absolute; inset: 0; transform: rotate(var(--car-rot, 0deg)); transition: transform var(--nav-glide, 0.4s) linear; }
.nav-car-body svg { display: block; width: 100%; height: 100%; overflow: visible; }
.nav-car-halo { fill: var(--nav-go); fill-opacity: 0.12; }
.nav-car-edge { fill: #fff; stroke: #fff; stroke-width: 5; stroke-linejoin: round; }
.nav-car-core { fill: var(--nav-go); stroke: var(--nav-go); stroke-width: 4; stroke-linejoin: round; }
.nav-car.is-weak { opacity: 0.55; }

@media (hover: hover) {
  .nav-btn:hover { background: var(--surface-hover); border-color: var(--blue-bright); }
  .nav-btn-end.is-armed:hover { background: #c92a39; }
}

/* ---- landscape phones: banner in a left column, bar bottom-right, map stays visible ---- */
@media (orientation: landscape) and (max-height: 520px) {
  .nav-top { right: auto; width: min(46%, 420px); }
  .nav-bottom { left: auto; width: calc(100% - min(46%, 420px)); min-width: min(400px, 54%); align-items: flex-end; padding-left: 12px; }
  .nav-controls { display: grid; grid-template-columns: auto auto auto; justify-content: end; justify-items: end; gap: 10px; }
  .nav-signs { grid-column: 1; grid-row: 1 / span 2; align-self: end; margin-inline-end: 0; }
  .nav-btn-mute, .nav-btn-view { grid-column: 2; }
  .nav-btn-overview { grid-column: 3; grid-row: 2; }
  .nav-arrow { width: 84px; }
  .nav-dist { font-size: clamp(2.75rem, 9vw, 4rem); }
  .nav-road { font-size: 1.25rem; margin-top: 2px; }
  .nav-banner { padding-block: 8px; }
  .nav-then { margin-top: 6px; margin-bottom: -8px; padding-block: 6px; }
  .nav-lane { height: 48px; }
  .nav-bar { width: 100%; padding-block: 6px; }
  .nav-traffic { min-height: 40px; }
  .nav-stat-val { font-size: 1.25rem; }
  .nav-stats { gap: 6px 14px; }
  .nav-dialog .nav-dialog-warn { font-size: 0.9375rem; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-headingup .map, .nav-car-body, .nav-btn, .nav-dial { transition: none; }
  .nav-limit.is-over { animation: none; will-change: auto; }
  .nav-cam { animation: none; }
  .nav-btn:active { transform: none; }
}
@media (forced-colors: active) {
  .nav-banner, .nav-bar, .nav-lanes, .nav-compass, .nav-btn, .nav-warn, .nav-arrived, .nav-traffic, .nav-note { border: 2px solid CanvasText; background: Canvas; color: CanvasText; forced-color-adjust: none; }
  .nav-warn > button { border: 2px solid ButtonText; background: ButtonFace; color: ButtonText; }
  .nav-arrow, .nav-then-arrow, .nav-btn, .nav-dist-unit, .nav-stat-label, .nav-then, .nav-then-label, .nav-then-text { color: CanvasText; background: Canvas; }
  .nav-dial-ring { stroke: CanvasText; opacity: 1; } .nav-dial-north, .nav-dial-n { fill: Highlight; } .nav-dial-south { fill: CanvasText; opacity: 1; }
  .nav-limit { forced-color-adjust: none; background: #fff; color: #000; border-color: #c8102e; }
  .nav-limit.is-over { outline: 4px solid Highlight; outline-offset: 2px; }
  .nav-cam { forced-color-adjust: none; background: Canvas; color: CanvasText; border-color: CanvasText; box-shadow: none; }
  .nav-cam[data-kind="zone"] { background: Mark; color: MarkText; } .nav-cam[data-kind="zone"] .nav-cam-detail { color: MarkText; }
  .nav-speed { forced-color-adjust: none; background: Mark; color: MarkText; border: 2px solid CanvasText; box-shadow: none; }
  .nav-lane { color: GrayText; opacity: 1; border-color: CanvasText; }
  .nav-dialog .nav-dialog-warn { border: 2px solid CanvasText; background: Canvas; color: CanvasText; }
  .nav-demo { border: 1px solid CanvasText; }
  .nav-lane.is-follow { background: Highlight; color: HighlightText; border-color: Highlight; }
  .nav-btn[aria-pressed="true"], .nav-btn-end.is-armed { border-color: Highlight; border-width: 4px; background: Canvas; color: CanvasText; }
  .nav-road-num { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
  .nav-car-halo { display: none; }
  .nav-car-edge { fill: Canvas; stroke: Canvas; forced-color-adjust: none; } .nav-car-core { fill: Highlight; stroke: Highlight; forced-color-adjust: none; }
  .app.nav-on .map-recentre, .nav-start { background: ButtonFace; color: ButtonText; border: 2px solid ButtonText; }
  .nav-btn:focus-visible, .nav-start:focus-visible, .nav-explore:focus-visible { outline-color: Highlight; }
}
