:root {
  --bg: #121316;
  --surface: #1c1e23;
  --surface-2: #262930;
  --border: #31353d;
  --text: #f1f1f1;
  --muted: #9ba1a8;
  --ok: #3ecf8e;
  --ok-bg: #143126;
  --bad: #ff5c5c;
  --bad-bg: #3a1c1c;
  --focus: #7aa2ff;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
}
main {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}

/* Kopfzeile */
.top { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.top a, .link {
  color: var(--muted); text-decoration: none; font-size: 16px;
  min-height: 44px; display: inline-flex; align-items: center; cursor: pointer;
}
.top .counter { color: var(--muted); font-variant-numeric: tabular-nums; }

h1 { font-size: 26px; font-weight: 650; margin: 8px 0 16px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 28px 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.big { font-size: 22px; font-weight: 600; }
.error { color: var(--bad); }

/* Buttons */
button { font: inherit; -webkit-tap-highlight-color: transparent; }
.btn {
  display: flex; width: 100%; align-items: center; justify-content: center;
  min-height: 56px; padding: 12px 18px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 18px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:active { opacity: .85; }
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible, .option:focus-visible, .deck:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.actions { margin-top: 24px; }

/* Start: Alle Decks */
.all { margin-bottom: 18px; }
.all-meta { color: var(--muted); font-size: 14px; margin-top: 8px; text-align: center; }

/* Start: Session fortsetzen */
.resume { flex-direction: column; gap: 2px; margin-bottom: 10px; }
.resume-sub { font-size: 13px; font-weight: 500; opacity: .7; }

/* Start: Fach-Auswahl */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.tab { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 16px; font-weight: 600; cursor: pointer; }
.tab.on { background: var(--surface-2); color: var(--text); }

/* Start: Decks */
.deck {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; color: inherit; cursor: pointer;
}
.deck:active { background: var(--surface-2); }
.deck-title { font-size: 19px; font-weight: 650; }
.deck-desc { color: var(--muted); font-size: 15px; margin-top: 2px; }
.deck-meta { margin-top: 10px; font-size: 15px; color: var(--muted); }
.deck-meta strong { color: var(--text); font-weight: 600; }
.deck-meta strong.due { color: var(--ok); }

/* Start: Statistik */
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-row strong { font-weight: 600; }
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 16px; }
.box { text-align: center; font-size: 12px; color: var(--muted); }
.box .bar { height: 64px; display: flex; align-items: flex-end; background: var(--surface); border-radius: 6px; overflow: hidden; }
.box .bar > div { width: 100%; background: var(--muted); min-height: 2px; }
.box.b5 .bar > div { background: var(--ok); }
.box .n { color: var(--text); font-weight: 600; font-size: 15px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Session */
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress > div { height: 100%; background: var(--text); }
.card { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 16px 0; }
.prompt { font-size: 24px; line-height: 1.35; font-weight: 500; }
.prompt .gap { display: inline-block; min-width: 3ch; border-bottom: 2px solid var(--muted); line-height: 1; }
mark { background: transparent; color: var(--ok); font-weight: 650; }
.hint { color: var(--muted); margin-top: 10px; font-size: 16px; }

.answer-form { margin-top: 24px; }
.answer-form input {
  width: 100%; font: inherit; font-size: 20px; padding: 14px 16px; min-height: 56px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.answer-form .btn { margin-top: 10px; }

.options { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 56px; padding: 12px 14px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer;
}
.option:active { background: var(--surface-2); }
.option .key {
  flex: none; width: 28px; height: 28px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

.dunno { display: block; width: 100%; margin-top: 14px; min-height: 44px; background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.dunno:active { color: var(--text); }

/* Feedback */
.verdict { font-size: 22px; font-weight: 700; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.compare > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; min-width: 0; }
.compare .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.compare .val { font-size: 19px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.compare .bad .val { color: var(--bad); }
.compare .ok .val { color: var(--ok); }
.typo { margin-top: 14px; color: var(--muted); }
.typo strong { color: var(--ok); }
.note { margin-top: 18px; padding: 4px 0 4px 14px; border-left: 3px solid var(--border); color: var(--muted); font-size: 16px; }

/* Ergebnis */
.score { font-size: 40px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.errors { list-style: none; padding: 0; margin: 0; }
.errors li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.errors .given { color: var(--muted); font-size: 15px; margin-top: 6px; }
.errors .given span { color: var(--bad); }
.errors .note { margin-top: 8px; padding: 0; border: 0; font-size: 15px; }

/* Einstellungen */
.setting { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.setting p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.setting .btn { background: var(--surface-2); }
.setting code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--text); }
.setting form .btn { margin-top: 10px; }
.file-btn { position: relative; }
.file-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.status { margin-top: 12px; font-size: 15px; color: var(--ok); }
.status.bad { color: var(--bad); }
.reset-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.reset-row:last-child { border-bottom: 0; }
.reset-row .btn { width: auto; min-height: 44px; padding: 8px 14px; font-size: 15px; flex: none; }

@media (min-width: 640px) {
  .prompt { font-size: 28px; }
}

/* Reload-Knopf (Homescreen-App hat keinen Browser-Reload) */
.reload { display: block; width: 100%; margin: 28px 0 0; min-height: 48px; background: transparent; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); font-size: 15px; cursor: pointer; }
.reload:active { background: var(--surface); }
.reload .arrow { display: inline-block; font-size: 18px; margin-right: 4px; }
.reload.spin .arrow { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reload.spin .arrow { animation: none; } }
