:root {
    --grund: #f3f5f1;
    --flaeche: #ffffff;
    --text: #1b211d;
    --leise: #5d6962;
    --rand: #d9dfd9;
    --akzent: #2f5d46;
    --auf-akzent: #ffffff;
    --rot: #b42318;
    --gelb: #8a5a00;
    --gruen: #1e7b3c;
    --gruen-hell: #e3f4e8;
    --gelb-hell: #fff4d6;
    --rot-hell: #fde8e6;
    /* Diagramme: geprüfte Palette, die Farbe folgt dem Raum */
    --reihe-1: #2a78d6; --reihe-2: #eb6834; --reihe-3: #1baf7a; --reihe-4: #eda100; --reihe-5: #e87ba4; --reihe-6: #008300; --reihe-7: #6250d6; --reihe-8: #e34948;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --grund: #141815;
        --flaeche: #1e2420;
        --text: #e8ece9;
        --leise: #a2ada6;
        --rand: #36403a;
        --akzent: #8fc7a7;
        --auf-akzent: #10231a;
        --rot: #ff8a7d;
        --gelb: #f2c14e;
        --gruen: #5fd17f;
        --gruen-hell: #143322;
        --gelb-hell: #3a2f12;
        --rot-hell: #3d1b18;
        --reihe-1: #3987e5; --reihe-2: #d95926; --reihe-3: #199e70; --reihe-4: #c98500; --reihe-5: #d55181; --reihe-6: #008300; --reihe-7: #9085e9; --reihe-8: #e66767;
    }
}

* { box-sizing: border-box; }

a { color: var(--akzent); }

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

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--grund);
    color: var(--text);
    font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

main {
    max-width: 560px;
    margin: 0 auto;
    padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}

h1 { font-size: 1.5rem; margin: 0; }
.leise { color: var(--leise); margin: 2px 0; }
.klein { font-size: 0.85rem; }

.kopf { text-align: center; margin: 12vh 0 24px; }
.kopf__bild { border-radius: 16px; display: block; margin: 0 auto 12px; }

.leiste { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

button {
    font: inherit;
    font-weight: 600;
    min-height: 48px;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
}
button:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: progress; }
.haupt { display: block; width: 100%; background: var(--akzent); color: var(--auf-akzent); border: 0; }
.zweit { background: var(--flaeche); color: var(--text); border: 1px solid var(--rand); }

.meldung { margin: 12px 0; font-weight: 600; text-align: center; }
.meldung:empty { display: none; }
.meldung--fehler { color: var(--rot); }

.schritte { padding-left: 22px; }
.schritte li { margin: 8px 0; }

