:root {
  --bg: #ebe0d4;
  --card: #f8efe4;
  --ink: #201a15;
  --muted: #76695d;
  --line: #dfd1c0;
  --shadow: 0 8px 20px rgba(100, 75, 40, 0.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
.shell { max-width: 420px; margin: 0 auto; padding: 12px 12px 102px; }
.content { display: flex; flex-direction: column; gap: 10px; }
.app-header h1 { margin: 2px 0; font-size: 34px; line-height: 1.02; letter-spacing: -0.03em; }
.app-header .eyebrow { margin: 0; font-size: 11px; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.app-header small { color: var(--muted); }
.card, .status-card, .impact, .settings-group { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.status-card { padding: 14px 14px 12px; }
.card { padding: 14px; }
.compact-card { padding: 12px; }
.status-card h2 { margin: 4px 0; font-size: 30px; line-height: 1.1; }
.status-kicker { margin: 0; color: var(--muted); font-size: 12px; }
.status-helper { margin: 0 0 8px; color: #2a251f; }
.status-row, .section-head, .setting-row, .impact-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.status-card.clear { background: #dbeed3; }
.status-card.forNow { background: #ddeaf9; }
.status-card.soon { background: #f7e4be; }
.status-card.closed { background: #f6d7d0; }
.status-card.unknown { background: #ece6de; }
.impact { padding: 11px 12px; margin-top: 8px; cursor: pointer; }
.impact p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.badge { text-transform: capitalize; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; min-height: 24px; }
.high { background: #cfe9bf; }
.medium { background: #f5ddb4; }
.low { background: #dedede; }
.expanded { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.expanded p { margin: 4px 0; }
button, .row-btn, .search { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 9px 12px; font-weight: 600; }
.ghost-btn { min-height: 40px; border-radius: 999px; }
.section-btn { min-height: 38px; padding: 8px 11px; font-size: 12px; }
.row-btn { width: 100%; text-align: left; }
.settings-group { padding: 12px; margin-top: 10px; }
.settings-group h4 { margin: 0 0 8px; }
.setting-row { min-height: 44px; border-top: 1px solid #e8dccd; padding: 10px 0; }
.setting-row:first-of-type { border-top: 0; }
.pill { background: #e3edd8; border: 1px solid #c9dbb8; border-radius: 999px; padding: 4px 9px; font-size: 11px; }
.toggle { width: 38px; height: 22px; background: #cec6bb; border-radius: 99px; position: relative; }
.toggle::after { content: ''; width: 16px; height: 16px; background: #fff; position: absolute; top: 3px; left: 3px; border-radius: 50%; }
.toggle.on { background: #8ec57b; }
.toggle.on::after { left: 19px; }
.search { color: #8f8375; display: flex; align-items: center; margin-bottom: 10px; }
nav { position: fixed; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(420px, 94vw); background: #f9f1e6; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 16px; padding: 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
nav button { min-height: 44px; border: 0; background: transparent; }
nav button.active { background: #ece1d3; border-radius: 12px; }
.safety { margin: 4px 2px 6px; color: var(--muted); font-size: 12px; padding-bottom: 4px; }
.stack p { margin: 4px 0 0; color: var(--muted); }

.next-card h3,
.section-head h3,
.section-head h2 { margin: 0; }
.next-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.next-window { margin: 0 0 8px; line-height: 1.2; }
.next-sub { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.next-sub p { margin: 0; color: var(--muted); font-size: 13px; }
.next-reason { margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 410px) {
  .section-head { flex-wrap: wrap; align-items: flex-start; }
  .section-btn { min-height: 36px; padding: 6px 10px; }
}

.button-row { display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
input.search { width:100%; margin:8px 0 10px; }
input[type="range"] { width:100%; }
nav { grid-template-columns: repeat(4, 1fr); }

.home-topbar { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:4px 2px 8px; margin-bottom:8px; }
.home-title-block { min-width:0; flex:1; }
.home-title-block h1 { margin:0; font-size:28px; line-height:1.05; letter-spacing:-0.02em; }
.home-title-block small { display:block; margin-top:2px; color:var(--muted); font-size:12px; }
.home-action-block { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.current-place { max-width:90px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--muted); font-size:12px; padding:5px 9px; border:1px solid var(--line); border-radius:999px; background:#f2e8db; }
.refresh-icon-button { min-width:44px; min-height:44px; width:44px; height:44px; border-radius:999px; padding:0; display:inline-flex; align-items:center; justify-content:center; font-size:20px; line-height:1; }
.badge-row{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:6px;}

.line-screen { display:flex; flex-direction:column; gap:10px; }
.line-header p { margin:0; color:var(--muted); font-size:12px; }
.line-top-status { display:flex; justify-content:space-between; font-size:12px; color:var(--muted); margin-bottom:4px; }
.line-title-row { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.line-heading { display:flex; justify-content:space-between; align-items:center; margin-top:4px; }
.line-heading h2 { margin:0; font-size:36px; line-height:1; letter-spacing:-0.03em; }
.line-stage { font-size:11px; padding:6px 9px; border-radius:999px; background:#f0dfbf; color:#5c4422; font-weight:600; }
.line-summary-card { background:#181614; color:#f7f1e8; border-radius:16px; padding:11px 12px; display:flex; justify-content:space-between; align-items:flex-end; }
.line-summary-card p { margin:0; font-size:11px; color:#c1b6a7; letter-spacing:0.08em; }
.line-summary-card h3 { margin:2px 0 0; font-size:26px; }
.line-counts { display:flex; gap:14px; }
.line-counts p { display:flex; flex-direction:column; align-items:flex-end; color:#e0d5c6; letter-spacing:0; }
.line-counts strong { color:#fff; font-size:20px; }
.line-activity { padding:10px; position:relative; }
.line-direction-head { display:grid; grid-template-columns:1fr 1fr; gap:10px; font-size:10px; color:var(--muted); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:8px; }
.line-direction-head p:last-child { text-align:right; }
.line-columns { display:grid; grid-template-columns:1fr 30px 1fr; min-height:260px; gap:8px; position:relative; }
.line-col { position:relative; }
.line-centre { position:relative; }
.rail-track { position:absolute; top:2px; bottom:2px; left:50%; width:4px; transform:translateX(-50%); background:#d3c6b4; border-radius:9px; }
.station-dot, .train-dot { position:absolute; left:50%; transform:translate(-50%, -50%); width:10px; height:10px; border-radius:50%; background:#93867a; border:2px solid #f8efe4; }
.station-dot.active { width:14px; height:14px; background:#6ea878; box-shadow:0 0 0 2px rgba(110,168,120,.2); }
.train-dot.stopping { background:#2a6170; }
.train-dot.passing { background:#42657f; }
.train-dot.freight { background:#7e5a46; }
.train-dot.empty { background:#6f6f87; }
.train-card { position:absolute; left:0; right:0; transform:translateY(-50%); background:#faf6f0; border:1px solid #e4d8c8; border-radius:11px; padding:6px 7px; box-shadow:0 4px 8px rgba(72,50,20,.05); }
.train-card p { margin:0; font-size:12px; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.train-card-main strong { margin-right:2px; }
.train-card-route { margin-top:1px; font-size:11px; color:#4d443b; }
.train-card-badge { color:var(--muted); font-size:10px; display:block; margin-top:2px; text-transform:uppercase; letter-spacing:0.03em; }
.line-empty { border-top:1px solid var(--line); margin-top:6px; padding-top:8px; }
.line-empty p { margin:0; font-weight:600; }
.line-empty small { color:var(--muted); }
.line-strip .strip-track { margin-top:8px; display:grid; grid-template-columns:repeat(6, 1fr); gap:6px; font-size:10px; color:var(--muted); }
.line-strip .strip-track span { text-align:center; position:relative; padding-top:14px; }
.line-strip .strip-track span::before { content:''; width:6px; height:6px; border-radius:50%; background:#9d9183; position:absolute; top:2px; left:50%; transform:translateX(-50%); }
.line-strip .strip-track .active { color:#285f30; font-weight:700; }
.line-strip .strip-track .active::before { background:#5aa462; width:8px; height:8px; }

/* Keep the next closure prominent and supporting caveats easy to scan. */
.status-card .closure-window { margin: 8px 0; font-size: 1.75rem; font-weight: 700; }
.status-card .prediction-data-stage { margin-bottom: 4px; font-weight: 600; }
.status-card small { display: block; margin-top: 8px; }

.stage-indicators { display: flex; flex-wrap: wrap; gap: .4rem .8rem; padding: 0; margin: .75rem 0; list-style: none; }
.stage-indicator { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; }
.stage-indicator-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #626872; flex-shrink: 0; }
.stage-indicator--used .stage-indicator-dot { background: #18763b; }
.stage-indicator--available .stage-indicator-dot { background: #976200; }
