/* Trainsheet's look, after Apple's system design: San Francisco type with
 * large bold titles, the system colors, materials (frosted glass) over the
 * map, inset grouped lists on rounded cards, iOS controls, widget-style
 * stats, and tracked trains as Live Activity-style cards with a countdown
 * and a progress bar.
 *
 * Loaded after style.css; it redefines the tokens and restyles components.
 */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 24px;
  --r-card: 14px;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 30px;

  /* System colors (light). */
  --bg: #f2f2f7;
  --panel: rgba(242, 242, 247, 0.8);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --glass-blur: blur(34px) saturate(1.9);
  --panel-solid: #ffffff;
  --group: #ffffff;                       /* an inset grouped list's card */
  --fill: rgba(118, 118, 128, 0.12);       /* search fields, segmented controls */
  --text: #000000;
  --muted: rgba(60, 60, 67, 0.62);
  --faint: rgba(60, 60, 67, 0.32);
  --line: rgba(60, 60, 67, 0.16);
  --hover: rgba(120, 120, 128, 0.1);
  --accent: #007aff;
  --good: #248a3d;
  --warn: #c45c00;
  --bad: #d70015;
  --switch-on: #34c759;
  --shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.04), 0 12px 40px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] {
  --bg: #000000;
  --panel: rgba(22, 22, 24, 0.8);
  --glass-edge: rgba(255, 255, 255, 0.1);
  --panel-solid: #1c1c1e;
  --group: #1c1c1e;
  --fill: rgba(118, 118, 128, 0.24);
  --text: #ffffff;
  --muted: rgba(235, 235, 245, 0.6);
  --faint: rgba(235, 235, 245, 0.3);
  --line: rgba(255, 255, 255, 0.11);
  --hover: rgba(120, 120, 128, 0.2);
  --accent: #0a84ff;
  --good: #30d158;
  --warn: #ff9f0a;
  --bad: #ff453a;
  --switch-on: #30d158;
  --shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 12px 40px rgba(0, 0, 0, 0.6);
}

html, body {
  font-family: var(--font);
  font-size: var(--fs-base);
  letter-spacing: -0.01em;
}

/* ---------- Materials ---------- */

.panel {
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: 372px;
  border-radius: var(--r-lg);
}

/* Map controls as Apple Maps' capsules: locate me on its own, zoom stacked
 * below, the credits as a round glass button, and a scale bar beside the
 * panel. */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0 12px 8px 0; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl:last-child { margin-bottom: 12px; }
.maplibregl-ctrl-group { border-radius: 12px !important; overflow: hidden; border: 0.5px solid var(--glass-edge) !important; }
.maplibregl-ctrl-group button { width: 42px !important; height: 40px !important; }
.maplibregl-ctrl-group button + button { border-top: 0.5px solid var(--line) !important; }
.maplibregl-ctrl-group button:hover { background: var(--hover) !important; }
.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon { transform: scale(0.9); }
.maplibregl-ctrl-attrib.maplibregl-compact {
  min-height: 30px; min-width: 30px; border-radius: 15px !important;
  background: var(--panel) !important; border: 0.5px solid var(--glass-edge);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
}
.maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) { padding: 0 !important; width: 30px; margin-right: 18px; } /* centred under the zoom buttons */
.maplibregl-ctrl-attrib.maplibregl-compact-show { padding: 7px 36px 7px 12px !important; }
.maplibregl-ctrl-attrib-button { width: 30px; height: 30px; border-radius: 15px; top: 0 !important; right: 0 !important; background-color: transparent !important; background-repeat: no-repeat !important; background-position: center !important; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-ctrl-bottom-left { left: calc(12px + 372px + 4px); bottom: 4px; }
.maplibregl-ctrl-scale {
  position: relative; margin: 0 0 12px 12px !important;
  padding: 0 0 3px; background: none !important; border: 0 !important; border-bottom: 2px solid var(--text) !important;
  font: 700 11px/1 var(--font); color: var(--text); text-align: right;
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg), 0 0 2px var(--bg);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--bg) 80%, transparent);
}
.maplibregl-ctrl-scale::before, .maplibregl-ctrl-scale::after { content: ""; position: absolute; bottom: -2px; width: 2px; height: 7px; background: var(--text); }
.maplibregl-ctrl-scale::before { left: 0; }
.maplibregl-ctrl-scale::after { right: 0; }

/* ---------- Controls ---------- */

.search-row { margin: 18px 16px 4px; }
.search {
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: var(--fill);
}
.search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.search input { font-size: 17px; letter-spacing: -0.02em; }
.search input::placeholder { color: var(--muted); }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--accent);
}
.icon-btn:hover { background: color-mix(in srgb, var(--fill) 100%, var(--text) 6%); color: var(--accent); }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.search-row .icon-btn { width: 38px; height: 38px; }
.icon-btn.sm { width: 26px; height: 26px; }

