/* Layout: one-screen app — sidebar planner beside a geographic map; on phones the
   panel becomes a bottom sheet over the map with a bottom navigation bar. */
:root {
  --ground: #ffffff;       /* map ground: plain white */
  --paper: #ffffff;
  --panel: #f4f6f8;
  --ink: #12161d;
  --ink-2: #4a5462;
  --ink-3: #7c8694;
  --rule: #d5dbe2;
  --accent: #1747c9;       /* signage blue for UI actions */
  --accent-ink: #ffffff;
  --accent-soft: #e3eafc;
  --neon: #C6FF00;          /* journey train, same on every line */
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --case: #ffffff;
  --shadow: 0 1px 2px rgba(18, 22, 29, .06), 0 8px 24px rgba(18, 22, 29, .08);

  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sidebar: 400px;
  --nav-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0d1116; --paper: #151a21; --panel: #11161c; --ink: #e7ecf2; --ink-2: #a9b3bf; --ink-3: #747f8c;
    --rule: #262d36; --accent: #7aa2ff; --accent-ink: #0b1020; --accent-soft: #1b2540; --warn: #f0b35a; --warn-soft: #2b2312;
    --case: #0d1116; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0d1116; --paper: #151a21; --panel: #11161c; --ink: #e7ecf2; --ink-2: #a9b3bf; --ink-3: #747f8c;
  --rule: #262d36; --accent: #7aa2ff; --accent-ink: #0b1020; --accent-soft: #1b2540; --warn: #f0b35a; --warn-soft: #2b2312;
  --case: #0d1116; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45); color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--ground); color: var(--ink); font-family: var(--f-body); font-size: 14px; overflow: hidden; }
* { box-sizing: border-box; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }

.app {
  height: 100%; display: grid;
  grid-template-columns: var(--sidebar) 1fr; grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "panel map";
}

/* ---------- Top bar ---------- */
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 20px;
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--paper); border-bottom: 1px solid var(--rule); position: relative; z-index: 6;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.bm-ring { fill: none; stroke: #E2231A; stroke-width: 3; }
.bm-bar { stroke: #1F5BB4; stroke-width: 4; stroke-linecap: round; }
.bm-dot { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--f-display); font-weight: 800; font-stretch: 78%; font-size: 21px; letter-spacing: .01em; text-transform: uppercase; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; }
.top-stats { display: flex; gap: 16px; margin-left: auto; color: var(--ink-3); font-size: 12.5px; }
.top-stats b { font-family: var(--f-mono); color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper);
  display: inline-grid; place-items: center; cursor: pointer; transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--panel); border-color: var(--ink-3); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.icon-btn.primary svg { fill: currentColor; stroke: none; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#theme .i-moon { display: none; } #theme.is-dark .i-moon { display: block; } #theme.is-dark .i-sun { display: none; }

/* ---------- Panel ---------- */
.panel {
  grid-area: panel; background: var(--paper); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 5;
}
.sheet-handle { display: none; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--rule); flex: none; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 4px 11px; cursor: pointer; color: var(--ink-3);
  font-weight: 600; font-size: 13px; border-bottom: 2.5px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .2s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabpane { overflow-y: auto; padding: 18px 20px 28px; flex: 1; min-height: 0; overscroll-behavior: contain; }
.pane-h { font-family: var(--f-display); font-stretch: 85%; font-weight: 750; font-size: 22px; margin: 0 0 14px; letter-spacing: -.005em; text-wrap: balance; }
.sub-h { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); margin: 20px 0 10px; font-weight: 700; }
.note { color: var(--ink-2); line-height: 1.5; margin: 10px 0; font-size: 13px; }
.note.small { font-size: 12px; color: var(--ink-3); }
.note.warn { background: var(--warn-soft); color: var(--warn); padding: 9px 12px; border-radius: 9px; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: left; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.linklike:hover { text-decoration-color: currentColor; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--paper); font-weight: 600; font-size: 13px; transition: transform .1s, background .15s;
}
.btn:hover { background: var(--panel); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; color: var(--ink-3); }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico-play, .ico-pause { fill: currentColor; stroke: none; }

.ldot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1.5px var(--paper); flex: none; }

