/* One consistent set of measurements:
 *   spacing  4 px steps (--s1 … --s6)
 *   radii    small 6, medium 10, large 14, plus pill and circle
 *   text     12 / 13 / 14 / 15 / 18 / 22 px
 */
:root {
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;

  --bg: #f4f3ef;
  --panel: rgba(255, 255, 255, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.6);
  --glass-blur: blur(24px) saturate(1.8);
  --panel-solid: #ffffff;
  --text: #1b1d21;
  --muted: #6b7079;
  --faint: #9aa0a8;
  --line: rgba(20, 24, 31, 0.09);
  --hover: rgba(20, 24, 31, 0.05);
  --accent: #1f5fad;
  --good: #1a8a4a;
  --warn: #b86e00;
  --bad: #c0312b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 28px rgba(0, 0, 0, 0.12);
  --car-ink: #2b3036;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #15171b;
  --panel: rgba(24, 27, 32, 0.58);
  --glass-edge: rgba(255, 255, 255, 0.09);
  --panel-solid: #1c1f24;
  --text: #eceef1;
  --muted: #a0a6b0;
  --faint: #6f7681;
  --line: rgba(255, 255, 255, 0.09);
  --hover: rgba(255, 255, 255, 0.06);
  --accent: #6aa6ff;
  --good: #4cc47e;
  --warn: #f0a83a;
  --bad: #ff6b62;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.45);
  --car-ink: #8d96a1;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base)/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#map { position: fixed; inset: 0; }

button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

/* Frosted glass, shared by the panel, the settings menu and the map controls. */
.panel, .menu, .maplibregl-ctrl-group {
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
}

/* ---------- Panel ---------- */

.panel {
  position: fixed;
  top: var(--s3);
  left: var(--s3);
  bottom: var(--s3);
  width: 340px;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  z-index: 2;
  overflow: hidden;
}

.panel > section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.panel > section[hidden] { display: none; }

.sheet-handle { display: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }

.search-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: var(--s4) var(--s4) 0;
}

.search-row .icon-btn { flex: none; width: 40px; height: 40px; }

.search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s3);
  height: 40px;
  border-radius: var(--r-md);
  background: var(--hover);
  border: 1px solid var(--line);
  color: var(--muted);
}

.search:focus-within { border-color: var(--accent); }

.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  min-width: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: var(--s3) var(--s4) var(--s2);
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--hover);
}

.segmented button {
  border: 0;
  background: transparent;
  padding: var(--s2) 0;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--muted);
}

.segmented button[aria-selected="true"],
.segmented button[aria-pressed="true"] {
  background: var(--panel-solid);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text);
  border-radius: var(--r-md);
  padding: var(--s2) var(--s4);
  font-weight: 600;
}

.btn:hover { background: var(--hover); }
.btn.small { padding: 6px var(--s3); font-size: var(--fs-sm); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

/* ---------- Tracked trains ---------- */

.tracked {
  flex: none;
  display: grid;
  gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s1);
}

.tracked[hidden] { display: none; }

.track-card {
  position: relative;
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: var(--s3);
  align-items: center;
  padding: var(--s2) var(--s1) var(--s2) 0;
  border-radius: var(--r-md);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  overflow: hidden;
}

.track-card:hover, .track-card:focus-visible { border-color: var(--c); outline: none; }
.track-card .bar { align-self: stretch; background: var(--c); border-radius: 0 3px 3px 0; }
.tc-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: var(--fs-xs); }
.tc-title { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 600; min-width: 0; padding: 2px 0 2px 2px; }
.tc-title > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-where { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-status { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.tc-status .stale { color: var(--warn); font-weight: 600; }

.tc-x {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: var(--fs-lg);
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
}

.tc-x:hover { background: var(--hover); color: var(--text); }

/* ---------- Track picker ---------- */

.tracking-note { font-size: var(--fs-sm); font-weight: 600; color: var(--good); }

.track-picker {
  flex: none;
  margin: var(--s3) 0 0;
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--hover);
  border: 1px solid var(--line);
}

.track-picker h3 { margin: 0; font-size: var(--fs-md); }
.track-picker > .sub { margin: 2px 0 var(--s2); font-size: var(--fs-xs); color: var(--muted); }

.tp-search {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 40px;
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  color: var(--muted);
}

.tp-search:focus-within { border-color: var(--accent); }
.tp-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: var(--fs-md); }
.tp-results { display: grid; gap: 2px; margin: var(--s2) 0 0; max-height: 240px; overflow-y: auto; }

