/* BMW M–style structure (see DESIGN.md) on a bright, high-contrast canvas by default.
   Type: Barlow, a grotesk modelled on highway and transit signage, chosen because this is a
   wayfinding tool (clear numerals, legible at a glance). Barlow Semi Condensed sets the
   uppercase labels and headings so long station names still fit. Every text colour below
   meets WCAG AA (4.5:1) against its background. */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --card: #f2f3f5;
  --elevated: #e6e8eb;
  --soft: #f7f8fa;
  --fg: #0d0d0d;          /* headings, key values: 19:1 */
  --body: #2e2e2e;        /* running text: 13:1 */
  --body-strong: #1a1a1a;
  --muted: #5c6066;       /* secondary text: 6.3:1 */
  --faint: #9aa0a6;       /* decoration only, never text */
  --line: #cfd3d8;
  --line-strong: #e3e6ea;
  --hover: #f2f3f5;
  --accent: #1c69d4;      /* links, focus: 5.2:1 */
  --start: #0a7d2c;       /* start pin, success: 5.4:1 */
  --end: #d42315;         /* end pin: 5.1:1 */
  --warn: #9a4a00;        /* warnings: 6.5:1 */
  --m1: #0066b1; --m2: #1c69d4; --m3: #e22718;
  --stripe: linear-gradient(90deg, var(--m1) 0 33.33%, var(--m2) 33.33% 66.66%, var(--m3) 66.66% 100%);
  --display: "Barlow Semi Condensed", Barlow, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --panel: #000000;
  --card: #1a1a1a;
  --elevated: #262626;
  --soft: #0d0d0d;
  --fg: #ffffff;
  --body: #c8c8c8;
  --body-strong: #e6e6e6;
  --muted: #9a9a9a;
  --faint: #5a5a5a;
  --line: #3c3c3c;
  --line-strong: #262626;
  --hover: #1a1a1a;
  --accent: #5b9cf0;
  --start: #22c55e;
  --end: #ff5a4e;
  --warn: #f4b400;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* the hidden attribute must win over any display rule below */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Barlow, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5; font-weight: 400;
  color: var(--body); background: var(--bg);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
b, strong { color: var(--fg); font-weight: 700; }
a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; }
ul, ol { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.ic { flex: none; vertical-align: -2px; }

.hint, .muted.small { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 8px 0 0; }
.muted { color: var(--muted); }
.warn, .err { color: var(--warn) !important; }

/* M tricolour stripe: brand divider only, never a fill for actions */
.m-stripe { height: 4px; background: var(--stripe); flex: none; }

#map { position: fixed; inset: 0; background: var(--bg); }

/* ---------- panel ---------- */
#panel {
  position: fixed; top: 0; left: 0; bottom: 0; width: 400px;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 24px; overflow-y: auto; z-index: 1000;
  display: flex; flex-direction: column; gap: 24px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
#sheet-handle { display: none; }

.brand { display: flex; align-items: center; gap: 16px; }
.brand + .m-stripe { margin-top: -10px; }
.logo {
  width: 40px; height: 40px; display: grid; place-items: center;
  color: var(--fg); border: 1px solid var(--fg);
}
.brand h1 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1; text-transform: uppercase; letter-spacing: -.5px; color: var(--fg); }
.brand h1 span { color: var(--fg); font-weight: 300; }
.brand p { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 400; }

.card + .card { border-top: 1px solid var(--line); padding-top: 24px; }
.card > h2 {
  margin: 0 0 16px; font-size: 14px; font-weight: 700; color: var(--fg);
  text-transform: uppercase; letter-spacing: 1.5px;
  display: flex; align-items: center; gap: 8px;
}
#planner { background: var(--card); padding: 24px; }
#planner > h2 { font-size: 24px; letter-spacing: -.5px; line-height: 1.1; margin-bottom: 16px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--body);
}
.icon-btn:hover { background: var(--elevated); color: var(--fg); }

