/* Every colour is a token here: the page, the header and the map (map.js reads them) all switch
   with the system's light or dark setting. Route colours are MBTA's own and come with the data. */
:root {
  --bg: #f6f7f9;
  --panel: #fdfdfe;
  --text: #14171c;
  --muted: #5d6673;
  --line: #e2e5ea;
  --accent: #0b6bcb;
  --late: #b4400b;
  --early: #1d7a46;
  --bar: color-mix(in srgb, var(--accent) 35%, var(--panel));
  --bone: color-mix(in srgb, var(--line) 70%, var(--bg));
  --head-bg: #012958;              /* the logo's navy (brand/mark.png) */
  --brand-orange: #fd6201;         /* the logo's orange */
  --ours: #c24a00;                 /* our times: the logo's orange, dark enough for small text */
  --head-text: #f3f4f6;
  --head-muted: #c9ced6;
  --head-current: #1b4275;
  --badge-bg: #f2b33d;
  --badge-text: #14171c;
  --vehicle-ring: #fdfdfe;
  --vehicle-label: #14171c;
  /* The track record's charts (charts.js): a categorical set checked for colour blindness and contrast
     on --panel in each theme. Ours is the brand's orange, MBTA's the set's blue. */
  --chart-subway: #2a78d6;
  --chart-bus: #eb6834;
  --chart-commuter_rail: #1baf7a;
  --chart-ferry: #eda100;
  --chart-ours: #c24a00;
  --chart-mbta: #2a78d6;
  --radius: 10px;
  --tap: 44px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --panel: #181c22;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --line: #2a3038;
    --accent: #5aa9f5;
    --late: #f08a4b;
    --early: #5cc98a;
    --head-bg: #0b0d10;
    --ours: #ff8a3d;
    --head-current: #252b33;
    --vehicle-ring: #e8eaed;
    --chart-subway: #3987e5;
    --chart-bus: #d95926;
    --chart-commuter_rail: #199e70;
    --chart-ferry: #c98500;
    --chart-ours: #d95926;
    --chart-mbta: #3987e5;
  }
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
h1, h2 { line-height: 1.25; text-wrap: balance; }
h1 { font-size: 22px; margin: 4px 0 8px; }
h2 { font-size: 17px; margin: 28px 0 8px; }
h1:focus { outline: none; }
p { max-width: 65ch; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -60px; z-index: 10; padding: 10px 14px; background: var(--panel); border-radius: var(--radius); }
.skip:focus { top: 8px; }

.top {
  display: flex; align-items: center; gap: 10px;
  padding: max(6px, env(safe-area-inset-top)) 12px 6px 16px;
  background: var(--head-bg); color: var(--head-text);
}
.brand { color: var(--head-text); font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: 0.01em; min-height: var(--tap); display: flex; align-items: center; gap: 8px; }
.brand img { display: block; height: 32px; width: auto; }
.brand-oracle { color: var(--brand-orange); }
.env { white-space: nowrap; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-text); font-weight: 600; }
.nav { margin-left: auto; display: flex; gap: 4px; }
.nav a {
  color: var(--head-muted); text-decoration: none; padding: 0 14px; border-radius: 999px; font-size: 15px;
  min-height: var(--tap); display: flex; align-items: center;
}
.nav a[aria-current="true"] { background: var(--head-current); color: var(--head-text); }
.top a:focus-visible { outline-color: var(--head-text); }

/* At least a screen tall, so the footer stays below the fold while a page loads: it jumped into view
   and out again as the app drew a page's loading shape and then its data over the Worker's copy (a
   layout shift of 0.3 to 0.6 on phones, 2026-10-23). */
