:root {
  --bg: #000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --line: #38383a;
  --text: #fff;
  --muted: #8e8e93;
  --green: #30d158;
  --amber: #ff9f0a;
  --red: #ff453a;
  --blue: #0a84ff;
  --radius: 18px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Sizes are in rem, and the root follows the iPhone's text-size setting.
   Browsers that do not know -apple-system-body keep the 17px above it. */
html { -webkit-text-size-adjust: 100%; font-size: 17px; font: -apple-system-body; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.35;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  min-height: 100vh;
}

/* The status bar is translucent in a home-screen app: keep page text from
   showing through the clock and battery when scrolled. */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: env(safe-area-inset-top); background: var(--bg);
}

a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
code { font: .824rem ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); }
small { font-size: .8em; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(96px + env(safe-area-inset-bottom));
}

.fixture-banner {
  background: #3a2a00;
  color: var(--amber);
  text-align: center;
  font-size: 0.765rem;
  font-weight: 600;
  padding: 4px var(--gutter);
}

/* Header */
.top {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--gutter) 0;
  min-height: 60px;
}
.top-actions { display: flex; gap: 6px; background: var(--card); border-radius: 999px; }
.top-actions:empty { display: none; }
.round-btn {
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
}
.round-btn.back { color: var(--muted); }

h1.big {
  font-size: 2.353rem;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.5px;
  margin: 12px 0 10px;
}

/* iOS zooms the page when a focused field's text is under 16px, and the
   zoom then sticks. Fields never go below that, whatever the text-size
   setting; the viewport's maximum-scale stops the zoom as well. */
input { font-size: max(16px, 1rem) !important; }

/* Search */
.search { display: flex; gap: 8px; margin: 4px 0 20px; }
.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  -webkit-appearance: none;
  appearance: none;
}
.search input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.search button {
  width: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--card-2);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}

