/* ======================================================================
   ZUGPULS · "Nachtzug" Edition · v3 (dark departure-board redesign,
   2026-06-10)
   ----------------------------------------------------------------------
   Ground-up visual redesign of the v2 layout. The DOM and all class/ID
   hooks are unchanged (app.js untouched apart from chart colors); only
   the design language is new:

   · Dark "Anzeigetafel" aesthetic: deep blue-black surfaces, the hero
     board sits on an even darker inset panel like a station display.
   · Brand kept (cyan #00B4F0, coral #FF4757) but used as light sources:
     glows on dots, focus rings, active states – not as fills everywhere.
   · Type system: Barlow Condensed (signage display), Inter (UI),
     Spline Sans Mono (times, delays, platforms, line chips).
   · Delay tones re-tuned for dark backgrounds (emerald/amber/orange/red).
   · Fernverkehr chips invert to light-on-dark (white chip), Nahverkehr
     stays cyan – same semantics as v2, higher contrast.
   ====================================================================== */

:root {
  /* Type stack */
  --display: 'Barlow Condensed', 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans:    'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono:    'Spline Sans Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  /* legacy alias (kept so stray var(--serif) references can't break) */
  --serif:   var(--display);

  /* Night surfaces – page < chrome < cards; the board panel is darkest */
  --bg:         #0c1219;
  --board:      #080d13;
  --surface:    #121a24;
  --surface-2:  #182230;
  --chrome:     rgba(13, 19, 27, 0.88);

  --ink:        #e9f0f7;
  --ink-2:      #b9c6d4;
  --muted:      #8295a9;
  --dim:        #4b5d70;

  --hairline:    rgba(154, 183, 211, 0.16);
  --hairline-2:  rgba(154, 183, 211, 0.08);
  --hl:          rgba(154, 183, 211, 0.05);
  --hl-hover:    rgba(154, 183, 211, 0.09);

  /* Brand – locked hues, dark-tuned applications */
  --brand:       #00B4F0;
  --brand-hi:    #45ccff;            /* readable cyan text on dark */
  --brand-soft:  rgba(0, 180, 240, 0.12);
  --brand-line:  rgba(0, 180, 240, 0.38);
  --brand-glow:  rgba(0, 180, 240, 0.30);
  --accent:      #FF4757;
  --accent-hi:   #ff6b78;
  --accent-soft: rgba(255, 71, 87, 0.14);

  /* Signal palette (legible on near-black) */
  --good:        #2dd285;  --good-soft:   rgba(45, 210, 133, 0.13);
  --leicht:      #f2c84b;  --leicht-soft: rgba(242, 200, 75, 0.13);
  --warn:        #ff9f43;  --warn-soft:   rgba(255, 159, 67, 0.14);
  --bad:         #ff7a52;  --bad-soft:    rgba(255, 122, 82, 0.15);
  --crit:        #ff5d6b;  --crit-soft:   rgba(255, 93, 107, 0.15);
  --info:        #6aa9ff;  --info-soft:   rgba(106, 169, 255, 0.14);
  --early:       #6aa9ff;

  --radius-s:  8px;
  --radius:    12px;
  --radius-l:  18px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 22px rgba(0,0,0,0.40), 0 2px 6px rgba(0,0,0,0.30);
  --shadow-lg: 0 16px 44px rgba(0,0,0,0.50), 0 4px 14px rgba(0,0,0,0.35);

  --topbar-h: 84px;
  --drawer-h: 56px;            /* collapsed drawer strip */
  --footer-h: 28px;

  color-scheme: dark;
  accent-color: var(--brand);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background:
    radial-gradient(1100px 420px at 50% -180px, rgba(0, 180, 240, 0.075), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
a { color: var(--brand-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(0, 180, 240, 0.30); color: var(--ink); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* Slim dark scrollbars (the page is an app-like dashboard) */
* { scrollbar-width: thin; scrollbar-color: rgba(154,183,211,0.28) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: rgba(154,183,211,0.22); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(154,183,211,0.36); }
*::-webkit-scrollbar-track { background: transparent; }

/* ===== Loading veil ===== */
#loading-veil {
  position: fixed; inset: 0; z-index: 4000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease;
}
#loading-veil.is-hidden { opacity: 0; pointer-events: none; }
.veil-inner { text-align: center; }
.veil-inner h2 {
  font-family: var(--display); font-weight: 700; font-size: 34px;
  margin: 0 0 4px; letter-spacing: 1.5px; text-transform: uppercase;
}
.veil-inner p {
  margin: 0 0 16px; color: var(--muted);
  font-family: var(--mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: 2px;
}
.veil-bar {
  width: 180px; height: 3px; margin: 0 auto; border-radius: 2px;
  background: var(--surface-2); overflow: hidden; position: relative;
}
.veil-bar::after {
  content: ""; position: absolute; inset: 0 60% 0 0;
  background: var(--brand); border-radius: 2px;
  box-shadow: 0 0 12px var(--brand-glow);
  animation: veil-slide 1.1s ease-in-out infinite;
}
@keyframes veil-slide {
  0% { transform: translateX(-100%); } 100% { transform: translateX(260%); }
}

/* ===== Topbar ===== */
#topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 1200;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px;
  background: var(--chrome);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--hairline);
}
#brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
#brand .mark img { display: block; width: 74px; height: auto; }
#brand h1 {
  font-family: var(--display); font-weight: 700; font-size: 27px;
  margin: 0; letter-spacing: 1px; white-space: nowrap;
  text-transform: uppercase;
}
.brand-suffix { color: var(--accent-hi); }

/* KPI strip: no boxes – a ribbon of figures with hairline dividers,
   like the data row of a split-flap board */
#kpi-strip {
  display: flex; align-items: stretch;
  flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none;
}
#kpi-strip::-webkit-scrollbar { display: none; }
.kpi {
  flex: 0 0 auto;            /* never shrink below the label width */
  padding: 4px 18px; min-width: 92px;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  border-left: 1px solid var(--hairline-2);
}
.kpi:last-child { border-right: 1px solid var(--hairline-2); }
.kpi-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--muted); white-space: nowrap;
}
.kpi-value {
  font-family: var(--mono); font-size: 19px; font-weight: 500;
  white-space: nowrap; color: var(--ink);
}
/* Fernverkehr is marked with light chips (inverted ink, station-board
   convention), NOT coral/red – red tones are reserved for delay severity.
   The KPI value therefore stays in default ink. */