.tp-match {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3); /* text lines up with the search box's */
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: var(--fs-base);
}

.tp-match:hover, .tp-match.active { background: var(--panel-solid); box-shadow: inset 0 0 0 1px var(--line); }
.tp-match.active { box-shadow: inset 0 0 0 1.5px var(--accent); }
.tp-name { font-weight: 600; display: flex; align-items: center; gap: var(--s2); }
.tp-tag { flex: none; white-space: nowrap; line-height: 1.5; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); background: var(--hover); padding: 1px var(--s2); border-radius: var(--r-pill); }
.tp-time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tp-empty { margin: var(--s2) var(--s1) 0; font-size: var(--fs-sm); color: var(--muted); }
.tp-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s3); }

/* ---------- Service notices ---------- */

.notices { flex: none; }
.notices .section-title { margin-bottom: var(--s2); }

.notice {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--s3);
  padding: var(--s3);
  margin-top: var(--s2);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  font-size: var(--fs-sm);
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-weight: 800;
  font-size: var(--fs-xs);
}

.notice-head { margin: 1px 0 0; font-weight: 600; line-height: 1.35; }
.notice details { margin-top: var(--s1); color: var(--muted); }
.notice summary { cursor: pointer; font-weight: 600; color: var(--text); font-size: var(--fs-xs); }
.notice details p { margin: 6px 0 0; line-height: 1.4; }
.notice a { display: inline-block; margin-top: var(--s1); font-size: var(--fs-xs); font-weight: 600; }
.notice-scope { display: block; margin-top: var(--s1); font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Settings menu ---------- */

.menu {
  position: fixed;
  z-index: 6;
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: var(--s2) var(--s2) var(--s2);
  border-radius: var(--r-lg);
}

.menu[hidden] { display: none; }

.menu-title {
  margin: var(--s2) var(--s3) 2px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.menu .segmented { margin: var(--s2) var(--s2) var(--s1); }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.menu .toggle { margin: 2px 0; }

/* ---------- Toggle ---------- */

.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s3);
  align-items: center;
  margin: var(--s1) var(--s4);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  cursor: pointer;
}

.toggle:hover { background: var(--hover); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: var(--r-pill);
  background: var(--faint);
  transition: background 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(14px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text { display: flex; flex-direction: column; font-size: var(--fs-sm); line-height: 1.3; }
.toggle-text span { color: var(--muted); font-size: var(--fs-xs); }

/* ---------- Agency list ---------- */

.agencies, .results {
  flex: 1;
  overflow-y: auto;
  padding: var(--s1) var(--s2) var(--s2);
  overscroll-behavior: contain;
}

.group-title {
  margin: var(--s3) var(--s2) var(--s1);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.agency {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s2);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
}

.agency:hover { background: var(--hover); }

.agency .check {
  width: 18px;
  height: 18px;
  border-radius: var(--r-sm);
  border: 2px solid var(--swatch);
  background: var(--swatch);
  display: grid;
  place-items: center;
}

.agency .check svg { opacity: 1; }
.agency.off .check { background: transparent; }
.agency.off .check svg { opacity: 0; }
.agency.off .name { color: var(--faint); }

.agency .name { font-weight: 550; line-height: 1.25; }
.agency .sub { display: block; font-weight: 400; font-size: var(--fs-xs); color: var(--muted); }

.agency .count {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--muted);
  min-width: 2ch;
  text-align: right;
}

.agency .count.err { color: var(--bad); font-size: var(--fs-xs); }

.agency-row { display: flex; align-items: center; }
.agency-row .agency { flex: 1; }

.zoom {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--faint);
  border-radius: var(--r-sm);
}

.zoom:hover { background: var(--hover); color: var(--text); }

.agency.unavailable { opacity: 0.6; cursor: default; }
.agency.unavailable:hover { background: transparent; }
.agency.unavailable .check { background: transparent; border-style: dashed; }

.note {
  margin: var(--s1) var(--s2) var(--s2);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ---------- Search results ---------- */

.result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; /* long names wrap instead of pushing the status off the edge */
  gap: var(--s3);
  align-items: center;
  width: 100%;
  padding: var(--s2);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
}

.result:hover, .result:focus-visible { background: var(--hover); outline: none; }
.result .title { font-weight: 600; }
.result .sub { font-size: var(--fs-xs); color: var(--muted); }
.empty { padding: var(--s4) var(--s2); color: var(--muted); }