.segmented {
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
}
.segmented button { border-radius: 7px; font-size: var(--fs-sm); font-weight: 500; color: var(--text); padding: 6px 0; }
.segmented button[aria-selected="true"],
.segmented button[aria-pressed="true"] {
  background: var(--panel-solid);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
:root[data-theme="dark"] .segmented button[aria-selected="true"],
:root[data-theme="dark"] .segmented button[aria-pressed="true"] { background: #636366; }

.btn { border: 0; border-radius: var(--r-pill); background: var(--fill); color: var(--accent); }
.btn:hover { background: color-mix(in srgb, var(--fill) 100%, var(--text) 6%); }
.btn.primary { background: var(--accent); color: #fff; }

/* iOS switches. */
.switch { width: 42px; height: 26px; background: var(--fill); }
:root[data-theme="dark"] .switch { background: rgba(120, 120, 128, 0.32); }
.switch::after { top: 2px; left: 2px; width: 22px; height: 22px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); }
.toggle input:checked + .switch { background: var(--switch-on); }
.toggle input:checked + .switch::after { transform: translateX(16px); }

/* ---------- Inset grouped lists ----------
   Rows sit on rounded cards (white on the grouped gray), divided by hairlines
   inset past their icon. */

.group-title {
  margin: 20px 16px 6px;
  font-size: var(--fs-sm);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
.agencies, .results { padding: 0 16px 16px; }
.agencies .group-title, .results .group-title { margin: 22px 4px 6px; }
/* The railroads by country: its name over its intercity and commuter cards. */
.agencies .country-title { margin-top: 28px; font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.agencies .country-title + .group-title { margin-top: 4px; }

/* The railroad list: consecutive rows form one card. */
.agency { position: relative; background: var(--group); border-radius: 0; }
.agency:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.group-title + .agency, .note + .agency { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.agency:has(+ .group-title), .agency:has(+ .note), .agency:last-child { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.agency + .agency::before { content: ""; position: absolute; top: 0; left: 46px; right: 0; height: 0.5px; background: var(--line); }
.agency .check { width: 22px; height: 22px; border-radius: 50%; }
.check-hit { padding: 11px 6px 11px 12px; }
.agency-open { padding: 11px 14px 11px 8px; }
.agency .name { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.02em; }
.agency .sub { font-size: var(--fs-sm); }
.agency .count { font-size: var(--fs-sm); }

/* Search results: the same cards. */
.result { position: relative; background: var(--group); border-radius: 0; padding: 10px 12px; }
.result:hover, .result:focus-visible { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.results .group-title + .result, .results > .result:first-child { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.results .result:has(+ .group-title), .results .result:last-child { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.results .result + .result::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 0.5px; background: var(--line); }
/* Near you: the closest trains at the top of the home list, a card like the
   railroads', each row with a Track button. */
.near-title { display: flex; align-items: center; justify-content: space-between; }
.near-refresh { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--faint); }
.near-refresh:hover { background: var(--group); color: var(--text); }
.near-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding-right: 12px; background: var(--group); }
.group-title + .near-row { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.near-row:has(+ .group-title) { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.near-row + .near-row::before { content: ""; position: absolute; top: 0; left: 80px; right: 0; height: 0.5px; background: var(--line); }
/* A train near you: its plate centred in a column of its own (so every row's
   text starts at the same place), then one line each for its name, its
   railroad and distance, and its next stop and status. */
.near-row .result.near-train, .near-row .near-btn { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; min-height: 64px; }
.near-plate, .near-row .near-btn .near-pin { justify-self: center; }
.near-text { display: flex; flex-direction: column; min-width: 0; }
.near-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-text .title { font-size: var(--fs-base); }
.near-text .sub { font-size: var(--fs-sm); color: var(--muted); }
.near-row .result { background: transparent; border-radius: inherit; }
.near-row .result .status { font-size: inherit; }
.near-btn { grid-column: 1 / -1; }
.near-btn[disabled] { opacity: 0.7; cursor: progress; }
.near-pin { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.near-row .track-btn, .near-tracking { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.near-tracking { font-size: var(--fs-xs); font-weight: 600; color: var(--accent); }
.near-note { grid-column: 1 / -1; margin: 0; padding: 12px 14px; font-size: var(--fs-sm); color: var(--muted); }

/* Lists on the detail pages: each a card of its own. */
.rr-trains, .rr-stations, .deps, .rr-lines, .served-by, .rr-cars, .stops-scroll {
  margin: 8px 0 0;
  padding: 0;
  border-radius: var(--r-card);
  background: var(--group);
  overflow: hidden;
}
.rr-trains > *, .rr-stations > *, .deps > *, .rr-cars > * { position: relative; border-radius: 0; }
.rr-trains > * + *::before, .rr-stations > * + *::before, .deps > * + *::before, .rr-cars > * + *::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 0.5px; background: var(--line);
}
.rr-trains .result, .rr-stations .result { background: transparent; }
.rr-lines { padding: 0 14px; }
.rr-lines li, .served-by > li { border-bottom-color: var(--line); border-bottom-width: 0.5px; }
.served-by { padding: 0 14px; }
.served-by .sb-row { margin: 0 -8px; }
.sb-lines { margin-left: 22px; }
.stops-scroll { padding: 6px 14px; }
.dep { border-radius: 0; padding: 10px 12px; }
/* Departure rows: plate, where it's going, the track as a platform sign,
 * and a countdown in rounded numerals with the clock time under it. */
.dep { grid-template-columns: auto minmax(0, 1fr) auto minmax(52px, auto); gap: 10px; }
.dep .what .sub .status-t { font-weight: 600; }
.dep .status-t.good { color: var(--good); }
.dep .status-t.warn { color: var(--warn); }
.dep .status-t.bad { color: var(--bad); }
.dep .status-t.inferred { text-decoration: underline dotted; text-underline-offset: 2px; }
.trk {
  min-width: 26px; height: 26px; padding: 0 5px; border-radius: 6px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  background: #121417; color: #fff; font-size: 13px; font-weight: 800; letter-spacing: 0;
}
:root[data-theme="dark"] .trk { background: #f2f2f7; color: #121417; }
/* A usual track, not yet posted: the same sign, dashed and empty. */
:root .trk.likely { background: transparent; color: var(--muted); border: 1.5px dashed var(--faint); }
.cd { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cd strong { font-family: var(--font-rounded); font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.cd strong small { font-size: 11px; font-weight: 600; margin-left: 1px; color: var(--muted); }
.cd > span { font-size: 11px; color: var(--muted); }
.cd.warn strong { color: var(--warn); }
.cd.bad strong { color: var(--bad); }
.cd.far strong { font-size: 15px; }
.rr-cars { padding: 4px 0; }
.rr-car { border-radius: 0; padding: 10px 12px; }

/* Section headings: bold, sentence case, like an app's own sections. */
.section-title {
  margin: 26px 0 0;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text);
}
.notices-toggle { font-size: inherit; font-weight: inherit; letter-spacing: inherit; }
.rr-count, .notices-count { font-size: var(--fs-sm); font-weight: 600; line-height: 20px; padding: 0 7px; }
.rr-count { background: var(--fill); color: var(--muted); }
.notices-toggle .chev { color: var(--muted); }
.rr-hint, .stops-hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; }

/* ---------- Pages ---------- */

.detail-top { padding-top: 14px; }
.back { font-size: 17px; letter-spacing: -0.02em; color: var(--accent); }

.hero { border-bottom: 0; padding-bottom: 6px; }
.hero h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.hero .agency-name { font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0; }
.hero .od { font-size: 17px; letter-spacing: -0.02em; }
.station-facts { color: var(--muted); }

/* Big rounded numbers, like widgets. */
.rr-stats { gap: 10px; margin-top: 16px; }
.rr-stat { padding: 12px 14px 10px; border-radius: 18px; background: var(--group); }
.rr-stat strong { font-family: var(--font-rounded); font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.rr-stat span { font-size: var(--fs-sm); font-weight: 500; }

.pill { padding: 5px 12px; font-size: var(--fs-sm); }
.model-card { border-radius: 18px; background: var(--group); border: 0; }
.plate { border-radius: 7px; }

/* ---------- Live Activity tracked trains ---------- */

/* Floating over the top of the map, centred in the space beside the panel
 * (on phones, across the top of the screen), like the Dynamic Island. */
.tracked {
  position: fixed;
  z-index: 3;
  top: 12px;
  left: calc(12px + 372px + 12px);
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  pointer-events: none;
}
.tracked .live { width: min(380px, 100%); pointer-events: auto; border-radius: 26px; padding: 14px 18px 16px; gap: 7px; }
.tracked .live.enter { animation: island-in 0.55s cubic-bezier(0.32, 1.25, 0.5, 1) var(--enter-at, 0ms) both; }
.tracked .live.enter > * { animation: island-content 0.55s ease var(--enter-at, 0ms) both; }
@keyframes island-in {
  0% { clip-path: inset(0 32% calc(100% - 34px) 32% round 17px); transform: translateY(-4px); }
  100% { clip-path: inset(0 0 0 0 round 26px); transform: none; }
}
@keyframes island-content { 0%, 35% { opacity: 0; } 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .tracked .live.enter, .tracked .live.enter > * { animation: none; }
}
.live {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
  border-radius: 22px;
  background: #0b0b0c;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), inset 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
.live:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.track-card.live { grid-template-columns: minmax(0, 1fr); border: 0; overflow: visible; }
.track-card.live:hover { border: 0; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34), inset 0 0 0 0.5px rgba(255, 255, 255, 0.14); }
.la-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.la-route { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: 600; color: rgba(255, 255, 255, 0.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.la-eta { font-family: var(--font-rounded); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.la-eta small { font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.7); margin-left: 2px; }
.la-where { font-size: var(--fs-sm); color: rgba(255, 255, 255, 0.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.la-where strong { color: #fff; }
.la-where .status { font-weight: 700; }
.la-where .status.good { color: #30d158; }
.la-where .status.warn { color: #ff9f0a; }
.la-where .status.bad { color: #ff453a; }
.la-where .stale { color: #ff9f0a; font-weight: 600; }
.live .tc-x { position: static; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.8); font-size: 15px; line-height: 1; }
.live .tc-x:hover { background: rgba(255, 255, 255, 0.24); color: #fff; }
.live .tc-share { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Menu, toast, loading ---------- */

.menu { border-radius: 20px; width: 320px; padding: 10px; }
.menu-title { margin: 14px 8px 6px; font-size: var(--fs-sm); font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); }
.menu .toggle { margin: 0; border-radius: 0; background: var(--group); position: relative; padding: 10px 12px; }
.menu .menu-title + .toggle, .menu .segmented + .toggle { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.menu .toggle:has(+ .menu-title), .menu .toggle:last-child { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.menu .toggle + .toggle::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 0.5px; background: var(--line); }
/* The label, then its switch at the right, as in Settings. */
.menu .toggle { grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 11px 14px; }
.menu .toggle .switch { order: 2; }
.menu .toggle-text strong { font-size: var(--fs-base); font-weight: 400; letter-spacing: -0.01em; }
.menu .toggle-text span { margin-top: 2px; font-size: var(--fs-xs); line-height: 1.3; }
.menu-head { display: none; }
.menu .toggle:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.menu .segmented { margin: 0 0 4px; }
/* The time zone picker heads the card the 24-hour clock toggle finishes. */
.menu-select {
  width: 100%; margin: 0; padding: 12px 14px; border: 0; background: var(--group);
  border-radius: var(--r-card) var(--r-card) 0 0; font-size: var(--fs-base);
}
.menu .menu-select + .toggle::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 0.5px; background: var(--line); }

.toast {
  border-radius: var(--r-pill) !important;
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
}

/* Loading: a train passing across the map's place, on the map's own land
 * color, so it hands over to the map without a change of color. */
:root { --map-land: rgb(242, 243, 240); }
:root[data-theme="dark"] { --map-land: rgb(12, 12, 12); }
.loading .loading-track::after { height: 1.5px; }
/* French: the panel's text waits for its translation (index.html). */
.i18n-wait :is(#panel, #settings-menu) > * { visibility: hidden; }

/* ---------- Phones ---------- */

@media (max-width: 720px) {
  .panel { top: auto; left: 0; bottom: 0; width: auto; border-radius: 24px 24px 0 0; }
  /* In the sheet, at its top (moved there by app.js). */
  .panel .tracked { position: static; flex: none; padding: 4px 14px 6px; pointer-events: auto; }
  .panel .tracked .live { width: 100%; }
  .sheet-handle::after { width: 36px; height: 5px; border-radius: 3px; top: 7px; }
  /* Folded down on the home page, just the search field shows (a page keeps
   * its title in view). */
  .panel.collapsed:has(> #view-list:not([hidden])) { height: calc(96px + env(safe-area-inset-bottom, 0px) + var(--tracked-h, 0px)); }
  /* The sheet is dragged by its grabber and its top bar (app.js). */
  .sheet-handle, .search-row, .detail-top { touch-action: none; }
  .sheet-handle { cursor: grab; }
  /* The map's buttons at the top right, as in Maps, clear of the sheet at
   * every height; the scale at the top left. Fingers pinch to zoom, so the
   * zoom buttons stay on computers. */
  .maplibregl-ctrl-bottom-right { top: env(safe-area-inset-top, 0px); bottom: auto; display: flex; flex-direction: column; align-items: flex-end; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 12px 12px 0 0; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl:last-child { margin-bottom: 0; }
  .maplibregl-ctrl-bottom-left { top: env(safe-area-inset-top, 0px); bottom: auto; left: 0; }
  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale { margin: 14px 0 0 14px !important; }
  /* A slow map's loading train runs across the part of it above the sheet. */
  .loading { padding-bottom: 46vh; }
}

/* ---------- Recents (under the search box) ---------- */

.recents { padding: 0 16px; flex: none; }
.recents[hidden] { display: none; }
.recents-head { display: flex; align-items: baseline; justify-content: space-between; padding-right: 4px; }
.recents + .agencies > .group-title:first-child { margin-top: 10px; }
.recents-head .group-title { margin: 14px 4px 6px; }
.recents-head .link-btn { margin: 0; font-size: var(--fs-sm); font-weight: 400; }
.recents-row {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px 6px; scroll-padding: 0 16px;
}
.recents-row::-webkit-scrollbar { display: none; }
.recent {
  flex: none; display: inline-flex; align-items: center; gap: 8px; max-width: 240px;
  min-height: 36px; padding: 5px 15px 5px 11px; border: 0; border-radius: 18px;
  background: var(--group); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  box-shadow: 0 0 0 0.5px var(--line);
}
.recent > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.recent:hover { background: color-mix(in srgb, var(--group) 88%, var(--text)); }
.recent:active { transform: scale(0.97); }
.rc-station { width: 15px; height: 15px; border-radius: 50%; border: 3px solid var(--c); box-sizing: border-box; background: #fff; flex: none; }
.rc-rr { width: 13px; height: 13px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Quiet hours (a railroad page with nothing running) ---------- */

.quiet { margin: 14px 0 4px; padding: 20px 16px 18px; border-radius: var(--r-card); background: var(--group); text-align: center; }
.quiet-moon { color: #8e8cf0; }
.quiet h3 { margin: 6px 0 4px; font-size: 17px; font-weight: 700; }
.quiet p { margin: 0 auto; max-width: 280px; font-size: var(--fs-sm); color: var(--muted); }
.quiet-first {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 5px 12px 5px 7px;
  border-radius: 16px; background: var(--fill); font-size: var(--fs-sm); font-weight: 600;
}

/* ---------- Hover card (a train on the map, on a computer) ---------- */

.hover-card .maplibregl-popup-content {
  min-width: 190px; max-width: 260px; padding: 10px 12px 9px; border-radius: 14px;
  background: var(--panel); border: 0.5px solid var(--glass-edge);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.hover-card .t { font-weight: 700; }
.hc-strip {
  display: flex; align-items: flex-end; margin: 7px 0 6px; overflow: hidden; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.hc-strip .car { margin: 0; flex: none; }
.hc-strip .car svg { display: block; height: 22px; width: auto; }
.hc-strip figcaption { display: none; }
.hover-card .s { font-size: 12px; color: var(--muted); }
.hover-card .s strong { color: var(--text); font-weight: 600; }
.hover-card .status-t { font-weight: 600; }
.hover-card .status-t.good { color: var(--good); }
.hover-card .status-t.warn { color: var(--warn); }
.hover-card .status-t.bad { color: var(--bad); }

/* ---------- Skeleton loading ---------- */

.sk {
  display: block; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg, var(--fill) 0%, color-mix(in srgb, var(--fill) 45%, transparent) 50%, var(--fill) 100%);
  background-size: 200% 100%; animation: sk-shimmer 1.3s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.sk-count { display: inline-block; width: 64px; height: 12px; vertical-align: middle; }
.sk-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px; background: var(--group); }
.sk-plate { width: 44px; height: 26px; border-radius: 6px; }
.sk-lines { display: grid; gap: 6px; }
.sk-sub { height: 9px; opacity: 0.7; }
.sk-end { width: 48px; height: 10px; }

/* ---------- Share ---------- */

.detail-actions { display: flex; gap: 8px; }
.detail-actions [hidden] { display: none; }

/* ---------- Keyboard shortcuts ---------- */

.menu .keys-link { display: none; }
@media (hover: hover) and (pointer: fine) { .menu .keys-link { display: flex; } }
.keys-sheet { position: fixed; inset: 0; z-index: 1500; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.32); }
.keys-card {
  width: min(340px, 100%); padding: 18px 18px 10px; border-radius: 22px;
  background: var(--panel); border: 0.5px solid var(--glass-edge); box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  animation: keys-in 0.25s cubic-bezier(0.32, 1.2, 0.5, 1);
}
.keys-card h3 { margin: 0 0 10px; font-size: 17px; font-weight: 700; }
.keys-card ul { margin: 0; padding: 0; list-style: none; }
.keys-card kbd { min-width: 38px; }
.keys-card li { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: var(--fs-base); border-top: 0.5px solid var(--line); }
.keys-card li:first-child { border-top: 0; }
kbd {
  display: inline-block; min-width: 26px; padding: 2px 7px; border-radius: 6px; box-sizing: border-box; text-align: center;
  background: var(--panel-solid); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 0.5px var(--line);
  font: 600 12px/1.4 var(--font); color: var(--text);
}
@keyframes keys-in { from { transform: scale(0.95); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .keys-card { animation: none; } }

/* ---------- Settings: Help ---------- */

.menu-link, .menu-about > summary {
  position: relative; display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 11px 14px; border: 0; background: var(--group); color: var(--accent);
  font: inherit; font-size: var(--fs-base); text-align: left; cursor: pointer;
}
.menu-link > span[aria-hidden] { color: var(--faint); font-size: 18px; line-height: 1; }
.menu-link:hover, .menu-about > summary:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.menu-title + .menu-link { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.menu-link + .menu-link::before, .menu-link + .menu-about > summary::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 0.5px; background: var(--line); }
.menu-about { margin-bottom: 4px; }
.menu-about > summary { list-style: none; color: var(--text); border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.menu-about > summary::-webkit-details-marker { display: none; }
.menu-about > summary::after { content: "›"; color: var(--faint); font-size: 18px; line-height: 1; transition: transform 0.2s; }
.menu-about[open] > summary::after { transform: rotate(90deg); }
.menu-about[open] > summary { border-radius: 0; }
.menu-about p { margin: 0; padding: 8px 14px 0; background: var(--group); font-size: var(--fs-sm); color: var(--muted); }
.menu-about p:last-child { padding-bottom: 12px; border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }

.menu-link[hidden] { display: none; }

/* ---------- On board, and the train's facts: equal chips, two to a row,
 * each group set off by a line ---------- */

.on-board, .facts { padding: 12px 0; border-top: 0.5px solid var(--line); border-bottom: 0; }
.on-board-title { margin: 0 0 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li {
  display: flex; align-items: center; gap: 6px; min-width: 0; height: 32px; padding: 0 12px; box-sizing: border-box;
  border-radius: 12px !important; background: var(--group); font-size: var(--fs-sm); color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.chips li > span { text-overflow: ellipsis; }
.chips li > span { overflow: hidden; color: var(--text); font-weight: 500; }
.amenity svg { color: var(--accent); flex: none; }

/* ---------- A train's facts as widget tiles ---------- */

.ft { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 12px; border-radius: 14px; background: var(--group); }
.ft-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ft-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.ft-value { font-family: var(--font-rounded); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-value small { margin-left: 3px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ft-value .ft-name { font-family: var(--font); font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.ft-value .inferred { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-thickness: 1.5px; cursor: help; }
.ft-sub { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The live card: the next stop and the speed as two tiles (the next stop
 * takes the whole width when there's no speed); a note under them says
 * where the position comes from. */
.facts { display: block; }
.ft-tiles { display: flex; gap: 8px; }
.ft-tiles .ft { flex-direction: column; align-items: stretch; gap: 1px; padding: 10px 13px; }
.ft-next { flex: 1 1 auto; min-width: 0; }
.ft-speed { flex: 0 0 34%; min-width: 0; }
.ft-speed:only-child { flex: 1 1 auto; }
.ft-speed .ft-value { margin-top: 1px; }
.ft-note { display: flex; align-items: center; gap: 5px; margin: 8px 4px 0; font-size: var(--fs-xs); color: var(--muted); }
.ft-note svg { color: var(--good); flex: none; }
.ft-gps { display: inline-flex; align-items: center; gap: 6px; }
.ft-gps svg { width: 15px; height: 15px; color: var(--good); flex: none; }

/* ---------- At the station ---------- */

.st-address {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px;
  padding: 12px 14px; border-radius: 14px; background: var(--group); color: var(--text); text-decoration: none; font-size: var(--fs-base);
}
.st-address span:last-child { color: var(--accent); }
.st-address:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.amenities { margin: 4px 0 0; padding: 0; list-style: none; border-radius: var(--r-card); background: var(--group); overflow: hidden; }
.amenities li { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; font-size: var(--fs-base); }
.amenities li + li::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; height: 0.5px; background: var(--line); }
.amenities svg { color: var(--accent); flex: none; }
.am-detail { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); text-align: right; }

/* ---------- How full (NJ Transit crowding) ---------- */

.crowd { padding: 12px 0; border-top: 0.5px solid var(--line); }
.crowd-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font-size: var(--fs-base); }
.crowd-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); align-self: center; flex: none; }
.crowd-sub { font-size: var(--fs-sm); color: var(--muted); }
.crowd-cars { display: flex; gap: 4px; height: 40px; margin-top: 10px; }
.cc { position: relative; flex: 1; border-radius: 6px; background: var(--fill); overflow: hidden; display: flex; align-items: flex-end; }
.cc-fill { width: 100%; border-radius: 0 0 6px 6px; opacity: 0.9; }
.cc-icons { position: absolute; top: 3px; left: 0; right: 0; display: flex; justify-content: center; gap: 1px; color: var(--muted); line-height: 0; }
.cc.none { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.crowd-ends { display: flex; justify-content: space-between; margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); }

/* ---------- A line's mark: a short stretch of line in its color ---------- */

.line-mark { display: inline-block; flex: none; width: 18px; height: 5px; border-radius: 3px; background: var(--c); vertical-align: middle; }
.served-name:has(> .line-mark) { align-items: center; }

/* ---------- One rhythm for the detail pages ----------
 * Every section under a page's header (on board, crowding, notices, the
 * live card, stops, a station's or railroad's sections) sits between thin
 * lines with the same space above and below, its heading flush at its top. */
#train-detail > :is(.on-board, .crowd, .facts, .notices, .rr-sec) {
  margin: 0; padding: 12px 0; border-top: 0.5px solid var(--line); border-bottom: 0;
}
/* Cards between them (a railroad's stats, quiet hours) keep their own
 * padding, with the same space around them. */
#train-detail > :is(.rr-stats, .quiet) { margin: 0 0 12px; }
#train-detail > :is(.notices, .rr-sec) > .section-title,
#train-detail > .rr-sec > .deps-head { margin-top: 0; }
#train-detail > .rr-sec > .deps-head .section-title { margin: 0; }
#train-detail > :is(.notices, .rr-sec):not(.collapsed) > .section-title { margin-bottom: 8px; }
/* The page scrolls as one flex column: sections keep their full height
 * rather than being squeezed to fit the panel (the crowding strip, whose
 * overflow is hidden, would otherwise shrink until its text is cut off). */
#train-detail > * { flex-shrink: 0; }
.crowd { overflow: hidden; }
.crowd-cars { min-width: 0; }
.cc { min-width: 0; }

/* ---------- Which train am I on? ----------
 * The guess sits with the tracked trains as one more island: a question,
 * how fast the rider is going, and a button to track it. */
.tracked .live.guess { cursor: default; }
.live .guess-go {
  justify-self: start; margin-top: 2px; padding: 7px 14px; border: 0; border-radius: var(--r-pill, 999px);
  background: #fff; color: #000; font: inherit; font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
}
.live .guess-go:hover { background: rgba(255, 255, 255, 0.86); }
.live .guess-go:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Colorblind-friendly ----------
 * Settings, Appearance. Green, orange and red are hard to tell apart with
 * red-green colorblindness, so statuses take blue, orange and magenta
 * (Paul Tol's "vibrant" colors), and each gets a shape too: a circle for on
 * time, a triangle for late, a diamond for very late. */
:root[data-colorblind] { --good: #0077bb; --warn: #c25a00; --bad: #cc3377; }
:root[data-colorblind][data-theme="dark"] { --good: #33bbee; --warn: #ee7733; --bad: #ee3377; }
:root[data-colorblind] :is(.status, .pill, .status-t):is(.good, .warn, .bad)::before {
  content: ""; display: inline-block; width: 0.62em; height: 0.62em; margin-right: 0.32em; vertical-align: 0.04em;
  background: currentColor;
}
:root[data-colorblind] :is(.status, .pill, .status-t).good::before { border-radius: 50%; }
:root[data-colorblind] :is(.status, .pill, .status-t).warn::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 0.7em; }
:root[data-colorblind] :is(.status, .pill, .status-t).bad::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: 0.72em; height: 0.72em; vertical-align: -0.02em; }
/* The tracked cards are always dark, with their own status colors. */
:root[data-colorblind] .la-where .status.good { color: #33bbee; }
:root[data-colorblind] .la-where .status.warn { color: #ee7733; }
:root[data-colorblind] .la-where .status.bad { color: #ee3377; }
/* ---------- Elevators, track record ----------
 * Lists drawn like the station's amenities: an icon, then the text. */

.lifts { margin-top: 0; }
.lift { align-items: flex-start !important; }
.lift svg { margin-top: 1px; }
.lift.out svg { color: var(--bad); }
.lift-what { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lift-what strong { font-weight: 600; }
.lift-sub { color: var(--muted); font-size: var(--fs-sm); }
.lift.out .lift-sub { color: var(--bad); }
.lifts-ok { margin-top: 8px; }
.lifts-ok-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; border: 0; border-radius: var(--r-card);
  background: var(--group); color: var(--text); font: 500 var(--fs-base) var(--font); text-align: left; cursor: pointer;
}
.lifts-ok-toggle::after { content: "›"; margin-left: auto; color: var(--faint); transition: transform 0.15s; }
.lifts-ok.open .lifts-ok-toggle::after { transform: rotate(90deg); }
.lifts-ok.open .lifts-ok-toggle { border-radius: var(--r-card) var(--r-card) 0 0; }
.lifts-ok.open > .lifts { border-radius: 0 0 var(--r-card) var(--r-card); border-top: 0.5px solid var(--line); }
.lift-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }

.rr-sec .rr-stats { margin-top: 0; }
.rr-stat.bad strong { color: var(--bad); }
.history-chart { display: block; width: 100%; height: auto; margin-top: 10px; overflow: visible; }
.history-chart .hc-base { stroke: var(--line); stroke-width: 1; }
.history-chart .hc-mark { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }
.history-chart .hc-label { fill: var(--muted); font: 600 10px var(--font); }
@media (prefers-reduced-motion: reduce) { .lifts-ok-toggle::after { transition: none; } }

/* A disruption's card on the map: the railroad's notice, a few lines. */
.hover-card .disruption-note { max-width: 260px; margin-top: 4px; font-size: 12px; line-height: 1.35; color: var(--text); }

/* ---------- Track ----------
 * One button under a train's name ("Track", or once tracked "Tracking to
 * Manassas"), opening a sheet over the train's page: "Where are you
 * getting off?", the stops ahead, one chosen, and Start tracking. */
.track-btn, .tracking-btn { display: inline-flex; align-items: center; gap: 6px; }
/* The status and the Track button side by side: one height, one type size. */
.hero-actions > :is(.pill, .btn) {
  display: inline-flex; align-items: center; height: 32px; box-sizing: border-box;
  padding: 0 14px; font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
}
.tracking-btn { color: var(--good); }
.track-sheet { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; border-radius: inherit; overflow: hidden; }
/* Closed, it must take no room at all: it sits over the whole panel. */
.track-sheet[hidden] { display: none; }
.ts-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.28); animation: ts-fade 0.2s ease both; }
.ts-card {
  position: relative; max-height: 78%; display: flex; flex-direction: column; gap: 12px;
  padding: 16px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0; background: var(--panel-solid); box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
  animation: ts-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.ts-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.ts-head h3 { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.ts-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--fill); color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.ts-list { min-height: 0; overflow-y: auto; border-radius: var(--r-card); background: var(--group); }
.ts-stop {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: var(--fs-md); text-align: left; cursor: pointer;
}
.ts-stop + .ts-stop { box-shadow: inset 0 0.5px 0 var(--line); }
.ts-stop:hover { background: var(--hover); }
.ts-stop:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ts-check { position: relative; flex: none; width: 22px; height: 22px; box-sizing: border-box; border-radius: 50%; border: 1.5px solid var(--faint); }
.ts-stop.on .ts-check { border-color: var(--accent); background: var(--accent); }
.ts-stop.on .ts-check::after { content: ""; position: absolute; left: 6.5px; top: 3px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.ts-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-stop.on .ts-name { font-weight: 600; }
.ts-time { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-actions { display: flex; gap: 8px; align-items: center; }
.ts-actions .btn.primary { flex: 1; padding: 13px; font-size: var(--fs-md); font-weight: 600; }
@keyframes ts-up { from { transform: translateY(100%); } }
@keyframes ts-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ts-card, .ts-scrim { animation: none; } }

/* A station a disruption leaves with no trains of a railroad: a note under
 * its name, with the railroad's notice, and its row in Served by says so. */
.oos-note {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 10px 12px;
  border-radius: var(--r-card); background: color-mix(in srgb, var(--warn) 12%, var(--group));
}
.oos-note svg { flex: none; margin-top: 1px; color: var(--warn); }
.oos-note > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-sm); color: var(--muted); }
.oos-note strong { color: var(--text); font-size: var(--fs-base); font-weight: 600; }
.sb-out { color: var(--warn); font-weight: 600; }

/* ---------- Account: signing in and a rider's trips (js/account.js) ---------- */

.menu .account-link { margin-bottom: 4px; border-radius: var(--r-card); font-weight: 600; }
.acct-sheet { position: fixed; inset: 0; z-index: 1500; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.32); }
.acct-card {
  display: flex; flex-direction: column; gap: 12px;
  width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; box-sizing: border-box;
  padding: 14px 18px 18px; border-radius: 22px;
  background: var(--panel); border: 0.5px solid var(--glass-edge); box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  animation: keys-in 0.25s cubic-bezier(0.32, 1.2, 0.5, 1);
}
@media (prefers-reduced-motion: reduce) { .acct-card { animation: none; } }
.acct-head { display: flex; align-items: center; gap: 4px; }
.acct-head h3 { flex: 1; margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.acct-back { border: 0; background: none; color: var(--accent); font-size: 26px; line-height: 1; padding: 0 6px 2px 0; cursor: pointer; }
.acct-lede, .acct-stats { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.acct-notice { margin: 0; padding: 9px 12px; border-radius: var(--r-md); background: var(--fill); font-size: var(--fs-sm); }
.acct-providers { display: grid; gap: 8px; }
.acct-provider { padding: 11px; font-size: var(--fs-base); font-weight: 600; color: var(--text); }
.acct-or { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); color: var(--muted); }
.acct-or::before, .acct-or::after { content: ""; flex: 1; height: 0.5px; background: var(--line); }
.acct-form { display: flex; flex-direction: column; gap: 10px; }
.acct-form > .btn.primary { padding: 11px; font-size: var(--fs-base); font-weight: 600; }
.acct-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; font-size: var(--fs-xs); color: var(--muted); }
.acct-field input, .acct-field select, .acct-field textarea {
  box-sizing: border-box; width: 100%; padding: 9px 11px; border: 0; border-radius: var(--r-sm);
  background: var(--fill); color: var(--text); font: inherit; font-size: var(--fs-md);
}
.acct-field textarea { resize: vertical; }
.acct-field :focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.acct-row { display: flex; gap: 10px; }
.acct-time { flex: 0 0 112px; }
.acct-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.acct-link { border: 0; background: none; padding: 2px 0; color: var(--accent); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.acct-who { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: var(--fs-sm); color: var(--muted); }
.acct-who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-bar { display: flex; align-items: center; gap: 10px; }
.acct-bar .segmented { flex: 1; margin: 0; grid-template-columns: 1fr 1fr; }
.acct-bar .btn { white-space: nowrap; }
.acct-trips { display: flex; flex-direction: column; border-radius: var(--r-card); background: var(--group); overflow: hidden; }
.acct-trips .empty { margin: 0; padding: 16px; font-size: var(--fs-sm); }
.acct-trip { display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 14px; border-left: 3px solid var(--c); }
.acct-trip + .acct-trip { border-top: 0.5px solid var(--line); }
.acct-trip-main { flex: 1; min-width: 0; }
.acct-trip-top { display: flex; align-items: center; gap: 8px; }
.acct-trip-route { flex: 1; min-width: 0; font-weight: 600; font-size: var(--fs-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-trip-when { margin-top: 3px; font-size: var(--fs-sm); color: var(--muted); }
.acct-trip-notes { margin-top: 3px; font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.acct-trip-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.acct-status { margin: 0; }
.acct-status label { position: relative; display: block; }
.acct-status input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.acct-status span { display: block; padding: 6px 0; border-radius: 7px; text-align: center; font-size: var(--fs-sm); font-weight: 500; }
.acct-status input:checked + span { background: var(--panel-solid); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
:root[data-theme="dark"] .acct-status input:checked + span { background: #636366; }
.acct-status input:focus-visible + span { outline: 2px solid var(--accent); }
.acct-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acct-actions .btn.primary { margin-left: auto; padding: 9px 22px; font-weight: 600; }
.acct-delete { color: var(--bad); }
.acct-danger summary { cursor: pointer; font-size: var(--fs-sm); color: var(--muted); }
.acct-danger p { margin: 8px 0; font-size: var(--fs-sm); color: var(--muted); }
.acct-legal { margin: 0; text-align: center; font-size: var(--fs-xs); }
.acct-legal a, .acct-danger a { color: var(--muted); }
a.menu-link { box-sizing: border-box; text-decoration: none; }

/* ---------- Home: your trips ----------
   The next trip on a card of its own; the ones after it, what you've
   ridden, and Browse on inset grouped cards, rows 44pt or more as elsewhere. */

.home-signin { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-card); background: color-mix(in srgb, var(--accent) 13%, var(--group)); }
.home-signin-title { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.02em; }
.home-signin p { margin: 4px 0 12px; font-size: var(--fs-sm); color: var(--muted); }
.home-signin-actions { display: flex; align-items: center; gap: 16px; }
.home-signin-actions .link-btn { margin: 0; font-weight: 500; }

.agencies .home-title { display: flex; align-items: center; justify-content: space-between; }
.home-title .link-btn { margin: 0; font-weight: 400; }
.home-note { margin: 0 4px; }

.next-trip {
  display: flex; flex-direction: column; gap: 6px; width: 100%; box-sizing: border-box;
  padding: 12px 14px 14px; border: 0; border-radius: var(--r-card); background: var(--group);
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
button.next-trip:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.next-trip:focus-visible, .home-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nt-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nt-top > span:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nt-name { font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-flag { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); }
.nt-date { font-size: var(--fs-sm); color: var(--muted); }
.nt-leg { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; margin-top: 4px; }
.nt-end { display: flex; flex-direction: column; min-width: 0; }
.nt-end.right { text-align: right; }
.nt-end strong { font-family: var(--font-display); font-size: 24px; white-space: nowrap; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.nt-end span { font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-span { padding-bottom: 20px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.nt-notes { font-size: var(--fs-sm); color: var(--muted); }
.next-trip.empty-trip { align-items: flex-start; gap: 10px; cursor: default; font-size: var(--fs-sm); color: var(--muted); }
.next-trip .sk-line { width: 60%; }
.next-trip .sk-line.short { width: 35%; }

.home-stats { margin: 0 0 8px; }
.home-stats .rr-stat { background: var(--group); }

/* A row on a home card: Browse, a trip, "3 more planned". */
.home-row {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; min-height: 44px;
  padding: 0 14px; border: 0; border-radius: 0; background: var(--group); color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.home-row:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.group-title + .home-row, .home-stats + .home-row { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.home-row:not(:has(+ .home-row)) { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.home-row + .home-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 0.5px; background: var(--line); }
.trip-row + .home-row::before, .home-row + .trip-row::before { left: 60px; }
.home-row-icon { display: grid; place-items: center; width: 22px; color: var(--accent); }
.home-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--fs-md); letter-spacing: -0.02em; }
.home-row .count { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.trip-row { padding: 10px 14px; }
.trip-row .plate { flex: none; min-width: 34px; }
/* Trip lists: the plates in a column of one width, so every row's text starts in the same place. */
.trip-row .plate, .confirm-open .plate { min-width: 50px; }
.trip-row .title { font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-row .sub { font-size: var(--fs-sm); letter-spacing: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-date { flex: none; display: flex; flex-direction: column; align-items: center; width: 34px; line-height: 1.1; }
.tr-date span { font-size: var(--fs-xs); color: var(--bad); font-weight: 600; }
.tr-date strong { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-bell { display: grid; color: var(--accent); }

/* All railroads: one line a railroad, under its country. */
.agencies .country-head {
  display: flex; justify-content: space-between; gap: 8px; width: calc(100% - 8px); padding: 0;
  border: 0; background: none; font: inherit; font-size: var(--fs-sm); color: var(--muted); text-align: left; cursor: pointer;
}
.agencies .country-head:hover { color: var(--text); }
.agency.compact .agency-open { padding-top: 11px; padding-bottom: 11px; }
.agency.compact .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agency.compact .rgn { font-weight: 400; font-size: var(--fs-sm); letter-spacing: 0; color: var(--muted); }

/* Search's filters: pills under the search field, each a menu. Shown while
   searching, or while one is set. */
.filters { display: none; gap: 6px; margin: 10px 16px 0; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.search-area:has(.search:focus-within, .filters:focus-within) .filters, .search-area.active .filters { display: flex; }
.filter {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 12px;
  border-radius: var(--r-pill); background: var(--fill); font-size: var(--fs-sm); font-weight: 500; color: var(--text); white-space: nowrap; cursor: pointer;
}
.filter svg { color: var(--muted); }
.filter.on { background: var(--accent); color: #fff; }
.filter.on svg { color: currentColor; }
.filter select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.filter:has(select:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-clear { flex: none; margin: 0 4px; font-weight: 500; }

/* The track sheet: riding it or just watching, and where the rider got on. */
.ts-mode { margin: 0; flex: none; }
.ts-from {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; box-sizing: border-box;
  padding: 0 14px; border-radius: var(--r-card); background: var(--group); font-size: var(--fs-md);
}
.ts-from select {
  min-width: 0; max-width: 62%; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: var(--fs-md); text-align: right; cursor: pointer;
}
.ts-from select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* "Were you on it?": a ride that ended, asked about before it goes to the rider's trips. */
.live .ask-actions { display: flex; align-items: center; gap: 10px; }
.live .ask-no { padding: 7px 12px; border: 0; border-radius: var(--r-pill, 999px); background: rgba(255, 255, 255, 0.16); color: inherit; font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.live .ask-no:hover { background: rgba(255, 255, 255, 0.26); }

/* Likely delays: on the live card, under each stop ahead, and on the next trip. */
.likely-note { margin: 8px 2px 0; font-size: var(--fs-sm); color: var(--muted); }
.likely-note .likely, .nt-usual { font-weight: 600; }
.likely.good, .nt-usual.good { color: var(--good); }
.likely.warn, .nt-usual.warn { color: var(--warn); }
.likely.bad, .nt-usual.bad { color: var(--bad); }
.stops small.likely { display: block; font-size: var(--fs-xs); font-weight: 500; line-height: 1.2; }
.stops small.likely.good { color: var(--muted); }
.nt-usual { font-size: var(--fs-sm); }

/* Plan a trip: from, to and the day, then the trains between them. */
.plan { display: flex; flex-direction: column; gap: 12px; }
/* The two fields stacked, the swap button beside them, level with the
   gap between the two inputs (and staying there while suggestions show). */
.plan-stations { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 0 8px; }
.plan-fields { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.plan-field { position: relative; }
.plan-swap {
  width: 36px; height: 36px; margin-top: 56px; padding: 0;
  border: 0; border-radius: 50%; background: var(--fill); color: var(--accent); font-size: 16px; cursor: pointer;
}
.plan-swap:hover { background: color-mix(in srgb, var(--fill) 100%, var(--text) 6%); }
/* Under the field, pushing the rest down (a floating list would be cut
   off by the card, which scrolls). */
.plan-suggest { margin-top: 6px; overflow: hidden; border-radius: var(--r-card); background: var(--group); }
.plan-suggest[hidden] { display: none; }
.plan-suggest-title { padding: 8px 14px 2px; font-size: var(--fs-xs); color: var(--muted); }
.plan-option {
  display: flex; flex-direction: column; justify-content: center; width: 100%; min-height: 44px; padding: 6px 14px;
  border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.plan-option + .plan-option { box-shadow: inset 0 0.5px 0 var(--line); }
.plan-option:hover, .plan-option:focus-visible { background: var(--hover); outline: none; }
.plan-option span { font-size: var(--fs-base); font-weight: 600; }
.plan-option small { font-size: var(--fs-xs); color: var(--muted); }
.plan-days { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.plan-date { position: relative; display: grid; place-items: center; border-radius: 7px; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.plan-date.on { background: var(--panel-solid); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
:root[data-theme="dark"] .plan-date.on { background: #636366; }
.plan-date input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.plan-hint { margin: 0; padding: 4px 2px; font-size: var(--fs-sm); color: var(--muted); }
.plan-trains { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; border-radius: var(--r-card); background: var(--group); }
/* A train: its plate, then its times and how long it takes, its line under them. */
.plan-train {
  position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 3px 10px; align-items: center;
  min-height: 60px; padding: 11px 16px 11px 12px; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.plan-train + .plan-train::before { content: ""; position: absolute; top: 0; left: 78px; right: 0; height: 0.5px; background: var(--line); }
.plan-train:hover, .plan-train:focus-visible { background: var(--hover); outline: none; }
.pt-plate { grid-row: 1 / 3; display: flex; justify-content: center; }
.pt-times { font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-span { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.pt-train { grid-column: 2 / -1; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-manual { align-self: center; }

/* ---------- Touch screens ---------- */
@media (pointer: coarse) {
  .maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-in) { display: none; }
}

/* ---------- Phones: search's Cancel, Settings as a sheet ---------- */

.search-cancel { display: none; }
@media (max-width: 720px) {
  /* While searching, Cancel stands where the gear was. */
  .search-cancel {
    flex: none; padding: 0 2px 0 4px; border: 0; background: none; color: var(--accent);
    font: inherit; font-size: 17px; letter-spacing: -0.02em; cursor: pointer;
  }
  .search-area:is(.active, :has(.search:focus-within, .filters:focus-within)) .search-cancel { display: block; }
  .search-area:is(.active, :has(.search:focus-within, .filters:focus-within)) #settings-btn { display: none; }

  .menu {
    left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; max-width: none;
    max-height: 90dvh !important; padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
    border-radius: 24px 24px 0 0; border-bottom: 0; background: var(--bg);
    animation: menu-up 0.4s cubic-bezier(0.32, 0.72, 0, 1) both;
  }
  .menu-head {
    position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: center;
    min-height: 56px; margin: 0 -12px 4px; padding: 0 16px; background: var(--bg);
  }
  .menu-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
  .menu-done {
    position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    border: 0; background: none; padding: 6px 0; color: var(--accent); font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
  }
  body.menu-open::before { content: ""; position: fixed; inset: 0; z-index: 5; background: rgba(0, 0, 0, 0.3); animation: ts-fade 0.25s ease both; }
  @keyframes menu-up { from { transform: translateY(100%); } }
  @media (prefers-reduced-motion: reduce) { .menu, body.menu-open::before { animation: none; } }
}

/* ---------- Moving between pages ---------- */
.page-in { animation: page-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .page-in { animation: none; } }

/* ---------- A train's stops: the ones it has passed, folded ---------- */
.stops li.fold { color: var(--accent); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.stops li.fold::before { top: 4px; bottom: 0; background: repeating-linear-gradient(to bottom, var(--faint) 0 2px, transparent 2px 5px); }
.stops li.fold .stop-dot { display: none; }
.stops li.fold .time { color: var(--faint); font-size: 17px; line-height: 1; }
.stops li.fold:hover > span:nth-child(2), .stops li.fold:focus-visible > span:nth-child(2) { text-decoration: underline; text-underline-offset: 2px; }
.stops li.fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--r-sm); }

/* ---------- All railroads: back, as on every page, under a large title ---------- */
.agencies .country-back { margin: 12px 0 0 -6px; padding: 6px 8px 6px 2px; font-size: 17px; letter-spacing: -0.02em; }
.agencies .country-back + .country-title { margin: 8px 4px 2px; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--text); }

/* ---------- Scrolling lists: slim scrollbars on a clear track ---------- */
.agencies, .results, #train-detail, .menu, .ts-list, .acct-card, .plan-trains { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent; }

/* Settings on a computer: a popover beside the panel, opening from its corner. */
@media (min-width: 721px) {
  .menu { transform-origin: top left; animation: menu-pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  @keyframes menu-pop { from { opacity: 0; transform: scale(0.97); } }
  @media (prefers-reduced-motion: reduce) { .menu { animation: none; } }
}

/* ---------- A train's number flipping into its plate ----------
 * As its page opens (app.js, flipPlate): each character drops in from above,
 * turning down like a split-flap board's leaf, one after another. */
.plate .flap {
  display: inline-block; white-space: pre;
  animation: flap 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--c) * 60ms + 120ms);
}
@keyframes flap {
  from { opacity: 0; transform: perspective(160px) translateY(-55%) rotateX(80deg); }
}

/* ---------- Pages: My trips, Browse, History ----------
 * Switched by a tab bar at the foot of the sheet on phones and by an icon
 * rail beside the panel on computers, as Apple's apps have it (app.js,
 * Pages). Search, recents and their results are Browse's alone. */

.tabbar[hidden] { display: none; }
.tabbar { display: flex; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  padding: 7px 0 5px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 10.5px; font-weight: 500; letter-spacing: 0; cursor: pointer;
}
.tab > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.tab-settings { display: none; }

#view-list:not([data-tab="browse"]) > :is(.search-area, #results, #recents) { display: none !important; }
#view-list:not([data-tab="browse"]) > #agencies { display: block !important; }

@media (max-width: 720px) {
  .panel .tabbar { flex: none; order: 99; padding: 0 8px; border-top: 0.5px solid var(--line); }
  body.has-tabs .panel.collapsed { height: calc(132px + 52px + var(--tracked-h, 0px)); }
  body.has-tabs .panel.collapsed:has(> #view-list:not([hidden])) { height: calc(96px + 52px + env(safe-area-inset-bottom, 0px) + var(--tracked-h, 0px)); }
}
@media (min-width: 721px) {
  body.has-tabs .tabbar {
    position: fixed; z-index: 2; top: 12px; bottom: 12px; left: 12px; width: 66px;
    flex-direction: column; align-items: center; gap: 4px; padding: 10px 0;
    border-radius: var(--r-lg); background: var(--panel); border: 0.5px solid var(--glass-edge); box-shadow: var(--shadow);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  }
  body.has-tabs .tab { flex: none; width: 60px; padding: 8px 2px 6px; border-radius: 12px; font-size: 10px; }
  /* Longer names ("Mes voyages") take two lines rather than being cut. */
  body.has-tabs .tab > span { white-space: normal; text-align: center; line-height: 1.15; }
  body.has-tabs .tab:hover { background: var(--hover); color: var(--text); }
  body.has-tabs .tab[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
  body.has-tabs .tab-settings { display: flex; margin-top: auto; padding: 10px 2px; }
  body.has-tabs .tab-settings[aria-expanded="true"] { background: var(--hover); color: var(--text); }
  body.has-tabs .panel { left: 86px; }
  body.has-tabs .tracked { left: calc(86px + 372px + 12px); }
  body.has-tabs .maplibregl-ctrl-bottom-left { left: calc(86px + 372px + 4px); }
  body.has-tabs .search-row #settings-btn, body.has-tabs .page-gear { display: none; }
}

/* A page's large title, its buttons beside it. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 2px 12px; }
.page-head h1 { margin: 0; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* My trips: the next trip, large. */
.trip-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 14px; border-radius: 20px; background: var(--group); }
.tk-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tk-train { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-base); font-weight: 600; }
.tk-train > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-label { margin-top: 8px; font-size: var(--fs-sm); color: var(--muted); }
.tk-big { font-family: var(--font-rounded); line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tk-big strong { font-size: 42px; font-weight: 700; }
.tk-big small { margin: 0 8px 0 3px; font-size: 17px; font-weight: 600; color: var(--muted); }
.tk-day { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.tk-leg { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; margin-top: 8px; }
.tk-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.tk-actions .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; font-size: var(--fs-sm); }
.tk-note { flex: 1; display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); }
.tk-note + .btn { flex: none; }
.trips-empty { padding: 16px; border-radius: var(--r-card); background: var(--group); font-size: var(--fs-sm); color: var(--muted); }
.trips-empty p { margin: 0 0 12px; }
.trips-empty div { display: flex; align-items: center; gap: 16px; }
.trips-empty .link-btn { margin: 0; }
.confirm-row { padding-right: 12px; cursor: default; }
.confirm-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.home-row .home-row-text .title { font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-row .home-row-text .sub { font-size: var(--fs-sm); letter-spacing: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-row:has(.sub) { padding-top: 9px; padding-bottom: 9px; }

/* History: the numbers, the train ridden most, favorites, every trip. */
.hist-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.rr-stat strong small { margin: 0 3px 0 2px; font-size: 15px; font-weight: 600; color: var(--muted); }
.hist-most { margin-top: 10px; padding: 12px 14px 13px; border-radius: 18px; background: var(--group); }
.hm-label { font-size: var(--fs-sm); color: var(--muted); }
.hm-cars {
  display: flex; align-items: flex-end; margin: 10px 0 8px; overflow: hidden; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.hm-cars .car { margin: 0; flex: none; }
.hm-cars .car svg { display: block; height: 36px; width: auto; color: var(--car-ink); }
.hm-cars .car image { filter: brightness(var(--car-logo-dim)); }
.hm-cars figcaption { display: none; }
.hm-name { font-size: var(--fs-base); font-weight: 600; }
.hm-sub { font-size: var(--fs-sm); color: var(--muted); }

/* Signed out: what an account gives, and the ways in. */
.so-hero { padding: 14px 12px 2px; text-align: center; }
.so-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.so-icon svg { width: 34px; height: 34px; }
.so-hero h2 { margin: 14px 0 6px; font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.so-hero p { max-width: 290px; margin: 0 auto; font-size: var(--fs-base); color: var(--muted); }
.so-list { margin-top: 18px; overflow: hidden; border-radius: var(--r-card); background: var(--group); }
.so-row { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.so-row + .so-row::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 0.5px; background: var(--line); }
.so-row svg { flex: none; width: 24px; height: 24px; color: var(--accent); }
.so-row > span { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); color: var(--muted); }
.so-row strong { font-size: var(--fs-base); font-weight: 600; color: var(--text); }
.so-actions { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 8px; }
.so-btn { padding: 12px; font-size: var(--fs-md); font-weight: 600; }
.so-skip { align-self: center; margin: 2px 0 0; font-size: var(--fs-base); font-weight: 500; }

/* Browse: a train's add button; from one station to another, the day. */
.results .result-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding-right: 12px; background: var(--group); }
.results .result-row:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.results .result-row > .result { background: transparent; border-radius: 0; }
.results .result-row > .result:hover, .results .result-row > .result:focus-visible { background: transparent; }
.results .result-row > .result::before { display: none; }
.results :is(.result, .result-row) + .result-row::before, .results .result-row + .result::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 0.5px; background: var(--line); }
.results :is(.group-title, .route-days) + .result-row, .results > .result-row:first-child { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.results .result-row:has(+ :is(.group-title, .results-more, p, .upcoming-stops)), .results .result-row:last-child { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.add-btn {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); cursor: pointer;
}
.add-btn:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.add-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.add-btn.added { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); cursor: default; }
.route-days { display: flex; gap: 6px; margin: 0 0 8px; overflow-x: auto; scrollbar-width: none; }
.route-days::-webkit-scrollbar { display: none; }
.route-days .filter { border: 0; font: inherit; font-size: var(--fs-sm); font-weight: 500; }
.route-days label.filter input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.route-days + .sk-row { border-radius: var(--r-card) var(--r-card) 0 0; }
.acct-menu { overflow: hidden; border-radius: var(--r-card); }
/* Search's trains: plates in a column of one width; each line one line. */
.results .result > .plate.sm { min-width: 58px; }
.results .result-row .result > span:nth-child(2) { min-width: 0; }
.results .result-row .result .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .result-row .result .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .result-row .result br { display: none; }

/* ---------- The rider's monogram ----------
 * Initials on a gray circle, as Apple's apps show an account (a person's
 * outline when signed out), in place of the Settings gear (app.js). */
.avatar {
  display: inline-grid; place-items: center; flex: none; overflow: hidden;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(180deg, #a6abb6, #858a94); color: #fff;
  font-family: var(--font-rounded); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; line-height: 1;
}
:root[data-theme="dark"] .avatar { background: linear-gradient(180deg, #8e8e93, #636366); }
.avatar svg { display: block; width: 100%; height: 100%; color: rgba(255, 255, 255, 0.92); }
.avatar.lg { width: 50px; height: 50px; font-size: 20px; }
.icon-btn.avatar-btn, .tab.avatar-btn { background: none; padding: 0; }
.icon-btn.avatar-btn .avatar { width: 34px; height: 34px; font-size: 14px; }
.icon-btn.avatar-btn:hover { background: none; }
.avatar-btn:hover .avatar, .avatar-btn[aria-expanded="true"] .avatar { filter: brightness(1.08); }
.avatar-btn:focus-visible { outline: none; }
.avatar-btn:focus-visible .avatar { box-shadow: 0 0 0 2px var(--panel-solid), 0 0 0 4px var(--accent); }
@media (min-width: 721px) {
  body.has-tabs .tab-settings.avatar-btn { width: auto; padding: 8px 0 4px; background: none; }
  body.has-tabs .tab-settings.avatar-btn .avatar { width: 34px; height: 34px; font-size: 14px; }
}

/* Settings opens on the account: its monogram, name and email. */
.menu-profile {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 4px; padding: 10px 14px 10px 12px;
  border: 0; border-radius: var(--r-card); background: var(--group); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu-profile[hidden] { display: none; }
.menu-profile:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.menu-profile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mp-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mp-text strong { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-text span { font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-text span:empty { display: none; }
.mp-go { color: var(--faint); font-size: 20px; line-height: 1; }

/* ---------- The panel put away (computers) ----------
 * The page you're on chosen again, or a tap on the map itself, slides the
 * panel away under the rail, leaving the map and the rail (app.js). */
@media (min-width: 721px) {
  .panel { transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease, visibility 0s linear 0s; }
  body.panel-away .panel {
    transform: translateX(calc(-100% - 90px)); opacity: 0; visibility: hidden; pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease 0.1s, visibility 0s linear 0.4s;
  }
  body.panel-away.has-tabs .tracked { left: calc(86px + 12px); }
  body.panel-away.has-tabs .maplibregl-ctrl-bottom-left { left: calc(86px + 4px); }
  .tracked, .maplibregl-ctrl-bottom-left { transition: left 0.4s cubic-bezier(0.32, 0.72, 0, 1); }
  /* No page is open: none of the rail's pages stands out. */
  body.panel-away.has-tabs .tab[aria-current="page"] { background: none; color: var(--muted); }
  body.panel-away.has-tabs .tab[aria-current="page"]:hover { background: var(--hover); color: var(--text); }
}
@media (prefers-reduced-motion: reduce) { .panel, .tracked, .maplibregl-ctrl-bottom-left { transition: none !important; } }

/* ---------- Trips with connections ----------
 * The form: each train a fieldset of the same fields, a "Change trains"
 * marker between them, and "+ Add a connection" under the last. */
.trip-leg { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.trip-leg-head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.trip-change { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); }
.trip-change::before, .trip-change::after { content: ""; flex: 1; height: 0; border-top: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
.trip-add-leg {
  align-self: flex-start; padding: 8px 14px; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--r-pill);
  background: none; color: var(--accent); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.trip-add-leg:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Each train, one under the other, on a line in its railroad's color, the
 * change between them marked on a dotted stretch. */
.jl { position: relative; margin: 10px 0 0; padding: 0; list-style: none; }
.jl-leg { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 0 6px 14px; }
.jl-leg::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 4px; border-radius: 2px; background: var(--c); }
.jl-leg .plate { min-width: 46px; }
.jl-leg.now .title { color: var(--accent); }
.jl-text { display: flex; flex-direction: column; min-width: 0; }
.jl-text .title { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jl-text .sub { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jl-change {
  position: relative; margin-left: 1px; padding: 3px 0 3px 15px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  background: radial-gradient(circle, var(--faint) 1.2px, transparent 1.6px) 0 50% / 2px 6px repeat-y;
}
.jl-change::before { content: ""; position: absolute; left: -3px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--panel-solid); box-shadow: 0 0 0 2px var(--faint); }

/* Time on each train and waiting between them, end to end. */
.jbar { display: flex; height: 5px; margin-top: 7px; overflow: hidden; border-radius: 3px; background: var(--fill); }
.jb-ride { background: var(--c); }
.jb-ride + .jb-ride { box-shadow: inset 1.5px 0 0 var(--group); }
.jb-wait { background: repeating-linear-gradient(90deg, var(--faint) 0 2px, transparent 2px 4px); opacity: 0.7; }
.tk-then { color: var(--faint); font-weight: 400; margin: 0 1px; }
.trip-card .jl { padding-top: 8px; border-top: 0.5px solid var(--line); }
.journey-row .home-row-text { padding: 2px 0; }

/* History: a trip with connections as a card of its own between the rows. */
.journey-card {
  display: block; width: 100%; box-sizing: border-box; margin: 8px 0; padding: 12px 14px 13px;
  border: 0; border-radius: var(--r-card); background: var(--group); color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.journey-card:hover { background: color-mix(in srgb, var(--group) 100%, var(--text) 4%); }
.journey-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.jc-head { display: flex; flex-direction: column; min-width: 0; }
.jc-head strong { font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jc-head span { font-size: var(--fs-sm); color: var(--muted); }
.group-title + .journey-card { margin-top: 0; }
.journey-card + .home-row { border-top-left-radius: var(--r-card); border-top-right-radius: var(--r-card); }
.home-row:has(+ .journey-card) { border-bottom-left-radius: var(--r-card); border-bottom-right-radius: var(--r-card); }
.journey-card + .home-row::before { display: none; }

/* The site opens on the map, the panel put away from the first paint
 * (index.html, app.js): no flash of it before the page's script runs. */
@media (min-width: 721px) {
  .panel-boot-away .panel { transform: translateX(calc(-100% - 90px)); opacity: 0; visibility: hidden; transition: none; }
}
@media (max-width: 720px) {
  .panel-boot-away .panel { height: calc(96px + 52px + env(safe-area-inset-bottom, 0px)); transition: none; }
}
/* A page folded down stays above the tab bar rather than showing under it. */
@media (max-width: 720px) { .panel > section { overflow: hidden; } }

/* A train's or a disruption's card on the map is to read, never to touch:
 * scrolling, pinching and dragging over it reach the map underneath, which
 * otherwise stopped zooming wherever a card was under the pointer. */
.maplibregl-popup.hover-card, .maplibregl-popup.hover-card .maplibregl-popup-content { pointer-events: none; }

/* Planning a trip: one tap on a train adds it. */
.plan-train { grid-template-columns: 56px minmax(0, 1fr) auto; }
.plan-train .pt-add {
  grid-row: 1 / 3; grid-column: 3; align-self: center; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.plan-train { padding-right: 12px; }
.plan-train .pt-times { white-space: normal; }
.plan-train .pt-train { grid-column: 2 / 3; }
.plan-train.added { cursor: default; }
.plan-train.added .pt-add { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.plan-train:disabled { opacity: 1; }
.plan .plan-day input { max-width: 220px; }
