/* Prüfungsfit – ruhige Fläche, Kugelschreiberblau für Aktionen, Textmarkergelb für Erfolge.
   Das wiedererkennbare Element: Antworten als Markierungskreise wie auf dem Lösungsbogen. */

:root {
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --ink: #172033;
  --muted: #5B6577;
  --line: #DCE1E8;
  --pen: #2747D6;
  --pen-soft: #E6EBFC;
  --on-pen: #FFFFFF;
  --marker: #FFE45C;
  --marker-ink: #3A3000;
  --ok: #138A5B;
  --ok-soft: #E3F4EC;
  --bad: #C4372F;
  --bad-soft: #FBE9E7;
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --shadow: 0 1px 2px rgba(23, 32, 51, .06), 0 8px 24px -12px rgba(23, 32, 51, .18);
  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161F; --surface: #1A2030; --ink: #EEF1F6; --muted: #A2ABBB; --line: #2D3548;
    --pen: #7D95FF; --pen-soft: #232D4D; --on-pen: #0E1430; --marker: #F2D63F; --marker-ink: #2A2300;
    --ok: #4CC793; --ok-soft: #173329; --bad: #FF7A70; --bad-soft: #3A1E1D;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161F; --surface: #1A2030; --ink: #EEF1F6; --muted: #A2ABBB; --line: #2D3548;
  --pen: #7D95FF; --pen-soft: #232D4D; --on-pen: #0E1430; --marker: #F2D63F; --marker-ink: #2A2300;
  --ok: #4CC793; --ok-soft: #173329; --bad: #FF7A70; --bad-soft: #3A1E1D;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.015em; }
h1 { font-size: clamp(28px, 6vw, 38px); font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
a { color: var(--pen); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Gerüst ---------- */
.shell { min-height: 100dvh; }
main { max-width: 640px; margin: 0 auto; padding: 24px 16px calc(110px + env(safe-area-inset-bottom)); outline: none; }

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.nav .brand { display: none; }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px; color: var(--muted);
  text-decoration: none; font-size: 12px; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--pen); }
.nav a[aria-current="page"] svg { stroke-width: 2.3; }

@media (min-width: 960px) {
  .nav {
    inset: 0 auto 0 0; width: 232px; display: flex; flex-direction: column; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line); padding: 24px 14px; background: var(--surface);
  }
  .nav .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: var(--ink); font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
  .nav .brand svg { width: 28px; height: 28px; }
  .nav a { flex-direction: row; gap: 12px; font-size: 16px; padding: 10px 12px; }
  .nav a[aria-current="page"] { background: var(--pen-soft); }
  .nav a.brand[aria-current] { background: none; }
  main { padding: 48px 32px 64px; max-width: 704px; }
  .shell.has-nav { padding-left: 232px; }
}

/* ---------- Bausteine ---------- */
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.section { margin-top: 36px; }
.section > h2 { margin-bottom: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.list-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px;
  background: none; border: 0; text-align: left; text-decoration: none; color: inherit; cursor: pointer;
}
.list-item:hover { background: color-mix(in srgb, var(--pen-soft) 45%, transparent); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.chev { width: 18px; height: 18px; flex: none; stroke: var(--muted); fill: none; stroke-width: 2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink);
  transition: transform .08s ease, background-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--pen); border-color: var(--pen); color: var(--on-pen); }
.btn.primary:hover { background: color-mix(in srgb, var(--pen) 88%, #000); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--pen); padding-inline: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--bad); }

.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 15px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--radius-s);
  border: 1.5px solid var(--line); background: var(--surface);
}
.textarea { min-height: 140px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--pen); box-shadow: 0 0 0 3px var(--pen-soft); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; }
.seg button { min-height: 42px; border: 0; border-radius: 10px; background: none; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--pen); color: var(--on-pen); }

.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--pen); border-radius: inherit; transition: width .4s ease; }
.bar.ok > i { background: var(--ok); }

.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--pen-soft); color: var(--pen); }
.tag.marker { background: var(--marker); color: var(--marker-ink); }

/* Textmarker-Strich hinter Text */
.hl { background: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 92%, transparent 92%); padding: 0 .1em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hl { color: var(--marker-ink); background: var(--marker); border-radius: 4px; } }

/* ---------- Heute ---------- */
.today-head { display: grid; gap: 6px; }
.countdown { font-size: 15px; color: var(--muted); }
.countdown b { color: var(--ink); }

.goal {
  display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center;
  margin-top: 24px; padding: 22px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.ring { --p: 0; width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--pen) calc(var(--p) * 1%), var(--line) 0); }
