/* Live Railway Trains UK — "Signal Box" theme
 *
 * The look borrows from two things every British rail traveller knows:
 * the illuminated track diagrams of signalling centres (ink-navy panels,
 * lit routes, red/amber/green aspects) and amber dot-matrix platform
 * displays (the Doto face). Tokens first; every colour below uses them.
 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #070b14;
  --panel: #0d1422;
  --panel-2: #141e31;
  --panel-3: #1c2942;
  --line: #22314d;
  --text: #e9eef7;
  --muted: #8e9bb4;
  --accent: #ffc02e;        /* signal amber: links, primary actions */
  --on-accent: #1a1000;
  --ok: #2ee37a;            /* green aspect */
  --warn: #ff9b3d;          /* late */
  --danger: #ff4d5e;        /* red aspect / cancelled */
  --route: #5ad1ff;         /* lit route on a track diagram */
  --dm-bg: #020409;
  --dm: #ffb627;
  --dm-glow: rgba(255, 170, 20, 0.55);
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-cond: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --font-dm: "Doto", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --top-h: 56px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.6);
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* Icons from the inline sprite */
.ic {
  width: 1.15em; height: 1.15em;
  display: inline-block;
  vertical-align: -0.2em;
  flex: none;
}

/* Dot-matrix text: the platform-display voice of the site */
.dm {
  font-family: var(--font-dm);
  font-weight: 900;
  color: var(--dm);
  text-shadow: 0 0 6px var(--dm-glow);
  letter-spacing: 0.04em;
}

/* ---------- Header ---------- */
#topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--top-h);
  padding: 0 16px;
  background: linear-gradient(180deg, #0f1729 0%, #0a101d 100%);
  border-bottom: 1px solid var(--line);
  z-index: 1000;
  flex: none;
}
#topbar::after {             /* a lit "route" running along the header */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 18%,
    var(--accent) 60%, var(--ok) 82%, transparent 100%);
  opacity: 0.7;
}

#brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.logo { width: 34px; height: 34px; flex: none; }
.lamp-r { fill: #3d0f16; }
.lamp-a { fill: #3d2f0a; }
.lamp-g { fill: var(--ok); filter: drop-shadow(0 0 4px var(--ok)); animation: lamp 3s ease-in-out infinite; }
@keyframes lamp { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .lamp-g, .badge.live::before { animation: none; } }

.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-name, #brand h1 {
  font-family: var(--font-cond);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-tag {
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

#stats { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

/* The header's own mini departure board */
.dm-board {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--dm-bg);
  border: 1px solid #1a2336;
  border-radius: 8px;
  padding: 3px 12px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 182, 39, 0.05);
  white-space: nowrap;
}
#train-count { font-size: 19px; }
.dm-lbl { font-size: 13px; opacity: 0.75; }
#pulse-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-left: 1px solid #1f2a40;
  padding: 2px 0 2px 12px;
  cursor: pointer;
  font-size: 15px;
}
#pulse-chip[hidden] { display: none; }
#pulse-chip .ic { color: var(--ok); filter: drop-shadow(0 0 4px var(--ok)); }
#pulse-chip.fair .ic { color: var(--dm); filter: drop-shadow(0 0 4px var(--dm)); }
#pulse-chip.poor .ic, #pulse-chip.bad .ic { color: var(--danger); filter: drop-shadow(0 0 4px var(--danger)); }
#pulse-chip:hover { filter: brightness(1.25); }

#updated { font-size: 12px; }

.nav-link, #nav-blog {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.nav-link:hover, #nav-blog:hover { color: var(--accent); }

/* Passenger Assist: always reachable, never hidden on small screens */
#nav-assist {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
#nav-assist:hover { border-color: var(--accent); color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.badge.live { background: #0a2716; color: var(--ok); border-color: #154d2c; }
.badge.live::before { box-shadow: 0 0 6px var(--ok); animation: lamp 2s infinite; }
.badge.simulated { background: #2e2108; color: var(--accent); border-color: #5a4212; }

/* ---------- Layout ---------- */
#layout { flex: 1; display: flex; min-height: 0; position: relative; }

#sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 900;
}

.search-wrap { position: relative; margin: 10px; }
.search-wrap .ic {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
#search {
  width: 100%;
  margin: 0;
  padding: 10px 12px 10px 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 192, 46, 0.15); }