.topbar-actions { display: flex; align-items: center; }
#status-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 999px; box-shadow: var(--shadow-sm);
  padding: 8px 15px; cursor: default; white-space: nowrap;
}
#status-pill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dim); flex: none;
}
#status-pill .txt { font-weight: 600; font-size: 13px; }
#status-pill .last-update-wrap { color: var(--muted); font-size: 12px; font-family: var(--mono); }
#status-pill .sep { margin: 0 6px 0 0; }
#status-pill[data-tone="good"]   .dot { background: var(--good);   box-shadow: 0 0 9px var(--good); }
#status-pill[data-tone="leicht"] .dot { background: var(--leicht); box-shadow: 0 0 9px var(--leicht); }
#status-pill[data-tone="warn"]   .dot { background: var(--warn);   box-shadow: 0 0 9px var(--warn); }
#status-pill[data-tone="bad"]    .dot { background: var(--bad);    box-shadow: 0 0 9px var(--bad); }
#status-pill[data-tone="off"]    .dot { background: var(--crit);   box-shadow: 0 0 9px var(--crit); }

/* ===== Main layout: hero board + supplementary stations (scrolls) ===== */
#layout {
  position: absolute;
  inset: var(--topbar-h) 0 calc(var(--drawer-h) + var(--footer-h)) 0;
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex; flex-direction: column; gap: 20px;
}
/* children must not shrink – #layout scrolls instead (otherwise the hero
   collapses to its min-height and clips the board) */