.ring.done { background: conic-gradient(var(--ok) 100%, var(--line) 0); }
.ring > div { width: 80px; height: 80px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring b { font-size: 26px; font-weight: 800; }
.ring small { display: block; font-size: 12px; color: var(--muted); }
.goal .stack { --gap: 10px; }
@media (max-width: 480px) {
  .goal { grid-template-columns: 1fr; gap: 16px; padding: 20px; }
  .goal .ring { position: absolute; right: 20px; top: 20px; width: 72px; height: 72px; }
  .goal .ring > div { width: 56px; height: 56px; }
  .goal .ring b { font-size: 20px; }
  .goal { position: relative; }
  .goal .stack h2, .goal .stack p { padding-right: 84px; }
  .goal .btn { width: 100%; }
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat b, .ring b, .counter, .timer, .result-score { font-variant-numeric: tabular-nums; }
.stat { padding: 14px; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); }
.stat b { display: block; font-size: 22px; font-weight: 800; }
.stat span { font-size: 13px; color: var(--muted); }

/* ---------- Fragen ---------- */
.runner-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; margin-bottom: 28px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); display: grid; place-items: center; cursor: pointer; border: 1px solid var(--line); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.counter { font-size: 14px; font-weight: 600; color: var(--muted); min-width: 48px; text-align: right; }

.q-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.q-text { font-size: clamp(20px, 4.6vw, 24px); font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; max-width: 34em; white-space: pre-line; }

.options { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; padding: 10px 16px 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-m);
  transition: border-color .15s ease, background-color .15s ease;
}
.opt:hover:not([disabled]) { border-color: var(--pen); }
.opt[disabled] { cursor: default; }
.bubble {
  position: relative; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  border: 2px solid var(--ink); color: var(--ink); background: transparent; text-transform: lowercase;
}
/* Ausfüllen wie mit Kuli */
.bubble::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--pen); transform: scale(0); transition: transform .22s cubic-bezier(.3,1.4,.5,1); }
.opt.picked .bubble::after { transform: scale(1); }
.opt.picked .bubble { color: var(--on-pen); border-color: var(--pen); }
.bubble span { position: relative; z-index: 1; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .bubble { border-color: var(--ok); }
.opt.correct .bubble::after { background: var(--ok); }
.opt.correct.show .bubble { color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .bubble::after { background: var(--bad); }
.opt.wrong .bubble { border-color: var(--bad); }
.opt.dim { opacity: .55; }

.feedback { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius-m); border-left: 4px solid var(--ok); background: var(--surface); }
.feedback.bad { border-left-color: var(--bad); }
.feedback h3 { margin-bottom: 4px; }
.xp-pop { display: inline-block; margin-left: 8px; animation: pop .6s ease; }
@keyframes pop { 0% { transform: translateY(6px); opacity: 0; } 60% { transform: translateY(-2px); opacity: 1; } 100% { transform: none; } }

.actionbar { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); margin-top: 20px; padding-top: 12px; }
.runner .actionbar { bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { .actionbar, .runner .actionbar { bottom: 24px; } }

/* Lernkarte */
.card-scene { perspective: 1400px; margin-top: 8px; }
.flash {
  position: relative; width: 100%; min-height: 320px; border: 0; padding: 0; background: none; cursor: pointer;
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.7,.2,1);
}
.flash.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 28px;
  border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: left;
}
.face.back { transform: rotateY(180deg); }
.face .q-text { font-size: 22px; }
.face .hint { position: absolute; bottom: 18px; left: 28px; font-size: 13px; color: var(--muted); }
.face .answer { font-size: 20px; font-weight: 700; }

/* Ergebnis */
.result-score { font-size: clamp(64px, 18vw, 112px); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.result-score .hl { padding: 0 .06em; }
@media (prefers-reduced-motion: no-preference) {
  .result-score .hl { background-size: 0% 100%; background-repeat: no-repeat; animation: marker .7s .25s ease-out forwards;
    background-image: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 90%, transparent 90%); background-color: transparent; }
  @keyframes marker { to { background-size: 100% 100%; } }
}