.list-head {
  display: flex;
  justify-content: space-between;
  padding: 0 14px 6px;
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

#train-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; scrollbar-color: var(--line) transparent; }

.train-item, .station-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  background: var(--panel-2);
  border-left: 4px solid transparent;
  transition: background 0.15s;
}
.train-item:hover, .station-item:hover { background: var(--panel-3); }
.train-item.selected { background: var(--panel-3); outline: 1px solid var(--accent); }
.station-item { border-left-color: var(--route); }

.train-item .hc {
  font-family: var(--font-dm);
  font-weight: 900;
  font-size: 15px;
  color: var(--dm);
  text-shadow: 0 0 5px var(--dm-glow);
  background: var(--dm-bg);
  padding: 0 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}
.station-item .hc { font-weight: 700; font-size: 14px; }
.train-item .toc, .station-item .toc { font-size: 11px; color: var(--muted); float: right; margin-top: 2px; }
.train-item .dest { font-size: 13px; color: var(--muted); margin-top: 4px; }
.station-item .dest { font-size: 12px; color: var(--route); margin-top: 3px; }
.train-item .late { color: var(--warn); font-size: 12px; font-weight: 700; }
.train-item .ontime { color: var(--ok); font-size: 12px; font-weight: 700; }

/* ---------- Map ---------- */
#map { flex: 1; background: var(--bg); }

/* "Signal box" night basemap: OSM tiles re-lit as a dark track diagram */
.tiles-night { filter: invert(1) hue-rotate(195deg) brightness(0.72) contrast(1.2) saturate(0.45); }
.tiles-rail { filter: saturate(0.75); }

.leaflet-container { font-family: var(--font); background: var(--bg); }
.leaflet-bar, .leaflet-control-layers {
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
  border-radius: 10px !important;
  overflow: hidden;
}
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--panel);
  color: var(--text);
  border-bottom-color: var(--line);
}
.leaflet-bar a:hover { color: var(--accent); }
.leaflet-control-layers { background: var(--panel); color: var(--text); }
.leaflet-control-layers-toggle { filter: invert(1) brightness(0.9); }
.leaflet-control-layers-expanded { padding: 8px 12px 8px 8px; font-size: 13px; }
.leaflet-control-layers-separator { border-top-color: var(--line); }
.leaflet-control-attribution {
  background: rgba(7, 11, 20, 0.8) !important;
  color: var(--muted);
}
.leaflet-control-attribution a { color: var(--accent); }

/* Train markers */
.train-marker { transition: transform 0.2s; }
.train-marker svg { display: block; filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9)); }

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.popup-hc {
  font-family: var(--font-dm);
  font-weight: 900;
  font-size: 18px;
  color: var(--dm);
  text-shadow: 0 0 6px var(--dm-glow);
  background: var(--dm-bg);
  padding: 1px 8px;
  border-radius: 5px;
  letter-spacing: 0.06em;
}
.popup-toc {
  font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
  color: #fff; margin-left: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.popup-row { font-size: 13px; margin-top: 6px; color: var(--muted); }
.popup-row b { color: var(--text); font-weight: 600; }
.popup-src { display: flex; align-items: center; gap: 6px; }
.popup-src.good { color: var(--ok); }
.popup-src.stale { color: var(--warn); }
.popup-buy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent) !important;
  font-weight: 700;
  text-decoration: none;
}
.popup-buy:hover { filter: brightness(1.1); }

/* Clickable elements inside train popups */
.plink { cursor: pointer; }
.plink:hover { text-decoration: underline; }
b.plink, .dest.plink, .via .plink { border-bottom: 1px dotted var(--muted); }

.station-tip {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); font-size: 12px;
}

/* ---------- Departure board panel ---------- */
#board {
  position: absolute;
  top: 12px; right: 12px;
  width: 440px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 1050; /* above Leaflet controls (z-index 1000) */
}

#board-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #05080f, #0a0f1b);
  border-bottom: 1px solid var(--line);
}
#board-station {
  font-family: var(--font-dm);
  font-weight: 900;
  font-size: 20px;
  line-height: 1.15;
  color: var(--dm);
  text-shadow: 0 0 7px var(--dm-glow);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#board-sub {
  font-family: var(--font-cond);
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-top: 4px;
}
#board-close {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; flex: none;
  display: grid; place-items: center;
}
#board-close:hover { color: var(--accent); border-color: var(--accent); }

/* Station photo (Wikimedia Commons) at the top of a station's board */
#station-photo { position: relative; margin: 0; background: var(--dm-bg); }
#station-photo[hidden] { display: none; }
#station-photo img {
  display: block; width: 100%; height: 170px; object-fit: cover;
  filter: saturate(0.9) contrast(1.05);
}
#station-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5, 8, 15, 0) 55%, rgba(5, 8, 15, 0.85) 100%);
  pointer-events: none;
}
#station-photo figcaption {
  position: absolute; left: 10px; right: 10px; bottom: 6px; z-index: 1;
  font-size: 10px; color: #c6cfdf; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#station-photo figcaption a { color: #fff; }