#layout > * { flex-shrink: 0; }

/* ----- Hero board (Hauptbahnhof by default) ----- */
#hero {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-l); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  min-height: 320px;
  overflow: hidden;           /* board panel meets the rounded corners */
}
.board-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 16px 20px 12px;
}
.board-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.board-title h2 {
  font-family: var(--display); font-weight: 700; font-size: 32px; margin: 0;
  line-height: 1.1; letter-spacing: .5px; text-transform: uppercase;
}
.board-sub {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: 1.2px; text-transform: uppercase;
}
#backToHbf {
  display: inline-flex; align-items: center; gap: 5px;
  align-self: flex-start;
  border: 1px solid var(--brand-line); border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-hi);
  padding: 3px 11px 3px 8px; font-size: 12px; font-weight: 600; cursor: pointer;
  margin-bottom: 6px;
}
#backToHbf:hover { background: rgba(0, 180, 240, 0.20); }
#backToHbf[hidden] { display: none; }   /* author display beats the hidden attr otherwise */
#backToHbf svg { width: 12px; height: 12px; }

.board-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.board-toggle {
  display: flex; border: 1px solid var(--hairline); border-radius: 999px;
  overflow: hidden; background: var(--board); padding: 3px; gap: 2px;
}
.btab {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 999px;
  padding: 5px 16px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.btab:hover { color: var(--ink-2); }
.btab.is-active {
  background: var(--brand-soft); color: var(--brand-hi); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--brand-line);
}

/* The board itself: an inset display panel, darker than its frame.
   flex-basis must stay auto: with `flex: 1` (basis 0) the auto-height hero
   collapses to its min-height and clips the board on mobile */
#board-scroll {
  flex: 1 1 auto; overflow-y: auto; min-height: 0; max-height: 56vh;
  background: var(--board);
  border-top: 1px solid var(--hairline);
  box-shadow: inset 0 10px 18px -14px rgba(0,0,0,0.8);
}
.board { width: 100%; border-collapse: collapse; }
.board thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--board);
  text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.1px; color: var(--muted); font-weight: 600;
  padding: 8px 14px 6px; border-bottom: 1px solid var(--hairline);
}
.board tbody td {
  padding: 10px 14px; border-bottom: 1px solid var(--hairline-2);
  vertical-align: middle;
}
.board tbody tr:hover { background: var(--hl); }
.board tbody tr.has-details { cursor: pointer; }
/* Cancelled trains: the WHOLE row struck through */
.board tbody tr.is-cancelled { opacity: .50; }
.board tbody tr.is-cancelled td,
.board tbody tr.is-cancelled .line-chip,
.board tbody tr.is-cancelled .dest-via { text-decoration: line-through; }
.board tbody tr.is-cancelled .dest-tags { text-decoration: none; }
.c-time { width: 84px; white-space: nowrap; }
.c-live { width: 120px; white-space: nowrap; }
.c-line { width: 100px; }
.c-plat { width: 72px; text-align: right; }
.board thead .c-plat { text-align: right; }

.t-plan { font-family: var(--mono); font-weight: 500; font-size: 14.5px; color: var(--ink-2); }

/* Live column: actual time + pulsing status dot */
.live-wrap { display: inline-flex; align-items: center; gap: 7px; }
.t-live { font-family: var(--mono); font-weight: 600; font-size: 14.5px; }
.t-live[data-tone="good"]   { color: var(--good); }
.t-live[data-tone="leicht"] { color: var(--leicht); }
.t-live[data-tone="warn"]   { color: var(--warn); }
.t-live[data-tone="bad"]    { color: var(--crit); }
.live-none { color: var(--dim); font-family: var(--mono); }
.live-count {
  display: block; font-size: 10.5px; color: var(--muted);
  margin: 1px 0 0 16px;   /* aligns under the time, past the dot */
  white-space: nowrap;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--dim);
  animation: live-pulse 2s ease-in-out infinite;
}
.live-dot[data-tone="good"]   { background: var(--good);   box-shadow: 0 0 8px var(--good); }
.live-dot[data-tone="leicht"] { background: var(--leicht); box-shadow: 0 0 8px var(--leicht); }
.live-dot[data-tone="warn"]   { background: var(--warn);   box-shadow: 0 0 8px var(--warn); }
.live-dot[data-tone="bad"]    { background: var(--crit);   box-shadow: 0 0 8px var(--crit); }
@keyframes live-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(0.72); opacity: .55; }
}