/* Upload */
.drop {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 32px 20px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius-l); background: var(--surface);
}
.drop.over { border-color: var(--pen); background: var(--pen-soft); }
.drop svg { width: 36px; height: 36px; stroke: var(--pen); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.notice { padding: 14px 16px; border-radius: var(--radius-m); background: var(--pen-soft); font-size: 15px; }
.notice.warn { background: color-mix(in srgb, var(--marker) 35%, var(--surface)); }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius-m);
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; width: 100%;
}
.choice[aria-pressed="true"] { border-color: var(--pen); box-shadow: 0 0 0 3px var(--pen-soft); }
.choice .bubble { flex: none; width: 24px; height: 24px; }
.choice .bubble::after { inset: 3px; }
.choice[aria-pressed="true"] .bubble { border-color: var(--pen); }
.choice[aria-pressed="true"] .bubble::after { transform: scale(1); }

.steps { display: flex; gap: 6px; margin-bottom: 28px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--pen); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  padding: 12px 18px; border-radius: 99px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; padding: 36px 16px; }
.empty p { max-width: 30em; margin: 8px auto 16px; }

.timer { font-weight: 700; font-size: 15px; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.timer.low { color: var(--bad); border-color: var(--bad); }

.review-item { padding: 16px; }
.review-item p + p { margin-top: 6px; }
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.check { width: 22px; height: 22px; flex: none; accent-color: var(--pen); margin: 0; }

/* ---------- Prüfungsteil ---------- */
.teil-seg { margin-top: 18px; }

/* ---------- Offene Aufgaben ---------- */
.task-card {
  display: grid; gap: 6px; width: 100%; padding: 18px 20px; text-align: left; cursor: pointer; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow);
}
.task-card:hover { border-color: var(--pen); }
.task-card-title { font-size: 19px; font-weight: 700; line-height: 1.25; }
.btn.small-btn { min-height: 38px; padding: 6px 16px; font-size: 15px; }

.task-title { font-size: clamp(24px, 5vw, 30px); margin-bottom: 14px; }
.situation { display: grid; gap: 10px; padding: 16px 18px; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); max-width: 40em; }
.situation p, .material-text p, .solution-text { white-space: pre-line; }
.material { margin: 14px 0 0; padding: 0; }
.material figcaption { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.material-text { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--radius-m); border: 1px dashed var(--line); font-size: 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 15px; }
.table-wrap th, .table-wrap td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap thead th { background: var(--bg); font-weight: 700; white-space: nowrap; }
.table-wrap tbody th { font-weight: 600; }
.table-wrap tr:last-child > * { border-bottom: 0; }

.ta { margin-top: 28px; display: grid; gap: 12px; }
.ta-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.ta-nr { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 99px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-weight: 800; font-size: 14px; }
.ta-q { font-weight: 600; font-size: 17px; line-height: 1.4; white-space: pre-line; padding-top: 2px; }
.ta-text { min-height: 96px; }
.result-field { display: grid; gap: 4px; max-width: 320px; }
.result-field .unit { font-weight: 700; color: var(--muted); }
.answer-box { padding: 12px 14px; border-radius: var(--radius-s); background: var(--surface); border: 1.5px solid var(--line); white-space: pre-wrap; }

.solution { padding: 16px 18px; border-radius: var(--radius-m); background: var(--ok-soft); border-left: 4px solid var(--ok); }
.solution h4 { margin: 0 0 6px; font-size: 15px; }
.criteria { display: grid; gap: 2px; }
.criterion { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; cursor: pointer; font-size: 15px; }
.criterion .grow { flex: 1; }
.criterion .pts { font-weight: 700; white-space: nowrap; }

