:root {
  --font: "Helvetica Neue", Helvetica, "Inter", "Segoe UI", Arial, sans-serif;
  --radius: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --panel-w: 372px;
  --gap: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b14;
  --glass: rgba(14, 20, 34, .72);
  --glass-border: rgba(255, 255, 255, .09);
  --glass-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  --text: #eef2fb;
  --muted: #8d99b3;
  --faint: rgba(255, 255, 255, .07);
  --accent: #5ee6a8;
  --warn: #ffb547;
  --bad: #ff6b6b;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #dfe7ee;
  --glass: rgba(255, 255, 255, .78);
  --glass-border: rgba(16, 24, 40, .1);
  --glass-shadow: 0 18px 50px rgba(30, 45, 70, .18);
  --text: #121826;
  --muted: #5d6779;
  --faint: rgba(16, 24, 40, .06);
  --accent: #0a9d63;
  --warn: #b76a00;
  --bad: #d43b3b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
/* No double-tap zoom anywhere (quick taps on +, Near me or Home were zooming the whole page
   on iPhones), and no pinch zoom on the small controls where it only happens by accident. The
   panel's text can still be pinch-zoomed, and Home undoes any page zoom (see app.js). */
body { touch-action: manipulation; }
.brand, .controls, .tour-chip, .find, .handle { touch-action: none; }
.dock { touch-action: pan-x; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
}

/* ---------- brand ---------- */
.brand {
  position: fixed; top: calc(var(--gap) + var(--safe-t)); left: var(--gap); z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px 10px 10px; border-radius: 999px;
  animation: drop .8s var(--ease) both .15s;
}
.mark { width: 40px; height: 40px; border-radius: 50%; position: relative; flex: none; background: conic-gradient(from 210deg, #0062CF, #009952, #F6BC26, #EB6800, #D82233, #9A38A1, #0062CF); animation: spin 14s linear infinite; }
.mark span { position: absolute; inset: 5px; border-radius: 50%; background: var(--bg); }
.mark span::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--text); animation: breathe 2.4s ease-in-out infinite; }
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand h1 em { font-style: normal; color: var(--accent); }
.brand p { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 2px; }
.brand p i { font-style: normal; margin: 0 6px; opacity: .5; }
.pulse { position: relative; width: 28px; height: 28px; flex: none; margin-left: 2px; }
.pulse svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.pulse circle { fill: none; stroke: var(--faint); stroke-width: 3; }
.pulse #pulse-ring { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; }
.pulse b { position: absolute; inset: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.pulse.flash b { animation: flash .7s var(--ease); }
.pulse.stale #pulse-ring, .pulse.stale b { stroke: var(--bad); background: var(--bad); box-shadow: 0 0 12px var(--bad); }

/* ---------- controls ---------- */
.controls { position: fixed; left: var(--gap); bottom: calc(var(--gap) + var(--safe-b)); z-index: 5; display: flex; flex-direction: column; gap: 8px; animation: rise .8s var(--ease) both .3s; }
.controls button, .controls a { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; transition: transform .2s var(--ease), background .2s; }
.controls button:hover, .controls a:hover { transform: translateY(-1px) scale(1.05); }
.controls button:active, .controls a:active { transform: scale(.94); }
/* every button says what it is under its icon, so nobody has to hover to find out */
.controls button, .controls a { width: 52px; height: 54px; align-content: center; gap: 3px; grid-template-rows: auto auto; }
.controls .lbl { display: block; font-size: 10px; font-weight: 600; line-height: 1; color: var(--muted); white-space: nowrap; }
.controls .on .lbl { color: var(--accent); }
.controls a { color: inherit; text-decoration: none; }
/* map controls above, then Autopilot and Help together at the bottom */
.controls .gap { height: 2px; }
.controls #btn-help b { font-size: 19px; font-weight: 700; line-height: 1; }
.controls svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .moon, :root[data-theme="light"] .sun { display: none; }

.controls button.on { color: var(--accent); box-shadow: var(--glass-shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }
.controls button.on svg path { fill: currentColor; }
/* the tour is on but waiting (you touched the map, opened something, pressed Home): not green */
.controls button.paused { box-shadow: var(--glass-shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--muted) 45%, transparent); }

/* ---------- the "More" menu: the less-used buttons, as rows ---------- */
/* Autopilot stays in the column only while it is running, so it can be stopped at a glance */
.controls > #btn-tour:not(.on) { display: none; }
#btn-more { position: relative; }
#btn-more .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; }
#btn-more.has-dot .dot { display: block; }
#btn-more[aria-expanded="true"] { color: var(--accent); }
/* nearly opaque: inside the column, the glass blur can't see the map behind it */
.more-menu { background: #f7f9fb; position: absolute; left: calc(100% + 10px); bottom: 0; z-index: 6; min-width: 210px; padding: 6px; border-radius: 16px; display: grid; gap: 2px; transform-origin: bottom left; animation: menu-in .18s var(--ease) both; }
.more-menu[hidden] { display: none; }
:root[data-theme="dark"] .more-menu { background: #141c2c; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } }
.controls .more-menu button, .controls .more-menu a {
  width: auto; height: 44px; padding: 0 12px; border-radius: 11px; display: flex; align-items: center; gap: 11px;
  background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--text); font: inherit; text-align: left;
}
.controls .more-menu button:hover, .controls .more-menu a:hover { transform: none; background: var(--faint); }
.controls .more-menu button:active, .controls .more-menu a:active { transform: none; background: var(--faint); }
.controls .more-menu .lbl { display: block; flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }
.controls .more-menu .state { font-size: 12.5px; color: var(--muted); }
.controls .more-menu .on .state, .controls .more-menu [aria-pressed="true"] .state { color: var(--accent); }
.controls .more-menu svg { flex: none; }
.controls .more-menu #btn-help b { width: 20px; text-align: center; font-size: 17px; }
.controls .more-menu button.on { box-shadow: none; }
.controls .more-menu button.on svg path { fill: none; }

/* ---------- heat legend: beside the button column, or under the title on a phone ---------- */
.heat-legend { position: fixed; z-index: 5; left: calc(var(--gap) + 64px); bottom: calc(var(--gap) + var(--safe-b)); padding: 9px 12px; border-radius: 14px; font-size: 11.5px; display: grid; gap: 6px; max-width: 220px; animation: rise .4s var(--ease) both; }
.heat-legend[hidden] { display: none; }
.heat-legend b { font-size: 12px; }
.heat-legend .rows { display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, auto); gap: 4px 12px; }
.heat-legend .rows span { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); }
.heat-legend i { width: 11px; height: 11px; border-radius: 50%; flex: none; box-sizing: border-box; }
.heat-legend i.hollow { border: 2.5px solid; background: transparent; }
.heat-legend i.mark { background: var(--c); box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--c) 35%, transparent); width: 8px; height: 8px; margin: 0 1.5px; }
.heat-legend a { color: var(--accent); font-size: 11px; text-decoration: none; }
.heat-legend small { color: var(--muted); font-size: 10.5px; line-height: 1.35; white-space: normal; }

