/* Fahrplan-App – nüchtern, hell und dunkel, ab 320 px Breite (Grundlage: Testportal) */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #d9dde3;
  --text: #1c2430;
  --muted: #5d6877;
  --accent: #205493;
  --accent-text: #ffffff;
  --ok: #1e7a3c;
  --ok-bg: #e3f3e8;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --info-bg: #e6eef8;
  --focus: #3b82f6;
  --radius: 8px;
  --mono: ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  /* Linienfarben je Verkehrsmittel */
  /* wie im Prototyp (nach Rheinbahn und DB); Fernverkehr als weißes Kennzeichen mit roter Schrift und rotem Rand,
     die Karte zeichnet ihn rot */
  --m-longdistance: #ec0016;
  --m-regional: #5d636c;
  --m-suburban: #008d4f;
  --m-subway: #0065ae;
  --m-tram: #d7191c;
  --m-bus: #ffcc00;
  --m-bus-text: #1d1d1b;
  --m-replacement: #e5007d;
  --m-ondemand: #0f766e;
  --m-ferry: #0369a1;
  --m-cablecar: #475569;
  --m-other: #6c7a99;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1a2028;
    --surface-2: #222a34;
    --line: #333d4a;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --accent: #6ea8fe;
    --accent-text: #0b1320;
    --ok: #6fd08f;
    --ok-bg: #16301f;
    --warn: #f3c262;
    --warn-bg: #352a12;
    --bad: #ff8a80;
    --bad-bg: #3a1a18;
    --info-bg: #1b2a3d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c;
  --surface: #1a2028;
  --surface-2: #222a34;
  --line: #333d4a;
  --text: #e6e9ee;
  --muted: #9aa5b4;
  --accent: #6ea8fe;
  --accent-text: #0b1320;
  --ok: #6fd08f;
  --ok-bg: #16301f;
  --warn: #f3c262;
  --warn-bg: #352a12;
  --bad: #ff8a80;
  --bad-bg: #3a1a18;
  --info-bg: #1b2a3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.88em; }
h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9em; margin: 0.4rem 0 0; min-height: 1.2em; }
/* verlinkte Verbindung (Kalender) nicht mehr zu finden; stärker als .hint der Designs */
.hint.link-missing, [data-design] .hint.link-missing { color: var(--warn); }
.panel > .hint:empty, .hits:empty { display: none; }
.error { color: var(--bad); margin: 0.5rem 0 0; min-height: 1.2em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Kopf */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.05rem; white-space: nowrap; }
/* Menü: Gruppen nach Aufgaben, je ein Aufklappmenü */
.tabs { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav-group { position: relative; }
.nav-head {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.55rem 0.35rem 0.7rem; border: 0; border-radius: 6px; background: none;
  font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.nav-head:hover, .nav-group.open > .nav-head { background: var(--surface-2); color: var(--text); }
.nav-group.current > .nav-head { background: var(--info-bg); color: var(--text); font-weight: 600; }
.nav-head svg.chev { width: 0.9em; height: 0.9em; opacity: 0.7; transition: transform 0.15s; }
.nav-group.open > .nav-head svg.chev { transform: rotate(180deg); }
.nav-group.user { margin-left: auto; }
.nav-group.user > .nav-head { color: var(--text); font-weight: 600; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  display: grid; gap: 2px; width: max-content; min-width: 15rem; max-width: calc(100vw - 32px); padding: 0.35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.18);
}
.nav-menu[hidden] { display: none; }
.nav-menu.to-left { left: auto; right: 0; }
/* Brücke über den Spalt: Das Menü bleibt offen, während die Maus hinüberfährt */
.nav-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.nav-item {
  display: flex; align-items: flex-start; gap: 0.6rem; width: 100%;
  padding: 0.45rem 0.6rem; border: 0; border-radius: 6px; background: none;
  font: inherit; text-align: left; color: var(--text); text-decoration: none; cursor: pointer;
}
.nav-item svg.icon { margin-top: 0.1em; color: var(--muted); }
.nav-item:hover, .nav-item:focus-visible { background: var(--surface-2); }
.nav-item[aria-current="page"] { background: var(--info-bg); font-weight: 600; }
.nav-item[aria-current="page"] svg.icon { color: var(--accent); }
.nav-text { display: grid; gap: 0.05rem; }
.nav-text small { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.nav-menu button.nav-item { margin-top: 0.2rem; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; }
@media (prefers-reduced-motion: reduce) { .nav-head svg.chev, .dep-notes > summary::before, .trip-notes > summary::before { transition: none; } }
/* Symbole wie im Prototyp (Tabler Icons) – nicht im Design „Myzel“ */
svg.icon { width: 1.15em; height: 1.15em; flex: none; }
.btn.small svg.icon { width: 1.05em; height: 1.05em; }
[data-design="myzel"] svg.icon { display: none; }
[data-design="myzel"] svg.icon.chev { display: block; }

main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 1rem; border-top: 1px solid var(--line); }
.foot a { color: inherit; }

/* Flächen und Bedienelemente */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.panel.narrow { max-width: 460px; margin: 2rem auto; }
label, .label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
label.check { display: flex; align-items: center; gap: 0.4rem; color: var(--text); font-size: 0.95rem; margin: 0.6rem 0; }
input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="number"],
input[type="datetime-local"], select {
  width: 100%; min-width: 0;
  padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 0.85rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.25rem 0.55rem; font-size: 0.85rem; }
