/* ---------- Farbschema ---------- */
:root {
  --bg: #f3f1ec;
  --card: rgba(255, 255, 255, 0.94);
  --card-solid: #ffffff;
  --ink: #1b1f26;
  --ink-2: #566070;
  --ink-3: #8a93a0;
  --hair: rgba(20, 28, 40, 0.1);
  --hover: rgba(20, 28, 40, 0.05);
  --accent: #2563eb;
  --ok: #16a34a;
  --shadow: 0 10px 32px rgba(15, 22, 34, 0.14), 0 1px 3px rgba(15, 22, 34, 0.12);
  /* Karte (werden von map.js ausgelesen) */
  --map-bg: #f3f1ec;
  --map-grid: rgba(30, 40, 55, 0.045);
  --station-fill: #ffffff;
  --station-stroke: #232831;
  --label: #232831;
  --label-halo: rgba(243, 241, 236, 0.94);
  --train-rim: #ffffff;
  --casing: rgba(255, 255, 255, 0.9);
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #12151a;
  --card: rgba(26, 30, 38, 0.94);
  --card-solid: #1a1e26;
  --ink: #e9edf3;
  --ink-2: #a3adbb;
  --ink-3: #6f7a89;
  --hair: rgba(220, 230, 245, 0.12);
  --hover: rgba(220, 230, 245, 0.07);
  --accent: #6c9bff;
  --ok: #4ade80;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.5);
  --map-bg: #12151a;
  --map-grid: rgba(200, 215, 235, 0.05);
  --station-fill: #1a1e26;
  --station-stroke: #e9edf3;
  --label: #dfe5ee;
  --label-halo: rgba(18, 21, 26, 0.92);
  --train-rim: #12151a;
  --casing: rgba(18, 21, 26, 0.85);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12151a;
    --card: rgba(26, 30, 38, 0.94);
    --card-solid: #1a1e26;
    --ink: #e9edf3;
    --ink-2: #a3adbb;
    --ink-3: #6f7a89;
    --hair: rgba(220, 230, 245, 0.12);
    --hover: rgba(220, 230, 245, 0.07);
    --accent: #6c9bff;
    --ok: #4ade80;
    --shadow: 0 10px 32px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.5);
    --map-bg: #12151a;
    --map-grid: rgba(200, 215, 235, 0.05);
    --station-fill: #1a1e26;
    --station-stroke: #e9edf3;
    --label: #dfe5ee;
    --label-halo: rgba(18, 21, 26, 0.92);
    --train-rim: #12151a;
    --casing: rgba(18, 21, 26, 0.85);
    color-scheme: dark;
  }
}