/* Boarding indicator – IDENTICAL mechanics to the BusPuls flight-board one:
   two stacked circles fill sequentially on a 1.6 s loop. Both dots run the
   same step-end keyframes; the bottom is offset by half a cycle so they are
   always in opposite states (one filled, one hollow) – an instant switch,
   no gradual fade. Green = var(--good) (45,210,133). */
.boarding { display: inline-flex; align-items: center; gap: 8px; }
.boarding-lbl { font-size: 12px; font-weight: 600; color: var(--good); }
.dep-status-boarding {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex-shrink: 0; width: 10px; height: 14px;
}
.board-dot {
  width: 6px; height: 6px; border-radius: 50%;
  border: 1.5px solid var(--good);
  background: rgba(45, 210, 133, 0);   /* hollow by default */
}
.board-dot-top {
  background: rgba(45, 210, 133, 1);   /* starts filled */
  animation: dep-board-switch 1.6s step-end infinite;
}
.board-dot-bottom {
  background: rgba(45, 210, 133, 0);   /* starts hollow */
  animation: dep-board-switch 1.6s step-end infinite;
  animation-delay: -0.8s;              /* half-cycle offset = always opposite */
}
@keyframes dep-board-switch {
  0%, 100% { background: rgba(45, 210, 133, 1); }   /* filled  */
  50%      { background: rgba(45, 210, 133, 0); }   /* hollow  */
}

/* Departed trains roll off the board: accelerating to the right (direction
   of travel) with a slight lean and motion blur – arrivals leave to the
   left. The row is removed on transitionend; the list closing up is the
   normal reflow. */
.board tbody tr.roll-away,
.board tbody tr.roll-away-left {
  transition: transform 1.6s cubic-bezier(.55, 0, .95, .55), opacity 1.3s ease-in;
  will-change: transform, opacity;
}
.board tbody tr.roll-away {
  transform: translateX(112%) skewX(-5deg);
  opacity: 0;
  filter: blur(1.5px);
}
.board tbody tr.roll-away-left {
  transform: translateX(-112%) skewX(5deg);
  opacity: 0;
  filter: blur(1.5px);
}

/* Two separate board tables: Fernverkehr (light/inverted) / Nahverkehr
   (brand cyan) – signage badges in the display face */
.board-section { margin-bottom: 6px; }
.board-section:last-of-type { margin-bottom: 0; }
.bsec-title {
  font-family: var(--display); font-weight: 600; font-size: 13.5px;
  text-transform: uppercase; letter-spacing: 2.5px;
  margin: 14px 14px 6px; padding: 3px 12px;
  border-radius: 6px; display: inline-block;
}
.bsec-title[hidden] { display: none; }
.bsec-fern  { background: var(--ink); color: var(--board); }
.bsec-regio { background: var(--brand-soft); color: var(--brand-hi); box-shadow: inset 0 0 0 1px var(--brand-line); }

.line-chip {
  display: inline-block; font-family: var(--mono); font-size: 12px;
  font-weight: 600; padding: 2px 8px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand-hi);
  border: 1px solid var(--brand-line); white-space: nowrap;
}
/* Long-distance: inverted light chip (station-board convention) – NOT
   red/coral, those tones mean "delayed" in this UI */
.line-chip.is-fern {
  background: var(--ink); color: var(--board); border-color: var(--ink);
}

