:root {
  /* Werkstattfarben: Stahlgrau, Signalorange, Petrol */
  --bg: #f3f5f7;
  --bg-2: #e8ecf0;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #637081;
  --line: #dde3e9;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --accent-soft: #fde8db;
  --teal: #0b7285;
  --teal-soft: #dcf0f3;
  --green: #2b8a3e;
  --green-soft: #e1f3e4;
  --red: #c92a2a;
  --red-soft: #fbe3e3;
  --warn-soft: #fff3d6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 30, 45, .05), 0 3px 12px rgba(20, 30, 45, .07);
  --topbar: rgba(243, 245, 247, .9);
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d; --bg-2: #1a2129; --card: #1c242d; --text: #e9eef3; --muted: #9aa7b5; --line: #2c3743;
    --accent: #ff8a3d; --accent-ink: #1d0d03; --accent-soft: #3d2516;
    --teal: #4fc3d4; --teal-soft: #15333a; --green: #69db7c; --green-soft: #183322; --red: #ff8787; --red-soft: #3d1d1f;
    --warn-soft: #3a3016; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --topbar: rgba(18, 23, 29, .9);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: none; }
a { color: var(--teal); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }
sub { font-size: .7em; }

/* ---------- Kopf- und Tab-Leiste ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 900px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 16px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 750; font-size: 1.02rem; margin-right: auto; }
.logo { width: 32px; height: 32px; border-radius: 9px; }
.pill { font-size: .8rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.teal { background: var(--teal-soft); color: var(--teal); }
body.fokus .tabbar { display: none; }
body.fokus main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.tabbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: stretch;
  background: var(--topbar); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: var(--tabbar-h);
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 650; }
.tabbar .ti { font-size: 1.35rem; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .ti { filter: none; opacity: 1; }

main { max-width: 900px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 760px) { .grid-auto { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } .grid-auto > * + * { margin-top: 0; } }

/* ---------- Karten, Listen ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.accent { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #ffb347)); color: #fff; }
.card.accent .muted { color: rgba(255, 255, 255, .85); }
.hero-num { font-size: 2.4rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.45rem; line-height: 1.15; }
.stat span { font-size: .8rem; color: var(--muted); }

.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > a, .list > .li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: var(--text); text-decoration: none; min-height: 56px; }
.list > a + a, .list > .li + .li, .list > a + .li, .list > .li + a { border-top: 1px solid var(--line); }
.list > a:active { background: var(--bg-2); }
.li-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--bg-2); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.li-main { flex: 1; min-width: 0; }
.li-main b { display: block; font-weight: 650; }
.li-main .small { display: block; }
.chev { color: var(--muted); font-size: 1.2rem; }

.bar { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .g { background: var(--green); }
.bar .t { background: var(--teal); opacity: .55; }
.bar .o { background: var(--accent); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.section-title { font-size: .8rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 8px; }

/* ---------- Knöpfe, Eingaben ---------- */
.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.plain { background: var(--bg-2); color: var(--text); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--teal); padding: 8px 10px; min-height: 40px; }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: .9rem; border-radius: 10px; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; width: 100%; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; font-weight: 650; color: var(--muted); margin: 0 0 5px 2px; }
.seg { display: flex; background: var(--bg-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 650; font-size: .92rem; color: var(--muted); border-radius: 9px; min-height: 40px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--line); background: var(--card); color: var(--text); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; min-height: 36px; }
.chip.on { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }

/* ---------- Lernkarte ---------- */
.lernkopf { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lernkopf .bar { flex: 1; }
.frage { font-size: 1.15rem; font-weight: 650; line-height: 1.4; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--bg-2); color: var(--muted); }
.tag.src { background: var(--teal-soft); color: var(--teal); text-decoration: none; cursor: pointer; border: 0; font-family: inherit; }
.tag.box { background: var(--accent-soft); color: var(--accent); }
.antwort { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--bg-2); white-space: pre-line; }
.erklaerung { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); font-size: .95rem; }
.optionen { display: grid; gap: 8px; margin-top: 14px; }
.option { text-align: left; border: 1.5px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 12px 14px; font: inherit; cursor: pointer; min-height: 52px; display: flex; gap: 10px; align-items: flex-start; }
.option .lit { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; font-weight: 750; font-size: .85rem; }
.option.richtig { border-color: var(--green); background: var(--green-soft); }
.option.falsch { border-color: var(--red); background: var(--red-soft); }
.option.gewaehlt { border-color: var(--teal); background: var(--teal-soft); }
.option:disabled { cursor: default; }
.ergebnis { margin-top: 12px; font-weight: 750; }
.ergebnis.ok { color: var(--green); }
.ergebnis.nok { color: var(--red); }
.bewerten { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.zahlfeld { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.zahlfeld input { flex: 1; font-size: 1.1rem; }
.zahlfeld .einheit { font-weight: 700; color: var(--muted); min-width: 30px; }
.stickybar { position: sticky; bottom: 0; padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }

/* ---------- Rechner ---------- */
.aufgabe { white-space: pre-line; }
.gegeben { margin: 10px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: .95rem; }
.gegeben li { padding: 6px 10px; background: var(--bg-2); border-radius: 9px; }
.felder { display: grid; gap: 10px; margin-top: 14px; }
.feld { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.feld > .lbl { grid-column: 1 / -1; font-size: .88rem; font-weight: 650; color: var(--muted); }
.feld .einheit { font-weight: 700; color: var(--muted); min-width: 34px; }
.feld input.ok { border-color: var(--green); background: var(--green-soft); }
.feld input.nok { border-color: var(--red); background: var(--red-soft); }
.loesung { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--bg-2); }
.loesung ol { margin: 6px 0 0; padding-left: 22px; }
.loesung li + li { margin-top: 5px; }
.formel { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .95rem; }

/* ---------- Formeln, Aufschriebe ---------- */
.formelkarte { padding: 12px 16px; }
.formelkarte + .formelkarte { border-top: 1px solid var(--line); }
.formelkarte .formel { display: block; font-size: 1.05rem; font-weight: 650; margin: 3px 0; color: var(--accent); }
.seiten { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.seite { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.seite img { width: 100%; aspect-ratio: 210 / 297; object-fit: cover; object-position: top; background: #fff; display: block; }
.seite span { font-size: .8rem; font-weight: 600; padding: 7px 9px; line-height: 1.3; }
.seitenbild { width: 100%; height: auto; border-radius: 10px; background: #fff; display: block; box-shadow: var(--shadow); }

/* ---------- Prüfung ---------- */
.timer { font-variant-numeric: tabular-nums; }
.timer.knapp { background: var(--red-soft); color: var(--red); }
.note { font-size: 3rem; font-weight: 850; line-height: 1; }
.review { border-left: 4px solid var(--line); padding: 8px 12px; margin-top: 10px; background: var(--card); border-radius: 0 12px 12px 0; }
.review.ok { border-color: var(--green); }
.review.nok { border-color: var(--red); }

/* ---------- Dialog, Toast ---------- */
dialog { border: 0; border-radius: 18px; padding: 0; background: var(--card); color: var(--text); max-width: min(560px, calc(100vw - 24px)); width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 15, 20, .55); }
dialog.sheet { margin: auto auto 0; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
dialog .content { padding: 18px; overflow: auto; max-height: calc(92vh - 70px); }
dialog footer { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
dialog.bild { max-width: min(900px, calc(100vw - 16px)); }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem; transition: .25s; z-index: 50; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); color: #fff; }

.leer { text-align: center; padding: 30px 10px; color: var(--muted); }
.leer .gross { font-size: 2.6rem; }
.verlauf { display: flex; gap: 3px; align-items: flex-end; height: 48px; }
.verlauf i { flex: 1; background: var(--teal); opacity: .75; border-radius: 3px 3px 0 0; min-height: 2px; }
.verlauf i.leer0 { background: var(--line); opacity: 1; }

/* ---------- Nachschlagen ---------- */
.suchfeld input { font-size: 17px; padding-left: 40px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23637081' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center; }
details.wissen { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 0 14px; margin-top: 8px; }
details.wissen summary { list-style: none; cursor: pointer; padding: 12px 0; display: flex; flex-direction: column; gap: 5px; }
details.wissen summary::-webkit-details-marker { display: none; }
details.wissen summary .tag { align-self: flex-start; }
details.wissen[open] summary { border-bottom: 1px solid var(--line); }
.wissen-text { padding: 12px 0 4px; white-space: pre-line; }
details.wissen .meta { padding-bottom: 12px; }
mark { background: #ffe066; color: inherit; border-radius: 3px; padding: 0 1px; }
@media (prefers-color-scheme: dark) { mark { background: #7a5d00; } }
a.chip { text-decoration: none; display: inline-flex; align-items: center; }

/* ---------- Auswertung ---------- */
a.admin-person { display: block; color: var(--text); text-decoration: none; }
.kennzahlen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kennzahlen > div { background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }
.kennzahlen.card > div { background: var(--bg-2); }
.kennzahlen b { display: block; font-size: 1.1rem; }
.kennzahlen span { font-size: .72rem; color: var(--muted); }
.kennzahlen.card { grid-template-columns: 1fr 1fr; }
@media (min-width: 700px) { .kennzahlen { grid-template-columns: repeat(6, 1fr); } .kennzahlen.card { grid-template-columns: repeat(4, 1fr); } }
.gut { color: var(--green); } .mittel { color: #e67700; } .schlecht { color: var(--red); }
.tabelle-wrap { overflow-x: auto; padding: 10px; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .85rem; }
.tabelle th { text-align: left; font-size: .72rem; color: var(--muted); font-weight: 700; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tabelle td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle .r { text-align: right; white-space: nowrap; }
.tabelle td:nth-child(2) { min-width: 90px; width: 30%; }
.bar.kaesten { height: 10px; }
.k0 { background: var(--bg-2); } .k1 { background: #fa5252; } .k2 { background: #fd7e14; } .k3 { background: #fab005; } .k4 { background: #82c91e; } .k5 { background: #2b8a3e; }
.legend i.k0 { border: 1px solid var(--line); }
.verlauf.gross { height: 90px; gap: 2px; }
.verlauf.gross i { position: relative; background: var(--teal); opacity: 1; background: color-mix(in srgb, var(--teal) 40%, transparent); display: flex; align-items: flex-end; }
.verlauf.gross i u { display: block; width: 100%; background: var(--green); border-radius: 2px 2px 0 0; }
.verlauf.gross i.leer0 { background: var(--line); }
.pruefverlauf { height: 110px; gap: 6px; }
.pruefverlauf i { position: relative; opacity: 1; }
.pruefverlauf i.ok { background: var(--green); } .pruefverlauf i.nok { background: var(--red); }
.pruefverlauf em { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: .65rem; font-style: normal; color: var(--muted); }
.tabbar a { font-size: .66rem; }

.tag.web { background: #e7f0ff; color: #1c5fc9; text-decoration: none; }
@media (prefers-color-scheme: dark) { .tag.web { background: #16284a; color: #8ab4ff; } }
@media (prefers-color-scheme: dark) { .card.accent { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 70%, #000), color-mix(in srgb, var(--accent) 45%, #000)); } }

/* ---------- Aufklappbare Fächer ---------- */
details.fach { margin-top: 12px; }
details.fach > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 64px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
details.fach > summary::-webkit-details-marker { display: none; }
details.fach > summary .li-main b { font-size: 1.05rem; }
details.fach > summary .chev { transition: transform .2s; }
details.fach[open] > summary .chev { transform: rotate(90deg); }
details.fach[open] > summary { border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }
.fach-inhalt { padding: 10px 0 4px 14px; border-left: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); margin-left: 8px; }
