:root {
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 48px;
}

/* Dunkel (Standard) — auch html[data-theme="dark"] */
html {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9aed;
  --accent-dim: #2a7bc8;
  --danger: #f07178;
  --ok: #7fd99a;
}

html[data-theme="light"] {
  --bg: #e8ecf2;
  --surface: #ffffff;
  --border: #c1cad6;
  --text: #152028;
  --muted: #5a6a7a;
  --accent: #1a6fd4;
  --accent-dim: #155aad;
  --danger: #c42d32;
  --ok: #1d7a45;
}

@media (prefers-color-scheme: light) {
  html[data-theme="system"] {
    --bg: #e8ecf2;
    --surface: #ffffff;
    --border: #c1cad6;
    --text: #152028;
    --muted: #5a6a7a;
    --accent: #1a6fd4;
    --accent-dim: #155aad;
    --danger: #c42d32;
    --ok: #1d7a45;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}

.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.header {
  padding: 0.5rem 0 1rem;
}

.header.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0;
}

/* Warten auf Server / externe Schnittstelle (TRIAS) */
@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-rotate 0.65s linear infinite;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--accent-dim);
    opacity: 0.9;
  }
}

/* Nur wenn sichtbar: sonst überschreibt display:flex das UA-[hidden]{display:none} */
.api-loading:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0 0.65rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.suggestion-msg--loading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card h2,
.card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.theme-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
}

.theme-option input[type='radio'] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 1.15rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.theme-muted {
  margin: 0;
  font-size: 0.82rem;
}

input[type="text"],
input[type="search"],
input[type="password"],
select {
  min-height: var(--tap);
  padding: 0 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  width: 100%;
}

.btn {
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent-dim);
  color: #fff;
}

.btn.secondary {
  background: transparent;
}

.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.btn.ghost {
  min-height: 40px;
  padding: 0 0.65rem;
  font-size: 0.9rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
}

.tab {
  flex: 1;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.tab.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.suggestions {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  max-height: 220px;
  overflow: auto;
}

.suggestions button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.suggestions button.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  justify-content: space-between;
}

.suggestions .suggestion-name {
  flex: 1 1 8rem;
  min-width: 0;
  text-align: left;
}

.suggestions .suggestion-lines {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  max-width: 100%;
}

.suggestions .line-badge--compact {
  min-width: 1.85rem;
  min-height: 1.45rem;
  padding: 0.12rem 0.35rem;
  font-size: 0.68rem;
  border-radius: 6px;
}

.suggestions .line-badge--bus {
  background: #5a6370;
  color: #f0f4f8;
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
}

.suggestions button:last-child {
  border-bottom: none;
}

