:root {
  --navy: #135a85;
  --navy-2: #0f4a6e;
  --region: #1d77b8;
  --ink: #231f20;
  --muted: #6d6e71;
  --line: #d8d7d2;
  --water: #d5ecf6;
  --rail: #d9dbdd;
  --paper: #efeeea;
  --paper-2: #e4e3de;
  --thumb: #dcdcd8;
  --rule: #9a9993;
  --rule-soft: #cfcec8;
  --ink-2: #4a4a4a;
  --accent: #135a85;
  --bar: #135a85;
  --halo: #231f20;
  --grab: #c8cbce;
  --alert-info: #f4f8fb;
  --alert-warn: #fff7ee;
  --alert-ok: #f2faf1;
  --veil: rgba(239, 238, 234, .6);
  --veil-strong: rgba(239, 238, 234, .9);
  --shadow: rgba(0,0,0,.06);
  --top: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden;
}
button { font: inherit; cursor: pointer; color: inherit; }
a { color: inherit; }

/* ---------- Views ---------- */
.view { display: none; }
body[data-view="map"] #view-map { display: grid; }
body[data-view="about"] #view-about, body[data-view="sources"] #view-sources { display: block; }
body[data-view="about"] .bottombar, body[data-view="sources"] .bottombar { display: none; }
body[data-view="about"], body[data-view="sources"] { background: var(--paper); }

