/* Railway Live: calm, rounded, readable. Warm paper background, white cards, one green. */
:root {
  --bg: #06130e;
  --surface: #0d2319;
  --surface-2: #0a1c14;
  --ink: #f3f7f4;
  --ink-2: #c5d3cb;
  --muted: #8aa093;
  --line: #1f3a2d;
  --line-2: #173024;
  --brand: #00573f;
  --brand-2: #003f2e;
  --green: #8cc63f;
  --green-ink: #b4e36e;
  --green-soft: #1d3a1c;
  --amber: #ffc53d;
  --amber-soft: #3a2e0c;
  --red: #ff6b5e;
  --red-soft: #40201c;
  --blue: #5aa9ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 30px -18px rgba(0,0,0,.7);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }
main { padding: 28px 0 64px; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 1000; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line-2); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 7px; right: 7px; height: 3px; border-radius: 2px; background: var(--green); }
.brand-mark::before { top: 10px; } .brand-mark::after { bottom: 10px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.header-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(47,207,120,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,207,120,.5); } 70% { box-shadow: 0 0 0 8px rgba(47,207,120,0); } 100% { box-shadow: 0 0 0 0 rgba(47,207,120,0); } }
@media (max-width: 760px) {
  .site-header .wrap { gap: 10px; }
  .nav { margin: 0; overflow-x: auto; }
  .nav a { padding: 7px 10px; font-size: 14px; }
  .brand span { display: none; }
}