/* ---------- planner ---------- */
.pl-fields { display: flex; align-items: center; gap: 12px; }
.pl-rail { display: flex; flex-direction: column; align-items: center; width: 14px; flex: none; }
.pl-line { width: 1px; height: 34px; margin: 4px 0; background: repeating-linear-gradient(var(--muted) 0 3px, transparent 3px 6px); }
.dot { width: 12px; height: 12px; flex: none; display: inline-block; }
.dot.a { border: 3px solid var(--start); background: transparent; }
.dot.b { background: var(--end); }
.pl-inputs { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field { position: relative; }
.field input {
  width: 100%; height: 48px; padding: 12px 16px; font: inherit; font-size: 16px; font-weight: 300;
  border: 1px solid var(--line); border-radius: 0;
  background: var(--bg); color: var(--fg); outline: none;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { border-color: var(--fg); }
#from { padding-right: 48px; }
.field input { text-overflow: ellipsis; }
.field-btn {
  position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; border: 0; background: transparent;
  color: var(--body); cursor: pointer; display: grid; place-items: center;
}
.field-btn:hover { color: var(--fg); background: var(--elevated); }
.field-btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
#swap { background: var(--bg); border: 1px solid var(--line); }
#swap:hover { border-color: var(--fg); }
#planner:has(#trip:not(:empty)) #plan-hint:not(.loc) { display: none; }
.data-warn {
  margin: 12px 0 0; padding: 12px; font-size: 13px; line-height: 1.45; color: var(--body-strong);
  background: var(--soft); border-left: 3px solid var(--warn);
}

.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  background: var(--bg); border: 1px solid var(--line);
  max-height: 300px; overflow-y: auto; z-index: 5;
}
.results li {
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--line-strong);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--body-strong);
}
.results li.active, .results li:hover { background: var(--elevated); color: var(--fg); }

