:root {
  --bg: #0e1418;
  --panel: rgba(16, 24, 30, 0.88);
  --ink: #e8eef2;
  --muted: #93a3ae;
  --line: #2a3943;
  --accent: #f2c230;
  --ok: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --none: #94a3b8;
  --f: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f); font-size: 15px; }
#map { position: fixed; inset: 0; }

.panel {
  position: fixed; z-index: 2;
  top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px));
  width: min(320px, calc(100vw - 24px));
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: .01em; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.count { margin: 0; font-size: 1rem; }
.count strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; margin-right: 4px; }
.status { margin: 0; color: var(--muted); font-size: .85rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:focus-visible, .close:focus-visible, input:focus-visible, .fav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stopsearch { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.stopsearch input {
  font: inherit; font-size: .95rem; color: var(--ink); background: rgba(255,255,255,.06);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.hint { margin: 0; font-size: .82rem; color: var(--accent); }

.sheet {
  position: fixed; z-index: 3;
  right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(12px + env(safe-area-inset-top, 0px));
  width: min(340px, calc(100vw - 24px)); max-height: calc(100% - 24px); overflow: auto;
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.close { position: absolute; right: 8px; top: 6px; font-size: 1.5rem; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.sheet h2 { margin: 0 32px 4px 0; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-block; min-width: 44px; text-align: center; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.delay { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .85rem; font-weight: 600; color: #0e1418; }
.rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0; font-size: .92rem; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-variant-numeric: tabular-nums; }
.upcoming { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.upcoming li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.upcoming time { font-variant-numeric: tabular-nums; color: var(--muted); }
.fav { margin-top: 12px; width: 100%; font: inherit; padding: 8px; border-radius: 8px; cursor: pointer; background: transparent; color: var(--ink); border: 1px solid var(--line); }
.fav[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.legal {
  position: fixed; z-index: 1; left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  max-width: min(520px, calc(100vw - 200px)); font-size: .72rem; color: var(--muted);
  background: var(--panel); padding: 4px 8px; border-radius: 6px;
}

@media (max-width: 640px) {
  .panel { width: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); padding: 10px 12px; gap: 8px; }
  .count strong { font-size: 1.5rem; }
  .sheet { top: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); width: auto; max-height: 55%; }
  .legal { max-width: calc(100vw - 110px); font-size: .66rem; bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.maplibregl-ctrl-attrib.maplibregl-compact, .maplibregl-ctrl-attrib { background: var(--panel) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--ink); }
.maplibregl-ctrl-group { background: var(--panel); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

/* ---------- Hilfe, Restzeit, Abfahrtsplan, Legende ---------- */
.help-btn {
  margin-left: auto; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--ink); background: transparent; border: 1px solid var(--line);
}
.help-btn:focus-visible, .line-btn:focus-visible, .legend-toggle:focus-visible, .deps li.live:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge { color: #0e1418; }
.rows dd { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; }
.t { white-space: nowrap; font-variant-numeric: tabular-nums; }
.t time { color: var(--ink); }
.rel { color: var(--muted); font-variant-numeric: tabular-nums; }
.upcoming time { color: var(--ink); }

.lines { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.line-btn { padding: 0; border: 2px solid transparent; border-radius: 999px; background: none; cursor: pointer; }
.line-btn .badge { min-width: 40px; padding: 2px 8px; font-size: .85rem; }
.line-btn[aria-pressed="true"] { border-color: var(--ink); }
.dirs { margin-bottom: 10px; }
.dirs .chip { font-size: .8rem; padding: 4px 10px; }

.deps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.deps li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.deps li.live { cursor: pointer; }
.deps li.live:hover { background: rgba(255,255,255,.04); }
.deps .badge { min-width: 40px; padding: 2px 8px; font-size: .82rem; }
.deps .to { display: flex; flex-direction: column; min-width: 0; }
.deps .to small { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }
.deps .dly { font-weight: 600; margin-left: 4px; }
.deps .t { text-align: right; }
.deps li.canceled .to, .deps li.canceled .t time { text-decoration: line-through; opacity: .6; }
.deps li.empty { display: block; color: var(--muted); }

.help { margin: 10px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; }
.sheet h3 { margin: 14px 0 4px; font-size: .95rem; }
.help-p { margin: 0; font-size: .85rem; color: var(--muted); line-height: 1.45; }

.legend {
  position: fixed; z-index: 1; left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .76rem; color: var(--muted);
}
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend-toggle { display: none; font: inherit; font-size: .8rem; color: var(--ink); background: none; border: 0; padding: 2px 4px; cursor: pointer; }
.sym { display: inline-block; width: 12px; height: 12px; flex: none; }
.sym.bus { border-radius: 50%; background: #29b6f6; border: 2px solid #94a3b8; }
.sym.bahn { border-radius: 2px; background: #ab47bc; border: 2px solid #94a3b8; }
.sym.ring { border-radius: 50%; background: #3b4a55; border: 2.5px solid var(--c); }
.sym.stop { width: 7px; height: 7px; margin: 0 2.5px; border-radius: 50%; background: rgba(207, 214, 219, .6); }

@media (max-width: 640px) {
  .legend { bottom: calc(124px + env(safe-area-inset-bottom, 0px)); padding: 4px 6px; }
  .legend-toggle { display: block; }
  .legend ul { display: none; margin-top: 6px; }
  .legend.open ul { display: grid; }
  .sheet[data-kind="stop"], .sheet[data-kind="help"] { max-height: 65%; }
  .deps li { font-size: .88rem; }
}
.dir-hint { align-self: center; font-size: .78rem; color: var(--muted); }

/* Anruf-Sammeltaxis */
.sym.ast { border-radius: 50%; background: #2a3943; border: 2px dashed #cfd6db; }
.deps li.demand .to, .deps li.demand .t { color: var(--muted); font-style: italic; }
.deps li.demand .badge { opacity: .55; }
.demand-note { margin: 10px 0 0; font-size: .82rem; color: var(--muted); font-style: italic; }

/* Umschalter 2D / 3D */
.view-btn {
  margin-left: auto; height: 28px; padding: 0 11px; border-radius: 999px; display: inline-flex; align-items: center;
  font-size: .85rem; font-weight: 700; letter-spacing: .03em; text-decoration: none;
  color: var(--bg); background: var(--accent); border: 1px solid var(--accent);
}
.view-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.view-btn + .help-btn { margin-left: 0; }

/* Hinweistext im aufklappbaren Info-Bereich (statt Fusszeile) */
.maplibregl-ctrl-attrib.maplibregl-compact { max-width: min(320px, calc(100vw - 24px)); }
.maplibregl-ctrl-attrib.maplibregl-compact-show { padding: 6px 28px 6px 10px; border-radius: 10px; }
.maplibregl-ctrl-attrib-inner { font-size: .74rem; line-height: 1.45; white-space: normal; }
.maplibregl-ctrl-attrib-inner .legal-note { display: block; margin-bottom: 4px; color: var(--ink); }
.legend { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 640px) { .legend { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 640px) { .hint-3d { display: none; } }

/* Version oben rechts, dezent und nicht klickbar */
.version {
  position: fixed; z-index: 1; pointer-events: none;
  top: calc(2px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px));
  font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); opacity: .5;
}
@media (max-width: 640px) { .version { font-size: 10px; top: env(safe-area-inset-top, 0px); } }