main { max-width: 40rem; margin: 0 auto; padding: 16px; min-height: 100vh; }
.foot { max-width: 40rem; margin: 24px auto 0; padding: 0 16px max(32px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; }
.foot-links { display: flex; gap: 4px; margin-left: -10px; }
.foot-links { flex-wrap: wrap; }
.foot-links a, .foot-links .linklike { min-height: var(--tap); display: flex; align-items: center; padding: 0 10px; font-size: 15px; }
.linklike { background: none; border: 0; border-radius: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.copyright { margin: 12px 0 0; }
.copyright a { color: inherit; display: inline-block; padding: 12px 0; margin: -12px 0; }

.home-title { font-size: 24px; margin-top: 8px; }
.lede { color: var(--muted); margin: 0 0 8px; }
/* Home's every stop and station (worker/views.js): the line lists fold away under the search. */
.browse summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--accent); font-weight: 600; }
.browse h3 { font-size: 15px; margin: 16px 0 2px; }
.browse ul { list-style: none; padding: 0; margin: 0; columns: 2 11rem; column-gap: 16px; }
.browse li a { display: inline-block; padding: 6px 0; }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
.label { display: block; font-weight: 600; font-size: 15px; margin: 0 2px 6px; }
.search-row { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; font: inherit; padding: 0 14px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
}
.search input::placeholder { color: var(--muted); }
button {
  font: inherit; padding: 0 14px; min-height: var(--tap); border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap;
  transition: transform 80ms ease-out;
}
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.list { list-style: none; padding: 0; margin: 12px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list li + li { border-top: 1px solid var(--line); }
.stop-link { display: block; padding: 12px 14px; color: inherit; text-decoration: none; }
.stop-link:active { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.stop-name { font-weight: 600; display: block; }
.sub { color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
  display: inline-block; min-width: 2.2em; text-align: center; padding: 1px 6px; border-radius: 4px;
  font-size: 13px; font-weight: 700; line-height: 1.5; background: var(--line); color: var(--text);
}
.hint { color: var(--muted); font-size: 14px; margin: 12px 2px 0; }
#favourites h2 { margin-top: 20px; }
#favourites .list { margin-top: 0; }
.nexts { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; font-size: 14px; }
.next { display: flex; align-items: center; gap: 8px; }
.next-dest { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.next b { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }

.back { display: inline-flex; align-items: center; min-height: var(--tap); padding-right: 12px; font-weight: 600; text-decoration: none; }
.back::before { content: ""; width: 8px; height: 8px; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(45deg); margin: 0 8px 0 4px; }
main > p:has(.back) { margin: 0; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stop-head h1 { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.save { font-size: 15px; font-weight: 600; flex: none; }
.save[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.notice {
  margin: 12px 0; padding: 10px 12px; border-radius: var(--radius); font-size: 14px; max-width: none;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
}
.notice b { font-weight: 700; }
.arrival { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 14px; }
.arrival .chip { grid-row: span 2; align-self: start; margin-top: 2px; }
.dest { font-weight: 600; overflow-wrap: anywhere; }
.when { text-align: right; white-space: nowrap; }
.source { display: block; font-size: 12px; font-weight: 700; line-height: 1.2; }
.source.ours, .ours-word { color: var(--ours); font-weight: 700; }
.source.theirs { color: var(--muted); }
.when-time { display: block; font-weight: 700; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.when-time small { font-size: 13px; font-weight: 600; }
.range { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; }
/* MBTA's time, under ours in the same column so the two compare at a glance. */
.when .mbta { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.when .mbta b { color: var(--text); font-weight: 600; }
.meta { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.late { color: var(--late); }
.early { color: var(--early); }
.updated { color: var(--muted); font-size: 13px; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 2px 14px; max-width: none; }
.error { color: var(--late); }

/* Loading: the shape of the rows to come. */
.bone { display: block; border-radius: 4px; background: var(--bone); }
.skeleton .chip-bone { width: 2.6em; height: 20px; }
.skeleton .line-bone { height: 16px; width: 70%; }
.skeleton .when-bone { width: 3em; height: 22px; }
.title-bone { height: 26px; width: 55%; margin: 4px 0 8px; }
/* A saved stop's row as it will be: its name, then three arrivals (.stop-link, .nexts). */
.fav-bone { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; }
.fav-bone .name-bone { height: 21px; width: 40%; margin: 1px 0 3px; }
.fav-bone .next-bone { height: 21px; width: 75%; }
@media (prefers-reduced-motion: no-preference) {
  .bone { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.55; } }
}

/* Track record. */
.table-wrap { overflow-x: auto; margin: 12px -16px 0; padding: 0 16px; }
.record { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.record caption { caption-side: top; text-align: left; color: var(--muted); font-size: 13px; padding-bottom: 4px; }
.record th, .record td { padding: 10px 0 10px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.record th:first-child { text-align: left; padding-left: 0; font-weight: 600; }
.record thead th { font-weight: 600; color: var(--muted); font-size: 13px; }
.record .sub { display: block; font-size: 12px; font-weight: 400; }
.record td b { font-size: 17px; }
.record td { width: 30%; }
.checks td { width: auto; }
.bar { display: block; height: 6px; width: var(--w); margin: 0 0 4px auto; border-radius: 3px; background: var(--bar); }
.bar.ours { background: var(--accent); }
.chart-card { margin: 12px 0 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.chart-card > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; padding: 0 14px; color: var(--accent); font-weight: 600; }
.chart-card[open] > summary { border-bottom: 1px solid var(--line); }
.chart { padding: 12px 14px 4px; }
.s-subway { --c: var(--chart-subway); }
.s-bus { --c: var(--chart-bus); }
.s-commuter_rail { --c: var(--chart-commuter_rail); }
.s-ferry { --c: var(--chart-ferry); }
.s-ours { --c: var(--chart-ours); }
.s-mbta { --c: var(--chart-mbta); }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding: 0; font-size: 13px; color: var(--muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-key { display: inline-block; flex: none; width: 14px; height: 2px; border-radius: 1px; background: var(--c); }
.chart-frame { position: relative; }
.chart-plot { touch-action: pan-y; border-radius: 4px; cursor: crosshair; }
.chart-plot svg { display: block; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* Across checks a mode had nothing to score at (ferries overnight): the line goes on, dashed. */
.chart-bridge { fill: none; stroke: var(--c); stroke-width: 2; stroke-dasharray: 4 4; stroke-linecap: round; opacity: 0.8; }
.chart-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chart-picks .mode { box-shadow: none; }
.chart-dot { fill: var(--c); stroke: var(--panel); stroke-width: 2; }
.chart-label-key { stroke: var(--c); stroke-width: 2; stroke-linecap: round; }
.chart-label { fill: var(--text); font-size: 12px; }
.chart-cross line { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; top: 4px; left: 0; z-index: 2; pointer-events: none; min-width: 150px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.14); font-size: 13px; }
.chart-tip p { margin: 0; }
.chart-tip-when { font-weight: 600; }
.chart-tip-sub { color: var(--muted); font-size: 12px; }
.chart-tip-sub + .chart-tip-row, .chart-tip-when + .chart-tip-row { margin-top: 4px; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-row b { font-variant-numeric: tabular-nums; min-width: 3.4em; }
.chart-tip-row + .chart-tip-sub { margin-top: 4px; }
.chart-table { margin-top: 4px; }
.chart-table > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--accent); font-size: 14px; }
.chart-table .record td { width: auto; }

/* The live map fills the screen under the header. */
body.map-mode { display: flex; flex-direction: column; height: 100dvh; }
body.map-mode main { max-width: none; padding: 0; flex: 1; min-height: 0; width: 100%; }
body.map-mode .foot { max-width: none; margin: 0; padding: 0 12px env(safe-area-inset-bottom); }
body.map-mode .foot-links, body.map-mode .attribution { display: none; }
body.map-mode .copyright { margin: 0; padding: 6px 0; font-size: 12px; }
.map-wrap { position: relative; height: 100%; }
/* More specific than MapLibre's own .maplibregl-map rule, which loads after this sheet. */
.map-wrap > .map { position: absolute; inset: 0; }
.map-modes {
  position: absolute; left: 8px; right: 56px; top: 8px; display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; z-index: 1;
}
.mode {
  font-size: 14px; border-radius: 999px; background: var(--panel); color: var(--muted);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 25%, transparent);
}
.mode[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }
.mode { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.mode[aria-pressed="false"] .swatch { opacity: 0.35; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Following one vehicle: its arrival on a card over the map. */
.follow-link { margin-left: auto; display: inline-flex; align-items: center; min-height: var(--tap); margin-block: -12px; padding: 0 2px 0 12px; font-weight: 600; }
.following .map-status { top: 8px; }
.recenter { position: absolute; left: 8px; top: 40px; z-index: 1; font-size: 14px; font-weight: 600; box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 25%, transparent); }
.follow-card {
  position: absolute; left: 8px; right: 8px; bottom: 28px; z-index: 2; max-width: 40rem; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 4px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 20%, transparent);
}
.follow-card .list { margin: 0 -12px; border: 0; border-radius: 0; background: none; }
.follow-title { margin: 4px 0; font-size: 14px; color: var(--muted); max-width: none; }
.follow-title b { color: var(--text); }
.follow-card .back { min-height: var(--tap); font-size: 14px; }
.map-status {
  position: absolute; left: 8px; top: 60px; z-index: 1; font-size: 12px; padding: 4px 8px;
  border-radius: 6px; background: var(--panel); color: var(--muted); box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 25%, transparent);
}
/* Prefixed with .map-wrap to outrank MapLibre's own rules, which load after this sheet. */
.map-wrap .maplibregl-popup-content { background: var(--panel); color: var(--text); font: 14px/1.4 system-ui, sans-serif; }
.map-wrap .maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 0 6px; }
.map-wrap .maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--panel); }
.map-wrap .maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--panel); }
.map-wrap .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--panel); }
.map-wrap .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--panel); }
.popup-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.popup-actions a { min-height: var(--tap); display: flex; align-items: center; }