/* ---------- trip ---------- */
#trip:empty { display: none; }
#trip { margin-top: 24px; }
.trip-head { position: relative; background: var(--soft); padding: 24px 24px 16px; border-top: 4px solid; border-image: var(--stripe) 1; }
.trip-time { font-size: 40px; font-weight: 700; letter-spacing: -.5px; line-height: 1; color: var(--fg); display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
.trip-meta { color: var(--body); font-size: 14px; margin-top: 8px; }
.trip-tools { position: absolute; top: 10px; right: 8px; display: flex; gap: 2px; }
#trip-share.done { color: var(--start); }
#trip-share.done::after { content: "Disalin"; position: absolute; right: 100%; margin-right: 4px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700; color: var(--start); white-space: nowrap; }
.trip-head { padding-right: 130px; }

.strip { display: flex; gap: 2px; margin-top: 16px; }
.seg {
  min-width: 44px; height: 36px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--c); color: var(--ct, #fff); font-weight: 700; font-size: 12px; letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: opacity .15s;
}
.seg small { font-weight: 300; font-size: 11px; letter-spacing: 0; }
.seg.walk { background: transparent; color: var(--body); border: 1px dashed var(--muted); }
.seg { box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.seg.active { outline: 2px solid var(--fg); outline-offset: 2px; }
.strip:has(.seg.active) .seg:not(.active) { opacity: .4; }
.strip-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 400; }

.stepper { display: flex; gap: 8px; margin-top: 16px; }
.pill {
  height: 48px; padding: 0 24px; border-radius: 0; border: 1px solid var(--line);
  background: transparent; color: var(--fg); cursor: pointer;
  font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.pill.grow { flex: 1; min-width: 0; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; color: var(--body); font-weight: 400; font-size: 11px; letter-spacing: 1px; }
#step-next { padding: 0 16px; }
.pill.grow.on { color: var(--fg); }
.pill.primary { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.pill.primary:not(:disabled):hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill:not(:disabled):hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.pill:disabled { opacity: .3; cursor: default; }
#step-prev { width: 48px; padding: 0; }
/* prev + next on one row, the step label underneath so uppercase text never clips */


.steps { margin-top: 24px; position: relative; }
.step {
  position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 16px;
  padding: 16px 12px 16px; cursor: pointer; scroll-margin-top: 28px;
  border-left: 2px solid transparent;
}
.step::before {
  content: ""; position: absolute; left: 25px; top: 44px; bottom: -8px; width: 4px;
  background: var(--c, var(--line));
}
.step.walk::before { background: repeating-linear-gradient(var(--muted) 0 4px, transparent 4px 9px); width: 2px; left: 26px; }
.step.end::before, .step.start::before { display: none; }
.step.start::after {
  content: ""; position: absolute; left: 26px; top: 38px; bottom: -8px; width: 1px;
  background: repeating-linear-gradient(var(--muted) 0 3px, transparent 3px 6px);
}
.step:hover { background: var(--soft); }
.step.active { background: var(--card); border-left-color: var(--c, var(--fg)); }
.step-num {
  width: 28px; height: 28px; background: var(--c); color: var(--ct, #fff); z-index: 1;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.step.walk .step-num { background: var(--bg); color: var(--body); border: 1px dashed var(--muted); }
.step-num.pin-a { background: var(--bg); border: 3px solid var(--start); width: 20px; height: 20px; margin: 4px; }
.step-num.pin-b { background: var(--end); width: 20px; height: 20px; margin: 4px; }
.step-body { min-width: 0; }
.step-title { font-weight: 700; font-size: 16px; color: var(--fg); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; line-height: 1.3; }
.step-dir { margin-top: 8px; font-size: 16px; color: var(--body-strong); display: flex; align-items: center; gap: 8px; }
.step-dir .ic { color: var(--c); }
.step-sub { color: var(--body); font-size: 14px; margin-top: 4px; }
.step-when { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.step-alight {
  margin-top: 12px; padding: 12px; font-size: 14px; color: var(--body-strong);
  background: var(--soft); border-left: 3px solid var(--c, var(--fg));
}
.step-alight .badge { vertical-align: 1px; }
.step-mid { margin-top: 8px; font-size: 13px; }
.step-mid summary { cursor: pointer; color: var(--fg); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; font-size: 11px; }
.step-mid ol { margin: 8px 0 0; padding-left: 4px; color: var(--body); }
.step-mid li { padding: 2px 0 2px 16px; position: relative; }
.step-mid li::before { content: ""; position: absolute; left: 0; top: 10px; width: 6px; height: 6px; border: 2px solid var(--c); }

/* ---------- station / line detail ---------- */
#detail { position: relative; }
#detail h3 { margin: 0 0 12px; font-size: 24px; font-weight: 700; line-height: 1.1; text-transform: uppercase; letter-spacing: -.5px; color: var(--fg); padding-right: 40px; }
#detail > .close { position: absolute; top: 18px; right: 0; }
.tag { font-size: 11px; font-weight: 700; color: var(--body); border: 1px solid var(--line); padding: 1px 8px; margin-left: 4px; letter-spacing: 1px; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions button, .pop-acts button {
  flex: 1; height: 44px; border-radius: 0; border: 1px solid var(--fg); background: transparent; color: var(--fg);
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.actions button:hover, .pop-acts button:hover { background: var(--fg); color: var(--bg); }
.dep { margin-top: 16px; }
.dep-line { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--fg); margin-bottom: 8px; }
.dep-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; border-bottom: 1px solid var(--line-strong); font-variant-numeric: tabular-nums; }
.dep-row .eta { font-weight: 700; color: var(--fg); }
.dep-row .eta small { font-weight: 300; color: var(--muted); }

.ldiag { margin: 16px 0 0; }
.ldiag li {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 34px; font-size: 14.5px; cursor: pointer; color: var(--body-strong);
}
.ldiag li:hover { background: var(--soft); color: var(--fg); }
.ldiag li::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 6px; background: var(--c); }
.ldiag li:first-child::before { top: 50%; }
.ldiag li:last-child::before { bottom: 50%; }
.ld-dot { position: absolute; left: 7px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--c); }
.ldiag li.inter .ld-dot { border-color: var(--fg); width: 16px; height: 16px; left: 6px; }
.ldiag li.inter .ld-name { font-weight: 700; color: var(--fg); }
.ldiag .badges { margin-left: auto; }
.ldiag .near { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }

/* line code chips keep the official line colours: they are data, not brand */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 20px; padding: 0 8px; border-radius: 0;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: 1px;
}
.badges { display: inline-flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.ldiag .badge { min-width: 30px; height: 17px; font-size: 10px; padding: 0 4px; }

/* ---------- line & live lists ---------- */
.row {
  display: flex; align-items: center; gap: 12px; padding: 8px 4px; cursor: pointer;
  font-size: 14.5px; user-select: none; color: var(--body-strong);
  border-bottom: 1px solid var(--line-strong);
}
.row:hover { color: var(--fg); background: var(--soft); }
.row.sel { color: var(--fg); font-weight: 700; box-shadow: inset 3px 0 0 var(--fg); padding-left: 10px; }
.row.off > :not(.switch) { opacity: .4; }
.row .meta { margin-left: auto; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 400; }
.row .meta.err { color: var(--warn); }
.switch {
  position: relative; width: 34px; height: 18px; border: 1px solid var(--muted); padding: 0; flex: none;
  background: transparent; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px;
  background: var(--muted); transition: transform .15s;
}
.switch.on { border-color: var(--fg); }
.switch.on::after { background: var(--fg); transform: translateX(16px); }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.swatch.sq { border-radius: 0; }

.live-pill {
  margin-left: auto; font-size: 11px; font-weight: 700; padding: 4px 8px; letter-spacing: 1.5px; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid currentColor;
}
.live-pill::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.live-pill.ok { color: var(--start); }
.live-pill.ok::before { animation: pulse 1.6s infinite; }
.live-pill.bad { color: var(--warn); }
.live-pill.loading { color: var(--muted); }
@keyframes pulse { 50% { opacity: .2; } }

footer.hint { text-transform: uppercase; letter-spacing: 1px; font-size: 11px; }

/* ---------- map ---------- */
.leaflet-container { font-family: inherit; background: var(--bg); }
.base-tiles { filter: grayscale(.75) contrast(1.02) brightness(1.03); opacity: .9; }
[data-theme="dark"] .base-tiles { filter: grayscale(1) invert(1) brightness(.62) contrast(1.05); opacity: .85; }
#map.dim .net { opacity: .18; transition: opacity .25s; }
#map.dim .net.focus { opacity: 1; }

.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: none !important; border-radius: 0 !important; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--bg) !important; color: var(--fg) !important; border-bottom-color: var(--line) !important; border-radius: 0 !important; }
.leaflet-bar a:hover { background: var(--fg) !important; color: var(--bg) !important; }
.leaflet-control-attribution { background: var(--bg) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--body); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg); color: var(--body); border: 1px solid var(--line); box-shadow: none; }
.leaflet-popup-content-wrapper { border-radius: 0; }
.leaflet-popup-content { margin: 16px; font-size: 14px; }
.leaflet-tooltip.stn {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 0; box-shadow: none;
  font-weight: 700; font-size: 11px; padding: 4px 8px; text-transform: uppercase; letter-spacing: 1px;
}
.leaflet-tooltip.stn::before { display: none; }