/* ---------- auto tour ---------- */
.spot { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 1.6s ease;
  background: radial-gradient(circle at var(--sx, 40%) var(--sy, 50%), transparent 0, transparent 24vmin, var(--spot) 78vmin); }
.spot.on { opacity: 1; }
:root[data-theme="dark"] { --spot: rgba(2, 4, 10, .62); }
:root[data-theme="light"] { --spot: rgba(40, 55, 80, .26); }

.tour-chip {
  position: fixed; z-index: 5; bottom: calc(var(--gap) + var(--safe-b)); left: calc((100vw - var(--panel-w) - var(--gap) * 2) / 2);
  transform: translateX(-50%); max-width: min(520px, calc(100vw - var(--panel-w) - 150px));
  display: flex; align-items: center; gap: 12px; padding: 11px 14px 13px 12px; border-radius: 18px; overflow: hidden; text-align: left;
  animation: chipin .7s var(--ease) both;
}
.tour-chip[hidden] { display: none; }
.tc-lines { display: flex; gap: 4px; flex: none; }
.tc-lines .bullet { font-size: 15px; }
.tc-lines .bullet.wide { font-size: 10.5px; }
.tc-lines .bullet + .bullet { margin-left: -9px; box-shadow: 0 0 0 2px var(--bg); }
.tc-text { min-width: 0; }
.tc-tag { display: inline-block; font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.tc-tag[hidden] { display: none; }
.tc-text b { display: block; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.tc-text small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-next { flex: none; margin-left: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; font-size: 17px; line-height: 1; color: var(--muted); transition: transform .2s var(--ease), color .2s; }
.tour-chip:hover .tc-next { color: var(--text); transform: translateX(2px); }
.tc-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--faint); }
.tc-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.tour-chip.run .tc-bar span { animation: chipbar var(--hold, 13s) linear both; }
.tour-chip.paused .tc-bar, .tour-chip.paused .tc-lines { display: none; }
.tour-chip.paused .tc-next { transform: none; }
/* the paused card says so for a moment, then fades out (see pausedCard) */
.tour-chip.leaving { animation: chipout .4s var(--ease) both; pointer-events: none; }
@keyframes chipout { to { opacity: 0; } }
@keyframes chipin { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } }
@keyframes chipbar { to { width: 100%; } }

