:root {
  --bg: #0f1115;
  --bg2: #171a21;
  --card: #1d212a;
  --card2: #242935;
  --fg: #e8ecf3;
  --muted: #9aa4b8;
  --accent: #4da3ff;
  --green: #35d07f;
  --amber: #ffb020;
  --red: #ff5f56;
  --violet: #b57bff;
  --line: #2b3140;
  --ease: cubic-bezier(.4, 0, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
  /* Manche Android-Browser (und WebViews) blasen Text eigenmaechtig auf, wenn
     er klein erscheint - dann sieht das Panel dreimal so gross aus wie die
     Menueleiste. Das wird hier abgeschaltet; die Groessen kommen aus dem CSS. */
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { padding-bottom: 76px; }

/* ---------- Material Icons (selbst gehostet) ---------- */
.ic { width: 20px; height: 20px; fill: currentColor; display: inline-block; vertical-align: -4px; flex: none; }
.icon-btn .ic { width: 22px; height: 22px; }
.map-btn .ic { width: 22px; height: 22px; }
.tabbtn .ic { width: 25px; height: 25px; }
.pill .ic, .seg-btn .ic { margin-right: 7px; }

.topbar { position: sticky; top: 0; z-index: 500; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; padding: 10px 14px;
  background: rgba(15,17,21,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Das Logo IST der Bus: gefuellte Silhouette in Seitenansicht mit
   Fensterband und zwei Raedern. Kein Gesicht, kein Farbquadrat - der
   Bus steht direkt auf der dunklen Kopfleiste und ist sofort als Bus
   erkennbar. */
.logo { position: relative; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 12px; padding: 0; border: 1px solid transparent; background: transparent;
  cursor: pointer; flex: none; overflow: visible;
  transition: transform .15s var(--ease), background .18s var(--ease), border-color .18s var(--ease); }
.logo:hover, .logo:focus-visible { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); }
.logo:active { transform: scale(.92); }
.logo-svg { width: 36px; height: 36px; display: block; }
.logo-body { fill: var(--accent); }
.logo-glass { fill: #0b0d11; }
.logo-wheel { fill: #0b0d11; }
/* Der Seitenhieb: antippen und die Sprechblase erscheint */
.logo-tip { position: absolute; top: calc(100% + 10px); left: 0; z-index: 600; display: none;
  padding: 9px 12px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); font-size: 12.5px; line-height: 1.45; color: var(--fg);
  white-space: nowrap; font-weight: 500; }
.logo-tip::before { content: ""; position: absolute; top: -5px; left: 16px; width: 9px; height: 9px;
  transform: rotate(45deg); background: var(--card2); border-left: 1px solid var(--line);
  border-top: 1px solid var(--line); }
.logo-tip .ic { width: 14px; height: 14px; vertical-align: -2px; color: var(--accent); }
.logo:hover .logo-tip, .logo.show-tip .logo-tip { display: block; }
h1 { margin: 0; font-size: 15px; }
h2 { font-size: 15.5px; margin: 16px 0 10px; }
h3 { font-size: 12.5px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sub { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); display: grid; place-items: center; cursor: pointer;
  transition: transform .12s var(--ease), background .18s var(--ease), border-color .18s var(--ease); }
.icon-btn:hover { border-color: #3a4356; background: var(--card2); }
.icon-btn:active { transform: scale(.93); }
.icon-btn.spinning .ic { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* In der Android-Shell sitzt rechts oben das Zahnrad fuer die Server-Adresse:
   der Aktualisieren-Knopf rueckt damit nach links. */
body.in-apk #refreshBtn { margin-right: 44px; }

/* ---------- LIVE-Anzeige ---------- */
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800;
  letter-spacing: .1em; color: var(--green); border: 1px solid #1e5c3d; background: #13251c;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(53,208,127,.6); animation: pulse 2.4s infinite; }
.live-badge.loading i { animation-duration: .9s; }
.live-badge.stale { color: var(--amber); border-color: #6b4d12; background: #2a2110; }
.live-badge.stale i { background: var(--amber); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(53,208,127,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(53,208,127,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,208,127,0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-badge i { animation: none; }
  .leaflet-marker-icon { transition: none !important; }
  .veh-rot { transition: none !important; }
}

/* ---------- Städtewahl ----------
   Ein Auswahlfeld oben: der Tracker holt die Live-Daten nur fuer die
   gewaehlte Stadt. Die Staedte stehen nach Bundesland gruppiert.
   Das Feld ist kompakt - es ist nur so breit wie der Stadtname und
   steht links neben dem Hinweistext, nicht mehr ueber die ganze Breite. */
.regionbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.regionbar-label { font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; flex: none; }
.region-sel { flex: 0 1 auto; width: auto; min-width: 92px; max-width: min(250px, 58vw);
  appearance: none; -webkit-appearance: none; min-height: 44px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  padding: 10px 28px 10px 11px; border-radius: 10px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: border-color .18s var(--ease), background .18s var(--ease);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa4b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
.region-sel:hover { border-color: #3a4356; }
.region-sel:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Die Liste des Auswahlfelds: heller Text auf dunklem Grund, sonst
   unlesbar im Systemdialog. */
.region-sel option, .region-sel optgroup { background: #171a21; color: var(--fg); }
.regionbar-hint { flex: 1 1 220px; min-width: 0; color: var(--muted); font-size: 12px;
  line-height: 1.4; margin: 0; }
.regionbar-hint b { color: var(--fg); }
/* Auf dem Handy ist der Platz knapp - der Hinweis steht ohnehin in der
   Kopfzeile (dort wird die Stadt genannt). */
@media (max-width: 620px) { .regionbar-hint { display: none; } }

/* ---------- Unter-Tabs ----------
   Die Seiten "Verspaetungen" und "Daten" haben viele Abschnitte. Statt
   ewig zu scrollen gibt es oben eine Leiste. Sie bleibt beim Scrollen
   kleben, damit man jederzeit umschalten kann - ohne lange zurueck-
   scrollen zu muessen. */
.subtabs { position: sticky; top: var(--topbar-h, 60px); z-index: 400;
  display: flex; gap: 2px; margin: 0 -14px 14px; padding: 0 8px;
  background: rgba(15,17,21,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab { flex: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 11px 10px 9px; font: inherit; font-size: 13px; font-weight: 600;
  white-space: nowrap; border-bottom: 2px solid transparent;
  transition: color .18s var(--ease); }
.subtab:hover { color: var(--fg); }
.subtab.active { color: var(--fg); border-bottom-color: var(--accent); }
.subtab b { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--card2); color: var(--muted); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; }
.subtab.active b { background: rgba(77,163,255,.16); color: var(--accent); }
.subpane { display: none; }
.subpane.active { display: block; }
.subpane h3:first-child { margin-top: 4px; }
/* Die Leiste im Ranking liegt eine Ebene tiefer - da darf sie nicht mit
   negativem Rand aus dem Rahmen rutschen (sonst scrollt die Seite seitlich). */
#rankBox .subtabs { margin-left: 0; margin-right: 0; }

main { padding: 12px 14px 24px; max-width: 1100px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 18px; }
.tab-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: -6px 0 10px; }
.tab-note b { color: var(--fg); }
.rules { color: var(--muted); font-size: 12px; line-height: 1.6; padding-left: 18px; }
.rules b { color: var(--fg); }

.pill { border: 1px solid var(--line); background: var(--card); color: var(--fg);
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s var(--ease), background .18s var(--ease), border-color .18s var(--ease); }
.pill.primary { background: var(--accent); color: #08111c; border-color: transparent; font-weight: 600; }
.pill.small { padding: 5px 9px; font-size: 11.5px; }
.pill:active { transform: scale(.96); }
.pill:hover { border-color: #3a4356; }
.pill:disabled { opacity: .45; cursor: default; }
.pill:disabled:active { transform: none; }
.input { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-size: 15px; }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.seg { display: flex; gap: 6px; margin-bottom: 12px; }
.seg-btn { flex: 1; padding: 9px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s var(--ease), background .18s var(--ease); }
.seg-btn.active { background: var(--card2); color: var(--fg); border-color: var(--accent); }
.seg-btn:active { transform: scale(.97); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-actions { display: flex; gap: 6px; flex: none; }
.card-title { font-weight: 600; font-size: 14px; }
.card-sub { color: var(--muted); font-size: 11.5px; }
.dep-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 9px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line); }
.dep-row:first-of-type { border-top: 0; }
.dep-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 3px; }
.dep-meta .rel { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.dep-meta .flags { margin-top: 0; }
.line-badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 30px; padding: 0 7px;
  border-radius: 8px; background: var(--card2); border: 1px solid var(--line);
  font-weight: 700; font-size: 13px; vertical-align: middle; }
.line-badge.tram { background: #23303f; border-color: #2f4d66; color: #7fd0ff; }
.dir { font-size: 13px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { text-align: right; font-variant-numeric: tabular-nums; }
.time b { font-size: 15px; }
.delay { font-size: 11px; display: block; }
.delay.plus { color: var(--amber); }
.delay.minus { color: var(--accent); }
.delay.zero { color: var(--muted); }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.flag { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: var(--card2); white-space: nowrap; }
.flag.live { color: var(--green); border-color: #1e5c3d; background: #13251c; }
.flag.warn { color: var(--amber); border-color: #6b4d12; background: #2a2110; }
.flag.bad { color: var(--red); border-color: #6d2622; background: #2a1614; }
.flag.info { color: var(--accent); border-color: #22486e; background: #111f2c; }
.flag.plan { color: var(--muted); }
.flag.violet { color: var(--violet); border-color: #4b3272; background: #1e1730; }
.flag .ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
/* Flags mit Erklaerung sind Buttons - auf dem Handy gibt es keine Tooltips. */
button.flag { font-family: inherit; line-height: inherit; cursor: pointer;
  transition: transform .12s var(--ease), border-color .18s var(--ease); }
button.flag:active { transform: scale(.95); }
button.flag:hover { border-color: currentColor; }

/* ---------- Quickinfo ---------- */
.info-box { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 1200;
  width: min(540px, calc(100% - 24px)); max-height: 52vh; overflow-y: auto;
  background: var(--card2); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; box-shadow: 0 16px 44px rgba(0,0,0,.62);
  animation: info-in .22s var(--ease); }
@keyframes info-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.info-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.info-box-title { font-weight: 700; font-size: 14px; color: var(--fg); }
.info-box-head .icon-btn { margin-left: auto; width: 30px; height: 30px; flex: none; }
.info-box-text { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
/* Waehrend des Nachladens wird der Inhalt leicht abgedunkelt - so ist zu
   sehen, dass aktualisiert wird, ohne dass die Seite springt. */
.stack.refreshing { opacity: .55; transition: opacity .18s var(--ease); }
.stack.refreshing::after { content: ""; }

/* Das hidden-Attribut muss auch bei Elementen mit eigener display-Regel
   greifen (z. B. .chips{display:flex}) - sonst bleiben eingeklappte
   Bereiche sichtbar. */
[hidden] { display: none !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: 13px; cursor: pointer;
  transition: transform .12s var(--ease), border-color .18s var(--ease); }
.chip.active { border-color: var(--accent); color: var(--accent); }
.chip:active { transform: scale(.95); }

/* Aufklappbare Linienliste in der Suche. Die Liste ist sehr lang, deshalb
   ist sie standardmaessig eingeklappt - das Suchergebnis steht dann
   sofort im Bild, ohne dass man weit scrollen muss. */
.sec-toggle { display: flex; align-items: center; gap: 8px; width: 100%; margin: 14px 0 8px;
  padding: 8px 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; }
.sec-toggle .ic { width: 18px; height: 18px; transition: transform .2s var(--ease); }
.sec-toggle[aria-expanded="true"] .sec-chevron { transform: rotate(90deg); }
.sec-toggle:hover { color: var(--fg); }
.sec-count { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--fg);
  background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
#busResults { scroll-margin-top: 78px; }

.map-wrap { position: relative; }
#map { height: calc(100vh - 186px); min-height: 380px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: var(--card); }
/* Ebenen-Schalter: links oben, kompakt, damit die Karte frei bleibt.
   Der Linienfilter sitzt mit im Panel - so kollidiert er nie mit dem
   Zoom-Knopf rechts oben (auf dem Handy ein echtes Problem). */
.map-layers { position: absolute; top: 10px; left: 10px; z-index: 450; display: flex;
  flex-direction: column; align-items: flex-start; gap: 6px; max-width: calc(100% - 76px);
  background: rgba(23,26,33,.92); padding: 7px 9px;
  border-radius: 12px; border: 1px solid var(--line); backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.map-layer-row { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.map-layers .switch .ic { width: 15px; height: 15px; opacity: .8; }
/* Linienfilter: nur die gewaehlte Linie bleibt auf der Karte sichtbar */
.map-line { display: flex; align-items: center; gap: 6px; width: 100%;
  border-top: 1px solid var(--line); padding-top: 6px; }
.map-line .ic { width: 17px; height: 17px; opacity: .75; flex: none; }
/* Das Feld fuellt die Breite des Panels aus und bekommt eine sichtbare
   Feldoptik - sonst schwebt es links in einem breiten, leeren Panel
   (auf dem Desktop besonders auffaellig). */
.map-line-input { flex: 1 1 auto; min-width: 0; width: auto; border: 1px solid var(--line);
  background: var(--card2); border-radius: 9px;
  color: var(--fg); font-size: 15px; font-weight: 600; letter-spacing: .04em;
  padding: 8px 10px; outline: none; }
.map-line-input:focus { border-color: var(--accent); }
.map-line-input::placeholder { font-weight: 400; letter-spacing: 0; color: var(--muted); opacity: .8; }
.map-line-clear { width: 30px; height: 30px; display: grid; place-items: center; border: 0;
  border-radius: 8px; background: var(--card2); color: var(--muted); cursor: pointer; flex: none; }
.map-line-clear[hidden] { display: none; }
.map-line-clear .ic { width: 15px; height: 15px; }
.map-line-clear:active { transform: scale(.93); }
/* Busse in der Liste sind antippbar */
.bus-card { cursor: pointer; transition: transform .12s var(--ease), border-color .18s var(--ease); }
.bus-card:hover { border-color: var(--accent); }
.bus-card:active { transform: scale(.995); }
.bus-hint { display: flex; align-items: center; gap: 4px; margin-top: 7px; opacity: .5; }
.bus-hint .ic { width: 13px; height: 13px; }
/* Fehlermeldung auf der Karte: kein stilles Leerbild */
.map-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 460; width: min(300px, calc(100% - 32px)); }
.map-msg-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 16px; border-radius: 14px; border: 1px solid #6d2622; background: rgba(42,22,20,.96);
  color: var(--fg); box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.map-msg-card span { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.map-msg-card .pill { margin-top: 2px; }

/* ---------- Alle Verspaetungen ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px;
  border-radius: 12px; background: var(--card2); border: 1px solid var(--line); }
.stat-tile b { font-size: 21px; line-height: 1.1; color: var(--fg); font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.25; }
.stat-tile.bad { border-color: #6d2622; background: #2a1614; }
.stat-tile.bad b { color: var(--red); }
.stat-tile.warn { border-color: #6b4d12; background: #2a2110; }
.stat-tile.warn b { color: var(--amber); }
.delay-card { cursor: pointer; transition: transform .12s var(--ease), border-color .18s var(--ease); }
.delay-card:hover { border-color: var(--accent); }
.delay-card:active { transform: scale(.995); }
/* Aktions-Buttons: rechts unten, daudiereich erreichbar */
.map-actions { position: absolute; right: 10px; bottom: 54px; z-index: 450; display: flex;
  flex-direction: column; gap: 8px; }
.map-btn { width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(23,26,33,.94);
  color: var(--fg); cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.45);
  transition: transform .12s var(--ease), background .18s var(--ease); }
.map-btn:hover { background: var(--card2); }
.map-btn:active { background: var(--card2); transform: scale(.94); }
.switch { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.switch input { width: 17px; height: 17px; accent-color: var(--accent); }
/* Legende: sitzt ueber der Leaflet-Attribution unten rechts, damit sich
   die beiden nicht ueberlagern. */
.legend { position: absolute; bottom: 26px; left: 10px; right: auto; z-index: 450;
  max-width: calc(100% - 80px); font-size: 11px; line-height: 1.4;
  color: var(--muted); background: rgba(23,26,33,.92); padding: 7px 10px; border-radius: 9px;
  border: 1px solid var(--line); backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0,0,0,.4); cursor: pointer; }
.legend:hover { border-color: rgba(255,255,255,.22); }
/* Ist die Quickinfo offen, verschwindet die Legende - sie wuerde sonst
   hinter dem Erklaerungsfenster verschwinden. */
body.info-open .legend { display: none; }
.legend-hint { display: flex; align-items: center; gap: 4px; margin-top: 3px;
  font-size: 10px; color: var(--fg); opacity: .75; }
.legend-hint .ic { width: 13px; height: 13px; }
.legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle; }
/* Leaflet-Steuerung auf die rechte obere Ecke, damit sie nicht mit den Schaltern kollidiert */
.leaflet-top.leaflet-right { margin-top: 8px; margin-right: 8px; }
.leaflet-control-zoom a { width: 40px !important; height: 40px !important; line-height: 40px !important;
  font-size: 20px !important; }
/* Die Leaflet-Steuerelemente sind standardmaessig weiss - das bricht im
   dunklen Design. Zoom-Knoepfe und Quellenangabe bekommen denselben Look
   wie die eigenen Karten-Knoepfe. */
.leaflet-control-zoom { border: 1px solid var(--line) !important; border-radius: 12px !important;
  overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.45) !important; }
.leaflet-control-zoom a { background: rgba(23,26,33,.94) !important; color: var(--fg) !important;
  border-bottom-color: var(--line) !important; }
.leaflet-control-zoom a:hover { background: var(--card2) !important; color: var(--accent) !important; }
.leaflet-control-attribution { background: rgba(23,26,33,.86) !important; color: var(--muted) !important;
  font-size: 10px !important; border-radius: 8px 0 0 0; padding: 2px 6px !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-container { background: #12151b; }
/* Die OSM-Kacheln sind hell. Mit invert + hue-rotate wird daraus eine
   dunkle Karte, die aber ihre Farben behaelt (Waelder, Gewaesser,
   Autobahnen) - eine echte Dark-Mode-Karte statt eines grauen Brettes.
   Die Beschriftungen bleiben dabei hell und lesbar. */
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(1.04) saturate(.62) contrast(.95); }
.leaflet-container { background: #12151b; }

/* ---------- Fahrzeug-Marker: Bus in Dachansicht ----------
   Wichtig: position muss "absolute" bleiben. Leaflet setzt seine Marker
   ueber .leaflet-marker-icon { position: absolute; left: 0; top: 0 } und
   positioniert sie per transform. Mit "relative" (Stand vor v34) lagen die
   Marker im normalen Textfluss - jeder wurde um 22 px nach unten
   geschoben, wodurch die Busse scheinbar alle suedlich von Graz standen. */
.veh-icon { position: absolute; width: 44px; height: 22px; background: none; border: 0;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.veh-rot { position: absolute; inset: 0; transform: rotate(var(--rot, 0deg));
  transition: transform .8s var(--ease); }
.veh-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.veh-body { fill: var(--veh-fill, #ffcf5c); stroke: var(--veh-stroke, #0b0d11);
  stroke-width: var(--veh-stroke-w, 2.2); stroke-linejoin: round; }
.veh-glass { fill: rgba(9,14,24,.55); }
.veh-light { fill: #fff6cf; }
.veh-wheel { fill: #0b0d11; }
/* Die Liniennummer sitzt IN der Karosserie - genau mittig ueber dem Dach.
   Sie dreht sich mit dem Bus mit und wird gegenlaeufig gedreht: so bleibt
   sie immer lesbar und sitzt dabei immer mittig in der Karosserie, egal
   wie der Bus steht (bei 90 Grad waere sie sonst seitlich herausgerutscht). */
.veh-num { position: absolute; left: 10px; top: 0; bottom: 0; width: 23px; display: grid;
  place-items: center; font-size: 10px; font-weight: 800; color: #0b0d11;
  letter-spacing: -.04em; pointer-events: none;
  transform: rotate(calc(-1 * var(--rot, 0deg))); transform-origin: 50% 50%;
  transition: transform .8s var(--ease); }
.veh-num-long { font-size: 8.6px; letter-spacing: -.06em; }
.veh-icon.tram { --veh-fill: #6ad2ff; }
.veh-icon.warn { --veh-fill: #ffb020; }
.veh-icon.planned, .veh-icon.ended { --veh-fill: #99a3b5; }
/* echte Fahrzeugposition aus der VAO-HAFAS-Schnittstelle */
.veh-icon.real { --veh-stroke: #35d07f; --veh-stroke-w: 3; }
.veh-icon.disagree { --veh-stroke: #ff5f56; --veh-stroke-w: 3; }
.veh-icon.real .veh-svg { filter: drop-shadow(0 0 6px rgba(53,208,127,.95)); }
.veh-icon.disagree .veh-svg { filter: drop-shadow(0 0 6px rgba(255,95,86,1)); }
.veh-icon.real.disagree .veh-svg {
  filter: drop-shadow(0 0 5px rgba(255,95,86,1)) drop-shadow(0 0 9px rgba(53,208,127,.7)); }
/* Sanfte Bewegung statt Sprung: Leaflet setzt die Position per transform */
.leaflet-marker-icon { transition: transform .9s var(--ease); }
.leaflet-zoom-anim .leaflet-marker-icon { transition: none; }
.leaflet-pan-anim .leaflet-marker-icon { transition: none; }

.legend .ok { color: var(--green); }
.legend .rot { color: var(--red); }
.legend .grey { color: var(--muted); }
.legend .dot.ok { background: var(--green); }
.legend .dot.rot { background: var(--red); }
.legend .dot.grey { background: #99a3b5; }
/* Zeile unter der Legende: wie viele abgeschlossene Fahrten es gerade gibt. */
.legend-note { margin-top: 4px; font-size: 10px; color: var(--muted); line-height: 1.35; }

/* ---------- Archiv ---------- */
.arc-row { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 9px; align-items: center;
  font-size: 13px; padding: 7px 0; border-top: 1px solid var(--line); }
.arc-row:first-of-type { border-top: 0; }
.arc-row .arc-bus { font-weight: 700; }
.arc-row .arc-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.arc-row .arc-delay { font-variant-numeric: tabular-nums; font-weight: 600; }
.arc-scroll { max-height: 260px; overflow-y: auto; }

/* ---------- Auswahl-Panel (eine Fahrt genau ansehen) ----------
   Festes Panel am unteren Rand der Karte. Kein Popup: ein Popup schiebt die
   Karte in die Mitte des Bildschirms - der Nutzer verliert den Ueberblick.
   Das Panel steht fest, die Karte bleibt liegen. */
.trip-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 500;
  background: rgba(20,23,29,.97); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.55);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  backdrop-filter: blur(8px); }
.trip-sheet[hidden] { display: none; }
/* Kurz-Modus: nur Kopf und eine Zeile. Dann hat die Karte fast die ganze
   Hoehe - und der Fahrweg ist wirklich zu sehen. */
.trip-sheet.min .sheet-body { display: none; }
.trip-sheet.min .sheet-summary { margin-top: 4px; }
.sheet-head { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.sheet-summary { margin: 6px 0 0; font-size: 12.5px; line-height: 1.35; color: var(--fg); }
.sheet-summary:empty { display: none; }
.sheet-min { width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  color: var(--fg); cursor: pointer; }
.sheet-min:active { transform: scale(.94); }
/* Pfeil nach unten = einklappen, nach oben = aufklappen.
   Das Chevron-Icon zeigt nach links - mit -90 Grad wird es nach oben. */
.sheet-min .ic { transform: rotate(90deg); }
.trip-sheet.min .sheet-min .ic { transform: rotate(-90deg); }
.sheet-title { min-width: 0; }
.sheet-title b { display: block; font-size: 13.5px; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-title span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-close { width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  color: var(--fg); cursor: pointer; }
.sheet-close:active { transform: scale(.94); }
/* Text des Panels auf dem Niveau der Menueleiste (10-13 px) - nicht groesser.
   Sonst wirkt das Panel auf dem Handy wie eine Ueberschrift. */
.sheet-body { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; }
.sheet-row { display: grid; grid-template-columns: 108px 1fr; gap: 8px; font-size: 12px;
  line-height: 1.3; align-items: baseline; }
.sheet-row > b { color: var(--muted); font-weight: 600; font-size: 11px; }
.sheet-row > span { color: var(--fg); min-width: 0; overflow-wrap: anywhere; }
.sheet-row .muted { color: var(--muted); }
.sheet-row .ok { color: var(--green, #4ec98a); }
/* Warnhinweis im Panel (z. B. Position passt nicht zum Fahrweg). */
.sheet-row .warn { color: var(--amber); }
/* Die Knoepfe bekommen ihre Breite vom Text - nicht gestreckt ueber die
   ganze Breite. So wirken sie wie die Pillen der App und nicht wie Schilder. */
.sheet-actions { display: flex; gap: 7px; margin-top: 8px; }
.sheet-actions .pill { flex: 0 1 auto; min-height: 44px; font-size: 12.5px;
  padding: 8px 13px; justify-content: center; }
/* Solange das Panel offen ist, haben die Karten-Knoepfe rechts unten keinen
   Platz mehr - sie wuerden hinter dem Panel verschwinden. Das Panel hat
   eigene Knoepfe (Position zeigen, Fahrweg, Schliessen). */
.map-wrap.sheet-open .map-actions { display: none; }
.map-wrap.sheet-open .legend { display: none; }
/* Der gewaehlte Bus bekommt einen hellen Ring - so ist klar, welcher ist. */
.veh-icon.sel .veh-rot { box-shadow: 0 0 0 3px rgba(120,180,255,.85), 0 2px 10px rgba(0,0,0,.55); }
.veh-icon.sel { z-index: 900 !important; }
/* Bussymbol an der Soll-Position (der Bus meldet sich gar nicht) */
.veh-icon.ghost { opacity: .8; filter: grayscale(.6); }
.veh-icon.ghost .veh-rot { border-radius: 8px; outline: 2px dashed rgba(255,196,107,.85); outline-offset: 1px; }

/* ---------- Verkehrsmeldungen ---------- */
.meld { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: start;
  font-size: 13px; padding: 9px 0; border-top: 1px solid var(--line); }
.meld:first-of-type { border-top: 0; }
.meld-typ { font-size: 10.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: var(--card2); white-space: nowrap; }
.meld-typ.wichtig { color: var(--amber); border-color: #6b4d12; background: #2a2110; }
.meld-typ.info { color: var(--accent); border-color: #22486e; background: #111f2c; }
.meld-text { color: var(--fg); line-height: 1.42; }
.meld-strasse { font-weight: 700; }
.meld-zeit { color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Auf dem Handy passt die Zeit nicht mehr neben den Text - sie rutscht darunter. */
@media (max-width: 620px) {
  .meld { grid-template-columns: auto 1fr; }
  .meld-zeit { grid-column: 2; }
}

/* ---------- Tab-Leiste ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 600; display: flex;
  background: rgba(15,17,21,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbtn { flex: 1 0 auto; min-width: 62px; border: 0; background: none; color: var(--muted);
  padding: 8px 4px 9px;
  font-size: 10.5px; display: grid; gap: 2px; justify-items: center; cursor: pointer;
  position: relative; transition: color .2s var(--ease); }
.tabbtn .ic { transition: transform .25s var(--ease); }
.tabbtn.active { color: var(--accent); }
.tabbtn.active .ic { transform: translateY(-1px) scale(1.08); }
/* Kleiner Akzent-Balken ueber dem aktiven Tab */
.tabbtn.active::before { content: ""; position: absolute; top: 0; left: 50%;
  width: 22px; height: 2px; margin-left: -11px; border-radius: 0 0 3px 3px;
  background: var(--accent); box-shadow: 0 0 10px rgba(77,163,255,.7); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.kv b { font-weight: 600; }

/* ---------- Ranking ---------- */
.rank-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 3px 10px; align-items: center;
  width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line);
  padding: 11px 2px; color: var(--fg); cursor: pointer; font-size: 14px; font-family: inherit; }
.rank-row:first-of-type { border-top: 0; }
.rank-row:hover { background: var(--card2); }
.rank-row:active { transform: scale(.995); }
.rank-pos { color: var(--muted); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.rank-name { font-weight: 600; }
.rank-score { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.rank-score.good { color: #5fd08a; }
.rank-score.mid { color: #ffc46b; }
.rank-score.bad { color: #ff7b7b; }
.rank-meta { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }
.rank-bar { grid-column: 2 / 4; height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 3px; }
.rank-back { margin-bottom: 10px; align-self: flex-start; }
.rank-line { display: grid; grid-template-columns: 52px 1fr auto; gap: 4px 10px; align-items: center;
  padding: 9px 0; border-top: 1px solid var(--line); }
.rank-line:first-of-type { border-top: 0; }
.rank-line-meta { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }
.rank-line .rank-bar { grid-column: 1 / 4; }
.rank-day { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: center;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.rank-day:first-of-type { border-top: 0; }
.rank-day b { font-variant-numeric: tabular-nums; }
.kv span { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.leg { border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--card); }
.leg + .leg { margin-top: 8px; }
.leg-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.walk { color: var(--muted); font-style: italic; }
.empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center;
  border: 1px dashed var(--line); border-radius: 12px; }
@media (min-width: 760px) {
  .dep-row { grid-template-columns: 56px 1fr auto; }
  #map { height: calc(100vh - 186px); }
}

/* ======================= Handy / PWA ======================= */
@media (max-width: 640px) {
  html, body { font-size: 16px; }

  /* Sichere Bereiche (Notch, Home-Anzeige) beruecksichtigen */
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; }
  .logo { width: 34px; height: 34px; font-size: 12px; border-radius: 9px; }
  .logo-svg { width: 31px; height: 31px; }
  h1 { font-size: 14px; }
  .sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
  .live-badge { padding: 5px 7px; font-size: 9px; }

  main { padding: 10px 12px 18px; }
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }

  /* Groessere Tippflaechen (mind. 44 px) - aber die Schrift bleibt klein.
     Sonst wirken die Knoepfe auf dem Handy doppelt so gross wie die
     Menueleiste, und das Panel frisst die halbe Karte. */
  .icon-btn { width: 44px; height: 44px; border-radius: 12px; }
  .pill { padding: 9px 13px; font-size: 12.5px; min-height: 44px; }
  .pill.small { padding: 8px 11px; font-size: 12px; min-height: 44px; }
  .chip { padding: 8px 12px; font-size: 12.5px; min-height: 40px; display: inline-flex; align-items: center; }
  .seg-btn { padding: 10px 6px; min-height: 44px; font-size: 13px; }
  .tabbtn { padding: 6px 2px 7px; font-size: 10px; }
  .tabbtn .ic { width: 26px; height: 26px; }

  /* Eingabefelder: 16 px verhindern den Auto-Zoom von iOS/Safari */
  .input { font-size: 16px; padding: 11px 12px; min-height: 44px; }
  /* Suchfeld bleibt beim Scrollen erreichbar */
  #searchStopsPane > .input, #searchBusesPane > .input {
    position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 400;
    box-shadow: 0 4px 14px rgba(0,0,0,.45); }
  .dep-row { padding: 10px 0; }
  .line-badge { height: 32px; }
  .card { padding: 12px; }

  /* Primaer-Aktionen ueber die volle Breite (Planer) */
  #planBtn { width: 100%; font-size: 15px; font-weight: 600; min-height: 48px; }

  /* Karte: volle Hoehe zwischen Kopfleiste und Tab-Leiste */
  #map { height: calc(100dvh - 178px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
         min-height: 320px; }
  .map-layers { top: 8px; left: 8px; padding: 6px 8px; gap: 5px; max-width: calc(100% - 70px); }
  .map-layer-row { gap: 4px 10px; }
  .switch { font-size: 11.5px; }
  .switch input { width: 16px; height: 16px; }
  .map-actions { right: 8px; bottom: 62px; gap: 9px; }
  .map-btn { width: 46px; height: 46px; }
  .legend { font-size: 10px; padding: 6px 8px; bottom: 24px; left: 8px; max-width: calc(100% - 70px); }
}

/* Sehr kleine Geraete (z. B. Galaxy S8 und kleiner): die Schalter bekommen
   kleinere Schrift, damit die Beschriftung sichtbar bleibt. Vorher wurden
   die Texte komplett versteckt - drei Kaestchen ohne Text sind nicht
   erklaerbar. */
@media (max-width: 380px) {
  .map-layers { padding: 7px 8px; }
  .map-layers .switch { font-size: 11px; gap: 4px; }
  .map-layers .switch .ic { width: 13px; height: 13px; }
  .map-layers .switch input { width: 15px; height: 15px; }
  .map-layer-row { gap: 3px 8px; }
}

/* Querformat auf dem Handy: Karte voller, Tab-Leiste kompakter */
@media (max-height: 480px) and (orientation: landscape) {
  #map { height: calc(100dvh - 120px); min-height: 220px; }
  .legend { display: none; }
  .map-actions { bottom: 10px; flex-direction: row; }
}

/* Groessere Bildschirme: Karte etwas hoeher, Aktionen groesser */
@media (min-width: 641px) {
  .map-btn { width: 46px; height: 46px; }
}
