:root {
  --ink: #f4ecdd;
  --ink-2: #c9bba3;
  --ink-3: #8f826e;
  --panel: rgba(20, 17, 14, 0.66);
  --panel-solid: #16130f;
  --line: rgba(255, 214, 150, 0.14);
  --line-2: rgba(255, 214, 150, 0.28);
  --amber: #ffb547;
  --amber-2: #ffd28a;
  --wb: #7cc544;
  --oebb: #ef3b4f;
  --radius: 14px;
  --gutter: 20px;
  --font: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: #14110e; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { overflow-x: hidden; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-feature-settings: 'zero' 0, 'tnum' 1; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; display: block; z-index: 0; touch-action: pan-y; }
body.live #gl { touch-action: none; }
.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(20, 12, 4, 0.38) 100%),
    linear-gradient(180deg, rgba(20, 14, 8, 0.25), transparent 18%, transparent 80%, rgba(20, 14, 8, 0.35)); }

/* ---------------------------------------------------------------- Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(1.25);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 236, 200, 0.06);
}
.hud { position: fixed; z-index: 10; transition: opacity 0.5s, transform 0.5s; }
body.loading .hud, body.loading #story, body.loading .credits { opacity: 0; pointer-events: none; }

.hud-tl { top: var(--gutter); left: var(--gutter); padding: 12px 16px 12px; min-width: 216px; }
.hud-row { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: 0.12em; color: var(--ink-2); }
.hud-sep { width: 1px; height: 11px; background: var(--line-2); display: inline-block; }
.hud-clock { font-size: 34px; font-weight: 500; letter-spacing: -0.01em; color: var(--amber); line-height: 1.05; margin: 6px 0 8px; text-shadow: 0 0 24px rgba(255, 181, 71, 0.25); }
.hud-clock small { font-size: 18px; color: var(--amber-2); opacity: 0.7; }
.hud-counts { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--ink-2); }
.hud-counts b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); box-shadow: 0 0 0 0 rgba(124, 197, 68, 0.6); }
.live-dot.on { background: var(--wb); animation: ping 2s infinite; }
.live-dot.warn { background: var(--amber); }
.live-dot.off { background: var(--oebb); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(124, 197, 68, 0.55); } 80%, 100% { box-shadow: 0 0 0 9px rgba(124, 197, 68, 0); } }

.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; flex: none; }
.sw.wb { background: var(--wb); }
.sw.oebb { background: transparent; border: 2px dashed var(--oebb); }
.sw.pulse { animation: ping 2s infinite; }

.hud-tc { top: var(--gutter); left: 50%; transform: translateX(-50%); padding: 9px 16px; display: flex; gap: 12px; align-items: center; font-size: 11px; letter-spacing: 0.16em; color: var(--ink-2); white-space: nowrap; }
.hud-tc span:first-child { color: var(--amber); font-weight: 700; }

/* ---------------------------------------------------------------- Toolbar */
.toolbar { top: var(--gutter); right: var(--gutter); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.tb { appearance: none; background: transparent; border: 0; border-radius: 10px; width: 62px; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; color: var(--ink-2); transition: background 0.2s, color 0.2s; }
.tb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tb span { font-size: 10px; letter-spacing: 0.04em; font-family: var(--mono); }
.tb:hover { background: rgba(255, 214, 150, 0.08); color: var(--ink); }
.tb[aria-pressed='true'] { color: var(--amber); background: rgba(255, 181, 71, 0.12); }
.tb:focus-visible, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
body.story #btnStory { display: none; }
body.live #btnMode { display: none; }

/* ---------------------------------------------------------------- Legende */
.legend { left: var(--gutter); bottom: calc(var(--gutter) + 92px); padding: 12px 14px; max-width: 300px; font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.lg-row { display: flex; gap: 8px; align-items: flex-start; line-height: 1.35; }
.lg-row .sw { margin-top: 4px; }
.lg-row small { display: block; color: var(--ink-3); font-size: 11px; }
.lg-status { font-size: 10px; color: var(--ink-3); letter-spacing: 0.04em; border-top: 1px solid var(--line); padding-top: 7px; }
.lg-status .ok { color: var(--wb); }
.lg-credits { font-size: 9.5px; color: var(--ink-3); line-height: 1.4; opacity: 0.8; }
.lg-status .bad { color: var(--oebb); }
body.story .legend { opacity: 0; pointer-events: none; transform: translateY(8px); }
body.story.show-legend .legend { opacity: 1; pointer-events: auto; transform: none; }

/* ---------------------------------------------------------------- Zugkarte */
.traincard { right: var(--gutter); bottom: calc(var(--gutter) + 92px); width: 320px; padding: 14px 16px 14px; }
.traincard[hidden] { display: none; }
.tc-close { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--ink-3); font-size: 20px; cursor: pointer; line-height: 1; padding: 4px; }
.tc-head { display: flex; align-items: center; gap: 10px; }
.tc-badge { font-size: 10px; letter-spacing: 0.1em; padding: 3px 7px; border-radius: 6px; font-weight: 700; }
.tc-badge.gps { background: rgba(124, 197, 68, 0.16); color: var(--wb); border: 1px solid rgba(124, 197, 68, 0.4); }
.tc-badge.tt { background: rgba(239, 59, 79, 0.12); color: #ff8592; border: 1px dashed rgba(239, 59, 79, 0.55); }
.tc-name { font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.tc-dir { color: var(--ink-2); font-size: 13px; margin: 2px 0 10px; }
.tc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 13px; }
.tc-grid small { display: block; font-size: 9.5px; letter-spacing: 0.12em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 1px; }
.tc-grid b { font-weight: 500; color: var(--ink); }
.tc-grid b.late { color: #ff9f6b; }
.tc-grid b.ontime { color: var(--wb); }
.tc-src { margin-top: 10px; font-size: 11px; color: var(--ink-3); line-height: 1.4; }
.tc-cams { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 12px; }
.tc-cams button { appearance: none; border: 1px solid var(--line); background: rgba(255, 214, 150, 0.05); color: var(--ink-2); border-radius: 9px; padding: 7px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.tc-cams button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tc-cams button span { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.02em; }
.tc-cams button:hover { color: var(--ink); background: rgba(255, 214, 150, 0.1); }
.tc-cams button[aria-pressed='true'] { background: var(--amber); color: #1a1208; border-color: var(--amber); }
.tc-follow { margin-top: 10px; width: 100%; padding: 8px; background: rgba(255, 181, 71, 0.1); border: 1px solid var(--line-2); border-radius: 9px; color: var(--amber); font-size: 11px; letter-spacing: 0.1em; cursor: pointer; }
.tc-follow[aria-pressed='true'] { background: var(--amber); color: #1a1208; }

/* ---------------------------------------------------------------- Zugliste */
.trainlist { right: calc(var(--gutter) + 86px); top: var(--gutter); width: 300px; max-height: min(52vh, 460px); padding: 10px 6px 8px; display: flex; flex-direction: column; }
body.story .trainlist { opacity: 0; pointer-events: none; transform: translateX(10px); }
.tl-head { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.16em; color: var(--ink-3); padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.tl-head span:last-child { color: var(--amber); }
#tlItems { list-style: none; margin: 0; padding: 4px 0 0; overflow-y: auto; scrollbar-width: thin; }
#tlItems li { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 7px 10px; border-radius: 9px; cursor: pointer; align-items: center; }
#tlItems li:hover, #tlItems li.sel { background: rgba(255, 214, 150, 0.08); }
#tlItems li.sel { box-shadow: inset 2px 0 0 var(--amber); }
#tlItems .n { font-weight: 600; font-size: 13px; }
#tlItems .d { grid-column: 2 / 4; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tlItems .x { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
#tlItems .x.late { color: #ff9f6b; }
#tlItems .grp { display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; color: var(--ink-3); padding: 9px 10px 3px; cursor: default; }
.tl-empty { font-size: 12px; color: var(--ink-3); padding: 10px; line-height: 1.4; }
.tl-empty[hidden] { display: none; }

/* ---------------------------------------------------------------- Höhenprofil */
.profile { left: 50%; transform: translateX(-50%); bottom: var(--gutter); width: min(1100px, calc(100vw - 2 * var(--gutter))); height: 76px; padding: 0; overflow: hidden; }
#profileSvg { position: absolute; inset: 0 0 18px 0; width: 100%; height: calc(100% - 18px); cursor: pointer; }
.pf-ticker { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; border-top: 1px solid var(--line); font-size: 10px; letter-spacing: 0.12em; color: var(--ink-2); padding: 3px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-ticker b { color: var(--amber); font-weight: 500; }

/* ---------------------------------------------------------------- Labels */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; transform: translate3d(-9999px, 0, 0); white-space: nowrap; font-size: 11px; line-height: 1; will-change: transform, opacity; transition: opacity 0.35s; }
.lbl .t { display: inline-block; padding: 4px 7px; border-radius: 6px; background: rgba(20, 16, 12, 0.72); border: 1px solid rgba(255, 214, 150, 0.16); color: var(--ink); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lbl::after { content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 10px; background: linear-gradient(rgba(255, 214, 150, 0.5), transparent); }
.lbl.place .t { background: none; border: 0; padding: 0; font-family: var(--serif); font-weight: 600; font-size: 14px; color: #fff8ea; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), 0 0 14px rgba(0, 0, 0, 0.45); backdrop-filter: none; }
.lbl.place.city .t { font-size: 20px; letter-spacing: 0.02em; }
.lbl.place.village .t { font-size: 11.5px; font-family: var(--font); font-weight: 500; }
.lbl.place::after, .lbl.peak::after { display: none; }
.lbl.peak .t { background: none; border: 0; color: #fff4e2; font-family: var(--mono); font-size: 10px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); backdrop-filter: none; }
.lbl.peak .t::before { content: '▲ '; color: var(--amber-2); }
.lbl.station .t { font-family: var(--mono); font-size: 10.5px; color: var(--amber); letter-spacing: 0.04em; }
.lbl.station .t::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--amber); margin-right: 6px; vertical-align: 0; }
.lbl.struct .t { font-family: var(--mono); font-size: 10px; color: var(--ink-2); background: rgba(20, 16, 12, 0.55); }
.lbl.struct .t em { font-style: normal; color: var(--amber-2); margin-left: 6px; }
.lbl.train { pointer-events: auto; cursor: pointer; z-index: 2; }
.lbl.train .t { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: #fff; display: inline-flex; align-items: center; gap: 6px; }
.lbl.train.wb .t { border-color: rgba(124, 197, 68, 0.55); }
.lbl.train.oebb .t { border-style: dashed; border-color: rgba(239, 59, 79, 0.6); }
.lbl.train .t i { width: 7px; height: 7px; border-radius: 50%; }
.lbl.train.wb .t i { background: var(--wb); box-shadow: 0 0 0 0 rgba(124, 197, 68, 0.6); animation: ping 2s infinite; }
.lbl.train.oebb .t i { border: 1.5px dashed var(--oebb); }
.lbl.train .t small { font-weight: 400; color: var(--ink-2); font-size: 9.5px; }
.lbl.train.sel .t { background: var(--amber); color: #1a1208; border-color: var(--amber); }
.lbl.train.sel .t small { color: #3a2a10; }
.lbl.train.tunnel .t { opacity: 0.85; }
body.nolabels .lbl:not(.train), body.hero-on .lbl { opacity: 0 !important; }

/* ---------------------------------------------------------------- Story */
#story { position: relative; z-index: 6; pointer-events: none; transition: opacity 0.6s; }
body.live #story { opacity: 0; visibility: hidden; height: 0; overflow: hidden; }
.ch { min-height: 120vh; position: relative; display: flex; align-items: flex-start; padding: 0 var(--gutter); }
.ch.tall { min-height: 170vh; }
.card { pointer-events: auto; position: sticky; top: 26vh; margin-top: 26vh; margin-left: max(0px, calc(50vw - 640px)); width: min(430px, 100%); padding: 22px 24px 20px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(24, 20, 16, 0.78), rgba(18, 15, 12, 0.72));
  border: 1px solid var(--line); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s cubic-bezier(.2,.7,.2,1); }
.card.on { opacity: 1; transform: none; }
.card.wide { width: min(560px, 100%); }
.kicker { font-size: 10.5px; letter-spacing: 0.16em; color: var(--ink-3); display: flex; gap: 10px; align-items: center; }
.kicker span { color: var(--amber); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 5px; }
.card h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3vw, 34px); line-height: 1.08; letter-spacing: -0.015em; margin: 12px 0 10px; }
.card p { font-size: 15px; line-height: 1.6; color: #e6dccb; margin: 0 0 12px; }
.card p.note { font-size: 11px; color: var(--amber-2); letter-spacing: 0.04em; margin: 10px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips span { font-size: 10.5px; padding: 4px 8px; border-radius: 7px; background: rgba(255, 214, 150, 0.07); border: 1px solid var(--line); color: var(--ink-2); }

.hero { min-height: 100vh; align-items: center; justify-content: center; text-align: center; }
.hero-inner { pointer-events: auto; max-width: 860px; padding-top: 4vh; }
.eyebrow { font-size: 11px; letter-spacing: 0.22em; color: var(--amber-2); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.hero h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(64px, 13vw, 168px); line-height: 0.92; letter-spacing: -0.035em; margin: 16px 0 18px; color: #fff7e8;
  text-shadow: 0 2px 2px rgba(60, 30, 0, 0.25), 0 18px 60px rgba(40, 18, 0, 0.45); }
.hero h1 span { font-style: italic; font-weight: 500; color: var(--amber); }
.lead { font-size: clamp(16px, 1.6vw, 20px); line-height: 1.55; color: #fff3df; max-width: 620px; margin: 0 auto 26px; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55); }
.stats { display: inline-grid; grid-template-columns: repeat(4, auto); gap: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); overflow: hidden; }
.stats div { padding: 12px 22px; border-left: 1px solid var(--line); text-align: left; }
.stats div:first-child { border-left: 0; }
.stats b { display: block; font-size: 26px; font-weight: 500; color: var(--amber); }
.stats small { font-size: 10px; letter-spacing: 0.12em; color: var(--ink-3); text-transform: uppercase; }
.hero-cta { margin-top: 30px; display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; }
.scroll-hint { font-size: 11px; letter-spacing: 0.16em; color: #fff0d6; display: inline-flex; align-items: center; gap: 10px; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.scroll-hint i { width: 18px; height: 28px; border: 1.5px solid rgba(255, 240, 214, 0.7); border-radius: 10px; position: relative; }
.scroll-hint i::after { content: ''; position: absolute; left: 50%; top: 5px; width: 2px; height: 6px; margin-left: -1px; border-radius: 1px; background: var(--amber); animation: wheel 1.8s infinite; }
@keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(9px); opacity: 0; } 100% { opacity: 0; } }
.btn-live { appearance: none; border: 1px solid var(--line-2); background: rgba(20, 16, 12, 0.6); color: var(--amber); padding: 10px 16px; border-radius: 11px; font-size: 11.5px; letter-spacing: 0.08em; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background 0.2s, color 0.2s, transform 0.2s; }
.btn-live:hover { background: var(--amber); color: #1a1208; transform: translateY(-1px); }
.btn-live.big { margin-top: 14px; padding: 13px 20px; font-size: 12px; }
.srcs { display: grid; gap: 10px; margin: 12px 0 4px; }
.src { display: flex; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 214, 150, 0.04); }
.src .sw { margin-top: 5px; }
.src b { display: block; font-size: 14px; margin-bottom: 3px; }
.src span { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.live-intro { min-height: 140vh; }

.credits { position: fixed; z-index: 4; left: 50%; transform: translateX(-50%); bottom: 4px; font-size: 9px; color: rgba(244, 236, 221, 0.45); letter-spacing: 0.04em; white-space: nowrap; pointer-events: none; }
body:not(.live) .credits { display: none; }

/* ---------------------------------------------------------------- Loader */
#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(80% 70% at 50% 45%, #2a1f14, #120f0c 70%); transition: opacity 0.9s ease, visibility 0.9s; }
body:not(.loading) #loader { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; width: min(340px, 80vw); }
.loader-mark { color: var(--amber); width: 120px; margin: 0 auto 14px; }
.loader-mark svg { width: 100%; overflow: visible; }
.loader-mark path:first-child { stroke-dasharray: 220; stroke-dashoffset: 220; animation: draw 2.4s ease-in-out infinite alternate; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.loader-title { font-family: var(--serif); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.loader-step { font-size: 11px; color: var(--ink-3); margin: 10px 0 14px; letter-spacing: 0.06em; min-height: 1.4em; }
.loader-bar { height: 2px; background: rgba(255, 214, 150, 0.12); border-radius: 2px; overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.3s; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 980px) {
  .hud-tc { display: none; }
  .trainlist { right: var(--gutter); top: auto; bottom: calc(var(--gutter) + 92px); width: min(300px, calc(100vw - 2 * var(--gutter))); max-height: 34vh; }
  body.has-card .trainlist { display: none; }
}
@media (max-width: 760px) {
  :root { --gutter: 12px; }
  .hud-tl { padding: 9px 12px; min-width: 0; }
  .hud-clock { font-size: 24px; margin: 3px 0 5px; }
  .hud-clock small { font-size: 13px; }
  .hud-counts { font-size: 10px; }
  .toolbar { flex-direction: row; top: var(--gutter); right: var(--gutter); padding: 4px; }
  .tb { width: 44px; padding: 7px 2px 5px; }
  .tb span { display: none; }
  #btnLabels, #btnHome { display: none; }
  .ch { padding: 0 var(--gutter); }
  .card { position: sticky; top: max(40svh, calc(100svh - 470px)); margin: 0; margin-top: 46svh; padding: 15px 15px 13px; width: 100%; }
  .card .chips span:nth-child(n+3) { display: none; }
  .card p.note { display: none; }
  .card h2 { font-size: 24px; margin: 8px 0 6px; }
  .card p { font-size: 13.5px; line-height: 1.48; margin-bottom: 8px; }
  .stats { grid-template-columns: repeat(2, auto); }
  .stats div:nth-child(3) { border-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stats div { padding: 10px 16px; }
  .stats b { font-size: 21px; }
  .hero-inner { padding-top: 10vh; }
  .eyebrow { font-size: 9.5px; letter-spacing: 0.12em; }
  .profile { height: 58px; }
  .pf-ticker { font-size: 9px; }
  .legend { bottom: calc(var(--gutter) + 70px); right: var(--gutter); max-width: none; padding: 9px 11px; font-size: 11px; }
  .traincard { left: var(--gutter); right: var(--gutter); width: auto; bottom: calc(var(--gutter) + 70px); }
  body.has-card .legend { display: none; }
  .trainlist { bottom: auto; top: calc(var(--gutter) + 104px); max-height: 34vh; width: calc(100vw - 2 * var(--gutter)); }
  .trainlist:not(.open) #tlItems, .trainlist:not(.open) .tl-empty { display: none; }
  .trainlist:not(.open) .tl-head { border-bottom: 0; padding-bottom: 0; }
  .tl-head { cursor: pointer; }
  .tl-head span:first-child::after { content: ' ▾'; color: var(--amber); }
  .trainlist.open .tl-head span:first-child::after { content: ' ▴'; }
  .legend small, .lg-credits { display: none; }
  .legend { gap: 4px; }
  body.live.has-card .trainlist { display: none; }
  .lbl.place.city .t { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .hud { transition: none; }
  .live-dot.on, .sw.pulse, .lbl.train.wb .t i { animation: none; }
}

/* ---------------------------------------------------------------- Kameraleiste */
.cambar { left: 50%; transform: translateX(-50%); bottom: calc(var(--gutter) + 86px); display: flex; align-items: center; gap: 2px; padding: 5px 6px; white-space: nowrap; }
body.story .cambar { opacity: 0; pointer-events: none; transform: translate(-50%, 10px); }
.cambar button { appearance: none; border: 0; background: transparent; color: var(--ink-2); min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; cursor: pointer; font-size: 15px; transition: background .2s, color .2s; }
.cambar button.mono { font-size: 10.5px; letter-spacing: 0.08em; }
.cambar button:hover { background: rgba(255, 214, 150, 0.1); color: var(--ink); }
.cambar button.on { color: var(--amber); background: rgba(255, 181, 71, 0.12); }
.cb-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
.cb-compass { width: 38px; height: 38px; padding: 0 !important; }
.cb-compass svg { width: 34px; height: 34px; }
.cb-compass .ring { fill: rgba(20, 16, 12, 0.6); stroke: var(--line-2); stroke-width: 1.2; }
.cb-compass .n { fill: var(--amber); } .cb-compass .s { fill: var(--ink-3); }
.cb-compass .nl { fill: var(--amber); font: 700 6px var(--mono); text-anchor: middle; }
#cbNeedle { transform-origin: 20px 20px; transition: transform .08s linear; }
.cb-mode { font-size: 10px; letter-spacing: 0.14em; color: var(--amber); padding: 0 8px; text-transform: uppercase; }
#cbFree[hidden] { display: none; }
#cbFree { color: var(--amber); }
body.cam-train .cambar [data-tilt], body.cam-train #cbRotL, body.cam-train #cbRotR, body.cam-train #cbZoomIn, body.cam-train #cbZoomOut { display: none; }

/* ---------------------------------------------------------------- Hilfe */
.help { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(10, 8, 6, 0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: var(--gutter); }
.help[hidden] { display: none; }
.help-card { position: relative; width: min(760px, 100%); padding: 24px 26px 22px; }
.help-card h2 { font-family: var(--serif); font-size: 28px; font-weight: 600; margin: 10px 0 16px; }
.help-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.help h3 { font-size: 10px; letter-spacing: 0.16em; color: var(--amber); margin: 0 0 8px; font-weight: 500; }
.help p { font-size: 13.5px; color: var(--ink-2); margin: 0 0 6px; line-height: 1.45; }
.help b { color: var(--ink); font-weight: 600; }
.help kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; margin-right: 3px; color: var(--ink); background: rgba(255, 214, 150, 0.06); }
.help-cams { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.help .btn-live { margin-top: 14px; }
@media (max-width: 1180px) { .cambar [data-tilt='horizon'] { display: none; } .cambar { bottom: calc(var(--gutter) + 84px); } }
@media (max-width: 760px) {
  .cambar { bottom: calc(var(--gutter) + 64px); max-width: calc(100vw - 2 * var(--gutter)); overflow-x: auto; }
  #cbRotL, #cbRotR, .cb-mode { display: none; }
  .help-grid { grid-template-columns: 1fr; gap: 10px; }
  .help-grid > div:nth-child(2) { display: none; }
  .help-card { padding: 18px; max-height: 86vh; overflow: auto; }
  .tc-cams button span { font-size: 7.5px; }
  body.live .legend { bottom: calc(var(--gutter) + 112px); }
  .traincard { bottom: calc(var(--gutter) + 112px); }
}
body.cam-train .cb-sep { display: none; }
@media (max-width: 760px) {
  .tc-src { display: none; }
  .tc-grid { gap: 4px 12px; font-size: 12px; }
  .tc-name { font-size: 20px; }
  body.cam-train .tc-grid > div:nth-child(n+3) { display: none; }
  body.cam-train .tc-dir { margin-bottom: 6px; }
  body.cam-train .traincard { padding: 10px 12px; }
}

/* Zugliste weicht der Zugkarte aus (sonst Überlappung bei niedrigen Fenstern) */
body.has-card .trainlist { max-height: min(30vh, calc(100vh - 2 * var(--gutter) - 360px)); }

/* ---------------------------------------------------------------- Menü „Mehr“ */
.menu { z-index: 26; top: var(--gutter); right: calc(var(--gutter) + 86px); padding: 6px; display: flex; flex-direction: column; min-width: 230px; }
.menu[hidden] { display: none; }
.menu button { appearance: none; border: 0; background: transparent; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 14px; color: var(--ink); }
.menu button[hidden] { display: none; }
.menu button svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.menu button:hover, .menu button:focus-visible { background: rgba(127, 127, 127, 0.12); }
.menu button.on { color: var(--amber); }

/* ---------------------------------------------------------------- Abfahrtstafel */
.board { left: var(--gutter); top: calc(var(--gutter) + 132px); width: min(520px, calc(100vw - 2 * var(--gutter))); padding: 0; overflow: hidden; background: #0b2a52 !important; color: #fff; border: 0 !important; }
.board[hidden] { display: none; }
.board .tc-close { color: rgba(255, 255, 255, 0.7); top: 8px; }
.bd-top { display: flex; align-items: center; gap: 10px; padding: 12px 40px 10px 14px; background: #071d3b; }
.bd-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: #9fb7d8; }
.board select { flex: 1; min-width: 0; appearance: none; background: transparent; border: 0; color: #fff; font: 800 19px var(--font); letter-spacing: -0.01em; cursor: pointer; padding: 2px 18px 2px 0;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%); background-position: right 6px center, right 1px center; background-size: 5px 5px; background-repeat: no-repeat; }
.board select option { color: #111; }
.bd-clock { font-size: 18px; font-weight: 600; color: #ffd200; }
.bd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bd-table th { text-align: left; font: 600 10px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: #9fb7d8; padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.15); }
.bd-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); vertical-align: top; }
.bd-table tr { cursor: default; }
.bd-table tr.live { cursor: pointer; }
.bd-table tr.live:hover { background: rgba(255, 255, 255, 0.08); }
.bd-table td.t { font: 700 15px var(--mono); white-space: nowrap; width: 54px; }
.bd-table td.n { font-weight: 700; white-space: nowrap; }
.bd-table td.n small { display: block; font: 400 10px var(--mono); color: #9fb7d8; }
.bd-table td.d { width: 100%; }
.bd-table td.p { font: 700 15px var(--mono); text-align: center; }
.bd-table td.p.chg { background: #ffd200; color: #0b2a52; }
.bd-table td.x { font: 700 12px var(--mono); color: #ffd200; white-space: nowrap; text-align: right; }
.bd-table td.x.cancel { color: #ff6b6b; }
.bd-table .cat { display: inline-block; min-width: 30px; padding: 1px 4px; margin-right: 4px; font: 800 10px var(--font); text-align: center; border-radius: 2px; background: #fff; color: #0b2a52; }
.bd-table .cat.fern { background: #e2002a; color: #fff; }
.bd-table .cat.wb { background: #1e9e4a; color: #fff; }
.bd-table .inmodel { color: #7fe39b; font-size: 10px; margin-left: 4px; }
.bd-foot { font-size: 10px; color: #9fb7d8; padding: 8px 12px 10px; }

/* ---------------------------------------------------------------- Führerstandsmitfahrt (ETCS-artige Anzeige) */
.ride { left: var(--gutter); bottom: calc(var(--gutter) + 92px); width: min(460px, calc(100vw - 2 * var(--gutter))); padding: 12px 14px; display: flex; gap: 14px; align-items: center; }
.ride[hidden] { display: none; }
.rd-dmi { position: relative; width: 118px; height: 118px; flex: none; }
.rd-dmi svg { width: 100%; height: 100%; }
.rd-speed { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rd-speed b { font: 800 30px var(--font); letter-spacing: -0.03em; line-height: 1; }
.rd-speed small { font: 600 10px var(--mono); color: var(--ink-3); }
.rd-info { flex: 1; min-width: 0; }
.rd-title { display: flex; align-items: center; gap: 8px; }
.rd-title b { font: 800 18px var(--font); }
.rd-badge { font-size: 9.5px; letter-spacing: 0.1em; padding: 2px 6px; background: var(--amber); color: #fff; border-radius: 2px; }
.rd-route { font-size: 12.5px; color: var(--ink-2); margin: 2px 0 6px; }
.rd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.rd-grid .wide { grid-column: 1 / 3; }
.rd-grid small { display: block; font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.rd-ctl { display: flex; gap: 3px; margin-top: 9px; flex-wrap: wrap; }
.rd-ctl button, .replay button { appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--ink); min-width: 34px; height: 30px; padding: 0 8px; border-radius: 4px; cursor: pointer; font: 600 12px var(--mono); }
.rd-ctl button.on, .replay button.on { background: var(--amber); border-color: var(--amber); color: #fff; }

/* ---------------------------------------------------------------- Zeitraffer */
.replay { left: 50%; transform: translateX(-50%); bottom: calc(var(--gutter) + 136px); display: flex; align-items: center; gap: 8px; padding: 7px 10px; width: min(760px, calc(100vw - 2 * var(--gutter))); }
.replay[hidden] { display: none; }
.rp-time { font-size: 20px; font-weight: 700; min-width: 58px; }
.replay input[type=range] { flex: 1; min-width: 80px; accent-color: var(--amber); }
.rp-rates { display: flex; gap: 3px; }
.rp-info { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
body.replaying .live-dot { background: var(--amber) !important; animation: none; }

/* ---------------------------------------------------------------- Hinweise */
.toasts { position: fixed; z-index: 30; top: calc(var(--gutter) + 50px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 2 * var(--gutter))); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: center; padding: 11px 12px 11px 14px; background: var(--panel-solid); color: var(--ink); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28); border-left: 5px solid var(--amber); animation: toastIn 0.35s ease; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: opacity 0.4s, transform 0.4s; }
.toast .tx { flex: 1; font-size: 13px; line-height: 1.4; }
.toast .tx b { display: block; font-size: 14px; }
.toast button { appearance: none; border: 0; background: var(--amber); color: #fff; font: 700 12px var(--font); padding: 8px 10px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.toast button.x { background: transparent; color: var(--ink-3); font-size: 18px; padding: 2px 4px; }
.tbar { align-items: flex-start; }
.tbar .tx { min-width: 0; }
.tb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tb-head b { flex: 1; min-width: 0; }
.tb-eta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.tb-eta .mono { font-size: 20px; font-weight: 700; color: var(--amber); }
.tb-eta small { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.tb-track { position: relative; height: 6px; margin: 10px 6px 6px; border-radius: 3px; background: var(--line-2); }
.tb-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: var(--amber); transition: width 0.5s linear; }
.tb-train { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px var(--panel-solid), 0 0 10px var(--amber); transition: left 0.5s linear; }
.tb-ends { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--ink-3); }
.tb-km { color: var(--ink-2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- Wetter im HUD */
.hud-wx { font-size: 11px; color: var(--ink-2); margin: -2px 0 6px; display: flex; gap: 6px; align-items: center; }
.hud-wx[hidden] { display: none; }
.hud-wx b { color: var(--ink); font-weight: 700; }

/* ---------------------------------------------------------------- Statistik */
.stats-card { width: min(860px, 100%); max-height: 88vh; overflow: auto; }
.st-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.st-tile { padding: 12px; background: rgba(127, 127, 127, 0.08); border-radius: var(--radius); }
.st-tile b { display: block; font: 800 30px var(--font); letter-spacing: -0.03em; line-height: 1.05; }
.st-tile small { font: 600 10px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.st-tile em { font-style: normal; font-size: 12px; color: var(--ink-2); display: block; margin-top: 2px; }
.st-sec { margin: 14px 0 6px; font: 700 11px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
.st-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 90px; }
.st-hours div { position: relative; background: rgba(127, 127, 127, 0.18); border-radius: 2px 2px 0 0; min-height: 2px; }
.st-hours div i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--amber); border-radius: 2px 2px 0 0; }
.st-hlab { display: grid; grid-template-columns: repeat(24, 1fr); font: 9px var(--mono); color: var(--ink-3); margin-top: 3px; }
.st-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.st-lines td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.st-lines td.bar { width: 45%; }
.st-lines .b { height: 8px; background: rgba(127, 127, 127, 0.18); border-radius: 4px; overflow: hidden; }
.st-lines .b i { display: block; height: 100%; background: #1e9e4a; }
.st-lines .b i.mid { background: #e8a200; } .st-lines .b i.bad { background: #e2002a; }
.st-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.st-late li { font-size: 13px; padding: 3px 0; list-style: none; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.st-late { padding: 0; margin: 0; }
.st-late li span:last-child { color: var(--amber); font-weight: 700; font-family: var(--mono); }
.st-note { font-size: 11px; color: var(--ink-3); margin-top: 14px; line-height: 1.5; }
.st-wait { color: var(--ink-2); }
.st-prog { height: 6px; background: rgba(127, 127, 127, 0.2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.st-prog i { display: block; height: 100%; background: var(--amber); }
.st-hist { display: flex; gap: 3px; align-items: end; height: 60px; }
.st-hist div { flex: 1; background: var(--amber); opacity: 0.8; min-height: 2px; border-radius: 2px 2px 0 0; }

@media (max-width: 760px) {
  .menu { right: var(--gutter); top: calc(var(--gutter) + 52px); }
  .board { left: var(--gutter); right: var(--gutter); top: auto; bottom: calc(var(--gutter) + 64px); width: auto; max-height: 58vh; overflow: auto; }
  .bd-table td.n small { display: none; }
  .bd-table th:nth-child(5), .bd-table td.x:empty { display: none; }
  .ride { left: var(--gutter); right: var(--gutter); width: auto; bottom: calc(var(--gutter) + 112px); padding: 9px; gap: 10px; }
  .rd-dmi { width: 86px; height: 86px; }
  .rd-speed b { font-size: 22px; }
  .rd-route { display: none; }
  .replay { bottom: calc(var(--gutter) + 112px); flex-wrap: wrap; }
  .rp-info { display: none; }
  .st-tiles { grid-template-columns: repeat(2, 1fr); }
  .st-cols { grid-template-columns: 1fr; }
  .toasts { top: calc(var(--gutter) + 96px); }
  body.riding .legend, body.riding .traincard, body.replaying .legend { display: none; }
}
body.riding .legend { display: none; }
body.riding.has-card .traincard { display: none; }
.lbl.station.clickable { pointer-events: auto; cursor: pointer; }
.lbl.station.clickable:hover .t { filter: brightness(1.15); }
.bd-table td.p { white-space: nowrap; }
.board { max-height: calc(100vh - 2 * var(--gutter) - 250px); overflow-y: auto; }
body.has-board .legend { display: none; }
body.in-mountain #labels { opacity: 0; }
body.replaying .legend { display: none; }

/* ---------------------------------------------------------------- Handy: nichts überlappt */
.bd-table .xi { display: none; }
@media (max-width: 760px) {
  /* Uhr-Tafel links neben der Werkzeugleiste (4 × 44 px + Rand) */
  .hud-tl { max-width: calc(100vw - 3 * var(--gutter) - 186px); }
  .hud-tl .hud-sep, .hud-date { display: none; }
  .hud-wx { white-space: nowrap; overflow: hidden; }
  .hud-wx span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .hud-counts span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Zugliste direkt unter der Uhr-Tafel */
  .trainlist { top: calc(2 * var(--gutter) + var(--hud-h, 104px) - 6px); max-height: calc(100svh - var(--hud-h, 104px) - 200px); }
  .trainlist.open { max-height: min(34vh, calc(100svh - var(--hud-h, 104px) - 200px)); }
  /* Abfahrtstafel ersetzt die Zugliste, endet über der Kameraleiste */
  body.has-board .trainlist { display: none; }
  .board { top: calc(2 * var(--gutter) + var(--hud-h, 104px) - 6px); bottom: calc(var(--gutter) + 122px); max-height: none; }
  .bd-top { position: sticky; top: 0; z-index: 1; }
  .bd-table { table-layout: fixed; }
  .bd-table th:nth-child(1), .bd-table td.t { width: 54px; }
  .bd-table th:nth-child(2) { width: 86px; }
  .bd-table th:nth-child(4) { width: 58px; }
  .bd-table td.p { font-size: 13px; padding: 7px 2px; }
  .bd-table th:nth-child(5), .bd-table td.x { display: none; }
  .bd-table td { padding: 7px 6px; }
  .bd-table td.n { white-space: normal; overflow-wrap: anywhere; }
  .bd-table td.d { overflow-wrap: anywhere; }
  .bd-table .xi { display: block; font: 700 11px var(--mono); color: #ffd200; }
  .bd-table .xi.cancel { color: #ff6b6b; }
  .bd-table .inmodel { display: block; margin: 1px 0 0; }
  body.has-board .traincard, body.has-board .ride, body.has-board .replay { display: none; }
  /* Karten über der Kameraleiste (die bis gutter + 112 px reicht) */
  .traincard, .ride, .replay, body.live .legend { bottom: calc(var(--gutter) + 122px); }
}