#board-tabs { display: flex; gap: 6px; padding: 10px 14px 0; }
#board-tabs button {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 9px;
  padding: 7px 0;
  font-family: var(--font-cond);
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
}
#board-tabs button:hover { color: var(--text); }
#board-tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
#board-tabs[hidden] { display: none; }

#board-buy { padding: 10px 14px 0; }
#board-buy[hidden] { display: none; }
#board-buy a {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ok);
  color: #04160b;
  font-size: 14px; font-weight: 700;
  padding: 10px;
  border-radius: 9px;
  text-decoration: none;
}
#board-buy a:hover { filter: brightness(1.08); }

#station-info { padding: 8px 14px 0; }
#station-info[hidden] { display: none; }
#station-info-toggle {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 9px;
  padding: 7px 0;
  font-family: var(--font-cond);
  font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
}
#station-info-toggle:hover { color: var(--text); }
#station-info-body {
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 10px 12px;
  margin-top: 6px;
  line-height: 1.5;
}
#station-info-body[hidden] { display: none; }
#station-info-body .via { line-height: 1.5; color: var(--muted); }
.fac-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 8px 0; }
.fac { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.fac .ic { color: var(--ok); }
.fac.no { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(142, 155, 180, 0.5); }
.fac.no .ic { color: var(--muted); }
.info-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.info-row .ic { color: var(--accent); margin-top: 2px; }

#fastest-form { padding: 10px 14px 0; }
#fastest-form[hidden] { display: none; }
#fastest-form input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}
#fastest-form input:focus { border-color: var(--accent); }

#board-messages { padding: 0 14px; }
#board-messages .msg {
  font-size: 12px; color: var(--warn);
  background: #2c1a08; border: 1px solid #50300f; border-radius: 8px;
  padding: 7px 9px; margin: 8px 0;
}

/* The board table itself: amber dot-matrix on black, like the platform */
#board-table {
  width: calc(100% - 20px);
  margin: 10px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--dm-bg);
  border: 1px solid #141c2c;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.95);
}
#board-table th {
  text-align: left;
  font-family: var(--font-cond);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: #8a7440;
  padding: 9px 7px 5px;
  border-bottom: 1px solid #1a1a12;
}
#board-table th:first-child, #board-table td:first-child { padding-left: 12px; }
#board-table td { padding: 8px 7px; border-bottom: 1px solid #10141d; vertical-align: top; color: #d8c49a; }
#board-table tr:last-child td { border-bottom: none; }
#board-table td:first-child, #board-table .dest, #board-table td:nth-child(3) {
  font-family: var(--font-dm);
  font-weight: 900;
  color: var(--dm);
  text-shadow: 0 0 5px var(--dm-glow);
  font-size: 15px;
  letter-spacing: 0.03em;
}
#board-table td:first-child .via { display: block; font-size: 10px; text-shadow: none; }
#board-table tr.linkable { cursor: pointer; }
#board-table tr.linkable:hover td { background: #0b1120; }
#board-table .via { font-family: var(--font); font-weight: 500; font-size: 11px; color: #8d8672; letter-spacing: 0; }
#board-table .ok { color: var(--ok); font-weight: 700; }
#board-table .late { color: var(--warn); font-weight: 700; }
#board-table .cancelled { color: var(--danger); font-weight: 800; }