/* Planner */
.planner { display: grid; grid-template-columns: 18px 1fr 36px; gap: 10px; align-items: center; }
.ends { display: flex; flex-direction: column; align-items: center; align-self: stretch; padding: 30px 0 14px; }
.end { width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 800; display: grid; place-items: center; color: #fff; font-family: var(--f-mono); }
.end.a { background: var(--ink); color: var(--paper); } .end.b { background: var(--accent); color: var(--accent-ink); }
.end-line { flex: 1; width: 2px; background: repeating-linear-gradient(var(--ink-3) 0 3px, transparent 3px 7px); margin: 4px 0; }
.fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.combo { position: relative; }
.combo label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; display: block; margin-bottom: 5px; }
.combo-row { display: flex; gap: 6px; }
.combo input {
  flex: 1; min-width: 0; height: 42px; border-radius: 10px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink);
  padding: 0 12px; font: 500 15px var(--f-body);
}
.combo input:focus { outline: none; border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--accent-soft); }
.pick-btn { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper); cursor: pointer; display: grid; place-items: center; flex: none; }
.pick-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.pick-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opts {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; list-style: none; margin: 0; padding: 4px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto;
}
.opts li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.opts li:hover, .opts li.act { background: var(--accent-soft); }
.opts li.empty { color: var(--ink-3); cursor: default; background: none; }
.opt-lines { display: flex; gap: 3px; }
.swap { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper); cursor: pointer; display: grid; place-items: center; margin-top: 18px; transition: transform .3s; }
.swap:hover { transform: rotate(180deg); }
.swap svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.results { margin-top: 18px; }
.empty-plan p { color: var(--ink-2); line-height: 1.55; margin: 0 0 10px; }
.empty-plan .eg-h { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; margin-top: 18px; }
.eg { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 12.5px; }
.chip:hover { border-color: var(--ink-3); }