/* Karopapier */
.sheet { --grid: color-mix(in srgb, var(--pen) 16%, transparent); border: 1.5px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.sheet canvas {
  display: block; width: 100%; touch-action: none; cursor: crosshair;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px; background-position: -1px -1px;
}
.sheet canvas.erasing { cursor: cell; }
.sheet.ro canvas { cursor: default; touch-action: auto; }
.sheet-tools { display: flex; align-items: center; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--bg); }
.sheet-tools .grow { flex: 1; }
.tool { width: 40px; height: 40px; border-radius: 10px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool[aria-pressed="true"] { background: var(--pen); color: var(--on-pen); }
.tool:hover:not([aria-pressed="true"]) { background: var(--pen-soft); }

/* Bestätigungsdialog */
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(12, 16, 26, .45); animation: fade .15s ease; }
.dialog { width: min(420px, 100%); padding: 22px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.dialog p { font-size: 17px; font-weight: 600; }
.dialog-actions { margin-top: 20px; justify-content: flex-end; flex-wrap: wrap; }
.dialog-actions .btn { flex: 1 1 140px; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: var(--surface); }
@keyframes fade { from { opacity: 0; } }

/* ---------- Lernkarten im Papier-Stil ----------
   Karteikarte: oben roter Strich, darunter blaue Linien. Alle Zeilenhöhen sind Vielfache von 30px,
   damit die Schrift auf den Linien sitzt. */
:root {
  --paper: #FFFDF5; --paper-line: #C9DAF0; --paper-red: #E7838B; --paper-ink: #1E2B5C; --paper-dark: #20232B;
  --mk-0: #FFE45C; --mk-1: #A8EFA3; --mk-2: #FFB3D1; --mk-3: #A9DDFF;
  --hand: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  --hand-head: "Caveat", "Segoe Print", "Bradley Hand", cursive;
}
.paper-scene { margin-top: 4px; perspective: 1200px; }
.paper-btn { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.paper-btn[disabled] { cursor: default; }
.paper-btn.turn-out { animation: turnOut .16s ease-in forwards; }
.paper-btn.turn-in { animation: turnIn .2s ease-out; }
@keyframes turnOut { to { transform: rotateY(90deg); } }
@keyframes turnIn { from { transform: rotateY(-90deg); } }

.paper {
  position: relative; isolation: isolate; min-height: 360px; padding: 30px 22px 30px 26px;
  background-color: var(--paper);
  border-radius: 6px; color: var(--paper-ink);
  box-shadow: 0 1px 1px rgba(0,0,0,.08), 0 10px 26px -12px rgba(23, 32, 51, .35);
  transform: rotate(-0.6deg);
  font-family: var(--hand); font-size: 18px; line-height: 30px;
}
/* Kopf: 30 + 60 = 90px bis zum roten Strich, darunter 30px-Linien. Der Kopf bleibt unliniert wie bei einer Karteikarte. */
.paper::before {
  content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: 88px; bottom: 0;
  background-image: linear-gradient(var(--paper-red), var(--paper-red)), repeating-linear-gradient(transparent 0 29px, var(--paper-line) 29px 30px);
  background-size: 100% 2px, 100% 100%; background-position: 0 0, 0 2px; background-repeat: no-repeat, repeat;
}
.paper-title { margin: 0; font-family: var(--hand-head); font-size: 36px; line-height: 60px; font-weight: 700; color: var(--paper-dark); letter-spacing: 0; }
.paper-frage { margin: 0; font-weight: 700; white-space: pre-line; }
.paper-h { margin: 30px 0 0; font-family: var(--hand-head); font-size: 26px; line-height: 30px; font-weight: 700; color: var(--paper-dark); letter-spacing: 0; }
.paper-title + .paper-h { margin-top: 0; }
.paper ul { list-style: none; margin: 0; padding: 0; }
.paper li { position: relative; padding-left: 20px; }
.paper li::before { content: "–"; position: absolute; left: 2px; }
.paper-text { margin: 30px 0 0; white-space: pre-line; }
.paper-formel {
  display: inline-block; margin: 30px 0 0; padding: 0 12px; line-height: 26px; font-weight: 700;
  border: 2px solid var(--paper-ink); border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
}
.paper-merke { margin: 30px 0 0; }
.paper-merke b { font-family: var(--hand-head); font-size: 24px; color: #C8323C; margin-right: 4px; }
.paper-hint { margin: 30px 0 0; font-family: var(--font); font-size: 14px; line-height: 30px; color: #8A8F9C; }
.paper-blank { display: grid; }
.paper-frage + .paper-blank { margin-top: 30px; }
.paper-blank i { display: block; height: 30px; position: relative; }
.paper-blank i::after { content: ""; position: absolute; left: 20px; right: 30%; top: 12px; height: 6px; border-radius: 4px; background: rgba(30, 43, 92, .08); }
.paper-blank i:nth-child(2n)::after { right: 45%; }
.paper-blank i:nth-child(3n)::after { right: 22%; }
.pen-ul { text-decoration: underline; text-decoration-color: #D9434D; text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* Textmarker: leicht schräg, nicht ganz bis zum Rand, wie von Hand gezogen */
.mk {
  --mk: var(--mk-0);
  padding: 0 .25em; margin-left: -.15em;
  background: linear-gradient(100deg, transparent .2em, var(--mk) .35em, var(--mk) calc(100% - .3em), transparent calc(100% - .1em));
  background-size: 100% 62%; background-position: 0 72%; background-repeat: no-repeat;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.mk-t, .mk-0 { --mk: var(--mk-0); }
.mk-1 { --mk: var(--mk-1); }
.mk-2 { --mk: var(--mk-2); }
.mk-3 { --mk: var(--mk-3); }

/* Im Dunkeln bleibt die Karte Papier, nur etwas gedämpft */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --paper: #ECE8DC; --paper-line: #B9C6D8; } }
:root[data-theme="dark"] { --paper: #ECE8DC; --paper-line: #B9C6D8; }
@media (max-width: 480px) { .paper { padding-left: 18px; padding-right: 14px; font-size: 17px; } .paper-title { font-size: 32px; } }

/* Zeichnungen: immer auf weißem Grund, wie auf dem Aufgabenblatt (schwarze Linien bleiben auch im Dunkelmodus lesbar) */
.q-bild { margin: 16px 0 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-m); }
.q-bild img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; }
.material .q-bild { margin-top: 0; }

/* ---------- Lernheft ----------
   Lesbar wie ein ordentlich geführtes Heft: Überschriften mit Textmarker in Handschrift,
   Fließtext in der normalen Schrift, Formeln in gezeichneten Kästen. */
.heft-formel-link { display: flex; align-items: center; gap: 12px; margin-top: 20px; padding: 16px 18px; border-radius: var(--radius-m);
  background: var(--paper); color: var(--paper-ink); text-decoration: none; box-shadow: var(--shadow); }
.heft-formel-link .mk { font-family: var(--hand-head); font-size: 26px; font-weight: 700; color: var(--paper-dark); }
.heft-formel-link .small { flex: 1; color: #6B7080; }
.heft-formel-link .chev { stroke: #8A8F9C; }
.heft-nr { width: 28px; flex: none; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }

.heft-seite { margin-top: 8px; }
.heft-titel { font-family: var(--hand-head); font-size: clamp(36px, 8vw, 46px); font-weight: 700; letter-spacing: 0; line-height: 1.1; margin-top: 4px; }
.heft-kurz { margin-top: 12px; font-size: 18px; color: var(--muted); max-width: 36em; }
.heft-h { margin: 30px 0 8px; font-family: var(--hand-head); font-size: 28px; font-weight: 700; letter-spacing: 0; line-height: 1.15; }
.heft-h a { color: inherit; }
/* Text auf dem Marker bleibt dunkel, auch im Dunkelmodus */
.heft-titel .mk, .heft-h .mk { color: var(--paper-dark); }
.heft-text { display: grid; gap: 10px; max-width: 38em; }
.heft-liste { margin: 0; padding-left: 22px; display: grid; gap: 6px; max-width: 38em; }
.heft-liste li::marker { color: var(--pen); }
.pen-ul { text-decoration-color: #D9434D; }

.heft-formel { margin-top: 16px; padding: 16px 18px; background: var(--paper); color: var(--paper-ink); border-radius: 6px; box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 8px 20px -12px rgba(23,32,51,.3); }
.heft-formel-titel { font-family: var(--hand-head); font-size: 24px; font-weight: 700; color: var(--paper-dark); line-height: 1.1; }
.heft-formel-zeile {
  display: inline-block; margin-top: 8px; padding: 6px 14px; font-size: 20px; font-weight: 700; color: var(--paper-dark);
  border: 2px solid var(--paper-ink); border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; overflow-wrap: anywhere;
}
.heft-groessen { margin: 12px 0 0; display: grid; gap: 4px; font-size: 15px; }
.heft-groessen div { display: grid; grid-template-columns: minmax(40px, auto) 1fr; gap: 10px; }
.heft-groessen dt { font-weight: 700; }
.heft-groessen dd { margin: 0; }
.heft-groessen .muted, .heft-beispiel { color: #5B6170; }
.heft-beispiel { margin-top: 10px; font-size: 15px; border-top: 1px dashed #C9C3B2; padding-top: 10px; }

.heft-box { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-m); max-width: 40em; }
.heft-box b { margin-right: 4px; }
.heft-box.merke { background: var(--paper); color: var(--paper-ink); transform: rotate(-0.4deg); box-shadow: 0 6px 16px -10px rgba(23,32,51,.35); }
.heft-box.merke b { font-family: var(--hand-head); font-size: 24px; color: #C8323C; }
.heft-box.falle { background: var(--bad-soft); border-left: 4px solid var(--bad); }
.heft-box.falle b { color: var(--bad); }
.heft-box.tipp { background: var(--pen-soft); border-left: 4px solid var(--pen); }
.heft-box.tipp b { color: var(--pen); }
.heft-seite .material { margin-top: 8px; }
.heft-blaettern { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.heft-blaettern .btn { max-width: 100%; white-space: normal; text-align: center; }
@media (max-width: 480px) { .nav a { font-size: 11px; padding-inline: 2px; } }

/* Konto */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