.werte { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gesamt + .werte, .weitere .werte { margin-top: 10px; }
.wert { display: flex; flex-direction: column; padding: 8px 10px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; min-width: 0; }
.wert__titel { font-size: 0.78rem; color: var(--leise); }
.wert__zahl { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; }
.wert .klein { font-size: 0.75rem; }

/* Rahmen */
.inhalt { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.inhalt > div > * + * { margin-top: 12px; }
.reiter { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: var(--flaeche); border-top: 1px solid var(--rand); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.reiter__knopf { flex: 1 1 0; max-width: 140px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--leise); text-decoration: none; font-size: 0.72rem; font-weight: 600; }
.reiter__knopf svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.reiter__knopf[aria-current="page"] { color: var(--akzent); }
.reiter__knopf:focus-visible { outline: 3px solid var(--text); outline-offset: -3px; }

/* Gesamtlage */
.gesamt { padding: 14px; border-radius: 14px; border: 2px solid var(--rand); background: var(--flaeche); }
.gesamt__kopf { display: flex; align-items: center; gap: 10px; }
.gesamt h2 { margin: 0; font-size: 1.15rem; font-weight: 700; line-height: 1.3; }
.gesamt--gruen { border-color: var(--gruen); background: var(--gruen-hell); }
.gesamt--gelb { border-color: var(--gelb); background: var(--gelb-hell); }
.gesamt--rot { border-color: var(--rot); background: var(--rot-hell); }
.gesamt--gruen > .gesamt__kopf .zeichen { color: var(--gruen); }
.gesamt--gelb > .gesamt__kopf .zeichen { color: var(--gelb); }
.gesamt--rot > .gesamt__kopf .zeichen { color: var(--rot); }
.gesamt__liste { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.gesamt__liste li { display: flex; gap: 8px; align-items: flex-start; }
.stufe--rot .zeichen { color: var(--rot); }
.stufe--gelb .zeichen { color: var(--gelb); }
.zeichen { flex: 0 0 auto; width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.gesamt__liste .zeichen { width: 20px; height: 20px; margin-top: 2px; }

.vorhersage { margin: 12px 0 0; padding: 10px 12px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; font-size: 0.92rem; }
.weitere { margin-top: 10px; }
.weitere summary { min-height: 36px; display: flex; align-items: center; color: var(--leise); font-size: 0.92rem; cursor: pointer; }
.stand { margin: 12px 0 0; text-align: center; }

/* Karten und Schalter */
.karte { display: block; padding: 14px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px; }
.karte h3 { margin: 0 0 10px; font-size: 1.02rem; }
.schalter { display: grid; gap: 12px; margin-top: 12px; }
.schalter__titel { margin: 12px 0 6px; font-size: 0.8rem; color: var(--leise); }
.schalter__aktion { display: flex; gap: 8px; margin-top: 12px; }
.schalter__aktion .haupt { flex: 1 1 auto; width: auto; }
.schalter__meldung { margin: 10px 0 0; font-weight: 600; font-size: 0.92rem; }
.schalter__meldung:empty { display: none; }
.schalter__meldung.fehler { color: var(--rot); }
.schalter__frage { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rand); }
.schalter__frage p { margin: 0; }
.schalter__mehr { margin-top: 12px; }
.schalter__mehr summary { min-height: 36px; display: flex; align-items: center; color: var(--leise); font-size: 0.92rem; cursor: pointer; }

.umschalter { display: flex; flex-wrap: wrap; gap: 6px; }
.umschalter button { flex: 1 1 auto; min-width: 48px; padding: 10px 12px; background: var(--grund); color: var(--text); border: 1px solid var(--rand); font-weight: 500; }
.umschalter button[aria-pressed="true"] { background: var(--akzent); color: var(--auf-akzent); border-color: var(--akzent); font-weight: 700; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stepper button { min-width: 64px; padding: 6px 0; font-size: 1.4rem; background: var(--grund); color: var(--text); border: 1px solid var(--rand); }
.stepper output { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Verläufe */
.verlauf { display: grid; gap: 12px; margin-top: 12px; }
.verlauf[aria-busy="true"] { opacity: 0.6; }
wh-zeitreihe { display: block; min-height: 60px; }
wh-zeitreihe svg { display: block; touch-action: pan-y; }
.raster line { stroke: var(--rand); stroke-width: 1; }
.raster text, .raster__zeit { fill: var(--leise); font-size: 11px; font-variant-numeric: tabular-nums; }
.bezug line { stroke: var(--leise); stroke-width: 1; stroke-dasharray: 4 4; }
.bezug text { fill: var(--leise); font-size: 11px; }
.linie { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linie--gestrichelt { stroke-dasharray: 6 4; }
.band { fill: currentColor; stroke: none; opacity: 0.18; }
.punkt { fill: currentColor; }
.spur { fill: var(--rand); opacity: 0.5; }
.spur__an { fill: currentColor; shape-rendering: crispEdges; }
.zeiger { stroke: var(--text); stroke-width: 1; opacity: 0.55; pointer-events: none; }
.flaeche { fill: transparent; }
.ablese { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 8px; min-height: 2.6em; align-content: flex-start; }
.ablese__zeit { flex: 0 0 100%; color: var(--leise); }
.ablese__reihe { display: inline-flex; align-items: center; gap: 5px; }
.taste { display: inline-block; flex: 0 0 auto; width: 14px; height: 3px; border-radius: 2px; background: currentColor; }
.taste--gestrichelt { width: 6px; box-shadow: 8px 0 0 currentColor; margin-right: 8px; }
.taste--spur { height: 9px; }
.reihe-1 { color: var(--reihe-1); } .reihe-2 { color: var(--reihe-2); } .reihe-3 { color: var(--reihe-3); } .reihe-4 { color: var(--reihe-4); }
.reihe-5 { color: var(--reihe-5); } .reihe-6 { color: var(--reihe-6); } .reihe-7 { color: var(--reihe-7); } .reihe-8 { color: var(--reihe-8); }
.raumwahl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.raumwahl button { min-height: 40px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px; background: var(--grund); color: var(--leise); border: 1px solid var(--rand); font-weight: 500; font-size: 0.9rem; }
.raumwahl button[aria-pressed="true"] { color: var(--text); border-color: var(--text); font-weight: 600; }
.raumwahl button[aria-pressed="false"] .taste { opacity: 0.35; }

/* Kameras */
.kamera__bild, .kamera__leer { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: var(--grund); }
.kamera__leer { display: grid; place-items: center; color: var(--leise); }
.kamera .zweit { display: block; width: 100%; margin: 8px 0; }
.ereignisse { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ereignisse li { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; }
.ereignisse img, .ereignisse__leer { display: block; width: 96px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--grund); }

/* Mehr */
.verweise { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.verweise li { display: grid; }
.verweise a { font-weight: 600; color: var(--akzent); min-height: 28px; }