/* ---------- Buttons, pills, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-weight: 600; cursor: pointer; transition: transform .08s ease, background .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); }
.btn-green { background: var(--green); border-color: var(--green); color: #06301b; }
.btn-danger { color: var(--red); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill .count { color: var(--muted); font-weight: 500; }
.pill[aria-pressed="true"] .count { color: inherit; opacity: .7; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.chip-green { background: var(--green-soft); color: var(--green-ink); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-grey { background: var(--line-2); color: var(--muted); }
.headcode { display: inline-flex; align-items: center; height: 26px; padding: 0 9px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 13px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.eyebrow { font-size: 12.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h1, h2, h3 { letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(30px, 4.6vw, 46px); font-weight: 750; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 650; }
.muted { color: var(--muted); }
.lead { font-size: 17px; color: var(--ink-2); max-width: 60ch; }

/* ---------- Hero + stats ---------- */
.hero { padding: 26px 0 8px; display: grid; gap: 22px; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.stat { padding: 16px 18px; }
.stat .value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.stat.feature { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.stat.feature .label { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.stat.feature .value { display: flex; align-items: center; gap: 10px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } .stat .value { font-size: 24px; } }

.section-head { margin: 34px 0 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Service cards ---------- */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.service { padding: 18px 18px 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.service-top { display: flex; align-items: flex-start; gap: 10px; }
.service-title { flex: 1; min-width: 0; }
.service-title .times { font-weight: 700; font-size: 16px; }
.service-title .route { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--ink-2); }
.service-meta span { display: inline-flex; align-items: center; gap: 6px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--line); object-fit: cover; flex: none; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.service-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 12px; }
.service-foot strong { color: var(--ink); font-weight: 650; }

/* ---------- Stop line (the route diagram) ---------- */
.stopline { --dot: 14px; --term: 26px; --rail: 6px; list-style: none; margin: 0; padding: 4px 0; position: relative; }
.stopline li { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; min-height: 34px; gap: 10px; }
.stopline li + li { margin-top: 2px; }
/* rail segment drawn from each stop down to the next */
.stopline li::before { content: ""; position: absolute; left: calc(17px - var(--rail) / 2); top: 50%; height: calc(100% + 2px); width: var(--rail); background: var(--line); border-radius: 3px; z-index: 0; }
.stopline li:last-child::before { display: none; }
.stopline li.done::before, .stopline li.passed::before { background: var(--green); }
.stopline .node { grid-column: 1; justify-self: center; position: relative; z-index: 1; width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--surface); border: 3px solid var(--line); }
.stopline .done .node, .stopline .passed .node { background: var(--green); border-color: var(--green); }
.stopline .terminus .node { width: var(--term); height: var(--term); background: #fff; border: 5px solid var(--ink); }
.stopline .terminus.done .node { border-color: var(--ink); }
.stopline .skipped .node { background: var(--surface); border: 3px dashed var(--muted); }
.stopline .current .node { background: var(--green); border-color: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.stopline .name { font-weight: 650; display: flex; align-items: center; gap: 8px; min-width: 0; }
.stopline .terminus .name { font-size: 16px; font-weight: 750; }
.stopline .skipped .name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.stopline .upcoming .name, .stopline .next .name { color: var(--ink-2); }
.stopline .time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; white-space: nowrap; }
.stopline .time s { opacity: .65; margin-right: 6px; font-size: 12.5px; }
.stopline .time .late { color: var(--amber); font-weight: 650; }
.stopline .tag { font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 999px; }
.stopline .tag.green { background: var(--green-soft); color: var(--green-ink); }
.stopline .tag.red { background: var(--red-soft); color: var(--red); }
.stopline .tag.grey { background: var(--line-2); color: var(--muted); }
/* the train between two stops */
.stopline li.train { min-height: 26px; }
.stopline li.train::before { background: linear-gradient(var(--green) 0 50%, var(--line) 50% 100%); }
.stopline .train-dot { grid-column: 1; justify-self: center; z-index: 1; width: 22px; height: 22px; border-radius: 7px; background: var(--ink); display: grid; place-items: center; box-shadow: 0 0 0 4px var(--surface); }
.stopline .train-dot::after { content: ""; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid var(--green); }
.stopline .train-text { font-size: 13px; color: var(--muted); }

/* ---------- Empty states ---------- */
.empty { padding: 44px 24px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty .art { width: 64px; height: 64px; border-radius: 20px; background: var(--green-soft); display: grid; place-items: center; }
.empty .art::before { content: ""; width: 28px; height: 6px; border-radius: 3px; background: var(--green); box-shadow: 0 -11px 0 var(--green), 0 11px 0 var(--green); }

/* ---------- Map page ---------- */
.map-page { height: calc(100dvh - 65px); display: grid; grid-template-columns: 380px 1fr; }
.map-page main { padding: 0; }
.map-side { overflow-y: auto; overflow-x: hidden; min-width: 0; grid-template-columns: minmax(0, 1fr); padding: 16px; border-right: 1px solid var(--line-2); background: var(--bg); display: grid; gap: 12px; align-content: start; }
#map { height: 100%; width: 100%; background: var(--surface-2); }
.list-item { min-width: 0; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line-2); cursor: pointer; text-align: left; width: 100%; }
.list-item:hover { border-color: var(--line); }
.list-item[aria-selected="true"] { outline: 2px solid var(--ink); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) {
  .map-page { grid-template-columns: 1fr; grid-template-rows: 55dvh auto; height: auto; }
  .map-side { order: 2; border-right: 0; }
}
/* train markers on the map */
.train-marker { background: none; border: 0; }
.train-pin { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; border-radius: 999px; background: var(--ink); color: #fff; font: 700 12px/1 var(--font); letter-spacing: .03em; box-shadow: 0 2px 6px rgba(0,0,0,.25); white-space: nowrap; transform: translate(-12px, -12px); }
.train-pin .arrow { width: 18px; height: 18px; border-radius: 50%; background: var(--green); display: grid; place-items: center; }
.train-pin .arrow { color: #06301b; }
.train-pin.late .arrow { background: #ffb020; }
.train-pin.selected { outline: 3px solid var(--green); }
.station-label { background: none; border: 0; font: 650 12.5px var(--font); color: var(--ink); text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface), 0 0 3px var(--surface); white-space: nowrap; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 11px; }

/* ---------- Profile ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.score-ring { --p: 0; width: 148px; height: 148px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line-2) 0); position: relative; flex: none; }
.score-ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.score-ring .inner { position: relative; text-align: center; }
.score-ring .inner b { display: block; font-size: 40px; letter-spacing: -.03em; line-height: 1; }
.score-ring .inner span { font-size: 12.5px; color: var(--muted); }
.bars { display: grid; gap: 10px; flex: 1; min-width: 220px; }
.bar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar .track, .bar .fill { display: block; }
.bar .track { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 4px; background: var(--green); }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.score-badge { display: inline-grid; place-items: center; min-width: 40px; height: 26px; padding: 0 8px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); cursor: pointer; }
.toggle:first-of-type { border-top: 0; }
.toggle input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 2px 0 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--green); }
.toggle input:checked::after { transform: translateX(18px); }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.signin { max-width: 560px; margin: 40px auto; text-align: center; padding: 36px 28px; display: grid; gap: 16px; justify-items: center; }
.notice { padding: 12px 14px; border-radius: 14px; background: var(--amber-soft); color: var(--ink); font-size: 14px; }

/* ---------- Legal pages ---------- */
.prose { max-width: 760px; margin: 0 auto; }
.prose .card { padding: clamp(22px, 4vw, 44px); }
.prose h1 { font-size: 34px; margin-bottom: 6px; }
.prose h2 { font-size: 20px; margin: 32px 0 8px; }
.prose h3 { font-size: 16px; margin: 20px 0 6px; }
.prose p, .prose li { color: var(--ink-2); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0; }
.prose th, .prose td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.prose th { font-size: 12.5px; color: var(--muted); }
.prose .summary { background: var(--green-soft); border-radius: 14px; padding: 14px 18px; margin: 18px 0; }
.prose .summary p { color: var(--ink); margin: 4px 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line-2); padding: 28px 0 40px; color: var(--muted); font-size: 13.5px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }
.skel { background: linear-gradient(90deg, var(--line-2), var(--surface-2), var(--line-2)); background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: 10px; }
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Southern-green hub theme ---------- */
.site-header { background: var(--brand); border-bottom: 3px solid var(--green); backdrop-filter: none; }
.site-header .wrap { height: 58px; }
.brand { color: #fff; font-size: 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: var(--green); display: grid; place-items: center; }
.brand-mark::before, .brand-mark::after { display: none; }
.brand-mark svg { width: 20px; height: 20px; }
.nav a { color: rgba(255,255,255,.85); border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.1); }
.nav a[aria-current="page"] { background: rgba(0,0,0,.25); color: #fff; box-shadow: none; }
.clock { font: 600 13px ui-monospace, Menlo, Consolas, monospace; background: #04100b; color: #fff; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
@media (max-width: 760px) { .clock { display: none; } }
.btn-primary, .btn-green { background: var(--green); border-color: var(--green); color: #0b1d08; }
.btn-primary:hover { background: #a0d655; }
.pill[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #0b1d08; }
.headcode { background: var(--green); color: #0b1d08; }
.stat.feature { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat.feature .label { color: rgba(255,255,255,.75); }
.stopline .terminus .node { background: var(--surface); border-color: #fff; }
.stopline .terminus.done .node { border-color: #fff; background: var(--green); }
.stopline .train-dot { background: #fff; }
.stopline .train-dot::after { border-top-color: var(--brand); }
.train-pin { background: #fff; color: #06130e; }
.avatar { color: var(--ink-2); }
.toggle input::after { background: #fff; }
.prose .summary p { color: var(--ink); }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(6,19,14,.8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--green-ink) !important; }

.band { background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-bottom: 1px solid var(--line); padding: 34px 0 38px; text-align: center; }
.band h1 { color: #fff; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.band p { margin: 10px auto 0; color: rgba(255,255,255,.85); font-size: 17px; max-width: 60ch; }
.band .brand-mark { width: 48px; height: 48px; } .band .brand-mark svg { width: 28px; height: 28px; }

.roles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 24px; }
@media (max-width: 1000px) { .roles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .roles { grid-template-columns: 1fr; } }
.role { overflow: hidden; display: flex; flex-direction: column; }
.role .art { height: 92px; display: grid; place-items: center; background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, var(--line-2) 14px 28px); }
.role .art svg { width: 44px; height: 44px; }
.role .body { padding: 16px 18px; flex: 1; display: grid; gap: 8px; align-content: start; }
.role .body p { margin: 0; color: var(--ink-2); font-size: 14px; }
.role .body b.n { color: #fff; font-variant-numeric: tabular-nums; }
.role .strip { padding: 10px 14px; text-align: center; font-weight: 700; font-size: 14px; color: #0b1d08; background: var(--c); }
.role h3 em { font-style: normal; color: var(--c); }

.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(0, 150px) 1fr; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar .lab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); text-align: right; }
.hbar .rail { background: var(--surface-2); border-radius: 4px; }
.hbar .val { display: block; height: 24px; min-width: 26px; border-radius: 4px; background: var(--green); color: #0b1d08; font-weight: 700; text-align: right; padding: 2px 8px 0 0; }
.hbar:nth-child(2n) .val { background: #ffc53d; }
.hbar:nth-child(3n) .val { background: #5fd3a8; }