/* ---------- Top nav ---------- */
.topnav {
  height: var(--top); flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--paper);
}
body[data-view="about"] .topnav, body[data-view="sources"] .topnav { background: var(--paper); border-color: var(--line); }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; text-decoration: none; }
.brand span { font-weight: 400; color: var(--accent); letter-spacing: .02em; }
.tabs { display: flex; gap: 28px; }
.tabs a { text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a.active { color: var(--ink); border-color: var(--ink); font-weight: 500; }

/* ---------- Map view ---------- */
.map-view { flex: 1; min-height: 0; grid-template-columns: 1fr 360px; position: relative; }
.map-wrap { position: relative; overflow: hidden; min-height: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
#map.grabbing { cursor: grabbing; }

.zoom { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px var(--shadow); }
.zoom button { width: 38px; height: 38px; border: 0; background: var(--paper); font-size: 20px; line-height: 1; }
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: var(--paper-2); }
.zoom button[data-zoom="reset"] { font-size: 17px; }

/* map layers */
.water { fill: var(--water); }
.rail { fill: none; stroke: var(--rail); stroke-width: 2.5; }
.region { font-weight: 800; fill: var(--region); font-size: 21px; letter-spacing: -0.01em; pointer-events: none; transform: scale(var(--ls, 1)); }
.station .lbl { transform: scale(var(--ls, 1)); }
.train .tb { transform: scale(var(--ts, 1)); }
.line-path { fill: none; stroke-width: calc(6.5px * var(--lk, 1)); stroke-linecap: round; stroke-linejoin: round; cursor: pointer; transition: opacity .25s; }
.station .halo { stroke: var(--halo); stroke-linecap: round; stroke-width: calc(11px * var(--lk, 1)); }
.station .fill { stroke: #fff; stroke-linecap: round; stroke-width: calc(7px * var(--lk, 1)); }
.hit { stroke: transparent; stroke-width: calc(26px * var(--lk, 1)); stroke-linecap: round; cursor: pointer; }
.station.selected .halo { stroke: var(--accent); stroke-width: calc(15px * var(--lk, 1)); }
.station { cursor: pointer; transition: opacity .25s; }
.station text { font-size: 14.5px; fill: var(--ink); }
.station text.bold { font-weight: 800; font-size: 17px; }
.station text.note { font-size: 9px; font-style: italic; font-weight: 700; }
.station:hover text, .station.hover text, .station.selected text { fill: var(--accent); }
#map.focus .line-path { opacity: .12; }
#map.focus .line-path.hl { opacity: 1; }
#map.focus .station { opacity: .25; }
#map.focus .station.hl, #map.focus .station.selected { opacity: 1; }

/* ---------- Side panel / bottom sheet ---------- */
.sheet { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--paper); }
.sheet-head { flex: none; border-bottom: 1px solid var(--line); }
.grab { display: none; }
.ptabs { display: flex; padding: 0 20px; gap: 22px; }
.ptabs button { border: 0; background: none; padding: 16px 0 12px; font-weight: 700; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; position: relative; }
.ptabs button.active { color: var(--ink); border-color: var(--ink); }
.dot-badge { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #F7941D; vertical-align: 2px; margin-left: 3px; }
.panel { padding: 20px; font-size: 14px; overflow-y: auto; flex: 1; min-height: 0; }

.panel h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.panel h3 { margin: 20px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.panel .sub { color: var(--muted); font-size: 13px; margin: 0; }
.panel ul { margin: 0; padding-left: 18px; line-height: 1.6; }
.empty { color: var(--muted); line-height: 1.5; }
.empty strong { color: var(--ink); display: block; font-size: 16px; margin-bottom: 4px; }
.line-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 8px 3px 3px; border-radius: 99px; background: var(--paper-2); }
.tag .badge { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 800; }

.dep { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dep .bar { width: 5px; align-self: stretch; border-radius: 3px; }
.dep .dest { flex: 1; font-weight: 700; }
.dep .dest small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.dep .mins { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; text-align: right; }
.dep .mins small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.refresh { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.refresh button { border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 3px 10px; font-size: 12px; }

.alert { border-left: 4px solid var(--accent); background: var(--alert-info); padding: 10px 12px; margin-bottom: 10px; border-radius: 0 6px 6px 0; line-height: 1.45; }
.alert.warn { border-color: #F7941D; background: var(--alert-warn); }
.alert.ok { border-color: #4DB848; background: var(--alert-ok); }
.alert small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* ---------- Bottom bar ---------- */
.bottombar {
  flex: none; background: var(--bar); color: #fff;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
}
.service { display: flex; align-items: center; gap: 12px; }
.toggle { display: flex; background: rgba(255,255,255,.12); border-radius: 8px; padding: 3px; }
.toggle button { border: 0; background: none; color: #fff; opacity: .75; padding: 7px 14px; border-radius: 6px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.toggle button small { font-weight: 400; font-size: 11px; opacity: .8; margin-left: 4px; }
.toggle button.active { background: #fff; color: var(--navy); opacity: 1; }
.status { font-size: 12px; opacity: .9; white-space: nowrap; }
.status b { background: #4DB848; color: #fff; padding: 2px 7px; border-radius: 99px; font-size: 10px; letter-spacing: .04em; margin-right: 6px; }
.chips { display: flex; gap: 8px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 99px; background: rgba(255,255,255,.1); color: #fff; padding: 4px 11px 4px 4px; font-size: 13px; white-space: nowrap; }
.chip .badge { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-weight: 800; font-size: 11px; }
.chip small { opacity: .7; font-size: 11px; }
.chip:hover { background: rgba(255,255,255,.2); }
.chip.on { background: #fff; color: var(--ink); }
.chip.off { opacity: .45; cursor: default; }

/* ---------- Tablet + phone: panel becomes a floating sheet ---------- */
@media (max-width: 1099px) {
  .map-view { grid-template-columns: 1fr; }
  .sheet {
    position: absolute; right: 16px; bottom: 16px; width: 380px; max-height: calc(100% - 32px);
    border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.15); overflow: hidden;
  }
  .sheet.collapsed .panel { display: none; }
  .sheet.collapsed .sheet-head { border-bottom: 0; }
  .grab { display: block; width: 100%; height: 18px; border: 0; background: none; position: relative; }
  .grab::after { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--grab); }
  .ptabs button { padding-top: 6px; }
  .chips { margin-left: 0; width: 100%; }
}

@media (max-width: 699px) {
  :root { --top: 50px; }
  .topnav { padding: 0 16px; }
  .tabs { gap: 18px; }
  .brand { font-size: 17px; }
  .sheet { left: 0; right: 0; bottom: 0; width: auto; border-radius: 16px 16px 0 0; max-height: 62%; border-left: 0; border-right: 0; border-bottom: 0; }
  .zoom { top: 10px; right: 10px; }
  .bottombar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); gap: 10px; }
  .service { width: 100%; flex-wrap: wrap; gap: 6px 10px; }
  .toggle { flex: 1; }
  .toggle button { flex: 1; padding: 8px 6px; }
  .toggle button small { display: none; }
  .status { display: none; }
  .toggle button.live::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4DB848; margin-left: 6px; vertical-align: 1px; }
  .chip { font-size: 12px; padding: 3px 10px 3px 3px; }
  .chip .badge { width: 18px; height: 18px; font-size: 10px; }
  .ptabs button { padding: 4px 0 10px; }
}

/* ---------- About view ---------- */
.about-view { flex: 1; overflow-y: auto; background: var(--paper); }
.about { max-width: 1200px; margin: 0 auto; padding: 40px 56px 32px; }
.about-grid { display: grid; grid-template-columns: minmax(220px, 290px) 44px 1fr; gap: 28px; align-items: start; }
.a-title { font-family: "Work Sans", sans-serif; font-weight: 900; font-size: clamp(64px, 7.5vw, 104px); line-height: .9; margin: 0; letter-spacing: -0.02em; }
.acronym { font-family: "Work Sans", sans-serif; font-size: 18px; margin: 12px 0 28px; letter-spacing: .01em; }
.acronym b { font-weight: 900; color: var(--region); }
.thumbs { display: flex; flex-direction: column; gap: 14px; }
.thumb { border: 0; padding: 0; background: var(--thumb); display: block; text-align: left; position: relative; outline: 2px solid transparent; transition: outline-color .2s; }
.thumb svg { width: 100%; height: auto; display: block; padding: 18px 12px 30px; }
.thumb span { position: absolute; left: 10px; bottom: 7px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.thumb.active { outline-color: var(--ink); }
.arrows { display: flex; gap: 14px; justify-content: flex-end; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rule); }
.arrows button { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--ink); background: none; font-size: 22px; line-height: 1; padding-bottom: 3px; }
.arrows button:hover { background: var(--ink); color: var(--paper); }

.a-years { font-family: "Work Sans", sans-serif; font-weight: 300; font-size: 30px; color: var(--ink-2); writing-mode: vertical-rl; transform: rotate(180deg); align-self: center; justify-self: center; white-space: nowrap; letter-spacing: .02em; }

.a-stage { position: relative; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; column-gap: 0; margin-top: 70px; }
.a-stage .divider { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--ink-2); }
.cell { min-width: 0; }
.car-front { padding-right: 0; align-self: end; }
.car-rear { align-self: start; margin-top: -8px; }
.car-front svg, .car-rear svg { width: 100%; height: auto; display: block; }
.text-top { padding: 0 0 0 22px; align-self: end; margin-bottom: 26px; }
.text-bottom { padding: 18px 22px 0 0; }
.text-top h2 { font-family: "Work Sans", sans-serif; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 8px; }
.a-stage p { font-size: 14px; line-height: 1.5; text-align: justify; hyphens: auto; margin: 0; }
.in { animation: rise .9s ease both; }
.car-rear.in { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.intro { max-width: 760px; margin: 56px auto 0; text-align: center; font-size: 18px; line-height: 1.6; }
.intro b { font-family: "Work Sans", sans-serif; font-weight: 800; }
.numbers { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 44px; border-top: 1px solid var(--rule); }
.numbers div { padding: 22px 18px 0; }
.numbers div + div { border-left: 1px solid var(--rule-soft); }
.numbers strong { display: block; font-family: "Work Sans", sans-serif; font-weight: 900; font-size: 34px; letter-spacing: -0.02em; }
.numbers span { color: var(--muted); font-size: 13px; }
.about-foot { margin-top: 48px; }
.cta { font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--ink); padding-bottom: 2px; }

@media (max-width: 999px) {
  .about { padding: 32px 32px 28px; }
  .about-grid { grid-template-columns: 1fr; gap: 20px; }
  .a-left { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; align-items: end; }
  .a-title, .acronym { grid-column: 1 / -1; }
  .thumbs { flex-direction: row; grid-column: 1 / -1; }
  .thumb { flex: 1; }
  .arrows { grid-column: 1 / -1; }
  .a-years { writing-mode: horizontal-tb; transform: none; justify-self: start; font-size: 26px; }
  .a-stage { margin-top: 10px; }
  .numbers { grid-template-columns: repeat(2, 1fr); }
  .numbers div:nth-child(3) { border-left: 0; }
  .numbers div:nth-child(n+3) { padding-top: 22px; }
}

@media (max-width: 599px) {
  .about { padding: 24px 18px 24px; }
  .a-stage { grid-template-columns: 1fr 1fr; grid-template-areas: "front rear" "t1 t1" "t2 t2"; }
  .a-stage .divider { display: none; }
  .car-front { grid-area: front; }
  .car-rear { grid-area: rear; margin-top: 0; align-self: end; }
  .text-top { grid-area: t1; padding: 22px 0 0; margin: 0; }
  .text-bottom { grid-area: t2; padding: 12px 0 0; }
  .a-stage p { text-align: left; }
  .intro { font-size: 16px; text-align: left; margin-top: 36px; }
  .numbers strong { font-size: 26px; }
}

/* ---------- Meet Karl ---------- */
.karl {
  display: grid; grid-template-columns: minmax(220px, 290px) 1fr; gap: 28px 44px;
  margin-top: 72px; padding-top: 40px; border-top: 1px solid var(--rule);
}
.kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.k-title { font-family: "Work Sans", sans-serif; font-weight: 900; font-size: clamp(64px, 7.5vw, 104px); line-height: .9; margin: 0; letter-spacing: -0.02em; }
.k-sub { font-family: "Work Sans", sans-serif; font-weight: 300; font-size: 28px; margin: 6px 0 0; color: var(--ink-2); }
.k-years { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.karl-art { overflow: hidden; border-radius: 2px; align-self: stretch; min-height: 220px; }
.karl-art svg { width: 100%; height: 100%; display: block; }
.fog path { will-change: transform; }
.fog .f1 { animation: drift 38s ease-in-out infinite alternate; }
.fog .f2 { animation: drift 52s ease-in-out infinite alternate-reverse; }
.fog .f3 { animation: drift 30s ease-in-out infinite alternate; animation-delay: -10s; }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(160px); } }
@media (prefers-reduced-motion: reduce) { .fog path { animation: none; } }

.karl-text { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule-soft); }
.karl-text > div { padding: 20px 18px 0; }
.karl-text > div + div { border-left: 1px solid var(--rule-soft); }
.karl-text h3 { font-family: "Work Sans", sans-serif; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 8px; }
.karl-text p { font-size: 14px; line-height: 1.55; margin: 0; }

@media (max-width: 999px) {
  .karl { grid-template-columns: 1fr; margin-top: 56px; }
  .karl-left { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
  .kicker { width: 100%; }
  .k-years { width: 100%; margin-top: 8px; }
  .karl-art { min-height: 0; aspect-ratio: 800 / 340; }
  .karl-text { grid-template-columns: 1fr 1fr; }
  .karl-text > div:nth-child(3) { border-left: 0; }
  .karl-text > div:nth-child(n+3) { padding-top: 24px; }
}
@media (max-width: 599px) {
  .karl-text { grid-template-columns: 1fr; }
  .karl-text > div { padding: 18px 0 0; border-left: 0 !important; }
  .k-sub { font-size: 22px; }
}

/* ---------- Mini trains ---------- */
.train { pointer-events: auto; transition: transform 1.8s linear, opacity .25s; }
#map.focus .train { opacity: 0; visibility: hidden; transition: transform 1.8s linear, opacity .25s, visibility 0s .25s; }
#map.focus .train.hl { opacity: 1; visibility: visible; transition: transform 1.8s linear, opacity .25s; }
.live-pill {
  position: absolute; left: 14px; bottom: 14px; display: flex; align-items: center; gap: 8px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 12px; font-size: 12px; font-weight: 500; box-shadow: 0 2px 8px var(--shadow);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--rule); }
.pulse.on { background: #4DB848; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(77,184,72,.6); } 100% { box-shadow: 0 0 0 8px rgba(77,184,72,0); } }
@media (max-width: 1099px) { .live-pill { top: 14px; bottom: auto; } }
@media (max-width: 699px) { .live-pill { top: 10px; left: 10px; font-size: 11px; } }

/* ---------- Opening fog intro ---------- */
.fog-intro { position: fixed; inset: 0; z-index: 100; overflow: hidden; cursor: pointer; transition: opacity .5s ease; }
.fog-intro.done { opacity: 0; pointer-events: none; }
.intro-veil {
  position: absolute; inset: 0; background: var(--veil);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  transition: opacity 1.8s ease, backdrop-filter 1.8s ease;
}
.fog-bank { position: absolute; top: -10%; bottom: -10%; width: 72%; transition: transform 2s cubic-bezier(.55, 0, .3, 1), opacity 2s ease; }
.fog-bank.left { left: -12%; -webkit-mask-image: linear-gradient(to right, #000 62%, transparent); mask-image: linear-gradient(to right, #000 62%, transparent); }
.fog-bank.right { right: -12%; -webkit-mask-image: linear-gradient(to left, #000 62%, transparent); mask-image: linear-gradient(to left, #000 62%, transparent); }
.fog-tex { position: absolute; inset: -20%; background-size: 700px 700px; opacity: .95; animation: fogdrift 14s linear infinite; }
.fog-tex.slow { background-size: 1100px 1100px; opacity: .7; animation-duration: 22s; animation-direction: reverse; }
.fog-bank.right .fog-tex { background-position: 300px 200px; }
@keyframes fogdrift { from { transform: translateX(-4%); } to { transform: translateX(4%); } }

.intro-words {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: .28em;
  font-family: "Work Sans", "Inter", sans-serif; font-weight: 900; font-size: clamp(44px, 9vw, 124px);
  letter-spacing: -0.02em; color: var(--ink); pointer-events: none;
}
.intro-words .w { opacity: 0; filter: blur(10px); transform: translateY(10px); transition: opacity 1s ease, filter 1s ease, transform 1s ease; }
.fog-intro.show .intro-words .w { opacity: 1; filter: blur(0); transform: none; }
.fog-intro.show .intro-words .w.right { transition-delay: .18s; }
.fog-intro.part .intro-words .w { opacity: 0; filter: blur(12px); transition: opacity 1.4s ease, filter 1.4s ease, transform 2s cubic-bezier(.55, 0, .3, 1); }
.fog-intro.part .intro-words .w.left { transform: translateX(-38vw); }
.fog-intro.part .intro-words .w.right { transform: translateX(38vw); }
.fog-intro.part .fog-bank.left { transform: translateX(-80vw); opacity: 0; }
.fog-intro.part .fog-bank.right { transform: translateX(80vw); opacity: 0; }
.fog-intro.part .intro-veil { opacity: 0; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); }

.intro-bart {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  font-family: "Inter", "Helvetica Neue", sans-serif; font-weight: 400; font-size: clamp(72px, 15vw, 210px);
  line-height: normal; letter-spacing: .02em; color: var(--accent); will-change: transform, opacity;
  opacity: 0; transform: scale(.9); transform-origin: center; pointer-events: none;
  transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1);
  text-shadow: 0 2px 30px var(--veil-strong);
}
.fog-intro.reveal .intro-bart { opacity: 1; transform: scale(1); }
.intro-bart.fly { transition: none; text-shadow: none; }
/* Keep the logo's BART hidden until the flying BART lands in it */
body.intro-on .brand span { visibility: hidden; }

.intro-skip {
  position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  border: 1px solid rgba(35,31,32,.25); background: var(--veil); border-radius: 99px;
  padding: 6px 14px; font-size: 12px; color: var(--ink);
}

/* ---------- Site footer ---------- */
.site-footer { background: var(--paper-2); border-top: 1px solid var(--rule-soft); margin-top: 56px; }
.sf-inner { max-width: 1200px; margin: 0 auto; padding: 28px 56px calc(28px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.sf-links { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.sf-official { display: inline-block; font-size: 13px; font-weight: 700; color: #fff; background: var(--navy); text-decoration: none; padding: 9px 16px; border-radius: 99px; }
.sf-official:hover { background: var(--navy-2); }
.sf-sources { font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 1px; }
.sf-sources:hover { color: var(--accent); }
.sf-credit { margin: 0; font-size: 13px; color: var(--muted); }
.sf-credit strong { color: var(--ink); }
.credit-link { margin-top: 18px; font-size: 12px; color: var(--muted); }
.credit-link a { color: var(--muted); }
.credit-link a:hover { color: var(--accent); }

/* ---------- Data & sources page ---------- */
.sources { max-width: 860px; }
.src-title { font-size: clamp(48px, 7vw, 88px); margin-top: 4px; }
.src-lede { font-size: 17px; line-height: 1.6; margin: 18px 0 8px; color: var(--ink-2); max-width: 640px; }
.src-group { margin-top: 40px; }
.src-group h2 { font-family: "Work Sans", sans-serif; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 6px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
.src { display: grid; grid-template-columns: 1fr auto; column-gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule-soft); text-decoration: none; color: var(--ink); }
.src-name { font-weight: 700; font-size: 16px; }
.src-desc { grid-column: 1; color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 3px; }
.src-arrow { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 18px; color: var(--muted); transition: transform .2s, color .2s; }
.src:hover .src-name { color: var(--accent); }
.src:hover .src-arrow { color: var(--accent); transform: translate(2px, -2px); }
.src-note { font-size: 15px; line-height: 1.65; margin: 12px 0 0; }

@media (max-width: 999px) { .sf-inner { padding: 24px 32px calc(24px + env(safe-area-inset-bottom)); } }
@media (max-width: 599px) {
  .sf-inner { flex-direction: column; align-items: flex-start; padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
  .src-lede { font-size: 16px; }
}

/* ---------- Evening (dark) theme: follows evening service ---------- */
:root[data-theme="night"] {
  --ink: #ecebe6;
  --ink-2: #b9b8b2;
  --muted: #9a9ca3;
  --line: #2c3038;
  --paper: #14171c;
  --paper-2: #1c2027;
  --thumb: #1f232a;
  --rule: #4a4e57;
  --rule-soft: #2c3038;
  --water: #16283a;
  --rail: #2f343c;
  --region: #5aa9e6;
  --accent: #6cb4ea;
  --bar: #0b0d11;
  --halo: #0b0d11;
  --grab: #3a3f48;
  --alert-info: #18222d;
  --alert-warn: #2a2116;
  --alert-ok: #162418;
  --veil: rgba(16, 18, 22, .62);
  --veil-strong: rgba(16, 18, 22, .9);
  --shadow: rgba(0,0,0,.4);
}
:root[data-theme="night"] .bottombar { border-top: 1px solid var(--line); }
:root[data-theme="night"] .toggle button.active { background: #ecebe6; color: #0b0d11; }
:root[data-theme="night"] .sf-official { background: #1f6fae; }
:root[data-theme="night"] .tag .badge, :root[data-theme="night"] .chip .badge { box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
/* Karl illustration at night */
:root[data-theme="night"] .karl-art .k-sky { fill: #141b2b; }
:root[data-theme="night"] .karl-art .k-water { fill: #142536; }
:root[data-theme="night"] .karl-art .k-land1 { fill: #2a2e36; }
:root[data-theme="night"] .karl-art .k-land2 { fill: #23272e; }

/* smooth day-to-night change */
body, .topnav, .sheet, .zoom, .zoom button, .bottombar, .site-footer, .live-pill, .thumb, .tag, .alert,
.about-view, .map-wrap, .karl-art rect, .karl-art path {
  transition: background-color .8s ease, color .8s ease, border-color .8s ease, fill .8s ease;
}
.water, .rail, .region, .station text, .station .halo { transition: fill .8s ease, stroke .8s ease; }

/* Bigger tap targets on touch screens */
@media (pointer: coarse) { .hit { stroke-width: calc(36px * var(--lk, 1)); } .line-path { stroke-width: calc(7.5px * var(--lk, 1)); } }

/* Night intro fog: soft moonlit haze instead of white clouds */
.fog-intro.night .intro-veil { background: rgba(12, 16, 24, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.fog-intro.night .fog-tex { opacity: .75; background-size: 900px 900px; }
.fog-intro.night .fog-tex.slow { opacity: .5; background-size: 1400px 1400px; }
.fog-intro.night .intro-words { color: #e9ecf2; text-shadow: 0 0 40px rgba(150, 175, 210, .35); }
.fog-intro.night .intro-bart { text-shadow: 0 0 40px rgba(12, 16, 24, .8); }
.fog-intro.night .intro-skip { background: rgba(20, 24, 32, .7); color: #e9ecf2; border-color: rgba(255,255,255,.2); }

/* Karl illustration at night: moonlit fog, a moon and a few stars */
.karl-art .k-night { display: none; }
:root[data-theme="night"] .karl-art .k-night { display: inline; }
:root[data-theme="night"] .fog .f1 { fill: #9fb2cc; opacity: .32; }
:root[data-theme="night"] .fog .f2 { fill: #b7c6db; opacity: .4; }
:root[data-theme="night"] .fog .f3 { fill: #8ea3c0; opacity: .22; }
:root[data-theme="night"] .karl-art g[fill="#c0442c"], :root[data-theme="night"] .karl-art g[stroke="#c0442c"] { filter: brightness(.9) saturate(.85); }