/* ---------- panel ---------- */
.panel {
  position: fixed; z-index: 6; top: calc(var(--gap) + var(--safe-t)); right: var(--gap); bottom: calc(var(--gap) + var(--safe-b));
  width: var(--panel-w); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slide .9s var(--ease) both .25s;
}
.handle { display: none; }
.dock { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 16px 14px; border-bottom: 1px solid var(--faint); flex: none; }
/* ---------- search, near me ---------- */
.find { flex: none; display: flex; align-items: center; gap: 8px; margin: 14px 16px 0; padding: 0 5px 0 12px; height: 42px; border-radius: 13px; background: var(--faint); transition: box-shadow .2s; }
.find:focus-within { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 60%, transparent); }
.find .mag { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.1; stroke-linecap: round; }
.find input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: 14.5px; -webkit-appearance: none; appearance: none; }
.find input::placeholder { color: var(--muted); opacity: .9; }
.find input::-webkit-search-cancel-button { -webkit-appearance: none; }
.find kbd { flex: none; font: 600 11px var(--font); color: var(--muted); border: 1px solid var(--glass-border); border-radius: 6px; padding: 2px 6px; }
.find:focus-within kbd { display: none; }
.find .near { flex: none; height: 32px; padding: 0 10px 0 7px; border-radius: 10px; display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--text); background: var(--glass); border: 1px solid var(--glass-border); transition: color .2s, background .2s; }
.find .near:hover, .find .near.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.find .near svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.find .near.on svg { fill: color-mix(in srgb, currentColor 25%, transparent); }
.find .near.busy svg { animation: breathe 1s ease-in-out infinite; }
.loc-help { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 12%, transparent); font-size: 13px; line-height: 1.45; }
.loc-help b { display: block; color: var(--warn); margin-bottom: 6px; }
.loc-help ol { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.row.hit { grid-template-columns: 1fr auto; }
.row.hit > span:first-child { min-width: 0; }
.hit .lines { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.hit .lines .bullet { font-size: 10.5px; }
.hit .lines .bullet.wide { font-size: 8px; }
.row.active { background: var(--faint); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.row .star { color: var(--warn); margin-left: 6px; font-size: 12px; }

/* ---------- saved stations ---------- */
.hero .pin { width: 32px; height: 32px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; color: var(--muted); transition: color .2s, transform .2s var(--ease); }
.hero .pin:hover { color: var(--text); }
.hero .pin svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.hero .pin.on { color: var(--warn); }
.hero .pin.on svg { fill: currentColor; }
.hero .pin:active { transform: scale(.88); }
.cards { display: grid; gap: 8px; }
.card { display: block; width: 100%; text-align: left; padding: 11px 12px 10px; border-radius: 14px; background: var(--faint); border: 1px solid transparent; transition: background .2s, border-color .2s; }
.card:hover { border-color: var(--glass-border); }
.card.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--faint)); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-top b { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-top .lines { display: flex; gap: 3px; flex: none; }
.card-top .bullet { font-size: 10px; }
.card-top .bullet.wide { font-size: 7.5px; }
.card .dir { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12.5px; min-height: 22px; }
.card .dir > small { flex: none; width: 74px; color: var(--muted); font-size: 11.5px; }
.card .deps { display: flex; gap: 10px; flex-wrap: wrap; min-width: 0; }
.card .dep { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .dep .bullet { font-size: 9.5px; }
.card .dep .bullet.wide { font-size: 7px; }
.card .dep.soon { color: var(--accent); }
.card .quiet { color: var(--muted); font-size: 12px; }
.card .note { display: block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--warn); line-height: 1.35; }
.card .note .bullet { font-size: 8.5px; margin: 0 1px; position: relative; top: -1px; }

.panel-body { flex: 1; overflow-y: auto; padding: 16px; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; overscroll-behavior: contain; }

.bullet {
  --c: #777; --t: #fff;
  display: inline-grid; place-items: center; flex: none;
  width: 1.75em; height: 1.75em; border-radius: 50%;
  background: var(--c); color: var(--t);
  font-weight: 700; font-size: 13px; line-height: 1; letter-spacing: -.02em;
  vertical-align: middle;
}
.bullet.sm { font-size: 11px; }
.bullet.lg { font-size: 26px; }
.bullet.wide { font-size: 9.5px; }
.bullet.lg.wide { font-size: 17px; }

.dock button { position: relative; border-radius: 50%; transition: transform .25s var(--ease), opacity .25s, box-shadow .25s; }
.dock button .bullet { font-size: 15px; width: 30px; height: 30px; }
.dock button .bullet.wide { font-size: 11px; }
.dock button:hover { transform: translateY(-2px) scale(1.1); }
.dock.filtered button:not(.on) { opacity: .28; }
.dock button.on { transform: scale(1.14); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c), 0 6px 22px color-mix(in srgb, var(--c) 60%, transparent); }
.dock button.idle .bullet { filter: grayscale(.85) opacity(.5); }
.dock button i { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--bg); }
.dock button i.bad { background: var(--bad); animation: breathe 1.4s ease-in-out infinite; }