/* MBTA's service alerts on a stop's page: one folded line each, most severe first. */
.alerts { margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.alert { border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: var(--radius); background: var(--panel); font-size: 14px; }
.alert.severe { border-left-color: var(--late); }
.alert summary { cursor: pointer; padding: 10px 12px; min-height: var(--tap); list-style-position: inside; }
.alert summary b { margin-right: 4px; }
.alert[open] summary { border-bottom: 1px solid var(--line); }
.alert > p, .alert ul { margin: 8px 12px; max-width: none; }
.alert ul { padding-left: 18px; }
.alert li + li { margin-top: 4px; }
.meta .track { color: var(--text); font-weight: 700; }
.meta .crowding { color: var(--text); }
.follow-alert { margin: 6px 0 0; font-size: 13px; color: var(--text); max-width: none; }
.follow-alert b { color: var(--late); margin-right: 4px; }
.follow-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.share { font-size: 14px; font-weight: 600; }

/* How a stop usually runs at this hour of the week (pipeline/reliability.py). */
.usual h2 { margin-top: 24px; }
.usual-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.usual-list li { display: flex; align-items: baseline; gap: 10px; }
.usual-list .chip { flex: none; }
.usual-dest { color: var(--muted); }
.usual-more { margin-top: 8px; font-size: 14px; }
.usual-more summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--accent); font-weight: 600; }
.meta .ghost { color: var(--late); font-weight: 600; flex-basis: 100%; }