.alts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.alt {
  border: 1px solid var(--rule); background: var(--paper); border-radius: 12px; padding: 10px 10px 11px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; min-width: 0; transition: border-color .15s, box-shadow .2s;
}
.alt:hover { border-color: var(--ink-3); }
.alt.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.alt-h { font-weight: 700; font-size: 12.5px; }
.alt-lines { display: flex; gap: 3px; margin: 2px 0 4px; flex-wrap: wrap; }
.alt-row { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.alt-row b { font-family: var(--f-mono); font-size: 13.5px; color: var(--ink-2); }
.alt-row.best { color: var(--ink); font-weight: 600; }
.alt-row.best b { color: var(--ink); }
.same { font-size: 10.5px; color: var(--ink-3); margin-top: 3px; font-style: italic; }

.insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; margin-top: 14px; }
.tile { background: var(--paper); padding: 10px 12px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tile.accent { grid-column: span 2; flex-direction: row; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tile-l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; }
.tile-v { font-family: var(--f-display); font-stretch: 80%; font-weight: 750; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile.accent .tile-v { font-size: 28px; color: var(--accent); }
.tile-s { font-size: 11.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.fare-day { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.fare-day > span { font-size: 12px; color: var(--ink-3); }
.seg-ctl { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--rule); gap: 2px; }
.seg-ctl button { border: 0; background: none; padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.seg-ctl button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg-ctl.tiny button { padding: 4px 7px; font-family: var(--f-mono); font-size: 11px; }
.journey-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }

.itin { list-style: none; margin: 16px 0 6px; padding: 0; }
.leg { position: relative; padding-left: 26px; }
.leg.ride { padding-bottom: 4px; }
.leg.ride::before { content: ""; position: absolute; left: 7px; top: 9px; bottom: -6px; width: 5px; border-radius: 3px; background: var(--c); }
.leg-st { font-weight: 700; font-size: 14.5px; position: relative; padding: 2px 0 6px; }
.leg-st::before { content: ""; position: absolute; left: -24px; top: 4px; width: 15px; height: 15px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-sizing: border-box; z-index: 1; }
.leg-st.end { padding-top: 10px; }
.leg-st.end::before { top: 12px; border-color: var(--accent); }
.leg-body { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 10px; }
.leg-line { font-weight: 600; }
.tw { font-weight: 400; color: var(--ink-2); }
.leg-meta { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.leg details { margin-top: 4px; }
.leg summary { cursor: pointer; font-size: 12px; color: var(--ink-2); }
.via { list-style: none; margin: 6px 0 2px; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.leg.change, .leg.walk { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px 9px 40px; margin: 4px 0 10px; background: var(--panel); border: 1px dashed var(--rule); border-radius: 10px; font-size: 13px; }
.chg-icons { position: absolute; left: 10px; top: 11px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.chg-icons .ico { width: 12px; height: 12px; transform: rotate(90deg); color: var(--ink-3); }
.leg.walk .chg-icons .ico { transform: none; width: 18px; height: 18px; color: var(--ink-2); }

/* Explorer */
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 700; margin: 0 0 4px; }
.ex-head h2 { font-family: var(--f-display); font-stretch: 82%; font-weight: 780; font-size: 28px; line-height: 1.05; margin: 0 0 10px; text-wrap: balance; }
.ex-lines { display: flex; flex-wrap: wrap; gap: 6px; }
.lchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, var(--paper)); font-size: 12px; font-weight: 600; }
.lchip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.ex-inter { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--panel); color: var(--ink-2); line-height: 1.5; font-size: 13px; }
.ex-inter .ico { vertical-align: -3px; }
.ex-actions { display: flex; gap: 6px; margin-top: 14px; }
.xl { margin-bottom: 12px; }
.xl h3 { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 0 0 6px; }
.xl-bar { width: 18px; height: 5px; border-radius: 3px; background: var(--c); }
.xl-op { margin-left: auto; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.nb { list-style: none; margin: 0; padding: 0 0 0 26px; display: flex; flex-direction: column; gap: 6px; }
.nb li { display: flex; flex-direction: column; }
.nb-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-align: left; }
.nb-btn .ico { width: 13px; height: 13px; color: var(--c); }
.nb-btn:hover { color: var(--accent); }
.nb-tw { font-size: 12px; color: var(--ink-3); padding-left: 19px; }

/* Live */

/* Lines */
.lines-list { display: flex; flex-direction: column; gap: 6px; }
.line-item { border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--paper); }
.line-item.on { border-color: var(--c); box-shadow: inset 3px 0 0 var(--c); }
.line-btn { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; background: none; border: 0; cursor: pointer; text-align: left; }
.leg-svg { width: 64px; height: 14px; overflow: visible; }
.leg-base { stroke-width: 5; stroke-linecap: round; fill: none; }
.leg-flow { stroke: rgba(255,255,255,.85); stroke-width: 1.6; stroke-dasharray: 2 7; fill: none; stroke-linecap: round; opacity: 0; transition: opacity .2s; }
.line-item:hover .leg-flow, .line-item.on .leg-flow { opacity: 1; animation: legflow .8s linear infinite; }
@keyframes legflow { to { stroke-dashoffset: -9; } }
.leg-end { fill: var(--paper); stroke-width: 2; }
.line-txt { display: flex; flex-direction: column; min-width: 0; }
.line-txt b { font-size: 14px; }
.line-txt span { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
.line-n { font-family: var(--f-mono); font-weight: 700; font-size: 15px; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.line-n small { font-family: var(--f-body); font-size: 10px; color: var(--ink-3); font-weight: 500; margin-top: 3px; }
.line-detail { padding: 0 14px 14px; }
.svc-h { font-size: 12px; font-weight: 700; margin: 12px 0 6px; color: var(--ink-2); }
.stn-list { list-style: none; margin: 6px 0 0; padding: 0 0 0 4px; position: relative; }
.stn-list::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 4px; border-radius: 2px; background: var(--c); }
.stn-list li { display: flex; align-items: center; gap: 6px; padding: 3px 0 3px 22px; position: relative; font-size: 13px; }
.stn-list li::before { content: ""; position: absolute; left: 4px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--paper); border: 2px solid var(--c); box-sizing: border-box; }
.stn-list li.x::before { width: 12px; height: 12px; margin-top: -6px; left: 3px; border: 2.5px solid var(--ink); }
.stn-list li.x .linklike { font-weight: 650; }

/* ---------- Map ---------- */
.mapwrap { grid-area: map; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--ground); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; --inv: 1;
}
#map.dragging { cursor: grabbing; }
#map.picking { cursor: crosshair; }
#map:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }

.line-g { transition: opacity .35s; }
.line { fill: none; stroke-width: calc(4.6px * var(--inv)); stroke-linecap: round; stroke-linejoin: round; }
.line-case { fill: none; stroke: var(--case); stroke-width: calc(8px * var(--inv)); stroke-linecap: round; stroke-linejoin: round; }
.walk-link { fill: none; stroke: var(--ink-2); stroke-width: calc(2px * var(--inv)); stroke-dasharray: calc(2px * var(--inv)) calc(4px * var(--inv)); stroke-linecap: round; }
#map.has-focus .line-g, #map.iso .line-g:not(.iso-on) { opacity: .16; }
#map.has-focus .walk-link { opacity: .3; }

.st { transform: translate(var(--x), var(--y)) scale(var(--inv)); cursor: pointer; transition: opacity .3s; }
.st .hit { fill: transparent; }
.st .dot { transition: transform .18s cubic-bezier(.3,1.6,.5,1); }
.st:hover .dot, .st.sel .dot { transform: scale(1.4); }
.st .node { fill: var(--paper); stroke-width: 2.8; filter: drop-shadow(0 0.5px 0.8px rgba(0,0,0,.25)); }
.st .ring { fill: var(--paper); stroke: var(--ink); stroke-width: 3; filter: drop-shadow(0 0.5px 1px rgba(0,0,0,.3)); }
/* Labels: position, size and visibility are set by the collision-free layout in app.js */
.st .lbl {
  font-family: var(--f-body); font-weight: 600; font-size: 11.5px; fill: var(--ink); paint-order: stroke; stroke: var(--ground); stroke-width: 3.6px; stroke-linejoin: round;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; pointer-events: none;
}
.st.term .lbl { font-weight: 750; font-family: var(--f-display); font-stretch: 85%; }
.st.is-from .lbl, .st.is-to .lbl, .st.xchg .lbl { font-weight: 700; }
.st.lbl-on .lbl, .st:hover .lbl { opacity: 1; visibility: visible; }
#map.has-focus .st:not(.hot), #map.iso .st:not(.hot) { opacity: .25; }
.st.is-from .ring, .st.is-from .node { stroke: var(--ink); stroke-width: 3.6; }
.st.is-to .ring, .st.is-to .node { stroke: var(--accent); stroke-width: 3.6; }
#map.riding .st.on-route .lbl { font-weight: 700; }
#map.riding .st.next .lbl { fill: var(--ink); }
#map.riding .st.next .dot { transform: scale(1.5); }
#map.riding .st.next .node, #map.riding .st.next .ring { fill: var(--neon); stroke: var(--ink); }
.st.arrive .dot { animation: arrive .6s ease; }
@keyframes arrive { 40% { transform: scale(2.1); } 100% { transform: scale(1); } }

/* Route */
.r-case { fill: none; stroke: var(--ground); stroke-width: calc(13px * var(--inv)); stroke-linecap: round; stroke-linejoin: round; }
.r-line { fill: none; stroke-width: calc(8px * var(--inv)); stroke-linecap: round; stroke-linejoin: round; }
.r-flow { fill: none; stroke: rgba(255,255,255,.9); stroke-width: calc(2.2px * var(--inv)); stroke-linecap: round;
  stroke-dasharray: calc(1px * var(--inv)) calc(11px * var(--inv)); animation: flow 1.1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: calc(-12px * var(--inv)); } }
.r-walk, .walk-anim { fill: none; stroke: var(--ink); stroke-width: calc(3px * var(--inv)); stroke-linecap: round;
  stroke-dasharray: calc(1px * var(--inv)) calc(6px * var(--inv)); animation: walkflow .7s linear infinite; }
@keyframes walkflow { to { stroke-dashoffset: calc(-7px * var(--inv)); } }
.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s cubic-bezier(.6,.1,.3,1) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.pin { transform: translate(var(--x), var(--y)) scale(var(--inv)); pointer-events: none; }
.pin-body { fill: var(--ink); stroke: var(--ground); stroke-width: 2; }
.pin-b .pin-body { fill: var(--accent); }
.pin-t { font: 800 11px var(--f-mono); fill: var(--paper); }
.pin-b .pin-t { fill: var(--accent-ink); }
.pin { animation: pindrop .5s cubic-bezier(.3,1.5,.5,1) both; }
@keyframes pindrop { from { opacity: 0; } }

