:root {
  --grund: #f6f7f9;
  --karte: #ffffff;
  --text: #1c2430;
  --leise: #5f6b7a;
  --akzent: #1f3a5f;
  --richtig: #1d7a46;
  --falsch: #b3261e;
  --taste: #e8ecf1;
  --taste-steuer: #d5dce5;
  --rand: #d0d7e0;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #12161c;
    --karte: #1b2129;
    --text: #e6eaf0;
    --leise: #9aa5b3;
    --akzent: #8fb4e3;
    --richtig: #5cc98a;
    --falsch: #f0857d;
    --taste: #262e39;
    --taste-steuer: #323c49;
    --rand: #36404d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--grund); color: var(--text); }
body { font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; }

.seite { max-width: 34rem; margin: 0 auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; min-height: 100dvh; }
.kopf { display: flex; justify-content: space-between; color: var(--leise); font-size: 15px; }
.titel { font-weight: 600; }

.aufgabe { background: var(--karte); border-radius: 14px; padding: 14px 16px; }
.auftrag { margin: 0 0 6px; }
.formel { font-size: 1.5em; overflow-x: auto; overflow-y: hidden; }
.formel math { margin: 4px 0; }

.termfeld { display: flex; flex-direction: column; gap: 8px; }
.vorschau { min-height: 2.6em; font-size: 1.45em; background: var(--karte); border-radius: 14px; padding: 8px 14px; display: flex; align-items: center; overflow-x: auto; }
.vorschau math { margin: 0; }
.termfeld.unlesbar .vorschau { opacity: .45; }
.feldzeile { display: flex; gap: 8px; }
.feld { flex: 1; min-width: 0; font: 20px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; padding: 10px 12px; border: 2px solid var(--rand); border-radius: 12px; background: var(--karte); color: var(--text); }
.feld:focus { outline: none; border-color: var(--akzent); }
.systemtasten { width: 48px; border: 2px solid var(--rand); border-radius: 12px; background: var(--karte); color: var(--leise); font-size: 20px; }
.hinweis { min-height: 1.3em; color: var(--leise); font-size: 15px; }

.taste.breit { grid-column: span 2; }
.tasten { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tasten[hidden], .tastaturplatz[hidden] { display: none; }
.tastaturplatz { position: sticky; bottom: 0; background: var(--grund); padding: 6px 0 calc(4px + env(safe-area-inset-bottom)); }
.taste { height: 52px; border: 0; border-radius: 10px; background: var(--taste); color: var(--text); font-size: 21px; font-family: inherit; }
.taste.ziffer { background: var(--karte); }
.taste.steuer { background: var(--taste-steuer); }
.taste:active { filter: brightness(.88); }

.aktionen { display: flex; gap: 8px; }
.knopf { flex: 1; height: 50px; border-radius: 12px; border: 2px solid var(--akzent); background: transparent; color: var(--akzent); font-size: 18px; font-weight: 600; }
.knopf.primaer { background: var(--akzent); color: var(--karte); }
.knopf:disabled { opacity: .4; }
.leise { color: var(--leise); margin: 0; }
.zurueck { border: 0; background: none; color: var(--akzent); font: inherit; padding: 0; }
.themen { display: grid; gap: 8px; }
.thema { text-align: left; padding: 14px 16px; border: 0; border-radius: 14px; background: var(--karte); color: var(--text); font: inherit; font-weight: 600; }
.thema span { display: block; font-weight: 400; color: var(--leise); font-size: 15px; }
.thema.gemischt { background: var(--akzent); color: var(--karte); }
.thema.gemischt span { color: inherit; opacity: .8; }
.frage { margin: 0; font-weight: 600; }
.erledigt:empty { display: none; }
.erledigt { margin-top: 6px; color: var(--richtig); }
.zwischen { margin-top: 2px; }
.weg { background: var(--karte); border-radius: 14px; padding: 4px 16px 10px; }
.weg h2 { font-size: 16px; color: var(--leise); margin: 10px 0 4px; }
.weg p { margin: 6px 0; }
.rueckmeldung { margin: 0; min-height: 1.4em; font-weight: 600; }
.rueckmeldung.richtig { color: var(--richtig); }
.rueckmeldung.falsch, .rueckmeldung.unlesbar { color: var(--falsch); }

/* Heft / unterwegs */
.modus { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--taste); border-radius: 12px; padding: 4px; }
.modus button { border: 0; background: none; padding: 10px; border-radius: 9px; font: inherit; color: var(--text); }
.modus button.aktiv { background: var(--karte); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Notizblock */
.notizblock { background: var(--karte); border-radius: 14px; padding: 8px 12px 12px; }
.reiter { display: flex; gap: 4px; margin-bottom: 6px; }
.reiter-knopf { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font: inherit; color: var(--leise); }
.reiter-knopf.aktiv { background: var(--taste); color: var(--text); font-weight: 600; }
.zeilen { margin: 0 0 6px; padding-left: 1.6em; }
.zeile { padding: 3px 0; font-size: 1.15em; cursor: pointer; border-radius: 6px; }
.zeile .roh { font-family: ui-monospace, Consolas, monospace; font-size: .8em; color: var(--leise); }
.zeile.falsch { background: color-mix(in srgb, var(--falsch) 12%, transparent); }
.mark { margin-left: 10px; font-weight: 700; font-size: .85em; }
.mark.ok { color: var(--richtig); }
.mark.falsch { color: var(--falsch); }
.notizblock .vorschau { min-height: 2em; font-size: 1.15em; background: var(--grund); }
.notizblock .feld { font-size: 17px; padding: 8px 10px; }
.skizze { width: 100%; height: 280px; display: block; background: var(--grund); border-radius: 10px; touch-action: none; color: var(--text); }
.reihe { display: flex; gap: 8px; margin-top: 6px; }
.klein-knopf { border: 1px solid var(--rand); background: var(--karte); color: var(--akzent); border-radius: 10px; padding: 7px 12px; font: inherit; font-size: 15px; align-self: flex-start; }
.hinweis-text { color: var(--text); font-weight: 400; }

/* Graphen */
.graph { width: 100%; height: auto; display: block; }
.g-gitter { stroke: var(--rand); stroke-width: .6; }
.g-achse { stroke: var(--leise); stroke-width: 1.2; }
.g-kurve { fill: none; stroke: var(--akzent); stroke-width: 2.4; }
.g-zahl { fill: var(--leise); font-size: 10px; font-family: system-ui, sans-serif; }
.g-name { fill: var(--akzent); font-size: 15px; font-style: italic; font-family: "Cambria Math", "STIX Two Math", serif; }
.g-marke { fill: var(--richtig); }
.g-marke.daneben { fill: var(--falsch); }
.graph.klickbar { cursor: crosshair; outline: 2px dashed var(--akzent); outline-offset: 2px; border-radius: 6px; }
.kandidaten { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kandidaten[hidden] { display: none; }
.kandidat { position: relative; border: 2px solid transparent; background: var(--karte); border-radius: 12px; padding: 4px; }
.kandidat .g-kurve { stroke: var(--text); }
.kand-id { position: absolute; top: 4px; left: 8px; font-weight: 700; color: var(--leise); }
.kandidat.falsch { border-color: var(--falsch); opacity: .55; }
.kandidat.richtig { border-color: var(--richtig); }

/* Mehrere Lösungen */
.liste { display: grid; gap: .4rem; }
.liste .termfeld .vorschau { min-height: 0; }
.feld.falsch { border-color: var(--falsch, #b3261e); background: color-mix(in srgb, var(--falsch, #b3261e) 8%, transparent); }
#mehr { margin-top: .4rem; }
.liste .hinweis:empty { display: none; }
.thema span.aktuell { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--akzent); color: var(--karte); font-size: 12px; font-weight: 600; vertical-align: 2px; }

/* Schritt für Schritt */
:root { --hervor: #b5580b; }
@media (prefers-color-scheme: dark) { :root { --hervor: #f2a65a; } }
.erklaerung { background: var(--karte); border-radius: 14px; padding: 4px 16px 12px; }
.erklaerung h2 { font-size: 16px; color: var(--leise); margin: 10px 0 4px; }
.schritte { margin: 0; padding-left: 1.4em; }
.schritt { padding: 6px 0 8px; border-bottom: 1px solid var(--rand); }
.schritt:last-child { border-bottom: 0; }
.schritt::marker { font-weight: 700; color: var(--akzent); }
.schritt h3 { margin: 0 0 4px; font-size: 17px; }
.schritt-text { margin: 0 0 6px; color: var(--leise); }
.s-zeile { margin: 4px 0; font-size: 1.15em; transition: opacity .45s ease, transform .45s ease; }
.s-zeile.verdeckt { opacity: 0; transform: translateY(6px); }
.schritt.abweichung { background: color-mix(in srgb, var(--falsch) 9%, transparent); border-left: 4px solid var(--falsch); padding-left: 8px; margin-left: -12px; border-radius: 6px; }
math .hervor { color: var(--hervor); }
.schritt-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.schritt-knoepfe .knopf { flex: 1 1 12rem; height: auto; min-height: 46px; padding: 6px 10px; font-size: 16px; }
.schritt-knoepfe p { flex-basis: 100%; margin: 0; }
@media (prefers-reduced-motion: reduce) { .s-zeile { transition: none; } }
.ruhig .s-zeile { transition: none; }

/* Start, Tagesrunde, Anmelden, Übersicht */
.woche { display: flex; gap: 6px; justify-content: space-between; margin: 4px 0 2px; }
.woche .tag { flex: 1; text-align: center; padding: 8px 0; border-radius: 10px; background: var(--taste); color: var(--leise); font-size: 0.9rem; }
.woche .tag.heute { outline: 2px solid var(--akzent); outline-offset: -2px; color: var(--text); }
.woche .tag.geuebt { background: var(--richtig); color: #fff; }
.geschafft { font-size: 1.3rem; font-weight: 600; color: var(--richtig); margin: 8px 0; }
.abschnitt { font-size: 1.05rem; margin: 24px 0 4px; }
.fertig { background: var(--karte); border-radius: 14px; padding: 16px; margin: 12px 0; }
.anmelden { display: flex; flex-direction: column; gap: 14px; background: var(--karte); border-radius: 14px; padding: 20px; margin-top: 12px; }
.anmelden h1 { font-size: 1.3rem; margin: 0; }
.anmelden label { display: flex; flex-direction: column; gap: 4px; color: var(--leise); }
.anmelden input { font: inherit; font-size: 1.1rem; padding: 10px 12px; border: 1px solid var(--rand); border-radius: 10px; background: var(--grund); color: var(--text); }
.tabelle-rahmen { overflow-x: auto; }
table.uebersicht { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.uebersicht th, .uebersicht td { padding: 6px 8px; border-bottom: 1px solid var(--rand); text-align: center; }
.uebersicht td:first-child { text-align: left; }
.uebersicht .z1 { background: color-mix(in srgb, var(--richtig) 15%, transparent); }
.uebersicht .z2 { background: color-mix(in srgb, var(--richtig) 30%, transparent); }
.uebersicht .z3 { background: color-mix(in srgb, var(--richtig) 45%, transparent); }
.uebersicht .z4, .uebersicht .z5 { background: color-mix(in srgb, var(--richtig) 65%, transparent); }
.anmelden .knopf { min-height: 48px; }
.uebersicht td:first-child { white-space: nowrap; }
