:root {
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  color-scheme: light;
  --page: #f7f6fa; --surface: #fff; --raised: #f1eef7; --ink: #211b3b;
  --muted: #625d73; --line: #d8d4e2; --accent: #6023de; --button: #7233f7;
  --hover: #eee6fc; --warning: #87510a; --footer: #16122a; --footer-ink: #b5b3be;
  --map-filter: none;
  color: var(--ink); background: var(--page);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #211b3b; --surface: #16122a; --raised: #393551; --ink: #e6e6e9;
  --muted: #b5b3be; --line: #524e66; --accent: #c7adfc; --button: #7233f7;
  --hover: #393551; --warning: #f7c575;
  --map-filter: brightness(.78) saturate(.72);
}
@media(prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #211b3b; --surface: #16122a; --raised: #393551; --ink: #e6e6e9;
    --muted: #b5b3be; --line: #524e66; --accent: #c7adfc; --button: #7233f7;
    --hover: #393551; --warning: #f7c575;
    --map-filter: brightness(.78) saturate(.72);
  }
}
* { box-sizing: border-box; }
body { margin: 0; }
header, main { max-width: 1100px; margin: auto; padding: 28px 24px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
h1 { font-size: 2rem; font-weight: 500; letter-spacing: -.045em; margin: 0; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 500; letter-spacing: -.025em; margin: 0; }
.route-subtitle { display: block; color: var(--muted); margin-top: 7px; font-size: .95rem; }
.theme-control { display: flex; align-items: center; gap: 10px; font-size: .875rem; color: var(--muted); }
main { padding-top: 0; }
#live-map, .timetable { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
#live-map { border-top: 3px solid var(--button); }
.map-toolbar, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.map-toolbar { padding: 20px 24px; }
.map-toolbar strong { font-weight: 600; color: var(--accent); }
#map-status-label[data-state="stale"], #map-status-label[data-state="error"] { color: var(--warning); }
.map-toolbar p { margin: 6px 0 0; font-size: .95rem; }
.freshness { display: flex; flex-wrap: wrap; gap: 5px 24px; margin-top: 10px; font-size: .875rem; color: var(--muted); }
.freshness span span { color: var(--ink); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
.map-toolbar .refresh-note { font-size: .8rem; color: var(--muted); }
button, select { font: inherit; font-size: .875rem; padding: 10px 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
button { white-space: nowrap; }
button:hover, select:hover { background: var(--hover); }
#refresh-location { color: white; background: var(--button); border-color: var(--button); }
#refresh-location:hover { background: #6023de; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
#shuttle-map { height: clamp(320px, 49vh, 520px); background: var(--raised); isolation: isolate; }
.leaflet-tile-pane { filter: var(--map-filter); }
.map-note { margin: 0; padding: 12px 24px; font-size: .875rem; color: var(--muted); }
.map-note:empty { display: none; }
.timetable { margin-top: 24px; padding: 24px; }
.direction-toggle { display: flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 6px; }
.direction-toggle button { border: 0; background: transparent; }
.direction-toggle button:hover { background: var(--hover); }
.direction-toggle .active, .direction-toggle .active:hover { background: var(--button); color: white; }
#schedule-direction { margin: 20px 0 14px; font-size: 1rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
th { font-size: .875rem; font-weight: 500; color: var(--muted); }
td { font: 1.125rem ui-monospace, "SFMono-Regular", Consolas, monospace; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); width: 50%; }
thead { background: var(--raised); }
tbody tr:last-child td { border: 0; }
.source-note { font-size: .8rem; line-height: 1.65; margin: 18px 0 0; color: var(--muted); }
a { color: var(--accent); text-underline-offset: 3px; }
footer { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding: 30px max(24px, calc((100vw - 1052px) / 2)); color: var(--footer-ink); background: var(--footer); font-size: .8rem; line-height: 1.6; }
footer p { margin: 0; }
footer strong { color: #e6e6e9; }
main > .theme-control { justify-content: flex-end; margin-top: 24px; }
.app-downloads { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); text-align: center; }
.app-downloads p { margin: 0 0 14px; color: var(--muted); font-size: .875rem; }
.app-store-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.app-store-link { display: inline-flex; align-items: center; gap: 12px; min-width: 180px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-align: left; text-decoration: none; }
.app-store-link:hover { background: var(--hover); border-color: var(--accent); }
.app-store-link svg { width: 28px; height: 32px; flex-shrink: 0; }
.app-store-link small, .app-store-link strong { display: block; }
.app-store-link small { font-size: .7rem; line-height: 1.4; }
.app-store-link strong { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
.bus-map-marker { border-radius: 50%; background: var(--button); border: 3px solid white; box-shadow: 0 2px 9px #0005; }
.bus-map-marker span { display: grid; place-items: center; height: 100%; }
.bus-map-marker svg { width: 24px; height: 24px; color: white; }
.bus-map-marker.stale { background: #6b7280; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { color: var(--ink); background: var(--surface); }
.leaflet-popup-content strong, .leaflet-popup-content span { display: block; }
.leaflet-popup-content span { margin-top: 5px; }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--hover); }
.leaflet-container .leaflet-control-attribution { background: var(--surface); color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }
@media(max-width: 660px) { footer { grid-template-columns: 1fr; gap: 10px; } header { flex-wrap: wrap; } }
@media(max-width: 560px) {
  header, main, footer { padding: 20px 16px; }
  h1 { font-size: 1.75rem; }
  .theme-control { gap: 6px; }
  main { padding-top: 0; }
  .section-heading { align-items: start; flex-direction: column; }
  .map-toolbar, .timetable { padding: 16px; }
  .map-toolbar { align-items: start; }
  button, select { padding: 10px 12px; }
}