.status { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.status.neutral { color: var(--muted); font-weight: 500; }

/* ---------- Stations ---------- */

.station-icon {
  width: 44px;
  display: grid;
  place-items: center;
}

.station-icon::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--panel-solid);
  border: 3px solid var(--c);
}

.served {
  list-style: none;
  margin: 0;
  padding: var(--s3) 0;
  display: grid;
  gap: var(--s2);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.served li { display: flex; gap: var(--s3); align-items: flex-start; font-size: var(--fs-sm); }
.served .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: var(--s1); }
.served .sub { color: var(--muted); font-size: var(--fs-xs); }

.deps { display: grid; gap: 2px; margin: var(--s2) calc(-1 * var(--s2)) 0; flex: none; }

.dep {
  display: grid;
  grid-template-columns: 64px auto 1fr auto;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s2);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
}

button.dep:hover, button.dep:focus-visible { background: var(--hover); outline: none; }
.dep .when { display: flex; flex-direction: column; line-height: 1.2; font-variant-numeric: tabular-nums; }
.dep .when strong { font-size: var(--fs-md); font-weight: 700; }
.dep .when span { font-size: var(--fs-xs); color: var(--muted); }
.dep .what { display: flex; flex-direction: column; min-width: 0; }
.dep .what .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep .what .sub { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deps .empty { padding: var(--s3) var(--s2); }

/* ---------- Detail ---------- */

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s3) var(--s3) var(--s1) var(--s2);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 6px var(--s2);
  border-radius: var(--r-sm);
  font-weight: 550;
}

.back:hover { background: var(--hover); }

/* The whole train page scrolls as one piece; content fades out at the
   panel's top and bottom edges instead of sliding under a heading. */
#train-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s3) var(--s4) var(--s6);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%);
}

.stops-scroll { position: relative; flex: none; }

/* The train's cars, front on the left, scrolling sideways when long. */
.consist { display: flex; flex-direction: column; align-items: stretch; gap: var(--s1); margin-top: var(--s3); }
.consist-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0; /* cars draw their own diaphragms, which meet */
  overflow-x: auto;
  padding-bottom: var(--s1);
  scrollbar-width: thin;
}
.consist .car { margin: 0; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.consist .car svg { display: block; color: var(--car-ink); }
.consist .car figcaption { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
/* Typical equipment: an "i" at the top left whose tip says the cars may not
   be the real ones. */
.consist-info {
  position: relative;
  flex: none;
  align-self: flex-start;
  margin-left: -5px; /* line the glyph up with the cars' left edge */
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: help;
}
.consist-info:hover, .consist-info:focus-visible { color: var(--text); background: var(--hover); }
.consist-info .tip {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 5;
  width: 220px;
  padding: var(--s2) 10px;
  border-radius: var(--r-sm);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.4;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s, visibility 0.12s;
}
.consist-info .tip strong { color: var(--text); font-weight: 600; }
.consist-info:hover .tip, .consist-info:focus .tip { opacity: 1; visibility: visible; }

.hero, .meta, .estimate-note, .consist { flex: none; }
.hero { padding: 6px 0 var(--s4); border-bottom: 1px solid var(--line); }
.hero .agency-name { font-size: var(--fs-xs); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.hero .dot { width: 9px; height: 9px; border-radius: 50%; }
.hero-title { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); }
.hero h2 { margin: 0; font-size: var(--fs-xl); letter-spacing: -0.015em; line-height: 1.15; }
.hero .od { margin: var(--s2) 0 0; font-size: var(--fs-md); }
.hero .od .arrow { color: var(--faint); margin: 0 var(--s1); }

/* Status and the Track button share one line. */
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); }

/* Number plate: the train's number on a white sign, railroad color on top. */
.plate {
  display: inline-flex;
  flex-direction: column;
  flex: none;
  min-width: 52px;
  border-radius: var(--r-sm);
  background: #fff;
  color: #121417;
  box-shadow: 0 0 0 1.5px #121417, 0 1px 2px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  text-align: center;
}

