/* Transit Tracker.
 *
 * Read outdoors, one-handed, in the ten seconds before deciding whether to wait
 * or walk. So: big minutes, high contrast, and the difference between LIVE and
 * SCHED visible at a glance without reading either word.
 */

/* Light first. Dark is a choice (Appearance, on the Saved tab), and so is the accent colour; a
 * phone's own setting is one more choice, "Match my phone". The routes' colours are not the accent:
 * they say what kind of route it is, and stay the same whatever the accent. */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #e9eff8;
  --text: #0f1b2d;
  --muted: #4a5a70;
  --line: #d6dfec;

  --live: #0a7d45;
  --live-soft: #e0f4e9;
  --sched: #52627a;
  --sched-soft: #e8edf5;
  --warn: #8f5200;
  --warn-soft: #fff0d1;
  --bad: #b3261e;
  --bad-soft: #fde7e5;

  --accent-base: #1f5fd1;
  --accent: var(--accent-base);
  --accent-soft: #e4edfc;
  --on-accent: #ffffff;

  /* What kind of route: colour is a signal, so an ordinary bus is plain and the rest are not. */
  --kind-bus: #475569;
  --kind-streetcar: #c8102e;
  --kind-express: #0e7a4b;
  --kind-night: #3730a3;
  --kind-other: #475569;

  --radius: 16px;
  --gutter: 16px;
  --tap: 48px;
  --shadow: 0 1px 2px rgb(15 27 45 / .06), 0 6px 18px rgb(15 27 45 / .07);
  color-scheme: light;
}