.btn.on { background: var(--info-bg); border-color: var(--accent); }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.8rem; }
.row.end { justify-content: flex-end; align-self: end; }

/* Haltestellensuche */
.searchbar { display: flex; gap: 0.5rem; }
.searchbar input { flex: 1; }
.hits { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.hits li + li { border-top: 1px solid var(--line); }
.hits button {
  display: flex; width: 100%; gap: 0.75rem; justify-content: space-between; align-items: baseline;
  padding: 0.55rem 0.3rem; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.hits button:hover, .hits button:focus-visible { background: var(--surface-2); }
.hit-name { font-weight: 600; }
.hit-meta { color: var(--muted); font-size: 0.85rem; text-align: right; }
.fav-mark { color: var(--warn); }
.fav-lines { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; align-items: center; margin: 0.6rem 0; }
.fav-lines .check { display: inline-flex; gap: 0.35rem; align-items: center; }
.fav-lines .dir { color: var(--muted); font-size: 0.9em; }

/* Plaketten */
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.chip {
  display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.78rem;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--info-bg); color: var(--text); border-color: transparent; }
.line {
  display: inline-block; min-width: 2.6em; padding: 0.1rem 0.4rem; border-radius: 4px;
  font-weight: 700; font-size: 0.85rem; text-align: center; color: #fff; background: var(--m-other); white-space: nowrap;
}
.line[data-mode="longdistance"] { background: #fff; color: var(--m-longdistance); box-shadow: inset 0 0 0 2px var(--m-longdistance); }
.line[data-mode="regional"] { background: var(--m-regional); }
.line[data-mode="suburban"] { background: var(--m-suburban); }
.line[data-mode="subway"] { background: var(--m-subway); }
.line[data-mode="tram"] { background: var(--m-tram); }
.line[data-mode="bus"] { background: var(--m-bus); color: var(--m-bus-text); }
.line[data-mode="replacement"] { background: var(--m-replacement); }
.line[data-mode="ondemand"] { background: var(--m-ondemand); }
.line[data-mode="ferry"] { background: var(--m-ferry); }
.line[data-mode="cablecar"] { background: var(--m-cablecar); }
/* Farbe aus dem Fahrplan (Livehub ab 0.22), gesetzt von lineEl() */
.line.painted { background: var(--lc); color: var(--lt); box-shadow: none; }

/* Tafel */
.board-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.board-tools { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.board-sources { margin-top: 0.7rem; }
.board-warning { margin: 0.4rem 0 0; color: var(--warn); font-size: 0.86rem; }
.hit-meta .chips { justify-content: flex-end; margin-top: 0.2rem; }
.board-filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.6rem; margin-top: 0.8rem; align-items: end; }
.table-wrap { overflow-x: auto; margin-top: 0.8rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.45rem 0.4rem; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
td.time { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.time .plan { font-weight: 600; }
tr.cancelled td.time .plan, tr.cancelled td.dir { text-decoration: line-through; color: var(--muted); }
.delay { font-weight: 600; font-variant-numeric: tabular-nums; }
.delay.ok { color: var(--ok); }
.delay.warn { color: var(--warn); }
.delay.bad { color: var(--bad); }
.changed { font-weight: 700; color: var(--warn); }
.sub { display: block; color: var(--muted); font-size: 0.84rem; margin-top: 0.15rem; }
.sub.alert-ref { color: var(--warn); }
.sub.source-note { min-width: 13rem; }  /* Fehler und Hinweise der Quellen nicht wortweise umbrechen */
.sub.alert-ref.disruption { color: var(--bad); }
/* Hinweise zu einer Abfahrt, eingeklappt: nur die Anzahl, aufklappbar */
.dep-notes { margin-top: 0.15rem; font-size: 0.84rem; }
.dep-notes > summary, .trip-notes > summary {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; list-style: none; color: var(--warn); font-weight: 600;
}
.dep-notes.bad > summary, .trip-notes.bad > summary { color: var(--bad); }
.dep-notes > summary::-webkit-details-marker, .trip-notes > summary::-webkit-details-marker { display: none; }
.dep-notes > summary::before, .trip-notes > summary::before {
  content: ""; width: 0.38em; height: 0.38em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s;
}
.dep-notes[open] > summary::before, .trip-notes[open] > summary::before { transform: rotate(45deg); }
.dep-notes > .sub { margin-top: 0.2rem; }
/* Hinweise zur Fahrt: hinter den Halten, eingeklappt */
.trip-notes > summary { display: flex; }
.trip-notes[open] > summary { margin-bottom: 0.8rem; }
.trip-reasons { margin-bottom: 0.8rem; color: var(--warn); }
.trip-reasons p { margin: 0.2rem 0 0; color: var(--text); }

/* Störungen */
.alert {
  border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 6px;
  padding: 0.6rem 0.8rem; margin-top: 0.6rem; background: var(--surface);
}
.alert.disruption { border-left-color: var(--bad); }
.alert.notice { border-left-color: var(--accent); }
.alert h3 { margin: 0.25rem 0; }
.alert p { margin: 0.3rem 0; white-space: pre-line; }
.alert .meta { color: var(--muted); font-size: 0.84rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; align-items: end; }

/* Ereignisse */
.events { list-style: none; margin: 0.5rem 0 0; padding: 0; max-height: 18rem; overflow-y: auto; font-size: 0.88rem; }
.events li { padding: 0.3rem 0; border-bottom: 1px solid var(--line); display: flex; gap: 0.6rem; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Verbindungen */
.places { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.6rem; align-items: end; }
.place { position: relative; min-width: 0; }
.field { display: flex; gap: 0.4rem; }
.field input { flex: 1; }
.swap { height: 2.4rem; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; list-style: none; margin: 0.2rem 0 0; padding: 0.2rem 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; max-height: 20rem; overflow-y: auto;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.15);
}
.suggest li { padding: 0.45rem 0.7rem; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-2); }
.suggest .kind { color: var(--muted); font-size: 0.8rem; margin-left: 0.4rem; }
/* breit genug für Datum mit Uhrzeit (gut 200 px) und die längsten Auswahltexte; auf dem Handy eine Spalte */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 0.8rem; margin-top: 0.9rem; align-items: end; }
.seg { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; padding: 0.45rem 0; }
.seg label { display: flex; gap: 0.3rem; align-items: center; color: var(--text); font-size: 0.95rem; margin: 0; }
.checks .check { margin: 0.45rem 0; }
.modes { border: 0; padding: 0; margin: 0.9rem 0 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.modes legend { font-size: 0.85rem; color: var(--muted); padding: 0; margin-bottom: 0.3rem; }
.modes label { display: flex; gap: 0.3rem; align-items: center; color: var(--text); font-size: 0.92rem; margin: 0; }

.journey { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 0.7rem; }
.journey.at_risk { border-left: 4px solid var(--warn); }
.journey.broken { border-left: 4px solid var(--bad); }
.journey > summary { list-style: none; cursor: pointer; padding: 0.75rem 1rem; }
.journey > summary::-webkit-details-marker { display: none; }
.j-top { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; align-items: baseline; }
.j-times { font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.j-meta { color: var(--muted); font-size: 0.9rem; }
.j-lines { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin-top: 0.4rem; }
.j-lines .walk { color: var(--muted); font-size: 0.85rem; }
.warnings { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.warnings li { color: var(--warn); }
.journey.broken .warnings li { color: var(--bad); }
/* wann losgehen: unter der Abfahrt im Kopf der Verbindung (Livehub) bzw. über den Abschnitten (Myzel) */
.depart { margin-top: 0.4rem; font-size: 0.92rem; color: var(--text); }
.depart .late { color: var(--warn); }
.depart .btn { margin-top: 0.1rem; }
.legs > .depart { padding-top: 0.6rem; margin-top: 0; }
/* gespeicherte Verbindungen oben bei den Abfahrten */
.saved-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.saved-item:last-child { margin-bottom: 0; }
.saved-main { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit;
  padding: 0.75rem 1rem 0.4rem; cursor: pointer; border-radius: inherit; }
.saved-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.saved-actions { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0 1rem 0.6rem; }
.saved-actions label.check { margin: 0; font-size: 0.9rem; }
.legs { padding: 0 1rem 0.8rem; }
.leg { display: grid; grid-template-columns: minmax(3.2rem, max-content) 1fr; gap: 0.2rem 0.8rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.leg .t { font-variant-numeric: tabular-nums; white-space: nowrap; }
.leg .t .d { display: block; }
.leg .stopname { font-weight: 600; }
.leg .via { color: var(--muted); font-size: 0.85rem; }
.leg.walk { color: var(--muted); }
.leg details { margin-top: 0.3rem; font-size: 0.86rem; }
/* Fahrzeugposition zum Abschnitt bzw. zur Abfahrt (siehe vehicle.js); der Punkt entspricht dem auf der Netzplanlinie */
.nl-veh { font-size: 0.85rem; margin-top: 0.15rem; }
.nl-veh:empty { display: none; }
/* ganze Karte bzw. Zeile führt zum Verlauf der Fahrt (linkTo in ui.js) */
.go { cursor: pointer; }
.go:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
tr.go:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.nl-veh::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 0.45rem; vertical-align: 0.1em;
  border-radius: 50%; background: currentColor; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c, var(--accent));
}
.leg details ol { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.pager { display: flex; justify-content: space-between; gap: 0.6rem; margin: 0.8rem 0; }
.recent-head { margin-top: 0; }
.recent-head h2 { margin: 0; }
.recent { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.3rem; }
.recent li { display: flex; gap: 0.4rem; align-items: center; min-width: 0; }
.recent-pick { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--text); font: inherit;
  padding: 0.35rem 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-pick:hover, .recent-pick:focus-visible { color: var(--accent); }

/* Zustand */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.empty { color: var(--muted); padding: 0.8rem 0; }
.loading { color: var(--muted); padding: 0.8rem 0; }
.loading::after { content: " …"; }

@media (max-width: 720px) {
  main { padding: 0.75rem 16px; }
  .top { gap: 0.5rem; padding: 0.5rem 16px; }
  .tabs { order: 3; flex-basis: 100%; position: relative; flex-wrap: nowrap; gap: 0.15rem; }
  /* schmal: vier gleich breite Knöpfe, Symbol über der Beschriftung; das Menü klappt in voller Breite auf */
  .nav-group { position: static; flex: 1 1 0; min-width: 0; }
  .nav-group.user { margin-left: 0; }
  .nav-head { flex-direction: column; gap: 0.1rem; width: 100%; padding: 0.3rem 0.2rem; font-size: 0.8rem; }
  .nav-label { max-width: 100%; }
  .nav-head svg.chev { display: none; }
  .nav-menu, .nav-menu.to-left { left: 0; right: 0; width: auto; min-width: 0; max-width: none; }
  .places { grid-template-columns: 1fr; }
  .swap { justify-self: end; height: auto; }
  .board-filters { grid-template-columns: 1fr 1fr; }
  .board-filters .btn { grid-column: 1 / -1; }
  .col-src { display: none; }
  th, td { padding: 0.4rem 0.25rem; }
  .searchbar { flex-wrap: wrap; }
  .searchbar input { flex-basis: 100%; }
}

/* --- Ergänzungen der App ---------------------------------------------------------------------- */
#views, #auth { width: 100%; }
.brand { display: flex; align-items: center; gap: 0.5rem; color: var(--text); text-decoration: none; }
.brand img { border-radius: 6px; }
.small { font-size: 0.85rem; }
select.small { width: auto; padding: 0.3rem 0.5rem; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.wide { width: 100%; }
.stack { display: grid; gap: 0.5rem; }
.or { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.85rem; margin: 1rem 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.fieldset { margin-bottom: 0.8rem; }
.fieldset .hint { margin-top: 0.25rem; }
.mailform { margin-top: 0.4rem; }
.panel > h1 + form, .panel > h1 + p { margin-top: 0.8rem; }

.items { list-style: none; margin: 0.4rem 0 0.6rem; padding: 0; }
.item { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; flex-wrap: wrap;
  padding: 0.6rem 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item > div:first-child { min-width: 0; flex: 1 1 16rem; }
.item .row { margin-top: 0; }
tr.warnrow td { color: var(--warn); }

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 1.2rem; width: min(440px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgb(0 0 0 / 0.3);
}
.dialog.wide { width: min(620px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-text { font-size: 1.02rem; margin-top: 0; }
.secret {
  font-family: var(--mono); font-size: 0.9rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.7rem; white-space: pre-wrap; word-break: break-all; user-select: all; margin: 0.6rem 0;
}
.secret-inline { word-break: break-all; }
.qr { display: flex; justify-content: center; margin: 0.6rem 0; }
.qr img { background: #fff; padding: 6px; border-radius: 6px; max-width: 100%; height: auto; }

#toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: min(520px, calc(100vw - 32px)); padding: 0.65rem 1rem; border-radius: 8px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}
#toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 720px) {
  .item { align-items: flex-start; }
}
.panel .kv + form, .panel form + form { margin-top: 1rem; }

/* --- Überwachung und Meldungen ---------------------------------------------------------------- */
.slots { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.slot { display: grid; grid-template-columns: minmax(3.4rem, max-content) 1fr; gap: 0.2rem 0.9rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.slot:first-child { border-top: 0; }
.slot.done { opacity: 0.6; }
.slot-time { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.slot-main { min-width: 0; }
.slot-name { font-weight: 600; color: var(--text); text-decoration: none; }
.slot-name:hover { text-decoration: underline; }
.slot-dep { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; margin-top: 0.35rem; }
.slot-dep .dir { min-width: 0; }
.slot-dep .time { font-variant-numeric: tabular-nums; }
.slot-dep .sub, .slot-dep .dep-notes { flex-basis: 100%; margin-top: 0; }
.slot-dep.cancelled .dir, .slot-dep.cancelled .time { text-decoration: line-through; color: var(--muted); }
.slot-dep.gone { opacity: 0.6; }
.group-title { display: flex; gap: 0.5rem; align-items: center; margin: 1rem 0 0.2rem; font-size: 0.95rem; }
.group-title a { color: inherit; }
.panel > .group-title:first-of-type { margin-top: 0.2rem; }
.switch { margin: 0; white-space: nowrap; }

.editor .part { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem 0.4rem; margin: 0 0 1rem; min-width: 0; }
.editor .part > legend { padding: 0 0.4rem; font-weight: 600; color: var(--text); }
.editor .chips.spaced { margin: 0 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; }
.grid2.tight { gap: 0 1rem; }
.inline { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.4rem; }
.inline.wrap { flex-wrap: wrap; }
.inline > input[type="text"] { flex: 1 1 10rem; width: auto; }
input.short { width: auto; min-width: 6.5rem; }
input[type="time"], input[type="date"], textarea {
  padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit;
}
.taglist { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; min-height: 1.9rem; }
.tag {
  display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.1rem 0.15rem 0.1rem 0.6rem; border-radius: 999px;
  background: var(--info-bg); font-variant-numeric: tabular-nums;
}
.tag-x { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 1.05rem; line-height: 1; padding: 0.1rem 0.4rem; border-radius: 999px; }
.tag-x:hover { color: var(--bad); }
.weekdays { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; }
.weekdays .day { display: flex; gap: 0.25rem; align-items: center; color: var(--text); font-size: 0.95rem; margin: 0; }
.places.two { grid-template-columns: 1fr 1fr; }
.picks { display: grid; gap: 0.5rem; margin: 0.2rem 0 0.6rem; }
.pick { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.pick .label { margin: 0 0.3rem 0 0; }
.pick-btn { border: 1px solid transparent; background: none; padding: 0.1rem; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); opacity: 0.55; }
.pick-btn.text { border-color: var(--line); padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.85rem; }
.pick-btn.on { opacity: 1; border-color: var(--accent); }
.pick-btn:hover { opacity: 1; }
.checks { display: grid; gap: 0.1rem; }
.rules .grid3 { margin-bottom: 0.4rem; }

.notes { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.note { border-left: 3px solid var(--line); padding: 0.4rem 0 0.5rem 0.8rem; margin: 0.6rem 0; }
.note.ok { border-left-color: var(--ok); }
.note.warn { border-left-color: var(--warn); }
.note.bad { border-left-color: var(--bad); }
.note.info { border-left-color: var(--accent); }
.note strong { display: block; margin-top: 0.2rem; }
.message-body { white-space: pre-line; color: var(--muted); margin: 0.3rem 0 0; font-size: 0.92rem; }
.dialog .message-body { color: var(--text); }

@media (max-width: 720px) {
  .places.two { grid-template-columns: 1fr; }
  .slot { grid-template-columns: 1fr; }
  .slot-time { font-size: 0.9rem; color: var(--muted); }
}
a.btn { text-decoration: none; color: var(--text); }
a.btn.primary { color: var(--accent-text); }
a.chip { text-decoration: none; }

/* Karte einer Verbindung */
.map-dialog { width: min(1100px, calc(100vw - 32px)); height: min(860px, calc(100dvh - 32px)); max-width: none; max-height: none;
  padding: 0; display: none; flex-direction: column; overflow: hidden; }
.map-dialog[open] { display: flex; }
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line); }
.map-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.6rem; min-width: 0; }
.map-title .j-lines { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.map-box { flex: 1; min-height: 240px; position: relative; }
/* Karte einer Fahrt (trip.js): ruhige Vorschau ohne Rand innen, Antippen öffnet sie groß */
.panel.trip-map-panel, [data-design] .panel.trip-map-panel { padding: 0; overflow: hidden; }
.trip-map { height: 200px; position: relative; cursor: pointer; }
.trip-map:focus-visible { outline-offset: -3px; }
.map-hint { margin: 0; padding: 0.6rem 0.8rem; }
@media (max-width: 640px) {
  .map-dialog { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
}
.maplibregl-popup-content { background: var(--surface); color: var(--text); border-radius: 10px; padding: 0.6rem 2rem 0.6rem 0.75rem;
  font: inherit; font-size: 0.9rem; box-shadow: 0 6px 24px rgb(0 0 0 / 0.25); }
.maplibregl-popup-close-button { color: var(--text); font-size: 1.2rem; padding: 0 0.4rem; }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.map-popup { display: grid; gap: 0.15rem; }
.map-popup .bad { color: var(--bad); }

/* Statistik */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin-top: 0.8rem; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius-s, 6px); padding: 0.6rem 0.75rem; background: var(--surface); }
.kpi-val { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-label { color: var(--text); font-size: 0.9rem; }
.kpi-sub { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.chart { margin-top: 1.2rem; }
.chart:first-child { margin-top: 0; }
.chart > h3 { margin-bottom: 0.6rem; }
.chart details { margin-top: 0.5rem; font-size: 0.88rem; }
.chart summary { cursor: pointer; color: var(--muted); }
.dist { display: grid; gap: 0.35rem; }
.dist-row { display: grid; grid-template-columns: minmax(7rem, 12rem) 1fr auto; gap: 0.6rem; align-items: center; font-size: 0.9rem; }
.dist-bar { height: 0.9rem; position: relative; }
.dist-bar > span { position: absolute; left: 0; top: 0; bottom: 0; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--muted); }
.dist-bar > .ok { background: var(--ok); }
.dist-bar > .warn { background: var(--warn); }
.dist-bar > .bad { background: var(--bad); }
.dist-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plot-wrap { position: relative; }
.plot { position: relative; height: 10rem; padding-left: 3.4rem; display: flex; gap: 2px; touch-action: pan-y; }
.plot .grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); height: 0; }
.plot .grid > span { position: absolute; left: 0; transform: translateY(-50%); font-size: 0.72rem; color: var(--muted);
  background: var(--surface); padding-right: 0.25rem; font-variant-numeric: tabular-nums; }
.col { position: relative; flex: 1 1 0; min-width: 0; cursor: default; }
.col.on { background: var(--surface-2); }
.bar { position: absolute; left: 0; right: 0; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar.neg { border-radius: 0 0 4px 4px; }
.col.on .bar { filter: brightness(1.15); }
.xlabels { display: flex; gap: 2px; padding-left: 3.4rem; margin-top: 0.25rem; height: 1.1rem; }
.xlabels > span { flex: 1 1 0; min-width: 0; font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: visible;
  font-variant-numeric: tabular-nums; }
.tip { position: absolute; top: 0.2rem; transform: translateX(-50%); z-index: 5; pointer-events: none; width: max-content;
  max-width: min(18rem, 90%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.55rem; font-size: 0.82rem;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.18); }
table.stats td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.stats th:not(:first-child) { text-align: right; }
table.stats td:first-child { min-width: 6rem; }
.st-more { margin-top: 0.8rem; }
.st-more > summary { cursor: pointer; color: var(--muted); }
#st-custom { margin-top: 0.8rem; }
@media (max-width: 520px) {
  .dist { gap: 0.55rem; }
  .dist-row { grid-template-columns: 1fr auto; gap: 0.2rem 0.6rem; }
  .dist-bar { grid-column: 1 / -1; grid-row: 2; height: 0.7rem; }
}

/* Tafel (Anzeigeseite /anzeige/ und Vorschau in der App) – Größen in em, die Seite skaliert die Schrift */
.tafel { display: flex; flex-direction: column; gap: 0.35em; }
.tafel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; padding-bottom: 0.3em;
  border-bottom: 1px solid var(--line); }
.tafel-head h1 { font-size: 1.25em; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tafel-clock { font-size: 1.25em; font-weight: 700; font-variant-numeric: tabular-nums; }
.tafel-stops { color: var(--muted); font-size: 0.75em; margin: 0; }
.tafel-stop { font-size: 0.85em; margin: 0.6em 0 0; color: var(--muted); }
/* Zeilen als Tabelle: Spalten über alle Fahrten bündig, alles in einer Zeile */
table.tafel-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.tafel-table th, .tafel-table td { padding: 0.32em 0.35em; border: 0; vertical-align: middle; white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.tafel-table th:first-child, .tafel-table td:first-child { padding-left: 0; }
.tafel-table th:last-child, .tafel-table td:last-child { padding-right: 0; }
.tafel-table thead th { font-size: 0.62em; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: 1px solid var(--line); }
.tafel-table tbody { border-bottom: 1px solid var(--line); }
.tafel-table .t-time { font-weight: 600; }
.tafel-table .t-rt { font-weight: 600; }
.tafel-table .t-rt .ok { color: var(--ok); }
.tafel-table .t-rt .warn { color: var(--warn); }
.tafel-table .t-rt .bad { color: var(--bad); }
.tafel-table .t-delay { font-size: 0.75em; margin-left: 0.3em; }
.tafel-table .t-plan { color: var(--muted); font-weight: 400; font-style: italic; }
.tafel .tafel-table .line { font-size: 0.8em; min-width: 3.2em; padding: 0.2em 0.4em; text-align: center; }
.tafel-table td.t-dest { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tafel-table .t-at { color: var(--muted); font-weight: 400; }
.tafel-table .t-plat, .tafel-table .t-in { text-align: right; }
.tafel-table td.t-plat { color: var(--muted); }
.tafel-table td.t-plat.changed { color: var(--warn); font-weight: 700; }
.tafel-table td.t-in { font-weight: 700; }
.tafel-table tr.cancelled .t-time, .tafel-table tr.cancelled .t-dest { text-decoration: line-through; color: var(--muted); }
.tafel-table tr.t-note td { padding-top: 0; font-size: 0.7em; color: var(--warn); white-space: normal; }
.tafel-table tbody.t-stop th { text-align: left; font-size: 0.8em; color: var(--muted); padding-top: 0.8em; font-weight: 600; }
.tafel-alerts { list-style: none; margin: 0.3em 0 0; padding: 0; font-size: 0.8em; }
.tafel-alerts li { border-left: 3px solid var(--bad); padding-left: 0.5em; margin-top: 0.3em; }
.tafel-foot { color: var(--muted); font-size: 0.7em; }
.tafel-empty { color: var(--muted); padding: 1em 0; margin: 0; }
.tafel.stale { opacity: 0.6; }
.tafel.off .tafel-empty { font-size: 1.2em; }
.tafel-preview { border: 1px solid var(--line); border-radius: var(--radius-s, 6px); padding: 0.8rem; margin-top: 0.8rem;
  background: var(--surface); }

/* --- Pixeluhren --------------------------------------------------------------------------------- */
.row.spaced { justify-content: space-between; }
.indent { margin-left: 1.6rem; }
.dim { opacity: 0.5; }
.fieldset.wide { grid-column: 1 / -1; }
.clock .warn, .clock-preview .warn, .editor .warn { color: var(--warn); }
.inline.color { margin-top: 0; }
.inline.color input[type="color"] { flex: none; width: 2.6rem; height: 2.3rem; padding: 2px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); cursor: pointer; }
.inline.color input[type="color"].dim { opacity: 0.35; }
.clock-lines { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.3rem; margin-top: 0.45rem; }
.clock-line { min-width: 0; overflow-x: auto; padding: 0.35rem 0.6rem; border-radius: 4px; background: #050505; color: #fff;
  font-family: var(--mono); font-size: 0.85rem; white-space: pre; }
.clock-badge { margin-right: 0.4rem; padding: 0 0.3rem; border-radius: 2px; }
.clock-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 1rem; align-items: start; }
.clock-editor > .editor { order: 1; margin: 0; }
.clock-preview { order: 2; position: sticky; top: 5rem; min-width: 0; margin: 0; }
.pixel-frame { margin: 0.7rem 0 0.4rem; padding: 6px; border-radius: 6px; background: #000; }
.pixel-clock { display: block; width: 100%; height: auto; }
.clock-json { max-height: 18rem; overflow: auto; margin: 0.4rem 0 0; padding: 0.6rem; border-radius: 6px;
  background: var(--surface-2); font-family: var(--mono); white-space: pre; }
.clock-preview details { margin-top: 0.6rem; }
details.awtrix > summary, .awtrix-group > summary { cursor: pointer; font-weight: 600; padding: 0.35rem 0; }
.editor details.part { padding-bottom: 0.6rem; }
.awtrix-group { border-top: 1px solid var(--line); padding: 0.15rem 0; }
.awtrix-group:first-of-type { border-top: 0; }
.awtrix-group > summary .chip { margin-left: 0.4rem; font-weight: 400; }
/* Zeitplan: je Ticker ein Tagesbalken */
.sched { display: grid; gap: 0.25rem; margin-top: 0.6rem; }
.sched-row { display: grid; grid-template-columns: minmax(6rem, 11rem) minmax(0, 1fr); gap: 0.6rem; align-items: center; }
.sched-label { overflow: hidden; font-size: 0.85rem; text-overflow: ellipsis; white-space: nowrap; }
.sched-row.is-off .sched-label { color: var(--muted); text-decoration: line-through; }
.sched-clock { margin-top: 0.5rem; font-size: 0.9rem; font-weight: 600; }
.sched-track { position: relative; height: 1.1rem; border-radius: 4px; background: var(--surface-2); }
.sched-axis .sched-track { height: 1rem; background: none; }
.sched-hour { position: absolute; transform: translateX(-50%); color: var(--muted); font-size: 0.72rem; }
.sched-hour:first-child { transform: none; }
.sched-hour:last-child { transform: translateX(-100%); }
.sched-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.sched-seg { position: absolute; top: 2px; bottom: 2px; min-width: 2px; border-radius: 3px; background: var(--accent); }
.sched-seg.is-display { background: var(--muted); opacity: 0.55; }
.sched-seg.is-outside { background: color-mix(in srgb, var(--accent) 40%, transparent); }
.sched-seg.is-every { background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 6px); }
.sched-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--bad); }
@media (max-width: 960px) {
  .clock-editor { grid-template-columns: minmax(0, 1fr); }
  .clock-preview { position: static; order: 0; }
}
@media (max-width: 520px) {
  .sched-row { grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.4rem; }
}