.plate::before { content: ""; height: 5px; background: var(--c); }
.plate > span {
  padding: 2px var(--s2) 3px;
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Smaller plate for lists (a station's departures, nearby trains). */
.plate.sm { min-width: 48px; }
.plate.sm::before { height: 4px; }
.plate.sm > span { font-size: var(--fs-lg); padding: 1px 6px 2px; }

/* Smallest plate, inline with a line of text (tracked cards, map hover). */
.plate.xs { min-width: 0; box-shadow: 0 0 0 1.25px #121417; border-radius: 4px; }
.plate.xs::before { height: 3px; }
.plate.xs > span { font-size: var(--fs-sm); font-weight: 750; padding: 0 5px 1px; line-height: 1.2; }

.pill {
  display: inline-block;
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: var(--fs-xs);
}

.pill.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pill.neutral { background: var(--hover); color: var(--muted); }
/* A delay Trainsheet worked out from GPS that the railroad hasn't posted. */
.pill.inferred, .status.inferred, .meta .inferred { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-thickness: 1.5px; cursor: help; }
.inferred-note { margin: var(--s3) 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--muted); }
.inferred-note strong { color: var(--text); font-weight: 600; }

/* Train details as a row of small rounded chips. */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: var(--s3) 0;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

.meta li {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  background: var(--hover);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.meta li strong { color: var(--text); font-weight: 600; }

.estimate-note {
  margin: var(--s3) 0 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--hover);
}

.stops { list-style: none; margin: var(--s2) 0 0; padding: 0; }

.stops li {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: 6px 0 6px 22px;
  font-size: var(--fs-base);
}

.stops li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.stops li:first-child::before { top: 50%; }
.stops li:last-child::before { bottom: 50%; }

.stops li::after {
  content: "";
  position: absolute;
  left: 1px;
  top: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--panel-solid);
  border: 2px solid var(--faint);
}

.stops li.past { color: var(--faint); }
.stops li.past::after { background: var(--faint); border-color: var(--faint); }
.stops li.next { font-weight: 650; }
.stops li.next::after { border-color: var(--line-color, var(--accent)); background: var(--line-color, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--line-color, var(--accent)) 25%, transparent); }
.stops .time { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.stops .time .late { color: var(--warn); }

.section-title {
  flex: none;
  margin: var(--s4) 0 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.foot {
  border-top: 1px solid var(--line);
  padding: var(--s3) var(--s4);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.foot summary { cursor: pointer; }
.foot p { margin: var(--s2) 0 0; }

/* ---------- Map bits ---------- */

/* Zoom buttons: a frosted-glass pill matching the panel. */
.maplibregl-ctrl-group {
  border-radius: var(--r-md) !important;
  background: var(--panel) !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button { width: 36px !important; height: 36px !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
:root[data-theme="dark"] .maplibregl-ctrl-icon { filter: invert(1); }

/* Location can't work here (no permission or no hardware): hide the button. */
.maplibregl-ctrl-group:has(.maplibregl-ctrl-geolocate:disabled) { display: none; }

.maplibregl-ctrl-attrib {
  background: color-mix(in srgb, var(--panel-solid) 80%, transparent) !important;
  color: var(--muted);
}

.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

.maplibregl-popup-content {
  background: var(--panel-solid);
  color: var(--text);
  border-radius: var(--r-md);
  padding: var(--s2) var(--s3);
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
}

.maplibregl-popup-tip { display: none; }
.hover-card .t { display: flex; align-items: center; gap: var(--s2); font-weight: 650; padding: 2px 0 2px 2px; }
.rail-net { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); line-height: 1.6; }
.rail-net .dot { width: 14px; height: 4px; border-radius: 2px; }
.hover-card .s { color: var(--muted); font-size: var(--fs-xs); }

.toast {
  position: fixed;
  bottom: var(--s6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  z-index: 5;
  font-size: var(--fs-sm);
}

/* ---------- Phone: bottom sheet ---------- */

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 46vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    transition: height 0.25s ease;
  }

  .panel.collapsed { height: calc(132px + var(--tracked-h, 0px)); }
  .panel.expanded { height: 86vh; }

  .sheet-handle {
    display: block;
    flex: none;
    width: 100%;
    height: 20px;
    border: 0;
    background: transparent;
    position: relative;
  }

  .sheet-handle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: var(--s2);
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: var(--faint);
    opacity: 0.6;
  }

  .maplibregl-ctrl-bottom-right { bottom: calc(46vh + 4px); transition: bottom 0.25s ease; }
  body.sheet-collapsed .maplibregl-ctrl-bottom-right { bottom: calc(136px + var(--tracked-h, 0px)); }
  body.sheet-expanded .maplibregl-ctrl-bottom-right { bottom: calc(86vh + 4px); }
  .toast { bottom: calc(46vh + 16px); }
}