/* Connection FX */
.fx-link { fill: none; stroke-width: calc(9px * var(--inv)); stroke-linecap: round; opacity: .55; }
.st-fx { transform: translate(var(--x), var(--y)) scale(var(--inv)); pointer-events: none; }
.fx-ring { fill: none; stroke-width: 2.5; transform-box: fill-box; transform-origin: center; animation: ring 1.8s ease-out infinite; }
.fx-ring.late { animation-delay: .9s; }
.fx-ring.delay { animation-delay: .5s; animation-iteration-count: 2; }
@keyframes ring { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(2.1); opacity: 0; } }
.plat { stroke: var(--paper); stroke-width: 2; }
.plat.pop { transform-box: fill-box; transform-origin: center; animation: pop .45s .3s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes pop { from { transform: scale(0); } }
.plat-path { fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-dasharray: 1.2 4; stroke-linecap: round; animation: platflow .8s linear infinite; }
@keyframes platflow { to { stroke-dashoffset: -5.2; } }
.plat-halo { fill: color-mix(in srgb, var(--paper) 88%, transparent); stroke: var(--rule); stroke-width: 1; }
.plat-lbl { font: 700 10.5px var(--f-body); fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; }
.walker-dot { fill: var(--neon); stroke: #12161d; stroke-width: 2; }

/* Trains */
.train { pointer-events: none; }
.train-rect { stroke: var(--paper); stroke-width: 1.5; }
.train-win { fill: rgba(255,255,255,.85); }
.train.sim { opacity: .95; }
.train.sim .train-rect { transform: scale(.72); }
.train.sim .train-win { transform: scale(.72); }
/* Journey train: one neon colour on every line */
.train.jtrain .train-rect { stroke: #12161d; stroke-width: 1.8; filter: drop-shadow(0 0 4px var(--neon)); }
.train.jtrain .train-win { fill: #12161d; }
.jhalo { fill: var(--neon); opacity: .35; transform-box: fill-box; transform-origin: center; animation: jhalo 1.4s ease-out infinite; }
@keyframes jhalo { 0% { transform: scale(.45); opacity: .55; } 100% { transform: scale(1.35); opacity: 0; } }
#map.has-focus .train.sim, #map.iso .train.sim { opacity: .18; }

/* Map chrome */
.mapctrl { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: 16px; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; z-index: 3; }
.mapctrl button { width: 40px; height: 40px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.mapctrl button + button { border-top: 1px solid var(--rule); }
.mapctrl button:hover { background: var(--panel); }
.mapctrl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mapmeta { position: absolute; left: 16px; bottom: 16px; display: flex; align-items: flex-end; gap: 12px; pointer-events: none; z-index: 2; }
.compass { display: flex; flex-direction: column; align-items: center; font: 700 10px var(--f-mono); color: var(--ink-2); }
.compass svg { width: 18px; height: 18px; fill: var(--ink-2); }
.scale { display: flex; flex-direction: column; gap: 3px; font: 500 10.5px var(--f-mono); color: var(--ink-2); }
.scale-bar { height: 6px; border: 2px solid var(--ink-2); border-top: 0; transition: width .2s; }
.tip { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; background: var(--ink); color: var(--paper); padding: 7px 10px; border-radius: 9px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; max-width: 240px; box-shadow: var(--shadow); }
.tip strong { font-weight: 700; }
.tip em { font-style: normal; font-size: 11px; opacity: .75; }
.tip-lines { display: flex; gap: 3px; }
.tip .ldot { box-shadow: 0 0 0 1.5px var(--ink); }
.pick-banner { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 4; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 6px 6px 6px 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 120px); }
.pick-banner button { border: 0; background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 12px; }

/* Journey pill (replaces the old control bar) */
.jride { position: absolute; z-index: 6; left: 50%; top: 16px; transform: translateX(-50%); width: min(460px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 13px 16px; background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden;
  animation: ridein .4s cubic-bezier(.3,1.3,.5,1); }
.jride[hidden] { display: none; }
@keyframes ridein { from { transform: translate(-50%, -14px); opacity: 0; } }
.ride-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--neon)); flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--neon)) 28%, transparent); }
.ride-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#ride-k { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: var(--ink-3); }
#ride-name { font-family: var(--f-display); font-stretch: 82%; font-weight: 800; font-size: 21px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ride-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--panel); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.ride-btn[hidden] { display: none; }
.ride-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#ride-sound .mute { display: none; }
#ride-sound.off { color: var(--ink-3); }
#ride-sound.off .wave { display: none; }
#ride-sound.off .mute { display: inline; }
.ride-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--rule); }
#ride-prog { height: 100%; background: var(--neon); box-shadow: 0 0 6px var(--neon); transform-origin: left; transform: scaleX(0); }
body.riding .m-top, body.riding .m-fabs, body.riding .m-hint, body.riding .pick-banner { display: none !important; }