.pop { min-width: 230px; }
.pop-name { font-weight: 700; font-size: 18px; color: var(--fg); text-transform: uppercase; margin-bottom: 8px; line-height: 1.15; }
.pop-acts { display: flex; gap: 8px; margin-top: 16px; }
.pop-acts button { height: 38px; font-size: 11px; }
.pop-link {
  width: 100%; margin-top: 12px; border: 0; background: none; color: var(--fg); cursor: pointer;
  font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.pop-link:hover { color: var(--accent); }

.train-icon {
  width: 22px; height: 22px; color: #fff; display: grid; place-items: center;
  border: 2px solid #fff;
}
.vpop b { font-size: 15px; }

.map-pin { position: absolute; transform: translate(-50%, calc(-100% - 10px)); width: max-content; max-width: 150px; text-align: center; }
.map-pin span { line-height: 1.25; }
.map-pin span {
  display: block; padding: 4px 12px; font-weight: 700; font-size: 11px; color: #fff;
  text-transform: uppercase; letter-spacing: 1.5px;
}
.map-pin::after {
  content: ""; position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff;
}
.map-pin.a span, .map-pin.a::after { background: var(--start); }
.map-pin.b span, .map-pin.b::after { background: var(--end); }
.map-num {
  width: 24px; height: 24px; background: var(--c); color: var(--ct, #fff);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 2px solid #fff;
}
.chev { width: 16px; height: 16px; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.8)); }
.ride-dot {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  border: 3px solid #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.15);
}
.ride-dot.walking { background: #7e7e7e !important; }

/* ---------- mobile bottom sheet ---------- */
/* Height and position come from setSheet() in app.js (peek / half / full). */
@media (max-width: 720px) {
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 236px; max-height: 90vh;
    border-right: 0; border-top: 1px solid var(--line);
    padding: 0 16px 24px; gap: 16px;
    transition: height .28s cubic-bezier(.2, .8, .2, 1);
    overscroll-behavior: contain;
  }
  .sheet-grab {
    position: sticky; top: 0; z-index: 4; margin: 0 -16px; padding: 0 0 4px;
    background: var(--panel); touch-action: none; cursor: grab;
  }
  .sheet-grab::before { content: ""; display: block; height: 4px; background: var(--stripe); }
  #sheet-handle { display: block; width: 100%; border: 0; background: none; padding: 10px 0 6px; cursor: grab; }
  #sheet-handle span { display: block; width: 44px; height: 5px; background: var(--muted); margin: 0 auto; border-radius: 3px !important; }
  .tabs { top: 32px; touch-action: none; }
  .brand, .brand + .m-stripe { display: none; }
  #planner { padding: 16px; }
  #planner > h2 { font-size: 20px; margin-bottom: 12px; }
  .leaflet-bottom.leaflet-right { bottom: calc(var(--sheet-vis, 236px) + 4px); transition: bottom .28s; }
  .trip-time { font-size: 32px; }
}

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