.check { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; line-height: 1.25; text-align: center; font-family: var(--font); }
.check.match { background: #0a2716; color: var(--ok); }
.check.differs { background: #2e2108; color: var(--accent); }
.check.nomatch { background: var(--panel-2); color: var(--muted); }

#board-foot { padding: 0 14px 12px; font-size: 11px; color: var(--muted); }

/* Follow-train button in the timetable panel */
#board-actions { padding: 10px 14px 0; }
#board-actions[hidden] { display: none; }
#btn-follow {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 9px;
  padding: 9px 0;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
}
#btn-follow:hover { background: var(--panel-3); }
#btn-follow.following { background: var(--accent); color: var(--on-accent); }

/* Timetable progress states */
#board-table tr.tt-departed td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
#board-table tr.tt-at td { background: rgba(46, 227, 122, 0.1); }
#board-table tr.tt-at td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
#board-table tr.tt-next td { background: rgba(255, 182, 39, 0.07); }
#board-table tr.tt-next td:first-child { box-shadow: inset 3px 0 0 var(--dm); }
.tt-tag { font-family: var(--font-cond); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.tt-tag-at { color: var(--ok); }
.tt-tag-dep { color: var(--danger); }
.tt-tag-next { color: var(--dm); }

/* Server-rendered station description inside the board panel */
#station-blurb {
  padding: 10px 14px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
#station-blurb p { margin: 0 0 6px; }
#station-blurb[hidden] { display: none; }

/* ---------- Network Pulse panel ---------- */
#pulse-panel {
  position: absolute;
  top: 12px; left: 362px;   /* clear of the 300px sidebar + zoom controls */
  width: 360px;
  max-width: calc(100% - 374px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 1045;
}
#pulse-panel[hidden] { display: none; }
.pp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #05080f, #0a0f1b);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
.pp-title { font-family: var(--font-cond); font-weight: 700; font-size: 17px; letter-spacing: 0.08em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.pp-title .ic { color: var(--ok); }
.pp-score { display: flex; align-items: center; gap: 14px; padding: 14px; }
.pp-big {
  background: var(--dm-bg); border-radius: 10px; padding: 8px 14px;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.95); text-align: center;
}
.pp-big .dm { font-size: 34px; line-height: 1; display: block; }
.pp-big small { font-family: var(--font-dm); font-weight: 900; color: var(--dm); font-size: 11px; opacity: 0.8; }
.pp-verdict { font-family: var(--font-cond); font-size: 20px; font-weight: 700; }
.pp-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pp-league { list-style: none; padding: 0 14px 6px; }
.pp-league li {
  display: grid; grid-template-columns: 1fr 96px 40px; gap: 8px; align-items: center;
  padding: 5px 0; font-size: 13px; border-bottom: 1px solid #16213a; cursor: pointer;
}
.pp-league li:hover .pp-name { color: var(--accent); }
.pp-name { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-bar { height: 7px; border-radius: 4px; background: #1a2439; overflow: hidden; }
.pp-bar span { display: block; height: 100%; border-radius: 4px; }
.pp-pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pp-foot { padding: 10px 14px 14px; font-size: 12px; color: var(--muted); }
.pp-foot a { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: none; }
.toc-chip { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.lvl-good { color: var(--ok); } .bg-good { background: var(--ok); }
.lvl-fair { color: var(--dm); } .bg-fair { background: var(--dm); }
.lvl-poor, .lvl-bad { color: var(--danger); } .bg-poor, .bg-bad { background: var(--danger); }
.pp-close { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.pp-close:hover { color: var(--accent); }

/* ---------- First-visit intro card (the USP, in three lines) ---------- */
#intro-card {
  position: absolute;
  left: 312px; bottom: 80px;
  width: 360px;
  background: linear-gradient(160deg, #111b2e, #0b1220);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 1040;
  overflow: hidden;
}
#intro-card[hidden] { display: none; }
.intro-top { padding: 14px 16px 6px; }
.intro-top h2 { font-family: var(--font-cond); font-size: 22px; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.1; }
.intro-top p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.intro-list { list-style: none; padding: 4px 16px 10px; }
.intro-list li { display: flex; gap: 11px; padding: 7px 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.intro-list b { color: var(--text); display: block; font-size: 14px; }
.intro-ic {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--dm-bg); color: var(--dm); border: 1px solid #1a2336;
}
.intro-ic .ic { width: 19px; height: 19px; filter: drop-shadow(0 0 4px var(--dm-glow)); }
.intro-ic.g { color: var(--ok); } .intro-ic.g .ic { filter: drop-shadow(0 0 4px var(--ok)); }
.intro-ic.r { color: var(--route); } .intro-ic.r .ic { filter: drop-shadow(0 0 4px var(--route)); }
.intro-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.intro-actions button, .intro-actions a {
  flex: 1; text-align: center; border-radius: 999px; padding: 9px 12px;
  font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font);
}
#intro-ok { background: var(--accent); color: var(--on-accent); border: none; }
#intro-pulse { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

/* ---------- Active-filter chip ---------- */
#filter-chip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 940;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 70%;
  white-space: nowrap;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
#filter-chip[hidden] { display: none; }
#filter-chip-label { overflow: hidden; text-overflow: ellipsis; }
#filter-chip-clear {
  background: var(--panel-2);
  border: none;
  color: var(--text);
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
#filter-chip-clear:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- Map tool buttons (locate / find my train) ---------- */
#map-tools {
  position: absolute;
  right: 12px;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 940;
}
#map-tools button {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--accent);
  display: grid; place-items: center;
}
#map-tools button .ic { width: 22px; height: 22px; }
#map-tools button:hover { background: var(--panel-2); border-color: var(--accent); }
#map-tools button.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Affiliate CTA buttons ---------- */
.cta-btn {
  position: absolute;
  bottom: 28px;
  z-index: 940;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 17px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.cta-btn:hover { filter: brightness(1.08); }
#btn-railcard { left: 312px; background: var(--panel); color: var(--text); border: 1px solid var(--line); }
#btn-railcard .ic { color: var(--accent); }
#btn-railcard:hover { border-color: var(--accent); }
#btn-tickets { right: 72px; }

/* ---------- GPS-sharing consent / status bar ---------- */
#share-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 86px;
  z-index: 1150;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: min(92%, 560px);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
#share-bar[hidden] { display: none; }
#share-bar-btns { display: flex; gap: 8px; margin-left: auto; }
#share-bar button {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
#share-yes { background: var(--accent); color: var(--on-accent); }
#share-no { background: var(--panel-2); color: var(--text); }

#toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 1200;
  max-width: 80%;
  text-align: center;
}

#btn-list {
  display: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 5px 8px;
  cursor: pointer;
}
#btn-list .ic { width: 20px; height: 20px; display: block; }

.user-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--route);
  border: 3px solid #fff;
  box-shadow: 0 0 12px rgba(90, 209, 255, 0.9);
}