:root[data-accent="teal"]   { --accent-base: #0a7c86; --accent-soft: #dff3f4; }
:root[data-accent="violet"] { --accent-base: #6a3fd1; --accent-soft: #ece6fb; }
:root[data-accent="orange"] { --accent-base: #c2410c; --accent-soft: #fdeadf; }
:root[data-accent="green"]  { --accent-base: #15803d; --accent-soft: #dff3e6; }

:root[data-theme="dark"] {
  --bg: #0f141c;
  --surface: #172030;
  --surface-2: #1f2a3d;
  --text: #eef2f8;
  --muted: #a3b0c3;
  --line: #2b3850;

  --live: #3ddc84;
  --live-soft: #12301f;
  --sched: #a3b0c3;
  --sched-soft: #232d3f;
  --warn: #ffb74d;
  --warn-soft: #33260f;
  --bad: #ff8a80;
  --bad-soft: #3a1714;

  --accent: #7aa7ff;
  --accent: color-mix(in srgb, var(--accent-base) 55%, #ffffff);
  --accent-soft: #1d2b44;
  --accent-soft: color-mix(in srgb, var(--accent-base) 32%, #0f141c);
  --on-accent: #0f141c;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f141c;
    --surface: #172030;
    --surface-2: #1f2a3d;
    --text: #eef2f8;
    --muted: #a3b0c3;
    --line: #2b3850;

    --live: #3ddc84;
    --live-soft: #12301f;
    --sched: #a3b0c3;
    --sched-soft: #232d3f;
    --warn: #ffb74d;
    --warn-soft: #33260f;
    --bad: #ff8a80;
    --bad-soft: #3a1714;

    --accent: #7aa7ff;
    --accent: color-mix(in srgb, var(--accent-base) 55%, #ffffff);
    --accent-soft: #1d2b44;
    --accent-soft: color-mix(in srgb, var(--accent-base) 32%, #0f141c);
    --on-accent: #0f141c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;      /* iOS before 15.4 ignores dvh and keeps the line above */
  padding-bottom: env(safe-area-inset-bottom);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

button { font: inherit; color: inherit; }

a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }

.hint { color: var(--muted); padding: 8px var(--gutter); margin: 0; }

/* ------------------------------------------------------------------ bar -- */

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--bg);   /* iOS before 16.2 ignores color-mix: solid, not see-through */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px;
  min-height: var(--tap);
}
.brand svg {
  width: 26px; height: 26px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round;
}

/* The feed pill: how old the live data is, in every view. */
.feed {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.feed .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sched); }
.feed[data-state="live"] .dot { background: var(--live); animation: pulse 2s ease-in-out infinite; }
.feed[data-state="behind"] { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.feed[data-state="behind"] .dot { background: var(--warn); }
.feed[data-state="down"] { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.feed[data-state="down"] .dot { background: var(--bad); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  .feed[data-state="live"] .dot { animation: none; }
}

/* ---------------------------------------------------------------- lists -- */

main { max-width: 640px; margin: 0 auto; outline: none; }

.group { margin-top: 20px; }

.group h2 {
  font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 0; padding: 0 var(--gutter) 8px;
}

.group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-right: var(--gutter);
}
.group-head h2 { padding-bottom: 8px; }
.group-actions { display: flex; align-items: center; gap: 4px; }
.group-actions .ghost + .ghost { border-left: 1px solid var(--line); padding-left: 8px; }

.ghost {
  border: 0; background: none; color: var(--accent); cursor: pointer;
  min-height: 36px; padding: 0 4px; font-size: 14px;
}
.map-filter { font-size: 12px; min-height: 24px; }
.map-filter.active {
  color: var(--text); background: var(--accent); border-radius: 999px; padding: 2px 8px;
}

.list {
  list-style: none; margin: 0; padding: 0 var(--gutter);
  display: grid; gap: 8px;
}

.stop {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 12px 14px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}

/* The card's own link — everything except the directions button, which is a
   second, separate link and so cannot live inside this one (nested links are
   invalid HTML and most browsers only honour the outer one). */
.stop-main {
  grid-column: 1; display: block; min-width: 0;
  color: var(--text); text-decoration: none;
}
.stop-main:active { opacity: .7; }

.stop-name { font-weight: 600; line-height: 1.25; }
.stop-label { color: var(--accent); font-weight: 700; }
/* Which way the stop faces: the first thing a stranger needs and the one thing
   the street name does not say. */
.stop-heading { color: var(--accent); font-weight: 700; }
.stop-dirs { display: grid; gap: 4px; }
.stop-dir { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.stop-dir-name { font-size: 13px; font-weight: 700; color: var(--accent); margin-right: 2px; }
.stop-agency { color: var(--muted); font-weight: 400; }
.stop-routes { display: flex; flex-wrap: wrap; gap: 4px; }

.stop-side { grid-column: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.stop-dist {
  color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.directions {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); color: var(--accent); text-decoration: none; font-size: 14px;
  vertical-align: -8px;
}
.directions:active { background: var(--line); }

/* A route's stops, expanded in place rather than navigating away. */
.route-stops-box {
  margin: -2px var(--gutter) 10px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface-2);
}
.route-stops-box[hidden] { display: none; }
.route-stops-direction + .route-stops-direction { margin-top: 10px; }
.route-stops-heading {
  font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted);
  margin-bottom: 4px; text-transform: uppercase;
}
.route-stops-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.route-stops-list a {
  display: block; padding: 5px 2px; color: var(--text); text-decoration: none; font-size: 14px;
}
.route-stops-list a:active { color: var(--accent); }

.route {
  display: inline-block; min-width: 30px; padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); font-size: 13px; font-weight: 600; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* A favourite you are standing at: promoted, per the spec's first behaviour. */
.promoted {
  margin: 16px var(--gutter) 0; padding: 14px;
  border: 2px solid var(--accent); border-radius: var(--radius);
  background: var(--surface);
}
.promoted p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.promoted a { font-weight: 700; font-size: 18px; text-decoration: none; }

/* ---------------------------------------------------------------- board -- */

.board-head {
  display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center;
  gap: 4px; padding: 12px 8px 4px;
}

.back, .star {
  display: grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 0; background: none; cursor: pointer; border-radius: 50%;
  color: var(--text); text-decoration: none; font-size: 30px; line-height: 1;
}
.star { font-size: 26px; color: var(--muted); }
.star[aria-pressed="true"] { color: var(--warn); }

.stop-title h1 { font-size: 20px; line-height: 1.2; margin: 0; }
.stop-title p { margin: 2px 0 0; font-size: 14px; }

.alerts { display: grid; gap: 8px; padding: 8px var(--gutter) 0; }

.alert {
  padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: var(--warn-soft); border-left: 4px solid var(--warn);
}
.alert.route-scope { background: var(--surface-2); border-left-color: var(--line); }
.alert.stop-scope { font-weight: 600; }
.alert summary {
  cursor: pointer; font-weight: 600; list-style: none;
  display: flex; align-items: baseline; gap: 4px; min-height: 24px;
}
.alert summary::-webkit-details-marker { display: none; }
.alert summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.alert[open] summary::after { content: "▴"; }
.alert .for { color: var(--muted); font-weight: 500; }
.notices { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }

.board-state {
  margin: 12px var(--gutter) 0; padding: 10px 12px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-size: 14px;
}

.arrivals { list-style: none; margin: 12px 0 0; padding: 0 var(--gutter); display: grid; gap: 8px; }

.arrival {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 72px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.arrival.live { border-left: 4px solid var(--live); }
.arrival.sched { border-left: 4px solid var(--line); }
.arrival.gone { opacity: .55; }
.arrival.gone .when strong { text-decoration: line-through; }

.arrival .route { font-size: 18px; min-width: 52px; padding: 6px 4px; }
.arrival .where { min-width: 0; }
.arrival .headsign {
  /* "Westbound · to High Park" is longer than a bare destination: let it wrap
     to a second line rather than cut the place off. */
  font-weight: 600; line-height: 1.25; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.arrival .headsign .dir { color: var(--accent); }
.arrival .detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.arrival .detail .late { color: var(--warn); font-weight: 600; }
.arrival .detail .early { color: var(--live); font-weight: 600; }

.arrival .when { text-align: right; font-variant-numeric: tabular-nums; }
.arrival .when strong { display: block; font-size: 28px; line-height: 1; font-weight: 800; }
.arrival .when small { font-size: 13px; color: var(--muted); }
.arrival.sched .when strong { color: var(--sched); font-weight: 700; }

.badge {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; vertical-align: 1px;
}
.badge.live { background: var(--live-soft); color: var(--live); }
.badge.sched { background: var(--sched-soft); color: var(--sched); }
.badge.occ-ok { background: var(--live-soft); color: var(--live); }
.badge.occ-busy { background: var(--warn-soft); color: var(--warn); }
.badge.occ-full { background: var(--warn-soft); color: var(--warn); }

.legend { font-size: 13px; padding: 10px var(--gutter) 14px; margin: 0; }
.edge-swatch {
  display: inline-block; width: 4px; height: 13px; border-radius: 2px;
  margin-right: 4px; vertical-align: -2px;
}
.edge-swatch.live { background: var(--live); }
.edge-swatch.sched { background: var(--line); }

/* ------------------------------------------------------------ vehicle map -- */

.map-toggle { margin: 4px var(--gutter) 0; }
.vehicle-map {
  height: 260px; margin: 8px var(--gutter) 0; border-radius: var(--radius);
  border: 1px solid var(--line); overflow: hidden; background: var(--surface);
}
.vehicle-map[hidden] { display: none; }
/* The primary way of seeing what's around her, not a secondary toggle like
   the others — more screen, since there is no list behind it to compete
   with for space the way a stop's board or route's planner has. */
.nearby-map { height: 360px; }

/* Stops are the supporting cast: green dots, clearly tappable but smaller than
   the 34 px vehicles, so the vehicles are what the eye lands on. Fixed colours,
   not theme variables: the OSM tiles stay light in the dark theme. The marker's
   own box (36 px) is bigger than the dot, so it is an easy thumb target.
   (Maria, 7 October: "make the dots bigger", after 12 px read as too small.) */
.stop-hit { display: grid; place-items: center; }
.stop-pin {
  width: 20px; height: 20px; border-radius: 50%; box-sizing: border-box;
  background: #2f9e5a; border: 3px solid #1d5c38;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .9), 0 1px 3px rgba(0, 0, 0, .35);
}
/* The same dot, inline in the legend. */
.stop-key {
  display: inline-block; width: 13px; height: 13px; margin-right: 5px; border-radius: 50%;
  box-sizing: border-box; vertical-align: -2px; background: #2f9e5a; border: 2.5px solid #1d5c38;
}
/* Embedded in the Android app: just the map block. The app supplies the header,
   the favourites and the schedules (see "embedded" in app.js). */
html.embed header.bar,
html.embed #promoted,
html.embed #home > section.group:not(#nearby-group),
html.embed #board,
html.embed #route,
html.embed #subway,
html.embed #commute,
html.embed #toast,
html.embed #tabs,
html.embed #near-search,
html.embed #locate { display: none; }
html.embed body { padding-bottom: 0; min-height: 0; }
html.embed #nearby-group { margin-top: 0; }

/* The one line that says the green dots can be tapped: above the map, where it
   is read before the map is touched, and in the body colour, not the muted one
   the legend uses (Maria, 7 October: "it wasn't clear that I could click the
   dots"). */
.tap-hint { margin: 0; padding: 4px var(--gutter) 2px; font-size: 14px; color: var(--text); }
.tap-hint[hidden] { display: none; }

/* "Which way?": under the map, each way a route leaves the nearby stops. */
.ways { padding: 4px 0 0; }
.ways-title { margin: 6px var(--gutter) 0; font-size: 16px; }
.ways-hint { margin: 2px var(--gutter) 8px; font-size: 13px; color: var(--muted); }
.way {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px var(--gutter);
  color: var(--text); text-decoration: none;
}
.way:active { background: var(--surface-2); }
.way-text { min-width: 0; }
.way-main { font-weight: 700; line-height: 1.25; }
.way-stop { font-size: 13px; color: var(--muted); }

/* On a board the heading is the first line of the title. */
.stop-title h1 .stop-heading { display: block; font-size: 14px; letter-spacing: .02em; text-transform: uppercase; }

/* Home's three parts. One is shown at a time; the bar is only on Home. */
#home > [data-tab] { display: none; }
#home[data-tab="nearby"] > [data-tab="nearby"],
#home[data-tab="saved"] > [data-tab="saved"],
#home[data-tab="plan"] > [data-tab="plan"] { display: block; }
#home > [data-tab][hidden] { display: none !important; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs[hidden] { display: none; }
.tabs button {
  flex: 1; min-height: 56px; padding: 8px 4px; font: inherit; font-weight: 600; cursor: pointer;
  background: none; border: 0; border-top: 3px solid transparent; color: var(--muted);
}
.tabs button[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }
html.tabs-on main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.plan-form { padding: 0 var(--gutter); display: grid; gap: 6px; }
.plan-select, .plan-form input[type="search"] {
  width: 100%; box-sizing: border-box; min-height: var(--tap); padding: 8px 12px; font: inherit;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
#plan-result { padding: 0 var(--gutter); }
.claim { margin: 8px var(--gutter); padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius); }
.fav-warning { list-style: none; padding: 12px; border: 2px solid var(--warn); border-radius: var(--radius);
  background: var(--warn-soft); }
.fav-warning p { margin: 0 0 8px; }
.fav-warning-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fav-warning-actions button { min-height: var(--tap); padding: 6px 14px; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--accent); background: none; color: var(--accent); }
.fav-warning-actions button.primary { background: var(--accent); color: var(--bg); }
.claim p { margin: 0 0 8px; }
.plan-field { display: flex; gap: 8px; }
.plan-field input { flex: 1; min-width: 0; }
.plan-chosen { margin: 0; font-weight: 700; color: var(--accent); }
.plan-chosen button { margin-left: 8px; }
.plan-more { margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.plan-unknown { font-weight: 400; color: var(--muted); }
.plan-rough { display: block; margin-top: 6px; padding: 8px 10px; font-weight: 400; color: var(--text);
  background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 10px; }
.plan-h { margin: 14px 0 4px; font-size: 16px; }
.plan-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.plan-card { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.plan-card.live { border-left: 4px solid var(--live); }
.plan-head { display: grid; gap: 2px; margin-bottom: 8px; }
.plan-tag { justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 800;
  background: var(--accent); color: var(--bg); }
.plan-why { font-size: 14px; color: var(--muted); }
.plan-sum { display: grid; gap: 4px; margin-bottom: 8px; }
.plan-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan-chip { min-width: 44px; min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center;
  justify-content: center; padding: 4px 12px; font-size: 20px; font-weight: 800; text-decoration: none;
  color: var(--text); border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
a.plan-chip { color: var(--accent); border-color: var(--accent); }
.plan-hint { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.plan-then { color: var(--muted); font-size: 20px; }
.plan-times { font-size: 15px; }
.plan-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.plan-step { padding-left: 14px; border-left: 3px solid var(--line); }
.plan-step.ride { border-left-color: var(--accent); }
.plan-step.change.tight { border-left-color: var(--warn); }
.plan-step.walk { color: var(--muted); }
.plan-step a { color: var(--accent); }
.plan-sub { font-size: 14px; color: var(--muted); }
.plan-route-link { font-weight: 800; }
.plan-actions { margin-top: 8px; }
.plan-map { height: 260px; margin-top: 8px; border-radius: 10px; overflow: hidden; }
.plan-map[hidden] { display: none; }
.plan-walk-note { margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.plan-walk-note.sooner { color: var(--text); font-weight: 700; padding: 8px 10px; border: 2px solid var(--accent);
  border-radius: 10px; }
.plan-other-ways { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.plan-other-ways a { color: var(--accent); }
.plan-others { margin: 12px 0 0; font-size: 14px; }
.plan-others summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: var(--tap); display: flex;
  align-items: center; }
.plan-others ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 4px; color: var(--muted); }
.rec-tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  color: var(--accent); margin-right: 6px;
}
.rec-walk { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
#nearby-ways-more { margin: 4px var(--gutter) 0; }

/* A saved commute: the places in order, and what is worth knowing at each. */
.commute-editor { padding: 0 var(--gutter) 8px; display: grid; gap: 6px; }
.commute-editor[hidden] { display: none; }
.commute-editor input[type="text"], .commute-editor input[type="search"] {
  width: 100%; box-sizing: border-box; min-height: var(--tap); padding: 8px 12px; font: inherit;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.commute-steps { list-style: none; margin: 0; padding: 0 var(--gutter); counter-reset: step; }
.commute-step { position: relative; padding: 0 0 14px 40px; }
.commute-step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; background: var(--accent); color: var(--bg);
}
.commute-step::after {
  content: ""; position: absolute; left: 13px; top: 32px; bottom: 0; width: 2px; background: var(--line);
}
.commute-step:last-child::after { display: none; }
.step-head { display: flex; align-items: center; gap: 8px; min-height: 28px; flex-wrap: wrap; }
.step-name { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.step-kind { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.step-tools { margin-left: auto; display: inline-flex; gap: 4px; }
.step-tools button { min-width: 36px; min-height: 36px; }
/* The cards use the full width: the step's number and line sit behind them. */
.step-body { margin: 6px 0 0 -40px; }
.commute-steps .arrival { gap: 8px; }
.commute-steps .arrival .route { min-width: 44px; }
.commute-steps .arrival .when strong { font-size: 20px; white-space: nowrap; }
.commute-steps .arrival .headsign { -webkit-line-clamp: 3; line-clamp: 3; }
.step-body .hop-head, .step-body .hop-note { margin-left: 40px; }
.step-body .arrivals, .step-body .subway-platforms { padding: 0; }
.hop-head { margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.hop-head strong { color: var(--accent); }
.hop-note { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

/* The pill is about the bus and streetcar feed; a station page has its own "estimate"
   line, and this one would read as vouching for those times. */
html.on-subway #feed { display: none; }

/* Subway and LRT: the TTC's own next-train times, one row per platform. */
.line-chip {
  display: inline-block; min-width: 28px; padding: 3px 8px; border-radius: 8px; text-align: center;
  font-weight: 800; color: #11151b; background: #8a8d8f;
}
.line-1 { background: #ffc524; } .line-2 { background: #00a651; color: #fff; }
.line-4 { background: #a12a8f; color: #fff; } .line-5 { background: #f07d00; } .line-6 { background: #8a8d8f; }
.station-lines { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.subway-note { margin: 4px var(--gutter) 8px; }
.subway-platforms { list-style: none; margin: 0; padding: 0 var(--gutter); display: grid; gap: 8px; }
.platform {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.platform .where .headsign { font-weight: 600; line-height: 1.25; }
.platform .where .detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.platform .when { text-align: right; font-variant-numeric: tabular-nums; }
.platform .when strong { display: block; font-size: 28px; line-height: 1; font-weight: 800; }
.platform .when small { color: var(--muted); }
.platform.unavailable .when strong { font-size: 16px; color: var(--muted); }

/* "Which gets me there first?" — the ways to somewhere, side by side. */
.compare { margin: 4px 0 8px; }
.compare-toggle { margin: 0 var(--gutter); }
.compare-box { padding: 8px var(--gutter) 0; }
.compare-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.compare-box input[type="search"] {
  width: 100%; box-sizing: border-box; min-height: var(--tap); padding: 8px 12px; font: inherit;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.compare-matches { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.compare-matches button {
  width: 100%; text-align: left; min-height: var(--tap); padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.compare-matches small { display: block; color: var(--muted); }
.compare-head { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.compare-head strong { color: var(--accent); }
.compare-head .ghost { margin-left: auto; }
.compare-result .arrivals { padding: 0; }
.compare-note { color: var(--muted); font-size: 14px; margin: 6px 0; }
.first-tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  color: var(--live); margin-right: 6px;
}
.arrival .route.walk { font-size: 14px; }
.plan-leg { margin-top: 4px; }
.plan-walk { margin-top: 4px; font-style: italic; }
.plan-change { color: var(--accent); font-weight: 600; margin-top: 4px; }
.plan-change.tight { color: var(--warn); }
.arrival .detail .board-at { display: block; margin-top: 2px; }
.arrival .when small { display: block; }
/* Room for the way and the destination: the arrival time is smaller here than on a board. */
.compare-result .arrival { gap: 8px; }
.compare-result .arrival .route { min-width: 44px; }
.compare-result .arrival .when strong { font-size: 20px; white-space: nowrap; }
.compare-result .arrival .headsign { -webkit-line-clamp: 3; line-clamp: 3; }

/* "Going the other way?" — one tap to the stop across the street. */
.other-side {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap);
  margin: 4px var(--gutter) 8px; padding: 8px 14px; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-size: 15px;
}
.other-side[hidden] { display: none; }
.other-side .os-text { display: grid; line-height: 1.3; }
.other-side .os-q { font-size: 13px; color: var(--muted); }
.other-side strong { color: var(--accent); }
.other-side .chev { margin-left: auto; color: var(--muted); font-size: 20px; }

/* On a stop's own schedule: the same ways, one line each. */
.stop-ways { list-style: none; margin: 0; padding: 0 var(--gutter) 4px; display: grid; gap: 4px; }
.stop-ways li { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.stop-ways .stop-way-text { color: var(--muted); }
.stop-ways .stop-way-text strong { color: var(--text); }

/* The map's "bring me back" button, and the dot that says where "me" is. */
.recenter-control a.recenter-btn {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  background: #fff; color: #1c5fd6; cursor: pointer;
}
.recenter-control a.recenter-btn svg { width: 20px; height: 20px; }
.you-are-here {
  width: 18px; height: 18px; border-radius: 50%; box-sizing: border-box;
  background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26, 115, 232, .35), 0 1px 4px rgba(0, 0, 0, .5);
}

/* Leaflet's own CSS sizes panes to their container in percent, so this has
   to be set or the map renders collapsed to zero height. */
.vehicle-map .leaflet-container { height: 100%; width: 100%; background: var(--surface); }

/* Leaflet's panes run up to z-index 800, far above the tab bar's 30. Kept inside
   the map, or a stop on the map scrolled under the bar takes the tap meant for a tab. */
.leaflet-container { isolation: isolate; }

/* The main event on every map: big, bold, white-ringed so it stands off the
   street grid, in a fixed strong blue (the theme accent is pale in dark mode,
   which left the white route number hard to read). 34px outer box (matches vehicleIcon's iconSize). The arrow is
   centred on the circle and pivots about the circle's centre, so it sits just
   outside the ring at any heading: its top is 12px above the padding box, the
   centre 14px below that edge, hence the 26px pivot. */
.vehicle-marker {
  position: relative; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 999px;
  background: #1c5fd6; color: #fff; font-size: 13px; font-weight: 800;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.vehicle-marker .arrow {
  position: absolute; top: -12px; left: 50%; margin-left: -6px; width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 9px solid #1c5fd6; transform-origin: 50% 26px;
}

/* -------------------------------------------------------- route search -- */

.search-box { padding: 0 var(--gutter); }
.search-box input {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 16px;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

.near-search { padding: 8px var(--gutter) 0; }
.near-search input {
  width: 100%; box-sizing: border-box; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  /* 16 px: iPhone zooms the whole page when an input below that is focused. */
  background: var(--surface); color: var(--text); font-size: 16px;
}
.near-search input::placeholder { color: var(--muted); }
.near-search input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.near-search input.is-chosen { font-weight: 700; color: var(--accent); border-color: var(--accent); }

/* Getting the app onto a phone. */
.install {
  margin: 8px var(--gutter); padding: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.install[hidden], .install-go[hidden] { display: none; }
.install-text { margin: 0; flex: 1 1 100%; font-size: 14px; }
.install-go {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px; font-weight: 700;
  color: #fff; background: var(--accent); border-radius: var(--radius); text-decoration: none;
}

/* -------------------------------------------------------- route planning -- */

.direction-tabs { display: flex; gap: 8px; padding: 4px var(--gutter) 0; flex-wrap: wrap; }
.direction-tab {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.direction-tab[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }

/* minmax(0, …), or a select grows to its longest stop name and pushes To off the side of a phone.
   One above the other there: stop names differ at the end, and half a phone's width cuts that off. */
.route-pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px var(--gutter) 0; }
@media (max-width: 520px) { .route-pickers { grid-template-columns: minmax(0, 1fr); } }
.picker { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.picker select {
  width: 100%; min-height: var(--tap); padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 15px;
}

/* ---------------------------------------------------------------- toast -- */

.update {
  position: fixed; left: var(--gutter); right: var(--gutter); z-index: 40;
  bottom: calc(68px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}
.update[hidden] { display: none; }
.update span { flex: 1 1 140px; font-weight: 600; }
.update button { min-height: var(--tap); padding: 6px 14px; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--bg); }
.update button.ghost { background: none; color: var(--accent); }
html.embed #update { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}

.skeleton {
  height: 64px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* The trip map alone, for the app's "Show on map". */
.trip-embed { position: fixed; inset: 0; z-index: 50; }
.trip-embed[hidden] { display: none; }
html.trip-only body > header, html.trip-only #app, html.trip-only #tabs, html.trip-only #update,
html.trip-only #toast { display: none; }
html.trip-only body { padding: 0; min-height: 0; }

/* A chosen place sits in the box, like an address she typed. */
.plan-form input.is-chosen { font-weight: 700; color: var(--accent); border-color: var(--accent); }

/* The next buses near you: the arrival card of the board, as a link to that stop's board. */
.next-near { margin: 6px 0 4px; }
.next-list a.arrival { text-decoration: none; color: inherit; }
.next-list a.arrival:active { background: var(--surface-2); }
.next-list .when small.when-state { display: block; font-size: 12px; font-weight: 700; }
.next-list .when small.when-state.live { color: var(--live); }
.next-list .when small.when-state.sched { color: var(--sched); }
.next-list .when small.when-later { display: block; font-size: 12px; margin-top: 2px; }
#next-near-more { margin: 4px var(--gutter) 0; }
html.embed #next-near { display: none; }

/* The board: the times first, then one row of what else can be done from here. */
.board-actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; padding: 0 var(--gutter); margin: 4px 0 8px; }
.board-actions .other-side { margin: 0; flex: 1 1 100%; border-radius: 12px; padding: 6px 12px; }
.board-actions .other-side .os-q { font-size: 12px; }
.board-actions .map-toggle, .board-actions .compare-toggle {
  margin: 0; min-height: var(--tap); padding: 6px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-weight: 600;
}
.board-actions .compare { display: contents; }
.board-actions .compare-box { flex: 1 1 100%; }
.directions.directions-words { display: inline; width: auto; height: auto; border-radius: 0; background: none;
  padding: 0 0 0 10px; font-size: inherit; font-weight: 600; white-space: nowrap; vertical-align: baseline; }
#arrivals.single-way .arrival .headsign { display: none; }
.legend-info { margin: 6px var(--gutter) 0; font-size: 14px; }
.legend-info summary { cursor: pointer; color: var(--accent); min-height: var(--tap); display: flex; align-items: center; }
.legend-info .legend { padding: 0 0 10px; }


/* ===================================================== design pass, 30 October ==
 * Usable, clear, informative, and friendlier: bigger type, softer cards, the answer large,
 * routes coloured by what kind they are, an icon on each tab. */

body { font-size: 17px; line-height: 1.45; }
.group h2 { font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--text); }
.hint, .ways-hint { font-size: 15px; }
.brand svg { stroke: var(--accent); }

.arrival, .plan-card, .stop, .claim, .commute-step-card {
  box-shadow: var(--shadow);
  border-color: transparent;
}
.arrival .when strong { font-size: 32px; }
.arrival.live { border-left-width: 5px; }

/* Route chips: what kind of route, at a glance. */
.route { border-radius: 8px; font-weight: 800; color: var(--text); }
.route.kind-bus, .route.kind-streetcar, .route.kind-express, .route.kind-night, .route.kind-other,
.plan-chip.kind-bus, .plan-chip.kind-streetcar, .plan-chip.kind-express, .plan-chip.kind-night, .plan-chip.kind-other {
  color: #ffffff; border-color: transparent;
}
.route.kind-bus, .plan-chip.kind-bus { background: var(--kind-bus); }
.route.kind-streetcar, .plan-chip.kind-streetcar { background: var(--kind-streetcar); }
.route.kind-express, .plan-chip.kind-express { background: var(--kind-express); }
.route.kind-night, .plan-chip.kind-night { background: var(--kind-night); }
.route.kind-other, .plan-chip.kind-other { background: var(--kind-other); }
a.plan-chip.kind-bus, a.plan-chip.kind-streetcar, a.plan-chip.kind-express, a.plan-chip.kind-night, a.plan-chip.kind-other {
  color: #ffffff;
}
.arrival .route { border-radius: 12px; }

/* The key: a few words under the heading. */
.kind-key { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 var(--gutter); margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.kind-key span { display: inline-flex; align-items: center; gap: 6px; }
.kind-dot { width: 14px; height: 14px; border-radius: 5px; display: inline-block; }
.kind-dot.kind-bus { background: var(--kind-bus); }
.kind-dot.kind-streetcar { background: var(--kind-streetcar); }
.kind-dot.kind-express { background: var(--kind-express); }
.kind-dot.kind-night { background: var(--kind-night); }

/* The tab bar: an icon each, and the open one is a soft pill in the accent. */
.tabs { border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgb(15 27 45 / .05); }
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; margin: 6px 6px; border-top: 0; border-radius: 14px; font-size: 14px;
}
.tabs button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-top-color: transparent; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html.tabs-on main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

/* Appearance. */
.look-box { padding: 0 var(--gutter) 8px; display: grid; gap: 8px; }
.look-label { margin: 8px 0 0; font-weight: 600; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; min-height: var(--tap); border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.swatches { display: flex; gap: 14px; flex-wrap: wrap; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); cursor: pointer;
  box-shadow: 0 0 0 2px var(--line);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--text); }
.swatch[data-accent-choice="blue"] { background: #1f5fd1; }
.swatch[data-accent-choice="teal"] { background: #0a7c86; }
.swatch[data-accent-choice="violet"] { background: #6a3fd1; }
.swatch[data-accent-choice="orange"] { background: #c2410c; }
.swatch[data-accent-choice="green"] { background: #15803d; }

.bar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--accent);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.look-label { font-size: 15px; font-weight: 600; color: var(--muted); }