.dest-head { display: flex; align-items: center; gap: 7px; }
.dest-main { font-weight: 500; }
.detail-hint {
  border: 0; background: transparent; color: var(--dim); cursor: pointer;
  padding: 0 2px; line-height: 1; display: inline-flex;
}
.detail-hint svg { width: 13px; height: 13px; }
tr:hover .detail-hint { color: var(--brand-hi); }
.board tbody tr.detail-row td {
  padding: 0 14px 10px; border-bottom: 1px solid var(--hairline-2);
  background: var(--surface);
}
.board tbody tr.detail-row:hover { background: var(--surface); }
.detail-inner { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 8px; }
.dest-via {
  font-size: 11.5px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch;
}
.dest-tags { margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  display: inline-block;   /* atomic inline: exempt from the cancelled-row strikethrough */
  font-size: 10.5px; padding: 1.5px 8px; border-radius: 5px; font-weight: 600;
  letter-spacing: .3px;
}
.tag-cancel { background: var(--crit-soft); color: var(--crit); box-shadow: inset 0 0 0 1px rgba(255, 93, 107, 0.35); }
.tag-plat   { background: var(--info-soft); color: var(--info); box-shadow: inset 0 0 0 1px rgba(106, 169, 255, 0.35); }
.tag-cause  { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px rgba(255, 159, 67, 0.35); }
.tag-added  { background: var(--good-soft); color: var(--good); box-shadow: inset 0 0 0 1px rgba(45, 210, 133, 0.35); }
.tag-info   { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--hairline-2); font-weight: 500; }

.plat-val { font-family: var(--mono); font-weight: 500; }
.plat-val.is-changed { color: var(--info); font-weight: 600; }
.plat-old { text-decoration: line-through; color: var(--dim); margin-right: 5px; font-family: var(--mono); }

#boardEmpty { color: var(--muted); text-align: center; padding: 32px 0; }

/* ----- Supplementary station cards ----- */
.strip-title {
  font-family: var(--display); font-weight: 600; font-size: 19px;
  letter-spacing: 1.5px; text-transform: uppercase;
  margin: 2px 2px 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.strip-title::before {
  content: ""; align-self: center;
  width: 5px; height: 17px; border-radius: 2px;
  background: var(--brand); box-shadow: 0 0 10px var(--brand-glow);
}
.strip-note {
  font-family: var(--sans); font-weight: 400; font-size: 12px;
  color: var(--muted); letter-spacing: 0; text-transform: none;
}
#stationCards {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.stn-card {
  text-align: left;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: var(--ink);
  padding: 12px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.stn-card:hover {
  border-color: var(--brand-line); transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--brand-soft);
}
.stn-card.is-active {
  border-color: var(--brand-line);
  background: linear-gradient(180deg, var(--brand-soft), var(--surface) 70%);
}
.stn-card-head { display: flex; align-items: center; gap: 8px; }
.stn-card-head .sdot { width: 8px; height: 8px; }
.stn-card-name {
  font-family: var(--display); font-weight: 600; font-size: 16.5px;
  letter-spacing: .6px; flex: 1;
}
.stn-card-meta { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.stn-card-deps { display: flex; flex-direction: column; gap: 4px; }
.mini-dep {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  color: var(--ink-2); min-width: 0;
}
.mini-dep .mt { font-family: var(--mono); font-weight: 500; flex: none; }
.mini-dep .mt[data-tone="leicht"] { color: var(--leicht); }
.mini-dep .mt[data-tone="warn"]   { color: var(--warn); }
.mini-dep .mt[data-tone="bad"]    { color: var(--crit); }
.mini-dep .ml {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; flex: none;
  color: var(--brand-hi);
}
.mini-dep .ml.is-fern { color: var(--ink); }
.mini-dep .md { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-dep.is-cancelled { text-decoration: line-through; opacity: .55; }
.mini-empty { font-size: 12px; color: var(--muted); }

/* ===== Drawer ===== */
#drawer-toggle {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--drawer-h) + var(--footer-h) - 14px);
  z-index: 1310;
  width: 44px; height: 28px; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--surface-2);
  box-shadow: var(--shadow-md); color: var(--ink-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: bottom .35s cubic-bezier(.2,.7,.2,1), border-color .15s ease;
}
#drawer-toggle:hover { border-color: var(--brand-line); color: var(--brand-hi); }
#drawer-toggle .chevron { width: 16px; height: 16px; transform: rotate(180deg); transition: transform .3s; }
body.drawer-open #drawer-toggle .chevron { transform: rotate(0deg); }
body.drawer-open #drawer-toggle { bottom: calc(min(46vh, 480px) + var(--footer-h) - 14px); }

#drawer {
  position: fixed; left: 0; right: 0; bottom: var(--footer-h); z-index: 1300;
  height: var(--drawer-h);
  background: var(--chrome);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -10px 32px rgba(0,0,0,0.45);
  overflow: hidden;
  transition: height .35s cubic-bezier(.2,.7,.2,1);
}
body.drawer-open #drawer { height: min(46vh, 480px); }
#drawer-inner { height: 100%; overflow-y: auto; padding: 10px 20px 20px; }