/* ---------- Site footer: required-page navigation on the map ---------- */
#sitefoot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 14px;
  padding: 6px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  z-index: 1000;
  flex: none;
}
#sitefoot nav { display: flex; flex-wrap: wrap; gap: 0 16px; }
#sitefoot nav a {
  color: var(--text); text-decoration: none; font-weight: 600;
  font-family: var(--font-cond); font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase;
}
#sitefoot nav a:hover { color: var(--accent); }
#sitefoot .foot-credit a { color: var(--accent); text-decoration: none; }

.noscript-station { max-width: 720px; margin: 20px auto; padding: 0 16px; line-height: 1.6; }
.noscript-station a { color: var(--accent); }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  #updated { display: none; }
  .brand-tag { display: none; }
}
@media (max-width: 900px) {
  #stats .nav-label { display: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  :root { --top-h: 52px; }
  #topbar { padding: 0 10px; gap: 8px; }
  .logo { width: 28px; height: 28px; }
  .brand-name, #brand h1 { font-size: 16px; letter-spacing: 0.03em; }
  #btn-list { display: block; }
  #nav-assist .nav-label { display: none; }
  #nav-assist { padding: 5px 8px; }
  #nav-blog, #nav-pulse { display: none; }  /* the Pulse chip + footer cover these */
  .brand-text { overflow: hidden; }
  .brand-name { overflow: hidden; text-overflow: ellipsis; }
  .dm-board { padding: 2px 8px; gap: 8px; }
  #train-count { font-size: 16px; }
  .dm-lbl { display: none; }
  #pulse-chip { font-size: 13px; padding-left: 8px; }
  #pulse-chip .pc-lbl { display: none; }
  #mode-badge { display: none; }

  /* Sidebar becomes a slide-in overlay toggled by the menu button */
  #sidebar {
    display: flex;
    position: fixed;
    top: var(--top-h); left: 0; bottom: 0;
    width: min(85vw, 320px);
    z-index: 1100;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.5);
  }
  #sidebar.open { transform: translateX(0); }

  /* Board and Pulse become bottom sheets */
  #board, #pulse-panel {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 64%;
    border-radius: 18px 18px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  #station-photo img { height: 130px; }

  #intro-card { left: 10px; right: 10px; width: auto; bottom: 78px; }
  .intro-list li:nth-child(3) { display: none; }

  #map-tools { bottom: 20px; right: 10px; }
  #map-tools button { width: 50px; height: 50px; }

  .cta-btn { bottom: 20px; font-size: 13px; padding: 9px 13px; }
  #btn-railcard { left: 10px; }
  #btn-tickets { right: 70px; }

  #sitefoot { font-size: 10px; padding: 4px 10px; }
  #sitefoot nav { gap: 0 12px; }
  #sitefoot nav a { font-size: 12px; }
  #sitefoot .foot-credit { display: none; }  /* nav stays; credit lives on /about/ */
}
@media (max-width: 400px) {
  .brand-name { font-size: 14px; letter-spacing: 0.01em; }
  #brand { gap: 7px; }
  .cta-btn { font-size: 12px; padding: 8px 11px; }
}