.suggestions button:active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.suggestions button.suggestion-row--active {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

.suggestions .suggestion-msg {
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.35;
}

.suggestions .suggestion-msg.error {
  color: var(--danger);
}

/* Kompaktere „Haltestelle suchen“-Karte */
.card--stop-search {
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.card--stop-search.stack {
  gap: 0.45rem;
}

.card--stop-search .field {
  gap: 0.25rem;
}

.card--stop-search .field span {
  font-size: 0.82rem;
}

.card--stop-search .search-with-bookmark {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.card--stop-search .search-with-bookmark input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 0.55rem;
  font-size: 0.95rem;
}

/* Wie Verbindungen-Suche (38px): .btn hätte sonst min-height: var(--tap) = 48px → Zeile + Input werden höher */
.card--stop-search .btn-stop-toolbar {
  flex-shrink: 0;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.card--stop-search .btn-stop-toolbar svg {
  width: 1.35rem;
  height: 1.35rem;
}

.card--stop-search .muted {
  margin: 0;
  font-size: 0.85rem;
}

.card--stop-search .row.row--full {
  width: 100%;
}

.card--stop-search .row.row--full .btn--load-departures {
  width: 100%;
  min-height: 38px;
  padding: 0 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.card--stop-search .suggestions {
  max-height: 180px;
  border-radius: 8px;
}

.card--stop-search .suggestions button {
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
}

.card--stop-search .suggestions .suggestion-msg {
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
}

/* Verbindungen: kompakte Suche unter Lesezeichen (analog card--stop-search) */
.card--route-search {
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  min-width: 0;
}

.card--route-search.stack {
  gap: 0.45rem;
}

.card--route-search .field {
  gap: 0.25rem;
}

.card--route-search .field span {
  font-size: 0.82rem;
}

.card--route-search input[type='search'] {
  min-height: 38px;
  padding: 0 0.55rem;
  font-size: 0.95rem;
}

/* Start / Ziel: eine Zeile je Feld (wie Haltestellen-Suche + Toolbar) */
.card--route-search .route-input-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.card--route-search .route-input-toolbar input[type='search'],
.card--route-search .route-input-toolbar input[type='text'] {
  flex: 1;
  min-width: 0;
}

.card--route-search .route-input-toolbar input[type='text'] {
  min-height: 38px;
  padding: 0 0.55rem;
  font-size: 0.95rem;
}

.card--route-search .route-input-toolbar .btn-stop-toolbar {
  flex-shrink: 0;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.card--route-search .route-input-toolbar .btn-stop-toolbar svg {
  width: 1.35rem;
  height: 1.35rem;
}

.card--route-search .btn-route-swap {
  flex-shrink: 0;
  min-height: 38px;
  height: 38px;
  min-width: 38px;
  width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.card--route-search .btn-route-swap svg {
  width: 1.35rem;
  height: 1.35rem;
}

/*
 * Datum / Uhrzeit / „jetzt“: Grid statt Flex-Wrap — auf schmalen Viewports (z. B. iPhone mini)
 * bleiben alle drei in einer Zeile; minmax(0,1fr) erlaubt Schrumpfen unter die iOS-Mindestbreite.
 */
.card--route-search .row--route-datetime {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.3rem 0.4rem;
  align-items: end;
  width: 100%;
  min-width: 0;
}

.card--route-search .row--route-datetime .field--route-dt {
  min-width: 0;
}

.card--route-search .row--route-datetime .btn--route-now {
  min-height: 32px;
  padding: 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 10px;
  white-space: nowrap;
}

/*
 * iOS ersetzt Datum/Zeit durch sehr runde „Pills“; appearance:none + gleicher Radius wie andere Inputs.
 */
.card--route-search input[type='date'],
.card--route-search input[type='time'] {
  min-height: 32px;
  min-width: 0;
  max-width: 100%;
  padding: 0 0.35rem;
  font-size: 0.85rem;
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

@media (max-width: 420px) {
  .card--route-search .row--route-datetime {
    gap: 0.25rem 0.3rem;
  }

  .card--route-search .row--route-datetime .btn--route-now {
    min-height: 30px;
    padding: 0 0.35rem;
    font-size: 0.78rem;
  }

  .card--route-search input[type='date'],
  .card--route-search input[type='time'] {
    font-size: 0.8rem;
    padding: 0 0.28rem;
  }

  .card--route-search .field--route-dt span {
    font-size: 0.78rem;
  }
}

.card--route-search .muted {
  margin: 0;
  font-size: 0.85rem;
}

.card--route-search .suggestions {
  max-height: 180px;
  border-radius: 8px;
}

.card--route-search .suggestions button {
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
}

.card--route-search .row--route-actions {
  width: 100%;
  gap: 0.4rem;
}

.card--route-search .row--route-actions .btn {
  flex: 1;
  min-height: 38px;
  font-size: 0.88rem;
}

/* Kompaktere Darstellung für Lesezeichen-Karten */
.card--bookmarks {
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.card--bookmarks h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}

.card--bookmarks .bookmark-list li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
  gap: 0.35rem;
}

.card--bookmarks .bookmark-name-btn {
  min-height: 34px;
  padding: 0.2rem 0.15rem;
  font-size: 0.9rem;
}

.card--bookmarks .bookmark-list .btn {
  min-height: 34px;
  padding: 0 0.45rem;
  font-size: 0.8rem;
}

.card--bookmarks .bookmark-list .btn-icon-delete,
.card--bookmarks .bookmark-list .btn-icon-edit {
  padding: 0;
  min-width: 34px;
  width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card--bookmarks .bookmark-list .btn-icon-delete svg,
.card--bookmarks .bookmark-list .btn-icon-edit svg {
  width: 1.05rem;
  height: 1.05rem;
}

.bookmark-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bookmark-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.bookmark-list li:last-child {
  border-bottom: none;
}

.bookmark-list .bookmark-name-btn {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.35rem 0.25rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  min-height: 36px;
}

.bookmark-list .bookmark-name-btn:hover {
  color: var(--accent);
}

.bookmark-list .bookmark-name-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bookmark-list .btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 0.5rem;
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data th,
.data td {
  text-align: left;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid var(--border);
}

.data th {
  color: var(--muted);
  font-weight: 500;
}

.data th.th-line,
.data td.td-line {
  text-align: center;
}

.data td.td-line {
  vertical-align: middle;
  width: 3rem;
  max-width: 3rem;
  padding-left: 0.2rem;
  padding-right: 0.15rem;
  box-sizing: border-box;
}

.data td.td-line .line-badge {
  min-width: 1.85rem;
  min-height: 1.55rem;
  padding: 0.12rem 0.32rem;
  font-size: 0.72rem;
  border-radius: 6px;
  white-space: nowrap;
}

.data td.td-abfahrt {
  white-space: nowrap;
}

.data th.th-gleis,
.data td.td-gleis {
  text-align: center;
}

.data td.td-gleis {
  white-space: nowrap;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.data tr.dep-row--departed {
  opacity: 0.55;
  font-style: italic;
  color: var(--muted);
}

/* Abfahrten: dezente Gleis-Gruppierung nur bei 2–4 erkannten Gleisen (ohne Bstg.) */
.data tr.dep-row--gleis-1 td {
  background-color: color-mix(in srgb, #3d9aed 18%, transparent);
}

.data tr.dep-row--gleis-2 td {
  background-color: color-mix(in srgb, #7fd99a 18%, transparent);
}

.data tr.dep-row--gleis-3 td {
  background-color: color-mix(in srgb, #e8a078 18%, transparent);
}

.data tr.dep-row--gleis-4 td {
  background-color: color-mix(in srgb, #b48cdc 18%, transparent);
}

html[data-theme="light"] .data tr.dep-row--gleis-1 td {
  background-color: color-mix(in srgb, #1a6fd4 14%, transparent);
}

html[data-theme="light"] .data tr.dep-row--gleis-2 td {
  background-color: color-mix(in srgb, #1d7a45 14%, transparent);
}

html[data-theme="light"] .data tr.dep-row--gleis-3 td {
  background-color: color-mix(in srgb, #c45a28 14%, transparent);
}

html[data-theme="light"] .data tr.dep-row--gleis-4 td {
  background-color: color-mix(in srgb, #7a5aa8 14%, transparent);
}

@media (prefers-color-scheme: light) {
  html[data-theme="system"] .data tr.dep-row--gleis-1 td {
    background-color: color-mix(in srgb, #1a6fd4 14%, transparent);
  }

  html[data-theme="system"] .data tr.dep-row--gleis-2 td {
    background-color: color-mix(in srgb, #1d7a45 14%, transparent);
  }

  html[data-theme="system"] .data tr.dep-row--gleis-3 td {
    background-color: color-mix(in srgb, #c45a28 14%, transparent);
  }

  html[data-theme="system"] .data tr.dep-row--gleis-4 td {
    background-color: color-mix(in srgb, #7a5aa8 14%, transparent);
  }
}

.dep-time {
  font-variant-numeric: tabular-nums;
}

.dep-time--on-time {
  color: var(--ok);
}

.dep-time--late {
  color: var(--danger);
}

.dep-delta {
  font-weight: 600;
}

/* KVV-Linien: abgerundetes Viereck, Farben aus Liniennetzplan / Stadtwiki KVV */
.line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 1.85rem;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  box-sizing: border-box;
}

.line-badge--empty,
.line-badge--unknown {
  background: var(--border);
  color: var(--text);
  font-weight: 600;
}

.line-badge--unknown {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--border) 55%, var(--surface));
}

/* Bus-Linie in Abfahrten: gleiche Fläche wie Autocomplete-Badge „Bus“ */
.line-badge.line-badge--bus {
  background: #5a6370;
  color: #f0f4f8;
  font-weight: 700;
}

.trip-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
}

.trip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.65rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.trip-meta__text {
  flex: 1 1 12rem;
  min-width: 0;
  line-height: 1.35;
}

.trip-meta__times {
  color: var(--text);
  font-weight: 600;
}

.trip-meta__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  justify-content: flex-end;
  flex: 0 1 auto;
}

.trip-meta__badges .line-badge--compact {
  min-width: 1.85rem;
  min-height: 1.45rem;
  padding: 0.12rem 0.35rem;
  font-size: 0.68rem;
  border-radius: 6px;
}

.trip-meta__badges .line-badge--bus {
  font-size: 0.62rem;
}

/* Umstieg / Modus in derselben Reihenfolge wie die Teilstücke (neben Linien-Badges) */
.trip-meta__mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--muted);
}

.trip-meta__mode-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.leg {
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}

.leg:first-child {
  border-top: none;
}

/* Umstieg / Fußweg (TRIAS InterchangeLeg / ContinuousLeg) */
.leg--transfer {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.leg__transfer-text {
  flex: 1;
  min-width: 0;
}

.leg__transfer-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}

.leg__transfer-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--muted);
  line-height: 0;
}

.leg__transfer-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.leg__transfer-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.leg__transfer-route {
  font-size: 0.92rem;
  line-height: 1.35;
}

.leg__transfer-walk {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Fahrten-Teilstück: Linien-Badge, Richtung, Haltestellen, Zeiten wie Abfahrten, Gleis */
.leg--timed-rich .leg__timed-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.2rem;
}

.leg--timed-rich .leg__timed-dest {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.leg--timed-rich .leg__timed-route {
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text);
  margin-top: 0.15rem;
}

.leg--timed-rich .leg__timed-stops {
  margin-top: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text);
}

.leg--timed-rich .leg__timed-stop-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
}

.leg--timed-rich .leg__timed-stop-time {
  flex: 0 0 auto;
  min-width: 4.75rem;
  font-size: 0.85rem;
}

.leg--timed-rich .leg__timed-stop-time .dep-time {
  font-weight: 600;
}

.leg--timed-rich .leg__timed-stop-name {
  flex: 1 1 10rem;
  min-width: 0;
}

.leg--timed-rich .leg__timed-stop-track {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

/* Umstieg ohne InterchangeLeg: gleicher vs. anderer Gleis am Umsteigepunkt */
.leg--timed-rich .leg__timed-track--change {
  color: var(--danger);
  font-weight: 700;
}

.leg--timed-rich .leg__timed-track--same {
  color: var(--ok);
  font-weight: 700;
}

.leg--timed-rich .leg__timed-puffer {
  font-weight: 400;
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
}

.ok {
  color: var(--ok);
  margin: 0;
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.settings-expert-heading {
  margin-top: 1.25rem;
}

.field--checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.field--checkbox input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

/* Einstellungen: Zeile mit Schalter rechts (iOS-ähnlich) */
.field.field--toggle {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
}

.field.field--toggle .field--toggle__text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.toggle {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  align-items: center;
}

.toggle__track {
  position: relative;
  display: block;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 85%, var(--text));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent);
  transition: background 0.2s ease;
  pointer-events: none;
}

.toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.5rem - 6px);
  height: calc(1.5rem - 6px);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px color-mix(in srgb, #000 22%, transparent);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle__input:checked + .toggle__track {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-dim) 40%, transparent);
}

.toggle__input:checked + .toggle__track::after {
  transform: translateX(1.25rem);
  background: #fff;
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .toggle__track,
  .toggle__track::after {
    transition: none;
  }
}

.modal[hidden] {
  display: none !important;
}

.modal:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 55%, #000);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 22rem;
  max-height: 90dvh;
  overflow-y: auto;
  margin: 0;
}

.modal__panel.card {
  margin-bottom: 0;
}

.modal__panel h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* Nur wenn sichtbar: sonst überschreibt display:flex das HTML-[hidden]-Attribut (gleiche Spezifität). */
.route-edit-interchange[hidden] {
  display: none !important;
}

.route-edit-interchange:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.route-edit-interchange .muted {
  margin: 0;
  font-size: 0.85rem;
}

.route-edit-interchange .suggestions {
  margin-top: -0.2rem;
}

.route-edit-remove {
  margin-top: 0.35rem;
}

.route-edit-remove .btn.danger {
  width: 100%;
  min-height: 38px;
  font-size: 0.88rem;
}

.row--modal-actions {
  margin-top: 0.75rem;
  gap: 0.5rem;
  width: 100%;
}

.row--modal-actions .btn {
  min-height: 38px;
  font-size: 0.88rem;
}