.drawer-banner {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-bottom: 8px;
}
.drawer-title { display: flex; flex-direction: column; min-width: 150px; }
.title-eyebrow {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted); font-weight: 600;
}
.title-main {
  font-family: var(--display); font-weight: 600; font-size: 19px;
  letter-spacing: .8px; text-transform: uppercase;
}
.drawer-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.dtab {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.dtab:hover { background: var(--hl-hover); color: var(--ink-2); }
.dtab.is-active {
  background: var(--brand-soft); color: var(--brand-hi);
  border-color: var(--brand-line); font-weight: 600;
}

.drawer-pane { display: none; }
.drawer-pane.is-active { display: block; }

.drawer-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.drawer-card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 13px 15px;
}
.drawer-card h3 {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--display); font-size: 15.5px; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase;
  margin: 0 0 10px;
}
.drawer-card h3 .accent {
  width: 4px; height: 15px; border-radius: 2px;
  background: var(--brand); box-shadow: 0 0 8px var(--brand-glow); flex: none;
}
.h3-meta {
  font-family: var(--sans); font-weight: 400; font-size: 11.5px;
  color: var(--muted); margin-left: auto;
  letter-spacing: 0; text-transform: none;
}
.card-note { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; }

.rowlist { display: flex; flex-direction: column; }
.rowlist .row {
  display: flex; align-items: center; gap: 10px;
  padding: 6.5px 2px; border-bottom: 1px solid var(--hairline-2);
  font-size: 13px;
}
.rowlist .row:last-child { border-bottom: 0; }
.rowlist .row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.rowlist .row .num { font-family: var(--mono); font-weight: 500; white-space: nowrap; }
.rowlist .row .num[data-tone="good"]   { color: var(--good); }
.rowlist .row .num[data-tone="leicht"] { color: var(--leicht); }
.rowlist .row .num[data-tone="warn"]   { color: var(--warn); }
.rowlist .row .num[data-tone="bad"]    { color: var(--crit); }
.rowlist .empty { color: var(--muted); padding: 10px 2px; font-size: 12.5px; }
.seg-label { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--ink); }
.seg-swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--brand); box-shadow: 0 0 7px var(--brand-glow); flex: none; }
.seg-swatch.is-fern { background: var(--ink); box-shadow: none; }
.sdot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none;
}
.sdot[data-tone="good"]   { background: var(--good);   box-shadow: 0 0 7px var(--good); }
.sdot[data-tone="leicht"] { background: var(--leicht); box-shadow: 0 0 7px var(--leicht); }
.sdot[data-tone="warn"]   { background: var(--warn);   box-shadow: 0 0 7px var(--warn); }
.sdot[data-tone="bad"]    { background: var(--crit);   box-shadow: 0 0 7px var(--crit); }

