:root {
  --navy: #1a3550;
  --flaeche: #f3f5f7;
  --tafel: #ffffff;
  --text: #1c2733;
  --text-2: #55616e;
  --linie: #d6dce2;
  --akzent: #1a3550;
  --akzent-text: #ffffff;
  --gut: #1f8a4c;
  --ruhe: #7a8693;
  --warn: #b26a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --flaeche: #0f151b;
    --tafel: #18212b;
    --text: #e7ecf1;
    --text-2: #9eabb8;
    --linie: #2b3744;
    --akzent: #9cc4ea;
    --akzent-text: #0f151b;
    --gut: #4cc27e;
    --ruhe: #8a97a5;
    --warn: #e0a040;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--flaeche); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.kopf { display: flex; align-items: center; gap: 14px; padding: 8px 16px; color: #fff; flex: none; }
.kopf .logo { height: 30px; display: block; }
.kopf .titel { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.kopf .titel strong { font-size: 16px; font-weight: 600; }
.kopf .titel span { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mmlink { margin-left: auto; color: #fff; font-size: 13px; text-decoration: none; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); white-space: nowrap; }
.mmlink:hover { background: rgba(255, 255, 255, .22); }
.mmlink + .status { margin-left: 0; }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.status .punkt { width: 9px; height: 9px; border-radius: 50%; background: var(--ruhe); flex: none; }
.status.live .punkt { background: #4cd98a; box-shadow: 0 0 0 0 rgba(76, 217, 138, .7); animation: puls 2s infinite; }
.status.stoerung .punkt { background: #f0b34a; }
@keyframes puls { 70% { box-shadow: 0 0 0 7px rgba(76, 217, 138, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 217, 138, 0); } }
@media (prefers-reduced-motion: reduce) { .status.live .punkt { animation: none; } }

.leiste, .zeit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 8px 16px; background: var(--tafel); border-bottom: 1px solid var(--linie); flex: none; }
.zeit { padding: 6px 16px; }
.stoffe { display: inline-flex; border: 1px solid var(--linie); border-radius: 8px; overflow: hidden; }
.stoffe button {
  font: inherit; font-weight: 600; padding: 7px 14px; border: 0; border-right: 1px solid var(--linie);
  background: transparent; color: var(--text); cursor: pointer; min-width: 58px;
}
.stoffe button:last-child { border-right: 0; }
.stoffe button[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); }
.stoffe button.leer { color: var(--text-2); font-weight: 400; }
.stoffe button.leer::after { content: " ·"; }
.stoffe button:focus-visible, .knopf:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.feld { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.feld select { font: inherit; color: var(--text); background: var(--tafel); border: 1px solid var(--linie); border-radius: 6px; padding: 5px 8px; max-width: min(430px, 100%); }
.schalter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.knopf { font: inherit; font-size: 13px; padding: 5px 12px; border: 1px solid var(--linie); border-radius: 6px; background: var(--tafel); color: var(--text); cursor: pointer; }
.knopf[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.kacheln { display: flex; gap: 22px; margin: 0 0 0 auto; }
.kacheln div { display: flex; flex-direction: column; }
.kacheln dt { font-size: 11px; color: var(--text-2); }
.kacheln dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zeit .knopf { white-space: nowrap; }
#spiel { min-width: 112px; }
.zeit input[type=range] { flex: 1; min-width: 160px; accent-color: var(--akzent); }
.zeit output { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 190px; text-align: right; }

/* Höhenprofil über den vier Karten: Höhe jedes Messwerts über der Zeit, Punkt am gezeigten Zeitpunkt (17.10.2026) */
.profil { flex: none; display: flex; flex-direction: column; gap: 2px; padding: 4px 16px 3px; background: var(--tafel); border-bottom: 1px solid var(--linie); }
.profil canvas { display: block; width: 100%; height: 104px; cursor: crosshair; touch-action: none; }
.profil .pk { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; color: var(--text-2); }
.profil .pk #profilText { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); font-weight: 600; }

.quad { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; background: var(--linie); }
.q { position: relative; min-height: 220px; background: #20262c; }
.q .karte { position: absolute; inset: 0; }
.q .tafel, .q .legende, .q .leerhinweis {
  position: absolute; z-index: 500; pointer-events: none;
  background: rgba(16, 22, 29, .78); color: #fff; border-radius: 8px; backdrop-filter: blur(2px);
}
.q .tafel { top: 8px; left: 8px; padding: 6px 10px; max-width: min(72%, 360px); }
.q .tafel h2 { margin: 0; font-size: 14px; font-weight: 600; }
.q .tafel p { margin: 2px 0 0; font-size: 11.5px; line-height: 1.3; opacity: .85; }
.q .legende { bottom: 8px; left: 8px; padding: 6px 10px; font-size: 11.5px; min-width: 200px; }
.q .legende .balken { height: 9px; border-radius: 3px; margin: 3px 0; }
.q .legende .enden { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.q .legende .zeiger { margin-top: 3px; opacity: .9; min-height: 1.3em; font-variant-numeric: tabular-nums; }
.q .leerhinweis { top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 10px 14px; font-size: 13px; text-align: center; max-width: 80%; }
.q .leerhinweis[hidden] { display: none; }
.leaflet-container { background: #20262c; font: inherit; }
.leaflet-control-attribution { font-size: 10px; }

.hinweise { flex: none; background: var(--tafel); border-top: 1px solid var(--linie); padding: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.hinweise summary { cursor: pointer; color: var(--text); }
.hinweise ul { margin: 6px 0; padding-left: 18px; max-width: 110ch; }
.hinweise li { margin: 2px 0; }
.hinweise b { color: var(--text); font-weight: 600; }
.hinweise .quelle { margin: 4px 0 2px; font-size: 11.5px; }

.optionen { display: contents; }
.nur-mobil { display: none; }
.reiter { display: none; }

/* Schmale Bildschirme: eine Ebene auf voller Fläche, Reiter schalten um */
@media (max-width: 760px), (max-height: 480px) and (orientation: landscape) {
  body { height: 100dvh; min-height: 520px; font-size: 15px; }
  .kopf { flex-wrap: wrap; gap: 6px 10px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); }
  .kopf .logo { height: 22px; }
  .kopf .titel span { display: none; }
  .kopf .titel strong { font-size: 15px; }
  .status { font-size: 12px; padding: 3px 10px; max-width: 100%; }
  .status #statusText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .leiste { padding: 8px 12px; gap: 8px; }
  .stoffe { display: grid; grid-template-columns: repeat(5, 1fr); flex: 1 1 100%; }
  .stoffe button { min-width: 0; padding: 11px 2px; font-size: 15px; }
  .nur-mobil { display: inline-block; }
  #optKnopf { order: 3; min-height: 40px; }
  .optionen { display: none; order: 4; flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 10px; padding: 4px 0; }
  .optionen.offen { display: flex; }
  .optionen .feld { justify-content: space-between; font-size: 14px; }
  .optionen .feld select { max-width: 62%; min-height: 40px; }
  .optionen .schalter { min-height: 36px; font-size: 14px; }
  .optionen .knopf { min-height: 40px; }
  .kacheln { order: 2; margin: 0; flex: 1 1 100%; display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 6px 10px; }
  .kacheln dt { font-size: 10px; }
  .kacheln dd { font-size: 13.5px; }

  .zeit { padding: 6px 12px; gap: 6px 10px; }
  .zeit .knopf { min-height: 36px; }
  .zeit input[type=range] { min-width: 0; height: 32px; }
  .zeit output { min-width: 0; flex: 1 1 100%; text-align: left; font-size: 12px; }

  .profil { padding: 4px 12px 2px; }
  .profil canvas { height: 72px; }
  .profil .pk #profilInfo { display: none; }

  .reiter { display: grid; grid-template-columns: repeat(4, 1fr); flex: none; background: var(--tafel); border-bottom: 1px solid var(--linie); }
  .reiter button { font: inherit; font-size: 13px; padding: 11px 2px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
  .reiter button[aria-pressed="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--akzent); }

  .quad { display: block; position: relative; flex: 1 1 auto; min-height: 300px; gap: 0; }
  .q { display: none; position: absolute; inset: 0; min-height: 0; }
  .q.aktiv { display: block; }
  .q .tafel { max-width: calc(100% - 64px); padding: 5px 9px; }
  .q .tafel h2 { display: none; }
  .q .tafel p { margin: 0; font-size: 11.5px; }
  .q .legende { min-width: 0; right: 8px; padding: 5px 9px; }
  .hinweise { padding: 6px 12px; padding-bottom: max(6px, env(safe-area-inset-bottom)); max-height: 40dvh; overflow: auto; }
}
@media (max-width: 380px) {
  .kacheln { grid-template-columns: repeat(2, 1fr); }
  .stoffe button { font-size: 14px; }
}
/* Querformat am Telefon: Kopf und Leisten knapp, die Karte bekommt die Höhe */
@media (max-height: 480px) and (orientation: landscape) {
  .kopf { padding-top: 4px; padding-bottom: 4px; }
  .kacheln dt { display: none; }
  .hinweise { display: none; }
  .profil canvas { height: 48px; }
}