/* The trip planner. */
.plan-form { display: flex; flex-direction: column; gap: 4px; }
.plan-form input {
  flex: 1; min-width: 0; font: inherit; padding: 0 14px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
}
.plan-form input::placeholder { color: var(--muted); }
.end { position: relative; }
.picks { list-style: none; margin: 4px 0 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.picks li + li { border-top: 1px solid var(--line); }
.picks button { display: flex; justify-content: space-between; gap: 8px; width: 100%; border: 0; border-radius: 0; background: none; text-align: left; white-space: normal; }
.end-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 8px; }
.end-head .label { margin-bottom: 6px; }
.swap { font-size: 14px; margin-bottom: 4px; }
.go { margin-top: 12px; background: var(--accent); color: var(--panel); border-color: var(--accent); font-weight: 700; }
.itineraries { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 12px; }
.itinerary { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.it-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 18px; font-variant-numeric: tabular-nums; }
.it-dur { color: var(--muted); font-size: 14px; font-weight: 600; }
.it-sure { margin: 4px 0 8px; font-size: 14px; color: var(--muted); max-width: none; }
.it-sure b { color: var(--text); }
.sure { color: var(--early); font-weight: 600; }
.sure.risky { color: var(--late); }
.legs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.leg { display: flex; gap: 10px; align-items: baseline; }
.leg .chip { flex: none; }
.leg.walk { color: var(--muted); padding-left: 2px; }
.leg-head, .leg-times { display: block; }
.leg-head { font-weight: 600; }
.leg-times b { font-variant-numeric: tabular-nums; }
.live { font-size: 11px; font-weight: 700; color: var(--ours); }
@media (max-width: 359px) { .brand > span { display: none; } }

/* The cookie choice (consent.js): fixed at the bottom, over the page, so it moves nothing. */
.consent {
  position: fixed; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60; max-width: min(420px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 10px 30px color-mix(in srgb, #000 22%, transparent); font-size: 14px;
}
.consent p { margin: 0 0 10px; }
.consent-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.consent-buttons button { font-weight: 600; }
.consent-yes { background: var(--accent); color: var(--panel); border-color: var(--accent); }
@media (max-width: 640px) { .consent { left: 12px; right: 12px; max-width: none; } }