/* ---------- theme toggle (top-right of the map) ---------- */
.theme-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 900; width: 44px; height: 44px;
  display: grid; place-items: center; cursor: pointer;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line);
}
.theme-toggle:hover { background: var(--fg); color: var(--bg); }
.theme-toggle .moon, [data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

/* ---------- time selector & saved trips ---------- */
.when { margin-top: 12px; }
.when-mode { display: flex; border: 1px solid var(--line); }
.when-mode button {
  flex: 1; height: 38px; border: 0; background: var(--panel); color: var(--body); cursor: pointer;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 0 4px;
}
.when-mode button + button { border-left: 1px solid var(--line); }
.when-mode button.on { background: var(--fg); color: var(--bg); }
#when-at {
  width: 100%; height: 44px; margin-top: 8px; padding: 0 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 0;
}
#when-at:focus { border-color: var(--fg); outline: none; }
.trip-when { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13.5px; color: var(--body-strong); }
#trip-fav.on { color: #e6a700; }
#trip-fav.on .ic { fill: currentColor; }

.saved { margin-top: 16px; }
#planner:has(#trip:not(:empty)) .saved { display: none; }
.saved h3 {
  margin: 12px 0 8px; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px; display: flex; justify-content: space-between; align-items: center;
}
.saved li + li { margin-top: 4px; }
.saved-trip {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; color: var(--body-strong); font-size: 14px;
}
.saved-trip:hover { border-color: var(--fg); }
.saved-trip .ic { color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
@media (max-width: 720px) {
  .theme-toggle { top: 10px; right: 10px; }
}

/* display cut for headings, big numbers and uppercase labels */
.brand h1, .card > h2, #detail h3, .trip-time, .pop-name, .seg, .pill, .when-mode button,
.actions button, .pop-acts button, .pop-link, .badge, .tag, .live-pill, .strip-ends, .saved h3,
.row .meta, .step-mid summary, .map-pin span, .leaflet-tooltip.stn, .brand p, footer.hint, .step-num, .map-num {
  font-family: var(--display);
}

/* ---------- route alternatives ---------- */
.alts { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.alt {
  flex: 1 1 120px; padding: 8px 12px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--body);
  display: flex; flex-direction: column; gap: 2px;
}
.alt b { font-family: var(--display); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--fg); }
.alt span { font-size: 12.5px; color: var(--muted); }
.alt small { font-size: 11.5px; color: var(--muted); }
.alt.on { border-color: var(--fg); box-shadow: inset 0 -3px 0 var(--fg); }
.alt:hover { border-color: var(--fg); }
.warn-box { color: var(--body-strong); background: var(--soft); border-left: 3px solid var(--warn); padding: 12px; }
.vpop .late { color: var(--warn); }