/* History charts */
.hist-charts {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.hist-chart-card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 12px 14px; height: 240px; position: relative;
}
.hist-chart-card h4 {
  margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.hist-chart-card .chart-wrap { position: absolute; inset: 36px 12px 10px; }
.charts-note { color: var(--muted); font-size: 12.5px; padding: 14px 2px; }

/* Stats tables (Linien / Stationen) */
.stats-controls { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.period-btn {
  border: 1px solid var(--hairline); background: var(--surface);
  border-radius: 999px; padding: 4px 13px; font-size: 12px; cursor: pointer;
  color: var(--muted);
}
.period-btn:hover { color: var(--ink-2); border-color: var(--hairline); background: var(--surface-2); }
.period-btn.is-active {
  background: var(--brand-soft); border-color: var(--brand-line);
  color: var(--brand-hi); font-weight: 600;
}
.stats-table-wrap { overflow-x: auto; }
table.stats {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
table.stats th, table.stats td { padding: 7px 12px; text-align: right; font-size: 13px; }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats thead th {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); border-bottom: 1px solid var(--hairline);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.stats tbody tr { border-bottom: 1px solid var(--hairline-2); }
table.stats tbody tr:hover { background: var(--hl); }
table.stats td.mono { font-family: var(--mono); }
.stats-meta { color: var(--muted); font-size: 11.5px; margin-top: 8px; }

/* ===== Footer ===== */
#site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--footer-h);
  z-index: 1320;
  background: var(--board); border-top: 1px solid var(--hairline);
  display: flex; align-items: center; padding: 0 14px;
  font-size: 11.5px; color: var(--muted);
}
.footer-row { display: flex; align-items: center; gap: 7px; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
#site-footer .sep { color: var(--dim); }
#site-footer .heart { color: var(--accent-hi); }
#site-footer .muted-note { color: var(--dim); overflow: hidden; text-overflow: ellipsis; }

/* ======================================================================
   Mobile ≤ 720 px
   ====================================================================== */
@media (max-width: 720px) {
  :root { --topbar-h: 110px; }

  #topbar { flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px; height: var(--topbar-h); align-content: center; }
  #brand { gap: 8px; }
  #brand .mark img { width: 44px; }
  #brand h1 { font-size: 19px; }
  .topbar-actions { margin-left: auto; min-width: 0; }
  #status-pill { padding: 5px 10px; min-width: 0; }
  #status-pill .txt { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  #status-pill .last-update-wrap { display: none; }
  #kpi-strip { order: 3; flex-basis: 100%; }
  .kpi { min-width: 80px; padding: 3px 12px; }
  .kpi-value { font-size: 15px; }

  #layout { padding: 10px 12px 18px; gap: 14px; }
  .board-head { padding: 13px 14px 9px; }
  .board-title h2 { font-size: 25px; }
  .board-controls { width: 100%; justify-content: space-between; gap: 6px; }
  .sftab, .btab { padding: 4px 12px; font-size: 12px; }
  #board-scroll { max-height: none; }
  .board thead th, .board tbody td { padding-left: 9px; padding-right: 9px; }
  .c-time { width: 56px; }
  .c-live { width: 92px; }
  .c-line { width: 72px; }
  .c-plat { width: 46px; }
  .dest-via { max-width: 34ch; }
  .boarding-lbl { display: none; }   /* dots alone carry it on narrow screens */

  #stationCards { grid-template-columns: 1fr 1fr; }

  body.drawer-open #drawer { height: min(72vh, 560px); }
  body.drawer-open #drawer-toggle { bottom: calc(min(72vh, 560px) + var(--footer-h) - 14px); }

  #site-footer { font-size: 10.5px; }
  #site-footer .muted-note { display: none; }
}

@media (max-width: 460px) {
  #stationCards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #drawer, #drawer-toggle, .stn-card { transition: none !important; }
  .live-dot, .board-dot { animation: none !important; }
  .board-dot { background: rgba(45, 210, 133, 1); }   /* both filled when static */
  .board tbody tr.roll-away,
  .board tbody tr.roll-away-left { transition: none !important; opacity: 0; }
}