.modal { position: fixed; inset: 0; z-index: 30; background: rgba(8, 10, 14, .5); display: grid; place-items: center; padding: 20px; }
.modal-card { background: var(--paper); border-radius: 16px; padding: 22px 24px; max-width: 620px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-card h2 { font-family: var(--f-display); font-stretch: 85%; font-weight: 780; font-size: 24px; margin: 0 0 10px; }
.modal-card p { line-height: 1.55; color: var(--ink-2); margin: 0 0 12px; max-width: 65ch; }
.modal-card b { color: var(--ink); }

/* ---------- Phone-only pieces (hidden on desktop) ---------- */
.m-top, .m-fabs, .m-hint, .m-sum, .m-pend, .m-only { display: none; }
.round-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper); display: grid; place-items: center; flex: none; cursor: pointer; color: var(--ink-2); }
.round-btn .ico { width: 17px; height: 17px; }

/* ---------- Phone: full-screen map, floating search, bottom sheet ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "map"; }
  .topbar, .tabs, .mapctrl, .mapmeta, .tip { display: none !important; }
  body::before { background: transparent; }

  /* Floating search card */
  .m-top { display: block; position: absolute; z-index: 7;
    top: max(10px, env(safe-area-inset-top, 0px)); left: max(10px, env(safe-area-inset-left, 0px)); right: calc(max(10px, env(safe-area-inset-right, 0px)) + 54px); }
  .m-top .planner { background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); padding: 4px 4px 4px 12px; grid-template-columns: 14px 1fr 36px; gap: 6px; }
  .m-top .ends { padding: 16px 0; }
  .m-top .end { width: 14px; height: 14px; font-size: 0; }
  .m-top .combo label, .m-top .pick-btn { display: none; }
  .m-top .fields { gap: 0; }
  .m-top .combo + .combo { border-top: 1px solid var(--rule); }
  .m-top .combo input { height: 44px; border: 0; background: transparent; font-size: 16px; padding: 0 6px; border-radius: 10px; }
  .m-top .combo input:focus { box-shadow: none; background: var(--panel); }
  .m-top .combo input::placeholder { color: var(--ink-3); }
  .m-top .swap { margin: 0; border: 0; width: 36px; height: 36px; }
  .m-top .opts { max-height: 46vh; border-radius: 14px; }
  .m-top .opts li { padding: 12px 10px; font-size: 15px; }

  /* Floating tool buttons */
  .m-fabs { display: flex; flex-direction: column; gap: 8px; position: absolute; z-index: 7;
    top: max(10px, env(safe-area-inset-top, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); }
  .fab { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--paper); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
  .fab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .fab[aria-pressed="true"] { color: var(--accent); }
  body[data-sheet="full"] .m-fabs { opacity: 0; pointer-events: none; }
  .m-fabs { transition: opacity .2s; }

  /* "What to tap next" pill */
  .m-hint { display: flex; align-items: center; gap: 10px; position: absolute; z-index: 5; left: 50%; transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); background: var(--ink); color: var(--paper); border-radius: 999px;
    padding: 9px 18px 9px 9px; font-weight: 650; font-size: 15px; white-space: nowrap; box-shadow: var(--shadow); animation: hintin .4s cubic-bezier(.3,1.4,.5,1); }
  .m-hint[hidden] { display: none; }
  body[data-sheet="peek"] .m-hint { bottom: calc(var(--peek-h, 0px) + 12px); }
  .m-hint .end { width: 24px; height: 24px; font-size: 12px; font-style: normal; box-shadow: 0 0 0 2px var(--paper); }
  .m-hint .end.a { background: var(--paper); color: var(--ink); }
  @keyframes hintin { from { opacity: 0; transform: translate(-50%, 10px); } }

  /* Bottom sheet: closed / peek / full */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; height: min(80vh, 680px); z-index: 8;
    border-right: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.14);
    padding-bottom: env(safe-area-inset-bottom, 0px); transform: translateY(0); transition: transform .38s cubic-bezier(.3,1,.4,1);
  }
  .panel[data-sheet="closed"] { transform: translateY(105%); box-shadow: none; }
  .panel[data-sheet="peek"] { transform: translateY(calc(100% - var(--peek, 0px))); }
  .sheet-handle { display: grid; place-items: center; height: 26px; border: 0; background: none; cursor: pointer; flex: none; }
  .sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--rule); }
  .tabpane { padding-top: 4px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .panel[data-sheet="peek"] .tabpane { overflow: hidden; }

  /* Plan results: only the essentials */
  #tab-plan .pane-h, .alts, .insights, .journey-actions, .results .note.small, .empty-plan { display: none; }
  .results { margin-top: 0; display: flex; flex-direction: column; }
  .results .itin { order: 2; margin-top: 4px; }
  .results .fare-day { order: 3; }
  .results .note.warn { order: 4; font-size: 12.5px; }

  .m-sum { display: flex; flex-direction: column; gap: 12px; padding: 2px 0 14px; }
  .ms-top { display: flex; align-items: center; gap: 10px; }
  .ms-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
  .ms-time { font-family: var(--f-display); font-stretch: 78%; font-weight: 800; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
  .ms-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
  .ms-fare { color: var(--accent); font-weight: 750; }
  .ms-play { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent); }
  .ms-play .ico { width: 22px; height: 22px; margin-left: 2px; }
  .ms-strip { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .ms-strip::-webkit-scrollbar { display: none; }
  .ms-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--c); color: var(--t, #fff); font-weight: 700; font-size: 12.5px; white-space: nowrap; flex: none; }
  .ms-pill small { font-family: var(--f-mono); font-size: 11px; opacity: .8; }
  .ms-sep { display: grid; place-items: center; color: var(--ink-3); flex: none; }
  .ms-sep .ico { width: 15px; height: 15px; }
  .ms-opts { display: flex; gap: 6px; }
  .ms-opts button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--rule); background: var(--paper); font-size: 12.5px; font-weight: 650; color: var(--ink-2); cursor: pointer; }
  .ms-opts button.on { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
  .ms-opts small { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); font-weight: 500; }

  .m-pend { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px; }
  .m-pend .end { width: 26px; height: 26px; font-size: 12px; flex: none; }
  .mp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
  .mp-txt b { font-size: 18px; font-family: var(--f-display); font-stretch: 85%; font-weight: 750; }
  .mp-lines { display: flex; gap: 4px; }
  .mp-lines .ldot { width: 11px; height: 11px; }

  /* Station card */
  .ex-peek { padding-bottom: 14px; }
  .ex-head .eyebrow { display: none; }
  .ex-head h2 { font-size: 24px; margin-bottom: 8px; }
  .ex-actions { margin-top: 12px; align-items: center; }
  .ex-actions .btn { flex: 1; justify-content: center; padding: 12px; font-size: 14px; border-radius: 12px; }
  .m-only { display: grid; }
  .panel[data-sheet="full"] .ex-actions .m-only .ico { transform: rotate(180deg); }

  /* Map: bigger, easier targets */
  .st .dot { transform: scale(1.25); }
  .st.sel .dot, .st.is-from .dot, .st.is-to .dot { transform: scale(1.7); }
  #map.riding .st.next .dot { transform: scale(1.8); }
  .jride { top: max(10px, env(safe-area-inset-top, 0px)); width: calc(100% - 20px); }
  .pick-banner { top: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .r-flow, .walk-anim, .r-walk, .plat-path { animation: none !important; }
}