/* ---------- get-off reminders ---------- */
.remind {
  width: 100%; height: 44px; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--muted); background: transparent; color: var(--body-strong); cursor: pointer;
  font-family: var(--display); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
}
.remind:hover { border-color: var(--fg); border-style: solid; }
.remind.on { border: 1px solid var(--start); color: var(--start); }
.remind-banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1200;
  width: min(440px, calc(100% - 24px)); padding: 16px 48px 16px 16px;
  background: var(--fg); color: var(--bg); border-top: 4px solid; border-image: var(--stripe) 1;
  display: flex; flex-direction: column; gap: 4px;
}
.remind-banner b { color: var(--bg); font-family: var(--display); font-size: 18px; text-transform: uppercase; letter-spacing: .5px; }
.remind-banner span { font-size: 14px; opacity: .9; }
.remind-banner .icon-btn { position: absolute; top: 8px; right: 8px; color: var(--bg); }
@media (min-width: 721px) { .remind-banner { left: calc(400px + (100% - 400px) / 2); } }

/* ---------- first-visit tips ---------- */
.tips { margin-top: 16px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); }
.tips h3 { margin: 0 0 8px; font-family: var(--display); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--fg); }
.tips ol { list-style: decimal; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--body); }
.tips .pill { margin-top: 12px; height: 36px; }
#planner:has(#trip:not(:empty)) .tips { display: none; }