/* Favourites */
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.group-head, .group-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  min-height: 56px;
}
.group-head { font-weight: 700; font-size: 1.118rem; justify-content: space-between; }
.group-row { border-top: 1px solid var(--bg); }
.group-row:active, .group-head:active, .card:active { background: var(--card-2); }
.group code { background: var(--card-2); color: #d1d1d6; padding: 2px 8px; border-radius: 6px; }
.arrow { color: var(--amber); font-weight: 700; }
.grow { flex: 1; min-width: 0; }
.chev { color: var(--muted); font-size: 1.412rem; line-height: 1; }

/* Board */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.chip-link {
  display: inline-block;
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 1.176rem;
  font-weight: 600;
  color: #d1d1d6;
}
.chip-link.subtle { font-size: 0.882rem; color: var(--muted); padding: 12px 14px; }
.chip-link.clear { min-width: 44px; text-align: center; }
.caret { color: var(--muted); font-size: .7em; }

.card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px 12px 16px;
  margin-bottom: 10px;
}
.svc-main { flex: 1; min-width: 0; }
.line1 { display: flex; gap: 10px; align-items: baseline; font-size: 1.118rem; font-weight: 700; }
.time { font-variant-numeric: tabular-nums; }
.dest { overflow-wrap: anywhere; }
.via { color: var(--muted); font-size: 0.824rem; }
.line2 { display: flex; flex-wrap: wrap; column-gap: 8px; color: var(--muted); font-weight: 600; font-size: 0.882rem; margin-top: 2px; }
.line2 span { white-space: nowrap; }
.line2 span + span::before { content: "·"; margin-right: 8px; }
.arr { color: #d1d1d6; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: var(--card-2);
  color: #aeaeb2;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.765rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip.op { color: #fff; background: #48484a; }
.op-SE { background: #0a6c93 !important; }
.op-SN { background: #2c7a3f !important; }
.op-TL { background: #b0347b !important; }
.op-GX { background: #b0102d !important; }
.op-VT { background: #c8401a !important; }
.op-GW { background: #0b5a45 !important; }
.op-SW { background: #1a5c8a !important; }
.op-LO { background: #c75a00 !important; }
.op-XR { background: #6a3ea1 !important; }
.op-LE { background: #a3004f !important; }
.op-GN { background: #6b2c91 !important; }
.op-TP { background: #3b2a7a !important; }
.op-NT { background: #1e3a8a !important; }
.op-XC { background: #7a1033 !important; }

.svc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
/* Minutes until it leaves: the figure to act on, so the largest on the card. */
.count { font-size: 1.647rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.count small { font-size: 0.824rem; font-weight: 600; color: #aeaeb2; margin-left: 3px; }
.count.far { font-size: 1.118rem; }
.status { font-weight: 700; font-size: 0.882rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.status .tick { width: 15px; height: 15px; }
.status.ok { color: var(--green); }
.status.late { color: var(--amber); }
.status.bad { color: var(--red); }
.status.unknown { color: var(--muted); }
.status small { font-weight: 600; }
.card.cancelled .status { font-size: 1rem; }
.plat { background: var(--card-2); border-radius: 8px; padding: 2px 9px; font-size: 0.765rem; font-weight: 600; color: #aeaeb2; white-space: nowrap; }
.plat b { color: #fff; font-size: 1rem; margin-left: 2px; }

.struck { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.late-text { color: var(--amber); }
.bad-text { color: var(--red); font-weight: 600; }
.changed { color: var(--amber); font-size: 0.824rem; margin: 2px 0 0; }
.chip.warn { color: var(--amber); }
.reason { color: var(--amber); font-size: 0.824rem; margin: 8px 0 0; }
.card.cancelled .dest, .card.cancelled .chips { opacity: .5; }
.card.cancelled .reason { color: var(--red); }
.alert { color: #ffd60a; font-size: 0.824rem; margin: 8px 0 0; }
.stop-name .alert { margin-top: 2px; }

.fastest-wrap { border: 2px solid var(--green); border-radius: calc(var(--radius) + 2px); margin-bottom: 10px; overflow: hidden; }
.fastest-wrap .card { margin: 0; border-radius: 0; }
.fastest-bar {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--green); color: #000;
  font-weight: 700; font-size: 0.882rem;
  padding: 6px 14px;
}

.notice { background: #2a2310; border-radius: 14px; margin-bottom: 10px; color: #ffd60a; font-size: 0.882rem; }
.notice summary { font-weight: 700; cursor: pointer; padding: 12px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice-preview { color: #e5e5ea; font-weight: 400; }
.notice[open] .notice-preview { display: none; }
.notice p { color: #e5e5ea; margin: 0; padding: 0 14px 12px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.footnote { color: var(--muted); font-size: 0.765rem; margin: 4px 4px 16px; }

.error-panel { background: #2b1414; border: 1px solid #5c2020; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.error-panel strong { color: var(--red); font-size: 1.059rem; }
.error-panel p { margin: 8px 0 0; }
.error-panel a { color: var(--blue); }
.error-panel a.button { display: inline-block; color: var(--text); background: var(--card-2); border-radius: 999px; padding: 12px 18px; font-weight: 600; }

.live.stale .card, .live.stale .route { opacity: .45; filter: grayscale(1); }
.updated { display: none; }

/* Bottom bar */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 10; /* above the route's dots, which are raised over its line */
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: rgba(28, 28, 30, .92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.age { color: var(--muted); font-size: 0.882rem; font-weight: 600; }
.age.bad { color: var(--red); }
.refresh-btn {
  font: inherit; font-weight: 600; font-size: 0.882rem;
  color: var(--text); background: var(--card-2);
  border: 0; border-radius: 999px; padding: 13px 18px;
}
.refresh-btn:disabled { opacity: .5; }

/* Train detail. The head stays in view while the stops scroll under it. */
.train-head {
  position: sticky; top: env(safe-area-inset-top); z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bg); padding: 6px 0 10px; border-bottom: 1px solid var(--line);
}
.train-title { min-width: 0; }
.train-head h1 { font-size: 1.412rem; line-height: 1.15; font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.train-dest { color: #aeaeb2; font-weight: 700; }
.train-title p { margin: 3px 0 0; font-size: 0.882rem; }
.train-title p b { color: var(--text); font-size: 1rem; }
.train-meta { padding-top: 10px; font-size: 0.882rem; }
.train-meta p { margin: 0 0 4px; }
.pill { background: #0f2b17; padding: 6px 12px; border-radius: 999px; flex-shrink: 0; }
.status.late.pill { background: #33240a; }
.status.bad.pill { background: #331313; }
.status.unknown.pill { background: var(--card); }
.pill.small { font-size: 0.882rem; padding: 3px 10px; margin-top: 4px; }

.route { list-style: none; margin: 0; padding: 8px 0 0; position: relative; }
.route::before { content: ""; position: absolute; left: 11px; top: 30px; bottom: 30px; width: 4px; background: #48484a; border-radius: 2px; }
.stop { display: flex; align-items: center; gap: 16px; padding: 12px 0; position: relative; min-height: 64px; }
.stop .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--green); flex-shrink: 0; z-index: 1; border: 4px solid var(--bg); box-sizing: content-box; margin: -4px; }
.stop-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stop .name { font-size: 1.118rem; font-weight: 600; }
.stop-status { color: var(--muted); font-size: 0.882rem; }
.stop-time { text-align: right; font-variant-numeric: tabular-nums; font-size: 1.059rem; display: flex; flex-direction: column; }
.stop-time s { color: var(--muted); font-size: 0.941rem; }
.stop.passed .dot { background: #636366; }
.stop.passed .name, .stop.passed .stop-time { color: var(--muted); }
.stop.cancelled .dot { background: var(--red); }
.stop.cancelled .name { text-decoration: line-through; color: var(--muted); }
.stop.cancelled .stop-status { color: var(--red); }
.stop.origin .name { font-size: 1.412rem; font-weight: 800; }
.stop.origin .stop-time { font-size: 1.294rem; font-weight: 800; }
.stop.origin .dot { box-shadow: 0 0 14px 4px rgba(48, 209, 88, .55); }
.stop.destination .name { font-weight: 800; }
.stop.destination .dot { box-shadow: 0 0 0 3px #fff; }
/* Where the train is now: smaller than a station and labelled, so it does
   not read as one more stop. */
.position { display: flex; align-items: center; gap: 22px; min-height: 30px; position: relative; }
.position .dot { width: 14px; height: 14px; margin-left: 6px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px rgba(10, 132, 255, .35); flex-shrink: 0; z-index: 2; }
.position .where { color: #64b0ff; font-size: 0.824rem; font-weight: 600; }

/* Sign in */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.login { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.login label { color: var(--muted); font-size: 0.882rem; }
.login input[type=password] {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.login input[type=password]:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.login button {
  font: inherit; font-weight: 700; color: #000; background: var(--green);
  border: 0; border-radius: 14px; padding: 14px 16px; margin-top: 6px;
}
.login p { margin: 0; }
.signout { text-align: center; margin-top: 28px; }
.signout button { font: inherit; font-size: 0.882rem; color: var(--muted); background: none; border: 0; padding: 12px 20px; }