.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow:first-child { margin-top: 0; }
.eyebrow span { letter-spacing: 0; text-transform: none; font-weight: 500; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--faint); border-radius: 14px; padding: 12px 14px; }
.tile b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.good b { color: var(--accent); }
.tile.warn b { color: var(--warn); }

.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 26px 1fr 26px; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 10px; width: 100%; text-align: left; transition: background .2s; }
.bar:hover { background: var(--faint); }
.bar .track { display: block; height: 8px; border-radius: 4px; background: var(--faint); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 4px; background: var(--c); width: 0; transition: width .9s var(--ease); }
:root[data-theme="dark"] .bar .fill { box-shadow: 0 0 10px var(--c); }
.bar em { font-style: normal; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.alert { padding: 11px 12px; border-radius: 14px; background: var(--faint); margin-bottom: 8px; font-size: 13px; line-height: 1.45; }
.alert .bullet { font-size: 10px; margin: 0 1px; position: relative; top: -1px; }
.alert .bullet.wide { font-size: 7.5px; }
.chip { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); margin-bottom: 6px; }
.chip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.chip.calm { background: var(--faint); color: var(--muted); }
.chip.good { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.more { width: 100%; padding: 10px; border-radius: 12px; background: var(--faint); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.more:hover { color: var(--text); }
.empty { font-size: 13px; color: var(--muted); padding: 6px 0 2px; }

.hero { display: flex; align-items: center; gap: 14px; }
.fresh > * { animation: fadeup .45s var(--ease) both; }
.hero h2 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.hero p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.hero .close { margin-left: auto; align-self: flex-start; width: 32px; height: 32px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; flex: none; font-size: 18px; line-height: 1; color: var(--muted); transition: transform .2s var(--ease), color .2s; }
.hero .close:hover { color: var(--text); transform: rotate(90deg); }
.hero-actions { margin-left: auto; align-self: flex-start; display: flex; gap: 6px; flex: none; }
.hero .hero-actions .close { margin-left: 0; }
.hero .share { width: 32px; height: 32px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; color: var(--muted); transition: color .2s; }
.hero .share:hover { color: var(--text); }
.hero .share svg, .ride-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ride-btn { margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.ride { margin-top: 10px; font-size: 13.5px; line-height: 1.4; }
.ride small { color: var(--muted); }
.pick { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pick .more { width: auto; padding: 6px 12px; }
.stops.picking .stop { outline: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -2px; margin-bottom: 3px; }
.stop.to { background: color-mix(in srgb, var(--c) 16%, transparent); font-weight: 700; }
.toast { position: fixed; left: 50%; top: calc(76px + var(--safe-t)); transform: translateX(-50%); z-index: 20; max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; animation: toast-in .3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }
.toast[hidden] { display: none; }

/* Rewind: an amber bar says the map is showing the past, with Play/Pause and Back to live. */
/* ---------- Rewind ---------- */
.rw-open { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--faint); transition: color .2s, transform .2s var(--ease); }
.rw-open:hover { color: var(--warn); transform: scale(1.06); }
.rw-open svg, .rewind svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.rewinding .rw-open { color: var(--warn); box-shadow: inset 0 0 0 1.5px var(--warn); }
.rewind { position: fixed; left: 50%; top: calc(76px + var(--safe-t)); transform: translateX(-50%); z-index: 15; width: min(580px, calc(100vw - 32px)); padding: 8px 10px 10px; border-radius: 20px; border: 1.5px solid var(--warn); font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.rewind[hidden] { display: none; }
.rw-row { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
.rewind-tag { color: var(--warn); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; padding-left: 4px; }
.rw-when { position: relative; min-width: 0; display: flex; }
#rewind-pick { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 10px; min-width: 0; }
#rewind-pick:hover { background: var(--faint); }
#rewind-pick svg { color: var(--muted); flex: none; }
.rewind-time { font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
/* the native picker sits under the time; tapping the time opens it */
#rewind-date { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; border: 0; padding: 0; font-size: 16px; }
.rewind-note { color: var(--muted); overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.rewind button { font-weight: 600; border-radius: 999px; }
.rw-ctl button, #rewind-live { padding: 7px 13px; background: var(--faint); color: var(--text); display: inline-flex; align-items: center; gap: 4px; }
.rw-ctl button:hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
#rewind-live { background: var(--warn); color: #111; margin-left: auto; flex: none; }
.rw-ctl { justify-content: center; gap: 8px; }
#rewind-play { min-width: 76px; justify-content: center; background: var(--text); color: var(--bg); }
#rewind-speed { min-width: 52px; justify-content: center; font-variant-numeric: tabular-nums; }
#rewind-speed.fast { color: var(--warn); box-shadow: inset 0 0 0 1.5px var(--warn); }
.rw-bar { position: relative; height: 58px; cursor: grab; touch-action: none; outline: none; border-radius: 10px; overflow: hidden; background: var(--faint); }
.rw-bar.dragging { cursor: grabbing; }
.rw-bar:focus-visible { box-shadow: inset 0 0 0 2px var(--warn); }
.rw-bar canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.rewinding .toast { top: calc(220px + var(--safe-t)); }
body.rewinding .pulse { display: none; }
body.rewinding .brand h1 em { color: var(--warn); }
.rewind .narrow { display: none; }
@media (max-width: 820px) {
  .rw-open { width: 28px; height: 28px; }
  .rewind { top: calc(64px + var(--safe-t)); left: var(--gap); right: calc(var(--gap) + 50px); width: auto; transform: none; }
  body.rewinding .controls { top: calc(var(--gap) + var(--safe-t) + 60px); }
}
@media (max-width: 520px) {
  .rewind { font-size: 12.5px; padding: 6px 8px 8px; gap: 4px; }
  .rewind-tag, .rewind .wide, .rw-ctl button span { display: none; }
  .rewind .narrow { display: inline; }
  .rw-when { flex: 1; }
  .rw-row:first-child { flex-wrap: wrap; }
  .rewind-note { order: 3; flex-basis: 100%; padding-left: 8px; }
  .rewind-note:empty { display: none; }
  .rw-ctl { justify-content: space-between; gap: 6px; }
  .rw-ctl button { padding: 7px 11px; }
  #rewind-live { padding: 7px 11px; }
}
.served { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.now { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.now::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 0 0 var(--c, var(--accent)); animation: ping 1.6s ease-out infinite; flex: none; }

.rows { display: grid; gap: 2px; }
.row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; width: 100%; text-align: left; font-size: 14px; transition: background .2s; }
button.row:hover { background: var(--faint); }
.row small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.row time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; white-space: nowrap; }
.row time.soon { color: var(--accent); }

.stops { position: relative; margin-left: 6px; padding-left: 22px; }
.stops::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px; width: 4px; border-radius: 2px; background: var(--c); opacity: .85; }
.stop { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 7px 6px; font-size: 13.5px; border-radius: 10px; width: 100%; text-align: left; }
.stop:hover { background: var(--faint); }
.stop::before { content: ""; position: absolute; left: -21px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--bg); border: 2.5px solid var(--c); box-sizing: border-box; }
.stop:first-child { font-weight: 700; }
.stop:first-child::before { background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); }
.stop time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.foot { font-size: 11px; color: var(--muted); margin-top: 22px; line-height: 1.5; opacity: .85; }
.foot a { color: var(--accent); font-weight: 600; }

/* ---------- tooltip ---------- */
.tip { position: fixed; z-index: 8; pointer-events: none; padding: 8px 12px; border-radius: 12px; font-size: 12.5px; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); white-space: nowrap; transform: translate(-50%, calc(-100% - 16px)); display: flex; align-items: center; gap: 8px; }
.tip small { color: var(--muted); display: block; }
.tip[hidden] { display: none; } /* .tip sets display: flex, which would otherwise beat the hidden attribute */

/* ---------- loader ---------- */
.loader { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 22px; transition: opacity .7s ease, visibility .7s; }
.loader.done { opacity: 0; visibility: hidden; }
.loader p { font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.loader-mark { display: flex; gap: 10px; }
.loader-mark i { width: 16px; height: 16px; border-radius: 50%; background: var(--c); animation: hop 1s ease-in-out infinite; box-shadow: 0 0 18px var(--c); }
.loader-mark i:nth-child(2) { animation-delay: .1s; } .loader-mark i:nth-child(3) { animation-delay: .2s; } .loader-mark i:nth-child(4) { animation-delay: .3s; } .loader-mark i:nth-child(5) { animation-delay: .4s; }

/* ---------- theme wipe ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: wipe .75s cubic-bezier(.6, 0, .2, 1) both; }
@keyframes wipe { from { clip-path: circle(0 at var(--wx, 50%) var(--wy, 50%)); } to { clip-path: circle(150vmax at var(--wx, 50%) var(--wy, 50%)); } }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(.72); opacity: .7; } }
@keyframes flash { 0% { transform: scale(2.4); opacity: .3; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 var(--c, var(--accent)); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes hop { 50% { transform: translateY(-12px) scale(1.15); } }
@keyframes drop { from { opacity: 0; transform: translateY(-18px); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } }

/* ---------- mobile: panel becomes a bottom sheet ---------- */
@media (max-width: 820px) {
  :root { --gap: 10px; }
  .brand { padding: 7px 10px 7px 7px; gap: 9px; }
  .mark { width: 34px; height: 34px; }
  .brand h1 { font-size: 14px; }
  .brand p { font-size: 11px; }
  .pulse { width: 24px; height: 24px; } .pulse b { inset: 8.5px; }
  .controls { top: calc(var(--gap) + var(--safe-t) + 60px); bottom: auto; left: auto; right: var(--gap); }
  .controls button, .controls a { width: 40px; height: 40px; border-radius: 13px; gap: 0; grid-template-rows: none; }
  /* on phones the two buttons people mistook for each other get a word under them */
  .controls #btn-tour, .controls #btn-fit { height: 50px; align-content: center; gap: 1px; grid-template-rows: auto auto; }
  .controls #btn-more { height: 50px; align-content: center; gap: 1px; grid-template-rows: auto auto; }
  .controls #btn-more .lbl { display: block; }
  /* phones pinch to zoom: no zoom buttons */
  .controls #btn-in, .controls #btn-out { display: none; }
  /* the menu opens to the left of the column, from its top */
  .more-menu { left: auto; right: calc(100% + 8px); top: 0; bottom: auto; transform-origin: top right; }
  .controls .lbl { display: none; font-size: 9.5px; }
  .controls #btn-tour .lbl, .controls #btn-fit .lbl { display: block; }
  /* "Autopilot" is the longest word in the column: a touch smaller so it fits a phone button */
  .controls #btn-tour .lbl { font-size: 8.5px; letter-spacing: -.02em; }
  /* above the bottom sheet, clear of the Rewind bar at the top */
  .heat-legend { left: var(--gap); bottom: calc(var(--peek, 184px) + var(--safe-b) + 10px); padding: 7px 10px; font-size: 10.5px; max-width: 190px; }
  .heat-legend .rows { gap: 3px 10px; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(74dvh, 640px);
    border-radius: 24px 24px 0 0; border-bottom: 0;
    transform: translateY(calc(100% - var(--peek, 184px) - var(--safe-b)));
    transition: transform .5s var(--ease);
    animation: none; will-change: transform;
  }
  .panel[data-state="half"] { transform: translateY(calc(100% - 46dvh)); }
  .panel[data-state="open"] { transform: none; }
  .panel.dragging { transition: none; }
  .handle { display: block; width: 100%; padding: 9px 0 3px; flex: none; touch-action: none; }
  .handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--muted); opacity: .45; margin: 0 auto; }
  .find { margin: 4px 14px 0; }
  .find input { font-size: 16px; } /* any smaller and iOS zooms the page on focus */
  .find kbd { display: none; }
  .dock { flex-wrap: nowrap; overflow-x: auto; padding: 10px 14px 12px; scrollbar-width: none; gap: 9px; }
  .dock::-webkit-scrollbar { display: none; }
  .panel-body { padding: 14px 14px calc(20px + var(--safe-b)); }
  .tip { display: none !important; }
  .tour-chip { bottom: auto; top: calc(var(--gap) + var(--safe-t) + 60px); left: var(--gap); transform: none; max-width: calc(100vw - var(--gap) * 2 - 50px); padding: 9px 12px 11px 10px; gap: 10px; animation-name: chipin-m; }
  .tc-text b { font-size: 13.5px; }
  @keyframes chipin-m { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
}

@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-new(root) { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* "About this train" and "About the line" */
.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; font-size: 13px; line-height: 1.4; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.facts small { color: var(--muted); font-size: 11px; }

/* ---------- line health ---------- */
.health { display: grid; gap: 2px; font-size: 13px; }
.hrow { display: grid; grid-template-columns: 46px 1fr 1fr 1.15fr 84px; align-items: center; gap: 6px; padding: 6px 6px; border-radius: 10px; width: 100%; text-align: left; font-variant-numeric: tabular-nums; transition: background .2s; }
button.hrow:hover { background: var(--faint); }
.hrow > span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.hrow > span:last-child { justify-content: flex-end; }
.hrow small { color: var(--muted); font-size: 11px; }
.hrow .warn { color: var(--warn); font-weight: 700; }
.hrow .chip { margin: 0; font-size: 9.5px; padding: 3px 7px; }
.hhead { padding-top: 0; padding-bottom: 2px; }
.hhead button { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hhead button:last-child { text-align: right; }
.hhead button.on { color: var(--text); }
.hhead button.on::after { content: " ↓"; }
.pw { font-style: normal; font-size: 8.5px; font-weight: 800; letter-spacing: .04em; padding: 1px 3px; border-radius: 4px; background: var(--faint); color: var(--muted); vertical-align: 1px; }
.hnote { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: 8px 0 2px; }
.hwhy { font-size: 13px; line-height: 1.45; margin: -2px 0 10px; }
.health + .hnote + .more, .health + .more, .health + .hnote + .hnote + .more { margin-top: 10px; }
.rules { margin-top: 10px; font-size: 12px; }
.tile b small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.spark { margin: 10px 0 12px; position: relative; }
.spark svg { cursor: pointer; }
.spark-guide { position: absolute; top: 0; height: 56px; width: 0; border-left: 1px solid var(--text); opacity: .5; pointer-events: none; }
.spark-tip { position: absolute; top: -22px; transform: translateX(-50%); padding: 2px 6px; border-radius: 6px; font-size: 11px; white-space: nowrap; background: var(--text); color: var(--bg); pointer-events: none; }
.spark-tip.end { transform: translateX(-100%); }
.spark svg { display: block; width: 100%; height: 56px; overflow: visible; }
.spark path { fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark path.run { stroke: var(--c); stroke-width: 2.2; }
.spark path.sch { stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: .8; }
.spark figcaption { display: flex; gap: 12px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.spark figcaption span:last-child { margin-left: auto; }
.spark i { display: inline-block; width: 12px; height: 0; border-top: 2px solid var(--c); vertical-align: middle; margin-right: 4px; }
.spark i.sch { border-top: 1.5px dashed var(--muted); }
.facts .link { color: inherit; text-align: left; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); text-underline-offset: 2px; font: inherit; padding: 0; }

/* Living light (prototype, ?fx=1): what time of day the map is lit for */
.light-cap { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5; pointer-events: none; padding: 4px 10px; border-radius: 999px; font: 600 12px/1.3 "Helvetica Neue", Helvetica, Inter, Arial, sans-serif; letter-spacing: .01em; color: var(--text); background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); white-space: nowrap; }
@media (max-width: 820px) { .light-cap { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 64px); } }

/* the Sound button: waves when on, a cross when off */
#btn-sound .wave { display: none; }
#btn-sound[aria-pressed="true"] .wave { display: inline; }
#btn-sound[aria-pressed="true"] .mute { display: none; }
#btn-sound[aria-pressed="true"] { color: var(--accent); }
/* on, but the browser hasn't let it start yet: the waves pulse until a tap */
#btn-sound.waiting .wave { animation: snd-wait 1.4s ease-in-out infinite; }
@keyframes snd-wait { 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { #btn-sound.waiting .wave { animation: none; opacity: 0.35; } }

/* Small discoveries: a station's story in its panel; a new find unfolds with a glint */
.story { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 2px; padding: 10px 12px; border-radius: 12px; background: var(--faint); }
.story svg { flex: none; width: 15px; height: 15px; margin-top: 2px; fill: var(--warn); }
.story p { margin: 0; font-size: 13.5px; line-height: 1.45; }
.story p + p { margin-top: 6px; }
.story small { display: block; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.story.new { animation: story-in .6s var(--ease) both; }
.story.new svg { animation: story-glint 1.2s ease-out .2s both; }
@keyframes story-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes story-glint { 0% { transform: scale(.4) rotate(-45deg); opacity: 0; } 50% { transform: scale(1.5) rotate(10deg); opacity: 1; } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .story.new, .story.new svg { animation: none; } }