/* ---------- GPS navigation ---------- */
.nav-card {
  margin-top: 8px; padding: 16px; background: var(--fg); color: var(--bg);
  border-top: 4px solid; border-image: var(--stripe) 1; display: flex; flex-direction: column; gap: 8px;
}
.nav-card b { color: var(--bg); }
.nav-card .badge { vertical-align: 1px; }
.nav-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.nav-live {
  font-family: var(--display); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
  display: inline-flex; align-items: center; gap: 6px; color: #3ddc84;
}
.nav-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.nav-live.est { color: #f4b400; }
.nav-eta { font-family: var(--display); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.nav-where { font-size: 18px; line-height: 1.3; }
.nav-next, .nav-exit { font-size: 14px; opacity: .92; }
.nav-exit { padding-top: 8px; border-top: 1px solid rgba(255,255,255,.18); }
[data-theme="light"] .nav-exit, :root:not([data-theme]) .nav-exit { border-top-color: rgba(255,255,255,.2); }
.nav-bar { height: 4px; background: rgba(127,127,127,.35); }
.nav-bar span { display: block; height: 100%; background: #3ddc84; transition: width .4s; }
.nav-off { display: flex; flex-direction: column; gap: 8px; padding: 8px; background: rgba(244,180,0,.15); color: var(--bg); font-size: 14px; }
.nav-card .pill { background: transparent; color: var(--bg); border-color: var(--bg); }
.nav-card .pill:hover { background: var(--bg); color: var(--fg); }
.nav-msg { margin: 0; font-size: 14px; }
.me-puck {
  width: 22px; height: 22px; border-radius: 50%; background: #1c69d4; border: 4px solid #fff;
  box-shadow: 0 0 0 6px rgba(28,105,212,.25), 0 2px 6px rgba(0,0,0,.35);
}
.me-puck.est { background: #f4b400; box-shadow: 0 0 0 6px rgba(244,180,0,.25), 0 2px 6px rgba(0,0,0,.35); }

/* search extras */
.results li .alias { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.results li.none { cursor: default; color: var(--muted); font-size: 13.5px; }
.results li.none:hover { background: none; }
.field input.nudge { animation: nudge 1.6s ease; }
@keyframes nudge { 0%, 100% { border-color: var(--line); } 20%, 60% { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); } }
.step-clock { font-size: 13px; color: var(--body-strong); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- panel tabs ---------- */
.sheet-grab { display: none; }
@media (max-width: 720px) { .sheet-grab { display: block; } }
.tabs {
  position: sticky; top: 0; z-index: 3; display: flex; background: var(--panel);
  border-bottom: 1px solid var(--line); margin-top: -8px;
}
.tabs button {
  flex: 1; height: 44px; border: 0; background: none; cursor: pointer; color: var(--muted);
  font-family: var(--display); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); }
.tabs button:hover { color: var(--fg); }
[data-panel] { display: flex; flex-direction: column; gap: 24px; }

/* ---------- one obvious next step after a route ---------- */
.trip-cta { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.cta {
  height: 56px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--fg); color: var(--bg); border: 0; cursor: pointer;
  font-family: var(--display); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
}
.cta:hover { background: var(--accent); color: #fff; }
.cta.on { background: var(--start); color: #fff; }
.cta-2 {
  border: 0; background: none; color: var(--accent); cursor: pointer; padding: 8px;
  font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.stepper { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 8px; margin-top: 16px; }
.stepper .cta-2 { grid-column: 1 / -1; justify-self: center; padding: 4px; }
.step-count { text-align: center; font-family: var(--display); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--fg); }
.nav-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-actions .pill { flex: 1; }
/* the panel is a fixed-height flex column: children must not shrink, or the sticky tabs collapse to 0 */
#panel > * { flex-shrink: 0; }
@media (max-width: 720px) { .tabs { top: 33px; } } /* sit below the sticky drag handle */

/* ---------- step-by-step guide card ---------- */
.cta-note { margin: 0; font-size: 13.5px; color: var(--muted); text-align: center; }
.guide-card {
  margin-top: 16px; padding: 16px; background: var(--panel);
  border: 2px solid var(--fg); border-top: 6px solid var(--c, var(--fg));
  display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 88px;
}
.guide-top { display: flex; justify-content: space-between; align-items: center; }
.guide-count { font-family: var(--display); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.guide-top .cta-2 { padding: 4px 0; font-size: 13px; }
.guide-progress { display: flex; gap: 4px; }
.guide-progress span { flex: 1; height: 6px; background: var(--line); }
.guide-progress span.done { background: var(--c); opacity: .45; }
.guide-progress span.now { background: var(--c); }
.guide-title { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--fg); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.guide-title .badge { font-size: 13px; height: 24px; min-width: 44px; }
.guide-list { list-style: none; counter-reset: g; display: flex; flex-direction: column; gap: 12px; }
.guide-list li { counter-increment: g; position: relative; padding-left: 36px; font-size: 16px; line-height: 1.5; color: var(--body-strong); }
.guide-list li::before {
  content: counter(g); position: absolute; left: 0; top: 0; width: 24px; height: 24px;
  display: grid; place-items: center; background: var(--fg); color: var(--bg);
  font-family: var(--display); font-size: 13px; font-weight: 700;
}
.guide-list li.warn::before { background: var(--warn); }
.guide-list .badge { vertical-align: 1px; }
.guide-hint { margin: 0; padding: 8px 12px; font-size: 13px; color: var(--muted); background: var(--soft); }
.guide-nav { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.guide-nav .pill { height: 56px; padding: 0 12px; }
.guide-nav .cta { height: 56px; font-size: 14px; }
/* Back / Next stay on screen while the instructions scroll */
.guide-nav { position: sticky; bottom: -24px; z-index: 2; margin: 0 -16px -16px; padding: 12px 16px 16px; background: var(--panel); border-top: 1px solid var(--line); }