/* ---------- Grundlagen ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font: 14px/1.4 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic UI', 'Noto Sans JP', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num, .t, .tm, .clock-time { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
#map.pick { cursor: pointer; }

.card { background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow); }
.hud { position: absolute; z-index: 5; }

/* ---------- Kopfzeile ---------- */
.top { top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none; }
.top > * { pointer-events: auto; }
.chip { background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; }
.brand strong { display: block; font-size: 14px; letter-spacing: 0.1px; }
.brand > div { min-width: 0; }
.brand small { display: block; color: var(--ink-2); font-size: 11.5px; margin-top: -1px; max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { padding: 7px 16px; text-align: center; min-width: 190px; }
.clock-time { font-size: 24px; font-weight: 650; letter-spacing: 0.5px; line-height: 1.15; }
.clock-time .tz { font-size: 11px; font-weight: 600; color: var(--ink-3); margin-left: 6px; letter-spacing: 0.4px; }
.clock-meta { font-size: 12px; color: var(--ink-2); display: flex; gap: 8px; justify-content: center; align-items: center; white-space: nowrap; }
.mode { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--hover); }
.mode::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.mode.live { color: var(--ok); }
.mode.live::before { background: var(--ok); animation: pulse 1.8s ease-in-out infinite; }
.mode.warn { color: #c2410c; }
.mode.warn::before { background: #ea580c; }
@keyframes pulse { 50% { opacity: 0.25; } }
.actions { display: flex; padding: 4px; gap: 2px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; color: var(--ink-2); font-weight: 600; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { color: var(--accent); }

/* ---------- Legende ---------- */
.legend { top: 76px; left: 12px; width: 232px; padding: 6px; max-height: calc(100% - 170px); overflow-y: auto; overflow-x: hidden; }
.legend-head { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 6px 8px; font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-2); text-align: left; }
.legend-head .count { margin-left: auto; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-size: 12px; }
.legend-head .chev { transition: transform 0.2s; color: var(--ink-3); }
.legend.collapsed .chev { transform: rotate(-90deg); }
.legend.collapsed ul, .legend.collapsed .type-key { display: none; }
.type-filter { display: flex; gap: 4px; padding: 2px 2px 6px; }
.tf { flex: 1 1 auto; min-width: 0; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 30px; padding: 0 3px; overflow: hidden; border: 1px solid var(--hair); border-radius: 8px; background: var(--hover); color: var(--ink); font-size: 12px; font-weight: 600; }
.tf:hover { border-color: var(--ink-3); }
.tf[aria-pressed='false'] { background: transparent; color: var(--ink-3); opacity: 0.7; }
.tf[aria-pressed='false'] svg { opacity: 0.4; }
.legend.collapsed .type-filter { padding-bottom: 2px; }
.type-key { margin: 6px 4px 2px; padding-top: 8px; border-top: 1px solid var(--hair); display: grid; gap: 5px; }
.type-key div { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-2); line-height: 1.25; }
.type-key svg { flex: none; }
.type-key small { color: var(--ink-3); font-size: 11px; }
#legendList { list-style: none; margin: 0; padding: 0; }
.leg-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: transparent; border-radius: 9px; text-align: left; }
.leg-item:hover { background: var(--hover); }
.leg-item.off { opacity: 0.4; }
.leg-item.off .leg-name b { text-decoration: line-through; text-decoration-thickness: 1px; }
.leg-group { margin-top: 2px; }
.leg-op-row { display: flex; align-items: center; gap: 2px; }
.leg-op { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 7px 6px 7px 6px; text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.2px; color: var(--ink-2); border-radius: 8px; }
.leg-op:hover { background: var(--hover); color: var(--ink); }
.leg-op .chev { flex: none; transition: transform 0.18s; color: var(--ink-3); }
.leg-group.folded .chev { transform: rotate(-90deg); }
.leg-op-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leg-op-name small { font-weight: 500; letter-spacing: 0; color: var(--ink-3); margin-left: 3px; }
.leg-opcount { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.leg-eye { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; color: var(--ink-2); }
.leg-eye:hover { background: var(--hover); color: var(--ink); }
.leg-eye .slash { display: none; }
.leg-eye.off { color: var(--ink-3); }
.leg-eye.off .slash { display: block; }
.leg-eye.partial { color: var(--accent); }
.leg-group.folded .leg-lines { display: none; }
.leg-lines { list-style: none; margin: 0 0 4px; padding: 0; }
.leg-item { padding-top: 5px; padding-bottom: 5px; }
.badge { --bh: 22px; flex: none; box-sizing: border-box; height: var(--bh); min-width: calc(var(--bh) + 4px); padding: 0 6px; border-radius: 7px; display: inline-grid; place-items: center; background: var(--c); color: var(--on, #fff); font-size: 11.5px; font-weight: 700; letter-spacing: 0.2px; line-height: 1; }
/* Offizielle Symbolformen: Kreis, Quadrat, abgerundet; gefüllt oder nur Rand */
.badge.shape-circle { width: var(--bh); min-width: var(--bh); padding: 0; border-radius: 50%; }
.badge.shape-square { width: var(--bh); min-width: var(--bh); padding: 0; border-radius: 3px; }
.badge.long { font-size: 10px; letter-spacing: 0; }
.badge.fill-outline { background: #fff; color: #1b1f26; box-shadow: inset 0 0 0 2.5px var(--c); }
.badge.fill-outline.letters-color { color: var(--c); }
/* Stationsnummer wie auf den Bahnhofsschildern: Buchstaben über Ziffern, Form/Farbe der Linie */
.nb { --nh: 26px; flex: none; box-sizing: border-box; width: var(--nh); height: var(--nh); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border-radius: 50%; background: var(--c); color: var(--on, #fff); line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; vertical-align: middle; }
.nb i { font-style: normal; font-size: calc(var(--nh) * 0.34); letter-spacing: -0.2px; }
.nb b { font-size: calc(var(--nh) * 0.45); letter-spacing: -0.2px; }
.nb.shape-rounded { border-radius: calc(var(--nh) * 0.3); }
.nb.shape-square { border-radius: 3px; }
.nb.fill-outline { background: #fff; color: #1b1f26; box-shadow: inset 0 0 0 calc(var(--nh) * 0.09) var(--c); }
.nb.fill-outline.letters-color { color: var(--c); }
.nb.none { background: transparent; box-shadow: none; visibility: hidden; }
.nums { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.tip-nums { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.tip-nums .nb { --nh: 22px; }
.leg-name { min-width: 0; line-height: 1.2; }
.leg-name b { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leg-name small { color: var(--ink-3); font-size: 11.5px; }
.leg-count { margin-left: auto; font-size: 12px; color: var(--ink-2); font-weight: 600; min-width: 22px; text-align: right; }

/* ---------- Zeitsteuerung ---------- */
.transport { left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px; }
.tbtn { white-space: nowrap; height: 36px; min-width: 36px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center; padding: 0 12px; font-weight: 600; color: var(--ink); }
.tbtn:hover { background: var(--hover); }
.tbtn.text { font-size: 13px; color: var(--ink-2); }
.tbtn.accent { color: var(--accent); }
.speeds { display: flex; background: var(--hover); border-radius: 10px; padding: 2px; }
.speeds button { border: 0; background: transparent; height: 32px; padding: 0 11px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.speeds button:hover { color: var(--ink); }
.speeds button.on { background: var(--card-solid); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }

.zoom { right: 12px; bottom: 14px; display: flex; flex-direction: column; overflow: hidden; }
.zoom button { width: 38px; height: 38px; border: 0; background: transparent; display: grid; place-items: center; font-size: 20px; line-height: 1; color: var(--ink-2); }
.zoom button + button { border-top: 1px solid var(--hair); }
.zoom button:hover { background: var(--hover); color: var(--ink); }

.notice { position: absolute; z-index: 6; top: 76px; left: 50%; transform: translateX(-50%); padding: 9px 16px; font-size: 13px; max-width: min(520px, calc(100% - 24px)); text-align: center; }
.notice b { font-weight: 650; }
.notice button { margin-left: 8px; border: 0; background: var(--hover); border-radius: 8px; padding: 3px 10px; font-weight: 600; font-size: 12.5px; }

.tooltip { position: absolute; z-index: 9; pointer-events: none; background: var(--card-solid); border: 1px solid var(--hair); box-shadow: var(--shadow); border-radius: 10px; padding: 7px 10px; font-size: 12.5px; max-width: 260px; line-height: 1.3; }
.tooltip b { font-weight: 650; }
.tooltip small { display: block; color: var(--ink-2); margin-top: 2px; }

/* ---------- Detailpanel ---------- */
.panel { position: absolute; z-index: 7; top: 74px; right: 12px; bottom: 12px; width: 392px; display: flex; flex-direction: column; overflow: hidden; background: var(--card-solid); }
.panel[hidden] { display: none; }
.ph { padding: 14px 14px 10px 16px; border-bottom: 1px solid var(--hair); position: relative; }
.ph-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); display: grid; place-items: center; }
.ph-close:hover { background: var(--hover); color: var(--ink); }
.ph h2 { margin: 0; font-size: 20px; line-height: 1.2; padding-right: 36px; font-weight: 650; }
.ph .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 4px; border: 1px solid var(--hair); background: transparent; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip-btn .badge { --bh: 20px; font-size: 11px; }
.chip-btn .badge.shape-rounded { border-radius: 99px; }
.chip-btn.on { background: var(--hover); color: var(--ink); border-color: var(--c, var(--ink-3)); }
.chip-btn.static { cursor: default; padding-right: 10px; color: var(--ink); }

.tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--hair); }
.tab { border: 0; background: transparent; padding: 8px 12px 9px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); border-color: var(--accent); }
.tabs .spacer { flex: 1; }
.tabs select { align-self: center; max-width: 150px; border: 1px solid var(--hair); background: var(--card-solid); border-radius: 8px; padding: 4px 6px; font-size: 12.5px; margin-bottom: 4px; }

.board { flex: 1; overflow-y: auto; position: relative; overscroll-behavior: contain; }
.row { content-visibility: auto; contain-intrinsic-size: auto 52px; width: 100%; display: grid; grid-template-columns: 52px 30px 1fr auto; gap: 10px; align-items: center; padding: 8px 14px 8px 16px; border: 0; border-bottom: 1px solid var(--hair); background: transparent; text-align: left; position: relative; }
.row:hover { background: var(--hover); }
.row .t { font-size: 16px; font-weight: 650; }
.row .t .next-day { font-size: 10px; color: var(--ink-3); font-weight: 600; margin-left: 2px; vertical-align: super; }
.row .badge { --bh: 24px; }
.row .dest { min-width: 0; line-height: 1.25; }
.row .dest b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .dest small { color: var(--ink-2); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .trk { text-align: right; font-size: 12px; color: var(--ink-2); line-height: 1.2; min-width: 44px; }
.row .trk b { display: block; font-size: 14px; color: var(--ink); font-weight: 650; }
.row .trk .none { color: var(--ink-3); }
.row.past { opacity: 0.42; }
.row.past:hover { opacity: 0.8; }
.row.next { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.row.next::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.row.live .t::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-left: 6px; vertical-align: middle; animation: pulse 1.6s ease-in-out infinite; }
.type-tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--hover); color: var(--ink-2); margin-right: 5px; vertical-align: 1px; }
.board-empty { padding: 28px 20px; text-align: center; color: var(--ink-2); }
.board-foot { border-top: 1px solid var(--hair); padding: 8px 14px; display: flex; gap: 10px; align-items: center; font-size: 11.5px; color: var(--ink-3); line-height: 1.3; }
.board-foot button { flex: none; border: 1px solid var(--hair); background: var(--card-solid); border-radius: 8px; padding: 5px 10px; font-weight: 600; font-size: 12.5px; color: var(--ink); }
.board-foot button:hover { background: var(--hover); }

/* Zugdetail */
.train-head { display: flex; align-items: center; gap: 12px; }
.train-head .badge { --bh: 32px; font-size: 14px; }
.train-head .badge.shape-rounded { border-radius: 9px; }
.train-head .badge.long { font-size: 12px; }
.train-head h2 { padding-right: 0; font-size: 18px; }
.status { margin: 10px 0 0; padding: 9px 12px; background: var(--hover); border-radius: 10px; font-size: 13px; line-height: 1.35; }
.status b { font-weight: 650; }
.status .eta { font-variant-numeric: tabular-nums; font-weight: 650; }
.panel-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn { border: 1px solid var(--hair); background: var(--card-solid); border-radius: 9px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.on { background: var(--accent); color: #fff; border-color: transparent; }

.timeline { flex: 1; overflow-y: auto; position: relative; padding: 10px 0 16px; overscroll-behavior: contain; }
.tl-wrap { position: relative; }
.rail-base, .rail-fill { position: absolute; left: 22px; width: 6px; border-radius: 3px; transform: translateX(-50%); background: var(--c); }
.rail-base { opacity: 0.25; }
.rail-fill { height: 0; transition: height 0.25s linear; }
.tl { position: relative; list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; height: 50px; padding-right: 16px; cursor: pointer; }
.tl li.skip { height: 30px; cursor: default; }
.tl li:hover:not(.skip) { background: var(--hover); }
.tl .rail { position: relative; height: 100%; }
.tl .dot { position: absolute; left: 22px; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--card-solid); border: 3px solid var(--c); transform: translate(-50%, -50%); z-index: 1; }
.tl li.skip .dot { width: 6px; height: 6px; border: 0; background: var(--c); opacity: 0.45; }
.tl li.passed .dot { background: var(--c); }
.tl li.here .dot { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); background: var(--c); }
.tl .nm { min-width: 0; line-height: 1.2; display: flex; align-items: center; gap: 9px; }
.tl .nt { min-width: 0; }
.tl .nt b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl .nt small { color: var(--ink-2); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl li.passed .nm, .tl li.passed .tm { color: var(--ink-3); }
.tl li.passed .nt small { color: var(--ink-3); }
.tl li.passed .nb { opacity: 0.6; }
.tl li.skip .nm { font-size: 12px; color: var(--ink-3); }
.tl li.skip .nt b { font-weight: 500; font-size: 12.5px; }
.tl li.skip .nb { --nh: 20px; opacity: 0.55; }
.tl li.skip .nb.none { display: inline-block; }
.tl .tm { text-align: right; line-height: 1.2; font-size: 14px; font-weight: 600; }
.tl .tm small { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.tl li.passed .tm small { color: var(--ink-3); }
.tl li.here .nm, .tl li.here .tm { color: var(--ink); }
.tl li.here .nt small, .tl li.here .tm small { color: var(--ink-2); }
.back { border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 12.5px; padding: 0 0 6px; margin: 0 0 0 -2px; }
.back:hover { text-decoration: underline; }
.marker { position: absolute; left: 22px; width: 22px; height: 22px; border-radius: 50%; background: var(--c); border: 3px solid var(--card-solid); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); transform: translate(-50%, -50%); z-index: 2; pointer-events: none; transition: top 0.25s linear; }
.marker::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid var(--c); opacity: 0.5; animation: ring 2s ease-out infinite; }
@keyframes ring { from { transform: scale(0.6); opacity: 0.7; } to { transform: scale(1.3); opacity: 0; } }
.through { margin: 8px 16px 0; padding: 8px 12px; border: 1px dashed var(--hair); border-radius: 10px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- Dialoge ---------- */
.dialog { border: 1px solid var(--hair); border-radius: 16px; padding: 20px 22px; background: var(--card-solid); color: var(--ink); box-shadow: var(--shadow); width: min(380px, calc(100% - 24px)); }
.dialog.wide { width: min(560px, calc(100% - 24px)); max-height: calc(100% - 40px); overflow: auto; }
.dialog::backdrop { background: rgba(10, 14, 22, 0.45); }
.dialog h3 { margin: 0 0 6px; font-size: 18px; }
.dialog p, .dialog li { color: var(--ink-2); font-size: 13.5px; }
.dialog a { color: var(--accent); }
.dialog ul { padding-left: 18px; margin: 6px 0 12px; }
.dialog-hint { margin: 0 0 14px; }
.field-row { display: flex; gap: 10px; }
.field-row label { flex: 1; display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.field-row input { border: 1px solid var(--hair); background: var(--card-solid); border-radius: 9px; padding: 8px 10px; font-size: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.presets button { border: 1px solid var(--hair); background: transparent; border-radius: 99px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.presets button:hover { background: var(--hover); color: var(--ink); }
.setting { border: 1px solid var(--hair); border-radius: 12px; padding: 10px 14px 12px; margin: 14px 0 0; }
.setting legend { padding: 0 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.4px; }
.radio { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 14px; cursor: pointer; }
.setting-hint { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }
.speed { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--hair); border-radius: 10px; }
.spd-val { font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; min-width: 2ch; }
.spd-unit { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.spd-note { margin-left: auto; font-size: 11.5px; color: var(--ink-3); text-align: right; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Mobil ---------- */
@media (max-width: 760px) {
  .top { top: 8px; left: 8px; right: 8px; flex-wrap: wrap; }
  .brand small { display: none; }
  .brand { padding-right: 10px; }
  .actions { gap: 0; }
  .actions .icon-btn { width: 32px; }
  .clock { min-width: 0; padding: 5px 12px; order: 3; flex: 1 0 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .clock-time { font-size: 20px; }
  .legend { top: 112px; left: 8px; width: 200px; max-height: 40%; }
  .legend:not(.collapsed) { box-shadow: var(--shadow); }
  .panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 58%; }
  .transport { bottom: 8px; max-width: calc(100% - 70px); left: 8px; transform: none; padding: 4px; gap: 2px; }
  .tbtn.text#btnTime { display: none; }
  .speeds button { padding: 0 8px; }
  .zoom { bottom: 8px; right: 8px; }
  body.panel-open .transport, body.panel-open .zoom { display: none; }
  .notice { top: 150px; }
}
@media (max-height: 520px) and (min-width: 761px) {
  .legend { max-height: calc(100% - 150px); }
}
@media (prefers-reduced-motion: reduce) {
  .mode.live::before, .marker::after, .row.live .t::after { animation: none; }
}

/* ---------- Live-Daten: Störungen und Verspätungen ---------- */
:root { --late: #d97706; --late-big: #dc2626; --late-bg: rgba(245, 158, 11, 0.14); --late-big-bg: rgba(239, 68, 68, 0.14); --info: #2563eb; }
:root[data-theme='dark'] { --late: #fbbf24; --late-big: #f87171; --info: #8ab4ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) { --late: #fbbf24; --late-big: #f87171; --info: #8ab4ff; } }

.live-btn { position: relative; }
.live-btn[hidden] { display: none; }
.live-btn.alert { color: var(--late); }
.live-count { position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 99px; background: var(--late-big); color: #fff; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; box-sizing: border-box; }
.live-count[hidden] { display: none; }

.leg-st { flex: none; width: 17px; height: 17px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; line-height: 1; color: #fff; margin-left: 2px; }
.leg-st[hidden], .leg-opst[hidden] { display: none; }
.leg-st.delay { background: #f59e0b; color: #1b1f26; }
.leg-st.suspended { background: #dc2626; }
.leg-st.info { background: var(--info); font-style: italic; font-family: Georgia, serif; }
.leg-opst { flex: none; font-size: 11px; font-weight: 800; padding: 0 6px; border-radius: 99px; background: #f59e0b; color: #1b1f26; margin-left: 4px; }

.row .t { position: relative; }
.dl { display: block; font-size: 11px; font-weight: 800; color: var(--late); line-height: 1.1; margin-top: 1px; font-variant-numeric: tabular-nums; }
.dl.big { color: var(--late-big); }
.dl[hidden], em.late[hidden] { display: none; }
em.late { display: inline-block; margin-left: 5px; font-style: normal; font-size: 11px; font-weight: 800; color: var(--late); }
em.late.big { color: var(--late-big); }
.tl li.passed em.late { display: none; }
.eta s { color: var(--ink-3); font-weight: 500; text-decoration-thickness: 1px; }
.eta .late { color: var(--late); font-weight: 700; }

.livebar { margin-top: 8px; display: grid; gap: 6px; }
.livebar[hidden] { display: none; }
.lv { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.lv i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.lv.ok i { background: var(--ok); }
.lv.mid { color: var(--late); }
.lv.mid i { background: #f59e0b; }
.lv.big { color: var(--late-big); }
.lv.big i { background: #ef4444; }
.lv b { font-weight: 650; }
.lm { display: block; font-size: 12.5px; line-height: 1.35; padding: 7px 10px; border-radius: 9px; background: var(--late-bg); color: var(--ink); }
.lm.suspended { background: var(--late-big-bg); }
.lm.info { background: color-mix(in srgb, var(--info) 14%, transparent); }

/* Betriebslage-Dialog */
.dialog h4 { margin: 16px 0 6px; font-size: 13px; letter-spacing: 0.2px; text-transform: uppercase; color: var(--ink-3); }
.live-sum { margin: 0 0 4px; line-height: 1.45; }
.live-sum b.late { color: var(--late); }
.live-empty { margin: 4px 0; color: var(--ink-2); }
.live-err { margin: 10px 0 0; font-size: 12px; color: var(--late-big); }
.lv-list, .lv-trains { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lv-item { border: 1px solid var(--hair); border-radius: 12px; padding: 9px 12px; background: var(--late-bg); }
.lv-item.suspended { background: var(--late-big-bg); }
.lv-item.info { background: color-mix(in srgb, var(--info) 12%, transparent); }
.lv-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.lv-head b { font-size: 14px; }
.lv-chip { margin-left: auto; font-size: 11px; font-weight: 750; padding: 2px 8px; border-radius: 99px; background: #f59e0b; color: #1b1f26; }
.lv-chip.suspended { background: #dc2626; color: #fff; }
.lv-chip.info { background: var(--info); color: #fff; }
.lv-text { margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--ink); }
.lv-trains button { width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid var(--hair); background: transparent; border-radius: 10px; padding: 7px 10px; text-align: left; color: var(--ink); }
.lv-trains button:hover { background: var(--hover); }
.lv-tn { flex: 1; min-width: 0; line-height: 1.25; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-tn small { display: block; color: var(--ink-3); font-size: 11.5px; }
.lv-late { font-weight: 800; font-size: 14px; color: var(--late); font-variant-numeric: tabular-nums; }
.lv-late.big { color: var(--late-big); }
.live-cover { margin-top: 16px; font-size: 12.5px; color: var(--ink-2); }
.live-cover summary { cursor: pointer; font-weight: 600; }
.live-cover table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.live-cover th, .live-cover td { text-align: left; padding: 3px 10px 3px 0; border-bottom: 1px solid var(--hair); font-weight: 500; }
.live-cover th { color: var(--ink-3); font-size: 11.5px; }

/* ---------- Sprachmenü ---------- */
.actions { position: relative; }
.menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 160px; padding: 4px; background: var(--card-solid); border: 1px solid var(--hair); border-radius: 12px; box-shadow: var(--shadow); z-index: 20; }
.menu[hidden] { display: none; }
.menu button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 14px; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; text-align: left; font-weight: 600; color: var(--ink); }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button i { font-style: normal; color: var(--accent); visibility: hidden; }
.menu button[aria-checked='true'] i { visibility: visible; }
.setting-hint .warn { color: var(--late); }
.setting-hint .warn[hidden] { display: none; }

/* ---------- Marke: tokyotrain.live ---------- */
:root { --brand: #cf3366; }
:root[data-theme='dark'] { --brand: #e8527f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) { --brand: #e8527f; } }
.wordmark { font-weight: 700; letter-spacing: -0.25px; white-space: nowrap; }
.wordmark span { color: var(--brand); }
.brand .wordmark { font-size: 15.5px; line-height: 1.15; }
.logo { flex: none; display: block; }
.about-brand { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--hair); }
.about-brand .wordmark { display: block; font-size: 22px; line-height: 1.1; }
.about-brand small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.attrib { left: 14px; bottom: 12px; padding: 3px 10px; font-size: 11px; color: var(--ink-2); background: var(--card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--hair); border-radius: 99px; }
.attrib a { color: inherit; text-decoration: underline; text-decoration-color: var(--hair); text-underline-offset: 2px; }
.attrib a:hover { color: var(--ink); }
@media (max-width: 760px) { .attrib { display: none; } }
.linklike { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-decoration-color: var(--hair); text-underline-offset: 2px; cursor: pointer; }
.linklike:hover { color: var(--ink); }
/* Quellenzeile: bei schmalen Fenstern über die Zeitsteuerung, damit nichts überlappt */
.attrib { max-width: calc(50vw - 230px); line-height: 1.35; }
@media (max-width: 1100px) and (min-width: 761px) {
  .attrib { bottom: 66px; max-width: 300px; border-radius: 12px; }
  .legend { max-height: calc(100% - 205px); }
}

/* Impressum/Datenschutz im Info-Dialog */
.about-legal { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--hair); font-size: 12.5px; color: var(--ink-2); }
.about-legal a { color: inherit; }
