/* Lernkontrolle – Gestaltung
   Idee: das Schulheft. Arbeitsblätter liegen als Karopapier auf dem Tisch, Antworten erscheinen in
   Königsblau wie mit Füller geschrieben, Korrekturen in Rot. Klassen sind Heftumschläge. */

@font-face {
  font-family: "Adventor";
  src: url("../fonts/texgyreadventor-regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Adventor";
  src: url("../fonts/texgyreadventor-bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --desk: #E7EBF0;
  --paper: #FFFFFF;
  --grid: #DDE6F0;
  --ink: #1F3A93;
  --ink-dark: #172C70;
  --ink-soft: #E7ECF9;
  --red: #C0302B;
  --red-soft: #FBEAE9;
  --green: #23794A;
  --green-soft: #E3F2E8;
  --amber: #A9670F;
  --amber-soft: #FBF0DC;
  --text: #1E2430;
  --muted: #5B6575;
  --line: #C6CED9;
  --line-soft: #E2E7ED;
  --surface-2: #F6F8FA;
  --focus: #7F98E6;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-hand: "Adventor", "Century Gothic", "Avenir Next", system-ui, sans-serif;

  --radius: 8px;
  --shadow-paper: 0 1px 2px rgba(22, 32, 52, .12), 0 14px 34px -20px rgba(22, 32, 52, .4);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
html:has(.submit-bar) { scroll-padding-bottom: 120px; }
body {
  margin: 0;
  font: 16px/1.55 var(--font-ui);
  color: var(--text);
  background: var(--desk);
  min-height: 100vh;
}
img { max-width: 100%; height: auto; }
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--ink-dark); }
p { margin: 0 0 .75em; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font: 700 31px/1.15 var(--font-hand); letter-spacing: -.01em; }
h2 { font: 700 21px/1.25 var(--font-hand); }
h3 { font-size: 17px; font-weight: 650; }
small { font-size: 13px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.lead { color: var(--muted); font-size: 17px; max-width: 62ch; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* ------------------------------------------------------------ Kopfzeile */
.topbar { background: var(--paper); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; min-height: 60px; display: flex; align-items: center; gap: 20px; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 700 19px var(--font-hand); }
.brand small { font: 400 13px var(--font-ui); color: var(--muted); border-left: 1px solid var(--line); padding-left: 10px; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topnav a { color: var(--text); text-decoration: none; padding: 7px 12px; border-radius: 6px; font-weight: 550; }
.topnav a:hover { background: var(--surface-2); }
.topnav a[aria-current="page"] { color: var(--ink); background: var(--ink-soft); }
.topnav form { margin: 0 0 0 6px; }
.who { color: var(--muted); padding: 0 8px; }

/* ------------------------------------------------------------ Seiten */
.page { max-width: 1160px; margin: 0 auto; padding: 28px 20px 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head > div:first-child { flex: 1 1 340px; }
.page-head h1 { margin-bottom: 4px; }
.crumb { display: inline-block; margin-bottom: 8px; font-size: 14px; text-decoration: none; color: var(--muted); }
.crumb::before { content: "‹ "; }
.crumb:hover { color: var(--ink); }
.section { margin-top: 36px; }
.section > h2 { margin-bottom: 12px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.panel { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.grid-2 > .panel + .panel, .grid-2 > .panel { margin-top: 0; }
.panel-title { font: 700 17px var(--font-hand); margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.empty-state { max-width: 560px; margin: 60px auto; text-align: center; }
.empty-code { font: 700 64px/1 var(--font-hand); color: var(--line); margin-bottom: 12px; }

/* ------------------------------------------------------------ Meldungen */
.flashes { max-width: 820px; margin: 0 auto 20px; display: grid; gap: 8px; }
.desk .flashes, .page .flashes { max-width: none; }
.desk .flashes { max-width: 820px; }
.flash { margin: 0; padding: 10px 14px; border-radius: 6px; border-left: 4px solid var(--ink); background: var(--ink-soft); }
.flash-ok { border-color: var(--green); background: var(--green-soft); }
.flash-error { border-color: var(--red); background: var(--red-soft); }
.flash-secret { border-color: var(--amber); background: var(--amber-soft); font-weight: 600; }

/* ------------------------------------------------------------ Knöpfe und Felder */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius);
  font: 600 15px/1.2 var(--font-ui); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text);
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-dark); color: #fff; }
.btn-quiet { border-color: var(--line); background: var(--paper); }
.btn-quiet:hover { border-color: var(--ink); color: var(--ink); }
.btn-danger { color: var(--red); border-color: #EBC6C4; background: var(--paper); }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-link { padding: 0 6px; min-height: 32px; color: var(--ink); }
.btn-link:hover { text-decoration: underline; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 14px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 17px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.icon-btn { min-width: 32px; min-height: 32px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--paper); border-color: var(--line); color: var(--text); }
.icon-btn.is-danger:hover { color: var(--red); border-color: #EBC6C4; }
form.inline { display: inline; margin: 0; }

.field { display: grid; gap: 5px; }
.field > span:first-child, .label { font-weight: 600; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
input[type="text"], input[type="password"], input[type="number"], input:not([type]), input[type="search"], input[type="url"], select, textarea {
  font: inherit; color: var(--text); background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--ink); flex: none; }
.check small { display: block; color: var(--muted); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ink); font: 600 14px var(--font-ui); cursor: pointer; padding: 6px 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }

/* ------------------------------------------------------------ Status */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; padding: 2px 10px; border-radius: 999px; background: #EDF0F4; color: #4A5462; white-space: nowrap; }
.pill-active { background: var(--green-soft); color: var(--green); }
.pill-active::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-draft { background: #EEF0F3; color: var(--muted); }
.pill-closed { background: #ECEEF1; color: #444D5A; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #AEB6C2; margin-right: 6px; vertical-align: 1px; flex: none; }
.dot-online { background: #2BA35E; box-shadow: 0 0 0 3px rgba(43, 163, 94, .18); }
.dot-working { background: #D79A2B; }
.dot-done { background: var(--ink); }

/* ------------------------------------------------------------ Heftumschläge (Klassen) */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 30px 24px; align-items: start; }
.heft {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  aspect-ratio: 3 / 4; max-width: 250px; padding: 22px 16px 16px 24px;
  background: var(--cover); color: var(--cover-ink); text-decoration: none;
  border-radius: 3px 9px 9px 3px;
  box-shadow: inset 7px 0 0 rgba(0, 0, 0, .13), inset 8px 0 0 rgba(255, 255, 255, .12),
              0 1px 2px rgba(22, 32, 52, .2), 0 10px 18px -12px rgba(22, 32, 52, .45);
  transition: transform .15s ease, box-shadow .15s ease;
}
a.heft:hover { color: var(--cover-ink); transform: translateY(-3px);
  box-shadow: inset 7px 0 0 rgba(0, 0, 0, .13), inset 8px 0 0 rgba(255, 255, 255, .12),
              0 2px 3px rgba(22, 32, 52, .2), 0 18px 26px -14px rgba(22, 32, 52, .5); }
.heft-label {
  display: grid; gap: 2px; background: #fff; color: var(--text);
  border-radius: 4px; padding: 10px 12px 9px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .07);
}
.heft-name { font: 700 30px/1.05 var(--font-hand); overflow-wrap: anywhere; }
.heft-sub { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 4px; margin-top: 4px; }
.heft-foot { display: grid; gap: 3px; font-size: 13.5px; line-height: 1.35; }
.heft-task { font-weight: 650; overflow-wrap: anywhere; }
.heft-task.is-idle { font-weight: 450; opacity: .85; }
.heft-count { opacity: .9; }
.heft-new { background: transparent; color: var(--text); border: 2px dashed var(--line); box-shadow: none; padding: 18px; aspect-ratio: auto; min-height: 250px; justify-content: flex-start; }
.heft-new summary { cursor: pointer; font: 700 18px var(--font-hand); color: var(--ink); list-style: none; display: grid; place-items: center; min-height: 210px; text-align: center; }
.heft-new summary::-webkit-details-marker { display: none; }
.heft-new summary::before { content: "+"; display: block; font-size: 44px; line-height: 1; margin-bottom: 6px; font-weight: 400; }
.heft-new[open] { background: var(--paper); border-style: solid; border-color: var(--line-soft); max-width: none; grid-column: span 2; }
.heft-new[open] summary { min-height: 0; place-items: start; margin-bottom: 12px; }
.heft-new[open] summary::before { display: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.swatches legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch .chip { display: block; width: 30px; height: 38px; border-radius: 2px 5px 5px 2px; background: var(--c); box-shadow: inset 4px 0 0 rgba(0,0,0,.14); }
.swatch input:checked + .chip { outline: 3px solid var(--text); outline-offset: 2px; }
.swatch input:focus-visible + .chip { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------ Klassenseite */
.class-head { border-left: 10px solid var(--cover); padding: 4px 0 0 18px; margin-bottom: 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 24px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { font-weight: 500; color: var(--muted); margin-left: 4px; }

.current-task { display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: center; border-left: 5px solid var(--green); }
.current-task h2 { margin: 2px 0 6px; }
.current-task .kicker { font-size: 14px; color: var(--green); font-weight: 650; margin: 0; }
.meter { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.meter-track { width: 180px; max-width: 40vw; height: 8px; border-radius: 4px; background: #E6EBF1; overflow: hidden; }
.meter-track span { display: block; height: 100%; background: var(--ink); }

.task-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
.task-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 18px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line-soft); }
.task-item-title { font-weight: 650; color: var(--text); text-decoration: none; font-size: 17px; }
.task-item-title:hover { color: var(--ink); text-decoration: underline; }
.task-item-meta { font-size: 13.5px; color: var(--muted); }
.accounts-new { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px 32px; align-items: start; }
.accounts-new p { max-width: 64ch; }
.accounts-form { display: grid; gap: 12px; background: var(--surface-2); border-radius: var(--radius); padding: 16px; }
.accounts-form input[type="number"] { font: 700 22px var(--font-hand); width: 120px; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.new-task { display: flex; gap: 10px; flex-wrap: wrap; }
.new-task input, .new-task select { flex: 1 1 260px; width: auto; }
.from-example { margin-top: 10px; }

/* ------------------------------------------------------------ Tabellen */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 650; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFBFD; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table a.name { font-weight: 600; text-decoration: none; color: var(--text); }
.table a.name:hover { color: var(--ink); text-decoration: underline; }
.cell-bar { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.cell-bar .bar { flex: 1; }
.cell-bar span.val { min-width: 74px; font-variant-numeric: tabular-nums; font-size: 14px; }
.bar { height: 8px; background: #E9EDF3; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.bar.is-good > span { background: var(--green); }
.bar.is-mid > span { background: #D79A2B; }
.bar.is-low > span { background: var(--red); }
.username { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
.table td .username.muted { font-size: 12.5px; margin-left: 8px; }

/* Klappmenüs (details) */
.pop { position: relative; display: inline-block; text-align: left; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(340px, 86vw); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 16px 36px -14px rgba(22, 32, 52, .4); white-space: normal; }
.pop-panel.is-left { left: 0; right: auto; }
.pop-panel .stack > * + * { margin-top: 10px; }
.menu-list { display: grid; gap: 2px; margin: -6px; }
.menu-list button, .menu-list a { text-align: left; width: 100%; justify-content: flex-start; }

/* ------------------------------------------------------------ Aufgabenseite */
.task-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 20px; margin-bottom: 22px; }
.task-head > div:first-child { flex: 1 1 380px; }
.task-head h1 { margin: 0 0 8px; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.share { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 20px; align-items: center; }
.share-qr svg { width: 148px; height: 148px; display: block; border-radius: 4px; }
.share-link { display: flex; gap: 8px; margin: 8px 0 12px; }
.share-link input { font: 600 16px var(--font-ui); color: var(--ink); }
.stats { display: flex; flex-wrap: wrap; gap: 10px 36px; margin: 0 0 16px; padding: 0; }
.stats div { display: grid; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font: 700 22px/1.25 var(--font-hand); font-variant-numeric: tabular-nums; }
.stats dd small { font: 400 14px var(--font-ui); color: var(--muted); }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.live-note { font-size: 13px; color: var(--muted); }

.analysis { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.analysis li { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 6px 22px; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); align-items: center; }
.analysis .where { font-size: 13px; color: var(--muted); }
.analysis .ctx { font-size: 15.5px; }
.analysis .ctx .blank { display: inline-block; min-width: 4ch; border-bottom: 2px solid var(--ink); color: var(--ink); font-family: var(--font-hand); font-weight: 700; padding: 0 4px; }
.analysis .wrong { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.analysis .wrong b { color: var(--red); font-weight: 600; }
.free-q { margin-bottom: 22px; }
.free-q h3 { margin-bottom: 4px; }
.free-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.free-list li { background: var(--paper); border: 1px solid var(--line-soft); border-radius: 6px; padding: 10px 14px; display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.free-who { font-weight: 600; color: var(--text); }
.free-list .ans { font-family: var(--font-hand); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.solution-note { font-size: 14px; color: var(--red); }

/* ------------------------------------------------------------ Arbeitsblatt (Karopapier) */
.desk { padding: 28px 14px 150px; }
.sheet {
  position: relative; max-width: 820px; margin: 0 auto;
  padding: 40px 56px 56px 92px;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
  border-radius: 3px;
  box-shadow: var(--shadow-paper);
}
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 66px; width: 2px; background: rgba(192, 48, 43, .32); }
.sheet-line { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.sheet-date { font: 700 16px var(--font-hand); color: var(--ink); white-space: nowrap; }
.sheet-title {
  font: 700 32px/1.2 var(--font-hand); margin: 0 0 18px;
  text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 9px;
}
.sheet-intro { background: rgba(255, 255, 255, .88); border-left: 3px solid var(--ink); padding: 8px 14px; margin: 0 0 26px; color: #2C3442; }
.sheet-intro p:last-child { margin-bottom: 0; }
.sheet-empty .sheet-title { text-decoration: none; }

.ws-h { font: 700 23px/1.3 var(--font-hand); margin: 34px 0 10px; text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 1.5px; text-underline-offset: 6px; }
.ws-text { font-size: 17px; line-height: 1.7; margin: 10px 0 16px; }
.ws-text p, .ws-text ul, .ws-text ol { background: rgba(255, 255, 255, .55); }
.ws-text ul, .ws-text ol { padding-left: 1.4em; margin: 0 0 .75em; }
.ws-img { margin: 18px 0 22px; }
.ws-img img { display: block; border-radius: 3px; box-shadow: 0 0 0 1px var(--line-soft); background: #fff; }
.ws-img.size-s img { max-width: min(260px, 100%); }
.ws-img.size-m img { max-width: min(460px, 100%); }
.ws-img.size-l img { width: 100%; }
.ws-img figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; font-style: italic; }

.ws-task { position: relative; margin: 24px 0 30px; }
.ws-no {
  position: absolute; left: -64px; top: 1px; width: 30px; height: 30px; display: grid; place-items: center;
  font: 700 16px var(--font-hand); color: var(--ink); border: 2px solid var(--ink); border-radius: 50%; background: var(--paper);
}
.ws-prompt { display: block; font-weight: 650; font-size: 17px; line-height: 1.5; margin-bottom: 10px; }
.ws-hint { display: block; font-weight: 400; font-size: 14px; color: var(--muted); margin-top: 2px; }
.ws-cloze { font-size: 18px; line-height: 2.3; }

.ws-cloze .gap {
  font: 700 17px/1.2 var(--font-hand); color: var(--ink);
  width: var(--w, 10ch); max-width: 100%;
  border: 0; border-bottom: 2px solid var(--ink); border-radius: 3px 3px 0 0;
  background: rgba(255, 255, 255, .94); padding: 4px 6px 3px; margin: 0 2px; vertical-align: baseline;
}
.ws-cloze .gap:focus { outline: none; background: var(--ink-soft); box-shadow: 0 3px 0 -1px var(--ink); border-color: var(--ink); }
.ws-cloze .gap-select {
  width: auto; min-width: 9ch; padding-right: 28px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231F3A93' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.ws-cloze .gap-select option { font-family: var(--font-ui); font-weight: 400; color: var(--text); }
.gap-filled { font: 700 17px/1.2 var(--font-hand); color: var(--ink); border-bottom: 2px solid var(--ink); padding: 0 4px; background: rgba(255, 255, 255, .9); white-space: pre-wrap; }
.gap-filled.is-wrong s { text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.gap-filled.is-wrong { border-bottom-color: var(--red); }
.gap-filled .mark { color: var(--green); margin-left: 5px; font-family: var(--font-ui); }
.gap-empty { display: inline-block; width: 8ch; height: 1.1em; border-bottom: 2px dashed #9AA5B4; vertical-align: -2px; background: rgba(255, 255, 255, .7); }
.correction { font: 700 17px/1.2 var(--font-hand); color: var(--red); margin-left: 6px; padding: 0 3px; background: rgba(255, 255, 255, .9); }

.ws-choice { border: 0; margin: 0; padding: 0; min-width: 0; }
.ws-choice legend { padding: 0; }
.box-opt { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 7px 10px; margin: 2px -10px; border-radius: 6px; cursor: pointer; font-size: 17px; line-height: 1.45; }
label.box-opt:hover { background: rgba(31, 58, 147, .06); }
.box-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.box { position: relative; flex: 0 0 22px; height: 22px; margin-top: 1px; border: 2px solid var(--text); border-radius: 2px; background: #fff; }
.box::before, .box::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 25px; height: 3px; border-radius: 2px; background: var(--ink);
  transform: translate(-50%, -50%) rotate(45deg) scale(0); transition: transform .12s ease-out;
}
.box::after { transform: translate(-50%, -50%) rotate(-45deg) scale(0); }
.box-opt input:checked + .box::before, .box-opt.is-picked .box::before { transform: translate(-50%, -50%) rotate(45deg) scale(1); }
.box-opt input:checked + .box::after, .box-opt.is-picked .box::after { transform: translate(-50%, -50%) rotate(-45deg) scale(1); }
.box-opt input:focus-visible + .box { outline: 3px solid var(--focus); outline-offset: 2px; }
.box-text { background: rgba(255, 255, 255, .6); }
.box-opt.is-static { cursor: default; }
.box-opt.is-picked .box-text { color: var(--ink); font-family: var(--font-hand); font-weight: 700; }
.box-opt.is-wrong .box::before, .box-opt.is-wrong .box::after { background: var(--red); }
.opt-mark { margin-left: auto; font-size: 14px; font-weight: 700; white-space: nowrap; padding-left: 10px; }
.opt-mark.is-right { color: var(--green); }
.opt-mark.is-wrong { color: var(--red); }

.ws-answer {
  display: block; width: 100%; font: 400 17px/1.65 var(--font-hand); color: var(--ink);
  background: rgba(255, 255, 255, .8); border: 1.5px solid var(--line); border-radius: 4px; padding: 10px 12px; resize: vertical;
}
.ws-answer-done { font: 700 17px/1.65 var(--font-hand); color: var(--ink); background: rgba(255, 255, 255, .85); border-left: 3px solid var(--ink); padding: 6px 12px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2.4em; }
.ws-answer-done.is-empty { border-left-color: #9AA5B4; color: var(--muted); }
.ws-answer-done.is-empty::before { content: "keine Antwort"; font: italic 400 15px var(--font-ui); }
.ws-solution { margin-top: 8px; padding: 6px 12px; color: var(--red); background: rgba(255, 255, 255, .9); border-left: 3px solid var(--red); white-space: pre-wrap; }

/* Formeln */
.m { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Cambria", "Times New Roman", serif; font-size: 1.08em; white-space: nowrap; }
.m i { font-style: italic; }
.m sup, .m sub { font-size: .68em; line-height: 0; }
.m-op { padding: 0 .18em; }
.m-sqrt { display: inline-block; position: relative; padding-left: .6em; }
.m-rad { position: absolute; left: 0; top: 0; width: .62em; height: 100%; overflow: visible; }
.m-rad path { fill: none; stroke: currentColor; stroke-width: 1.4px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.m-arg { display: inline-block; border-top: 1.4px solid currentColor; padding: .08em .14em .06em .06em; line-height: 1.12; }
.m-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .15em; line-height: 1.15; }
.m-num { border-bottom: 1.5px solid currentColor; padding: 0 3px 1px; }
.m-den { padding: 1px 3px 0; }

/* Raster für halbe Breite, Kästen */
.ws-flow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; }
.wsb { grid-column: 1 / -1; min-width: 0; }
.wsb.is-half { grid-column: auto; }
.wsb.is-half .ws-no { position: static; display: inline-grid; width: 26px; height: 26px; font-size: 14px; margin: 0 0 6px; }
.ws-box { position: relative; background: rgba(240, 245, 255, .94); border: 2px solid #C9D6F4; border-radius: 8px; padding: 14px 18px 16px; margin: 18px 0 22px; }
.ws-box .ws-text { margin: 0; font-size: 16.5px; }
.ws-box .ws-text p, .ws-box .ws-text ul { background: none; }
.ws-box-title { font: 700 18px/1.3 var(--font-hand); color: var(--ink); margin: 0 0 8px; }
.ws-plain .ws-box-title { color: var(--text); font-size: 19px; margin-top: 18px; }
.ws-task.ws-box { margin: 18px 0 22px; }
.ws-task.ws-box .ws-no { left: -66px; top: 14px; }
.ws-task.ws-box .ws-cloze { font-size: 17px; }

/* Teilziele */
.ws-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 22px; padding: 8px; background: rgba(255,255,255,.9); border-radius: 10px; box-shadow: 0 0 0 1px var(--line-soft); }
.ws-tab { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 14px 6px 6px; font: 600 15px var(--font-ui); color: var(--text); cursor: pointer; }
.ws-tab:hover { border-color: var(--ink); }
.ws-tab-no { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink-soft); color: var(--ink); font: 700 14px var(--font-hand); }
.ws-tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.ws-tab[aria-selected="true"] .ws-tab-no { background: #fff; }
.ws-tab.is-complete .ws-tab-no { background: var(--green); color: #fff; }
.ws-tab.is-complete .ws-tab-no::after { content: "✓"; position: absolute; }
.ws-tab.is-complete .ws-tab-no { position: relative; color: transparent; }
.ws-tab.is-complete .ws-tab-no::after { color: #fff; font-family: var(--font-ui); }
.ws-section + .ws-section { margin-top: 34px; }
.ws-section-title { font: 700 25px/1.3 var(--font-hand); margin: 8px 0 14px; text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 7px; }
.ws-section-no { display: block; font: 700 14px var(--font-ui); color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.ws-section-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line); }
.ws-section-foot .btn-primary { margin-left: auto; }
.check-result { font-weight: 600; font-size: 15px; }
.check-result.is-right, .check-note.is-right { color: var(--green); }
.check-result.is-wrong, .check-note.is-wrong { color: var(--red); }
.check-note { font-weight: 600; font-size: 14.5px; margin: 10px 0 0; }
.ws-cloze .gap.is-right { border-bottom-color: var(--green); background: var(--green-soft); }
.ws-cloze .gap.is-wrong { border-bottom-color: var(--red); background: var(--red-soft); }
.ws-choice.is-right { box-shadow: -4px 0 0 var(--green); }
.ws-choice.is-wrong { box-shadow: -4px 0 0 var(--red); }
.widget-status { font-size: 14.5px; color: var(--muted); margin: 6px 0 10px; }
.widget-status strong { color: var(--ink); font-family: var(--font-hand); font-size: 17px; }

/* Paare finden */
.pairs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 16px; border: 2px dashed var(--line); border-radius: 12px; background: rgba(255, 255, 255, .7); }
.pcard {
  min-height: 64px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font: 600 17px/1.3 var(--font-ui); color: var(--text);
  transform: rotate(var(--r, 0deg)); transition: transform .14s ease, opacity .25s ease, box-shadow .14s ease;
  overflow-wrap: anywhere;
}
.pcard-l { background: #FFD966; border: 2px solid #E2B12F; box-shadow: 0 4px 0 #D29E1B; }
.pcard-r { background: #CFF1EC; border: 2px solid #3AA597; box-shadow: 0 4px 0 #2B8C7F; border-radius: 16px; }
.pcard:hover:not(:disabled) { transform: rotate(0deg) translateY(-2px); }
.pcard.is-selected { transform: rotate(0deg) translateY(-4px); outline: 3px solid var(--ink); outline-offset: 2px; }
.pcard.is-matched { opacity: .28; transform: none; box-shadow: none; cursor: default; }
.pcard.is-wrong { animation: shake .45s ease; outline: 3px solid var(--red); outline-offset: 2px; }
@keyframes shake { 0%, 100% { translate: 0; } 25% { translate: -6px; } 75% { translate: 6px; } }
.pairs-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.pairs-table td { padding: 8px 12px; background: rgba(255,255,255,.9); vertical-align: middle; }
.pcell-l { border-left: 4px solid #E2B12F; font-weight: 600; width: 42%; }
.pcell-r { border-left: 4px solid #3AA597; font-family: var(--font-hand); color: var(--ink); font-weight: 700; }
.pairs-table tr.is-open .pcell-r { color: var(--muted); }
.pcell-mark { text-align: right; white-space: nowrap; }
.opt-mark.is-mid { color: var(--amber); }

/* Reihenfolge / Domino */
.order-label { font-weight: 650; font-size: 15px; margin: 14px 0 8px; display: flex; justify-content: space-between; gap: 10px; }
.order-chain, .order-done { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: step; }
.order-chain li, .order-done li { display: flex; align-items: center; gap: 8px; counter-increment: step; }
.order-chain li::before, .order-done:not(.is-domino) li::before { content: counter(step); width: 22px; text-align: right; font: 700 15px var(--font-hand); color: var(--ink); flex: none; }
.order.is-domino .order-chain li::before, .order-done.is-domino li::before { content: none; }
.order-chain:empty { display: none; }
.order-empty { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); background: rgba(255,255,255,.75); margin: 0; }
.order-pool { display: grid; gap: 8px; }
.stone-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.order-chain .stone-btn, .order-chain li > .stone, .order-done li > .stone { flex: 1; }
.stone { display: flex; align-items: stretch; min-height: 54px; background: #FBF6EA; border: 1.5px solid #D9CDB0; border-radius: 10px; box-shadow: 0 3px 0 #D9CDB0; font-size: 17px; overflow: hidden; }
.stone-btn:hover .stone { border-color: var(--ink); }
.stone-btn:focus-visible { outline: none; }
.stone-btn:focus-visible .stone { outline: 3px solid var(--focus); outline-offset: 2px; }
.stone-l { flex: 0 0 96px; display: grid; place-items: center; padding: 8px; border-right: 2px solid var(--text); position: relative; font-weight: 600; }
.stone-l::after { content: ""; position: absolute; right: -5px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--text); transform: translateY(-50%); }
.stone-r { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px 14px; text-align: center; }
.order:not(.is-domino) .stone-r, .order-done:not(.is-domino) .stone-r { justify-content: flex-start; text-align: left; }
.stone.is-start { background: var(--green-soft); border-color: #A9D3B9; box-shadow: 0 3px 0 #A9D3B9; }
.stone.is-ok { border-color: #8CC5A3; }
.stone.is-bad { border-color: #E3A3A0; background: #FFF4F3; }
.order-done li .opt-mark { margin-left: 0; }
.order-done.is-solution { margin-top: 8px; opacity: .9; }
.stone-up { flex: none; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; color: var(--muted); font-size: 16px; }
.stone-up:hover { color: var(--ink); border-color: var(--ink); }
.order-chain li:first-child .stone-up, .order-chain li.is-fixed + li .stone-up { visibility: hidden; }

/* Einordnen */
.sort-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sort-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; background: rgba(255,255,255,.92); border: 1px solid var(--line-soft); border-left: 4px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.sort-item.is-done { border-left-color: var(--ink); }
.sort-text { flex: 1 1 150px; font-weight: 600; }
.sort-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px; padding: 4px 10px; font: 600 13.5px var(--font-ui); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; }
.bucket { background: rgba(255,255,255,.92); border: 2px solid #C9D6F4; border-radius: 10px; padding: 10px 12px; min-height: 80px; }
.bucket-title { font: 700 16px var(--font-hand); color: var(--ink); margin: 0 0 6px; border-bottom: 1px solid var(--line-soft); padding-bottom: 4px; }
.bucket ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 15px; }
.bucket li { font-family: var(--font-hand); color: var(--ink); font-weight: 700; }
.bucket li.is-bad { color: var(--text); text-decoration: line-through; text-decoration-color: var(--red); }
.bucket li.is-bad .correction { text-decoration: none; display: inline-block; }

/* Fehler finden */
.markbox { white-space: pre-wrap; line-height: 2.05; font-size: 17px; background: rgba(255,255,255,.92); border-radius: 8px; padding: 12px 16px; box-shadow: 0 0 0 1px var(--line-soft); overflow-x: auto; }
.markbox.style-beleg { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 14.5px; line-height: 1.9; white-space: pre; background: #fff; box-shadow: 0 1px 2px rgba(22,32,52,.15), 0 8px 18px -12px rgba(22,32,52,.35); border-top: 6px solid #E9EDF2; }
.tok { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; border-radius: 2px; cursor: pointer; line-height: inherit; letter-spacing: inherit; }
.tok:hover { background: var(--ink-soft); box-shadow: 0 0 0 2px var(--ink-soft); }
.tok.is-flagged { background: #FFE07A; box-shadow: 0 0 0 2px #FFE07A, inset 0 -2px 0 #D29E1B; }
span.tok { cursor: default; }
span.tok.is-flagged { background: #FFE07A; }
.tok.is-found { background: var(--green-soft); box-shadow: inset 0 -2px 0 var(--green); }
.tok.is-found .mark { color: var(--green); margin-left: 3px; font-family: var(--font-ui); }
.tok.is-missed { box-shadow: inset 0 -2px 0 var(--red); background: var(--red-soft); }
.tok.is-false { text-decoration: line-through; text-decoration-color: var(--red); background: #FFF0D6; }
.markbox .correction { font-size: .95em; }

/* Übungs-Website */
.sheet.is-wide, .done-banner.is-wide, .preview-banner.is-wide { max-width: 1240px; }
.sheet.is-wide { padding-left: 76px; }
.sheet.is-wide::before { left: 52px; }
.sheet.is-wide .ws-no { left: -54px; }
.htmlbox { border: 2px solid #C9D6F4; border-radius: 10px; overflow: hidden; background: #fff; }
.htmlbox-bar { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line-soft); }
.htmlbox-name { font-weight: 650; font-size: 14px; color: var(--muted); margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htmlbox iframe { display: block; width: 100%; height: 640px; border: 0; background: #fff; }
.htmlbox.is-screen iframe { height: calc(100vh - 210px); min-height: 420px; }
.htmlbox:fullscreen { border: 0; border-radius: 0; display: flex; flex-direction: column; }
.htmlbox:fullscreen iframe { flex: 1; height: auto !important; }
.html-result { background: rgba(255,255,255,.92); border-left: 3px solid var(--ink); padding: 6px 12px; }
.sheet .wsb-html .ws-task { margin-left: 0; }
.help-details > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink); }
.help-details[open] > summary { margin-bottom: 8px; }
.prompt-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; }
.html-info { display: grid; gap: 4px; font-size: 14px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.html-info .warn { color: var(--amber); font-weight: 600; }

.timer { font: 700 17px var(--font-hand); color: var(--ink); background: var(--ink-soft); border-radius: 999px; padding: 4px 12px; font-variant-numeric: tabular-nums; }

/* Abgabeleiste */
.submit-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--paper); border-top: 1px solid var(--line-soft); box-shadow: 0 -10px 24px -18px rgba(22, 32, 52, .45); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.submit-bar-inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.submit-bar form { margin: 0 0 0 auto; }
.progress { display: grid; gap: 5px; }
.progress-text { font-size: 15px; }
.progress-track { width: 180px; height: 7px; border-radius: 4px; background: #E6EBF1; overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--ink); transition: width .3s ease; }
.save-state { font-size: 13.5px; color: var(--muted); }
.save-state.is-warn { color: var(--red); font-weight: 600; }

.done-banner { max-width: 820px; margin: 0 auto 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; justify-content: space-between; background: var(--green-soft); border: 1px solid #BFDDC9; border-radius: var(--radius); padding: 16px 20px; }
.done-banner h2 { margin: 0 0 4px; color: var(--green); }
.done-banner p { margin: 0; }
.preview-banner { max-width: 820px; margin: 0 auto 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; background: var(--amber-soft); border: 1px solid #EBD3A7; border-radius: var(--radius); padding: 12px 16px; }
.preview-banner p { margin: 0; flex: 1 1 280px; }

/* Dialog und Hinweis-Ebene */
.dialog { border: 0; border-radius: 12px; padding: 24px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 30px 60px -20px rgba(22, 32, 52, .5); color: var(--text); }
.dialog::backdrop { background: rgba(30, 36, 48, .5); }
.dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(30, 36, 48, .6); display: grid; place-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-card { background: var(--paper); border-radius: 12px; padding: 26px; max-width: 440px; }

/* ------------------------------------------------------------ Anmeldung */
.login-desk { min-height: 100vh; display: grid; place-items: center; padding: 24px 14px; }
.login-sheet {
  width: 100%; max-width: 430px; padding: 34px 34px 28px;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px; background-position: -1px -1px;
  border-radius: 3px; box-shadow: var(--shadow-paper);
}
.login-sheet h1 { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 8px; margin-bottom: 14px; }
.login-sheet .lead { font-size: 16px; background: rgba(255,255,255,.8); }
.login-sheet .field > span:first-child { background: rgba(255,255,255,.85); justify-self: start; padding-right: 4px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-app { font: 700 22px/1.1 var(--font-hand); margin: 0; }
.login-school { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.login-help { margin: 18px 0 0; font-size: 14px; color: var(--muted); background: rgba(255,255,255,.8); }
.login-sheet .btn-lg { width: 100%; margin-top: 20px; }

/* ------------------------------------------------------------ Editor */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.editor-aside { position: sticky; top: 80px; font-size: 14.5px; }
.editor-aside h2 { font-size: 17px; }
.editor-aside code, .help code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; background: var(--ink-soft); color: var(--ink-dark); padding: 1px 5px; border-radius: 4px; }
.help dl { margin: 0; display: grid; gap: 12px; }
.help dt { font-weight: 600; margin-bottom: 3px; }
.help dd { margin: 0; color: var(--muted); }
.editor-bar { position: sticky; top: 60px; z-index: 15; background: var(--desk); padding: 12px 0; margin: -12px 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-soft); }
.editor-bar .save-state { margin-right: auto; }
.editor-meta { display: grid; gap: 14px; margin-bottom: 18px; }
.editor-meta .options { display: grid; gap: 10px; padding-top: 4px; }
.eblocks { display: grid; gap: 14px; }
.eblock { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.eblock:focus-within { border-color: #AFC0EE; box-shadow: 0 0 0 3px var(--ink-soft); }
.eblock-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.eblock-type { font-weight: 650; font-size: 14px; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.eblock-type .tag { font: 700 13px var(--font-hand); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; }
.eblock-body { padding: 14px; display: grid; gap: 12px; }
.eblock-body textarea.code { font: 15.5px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.eblock-preview { margin: 0 14px 14px; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 6px; font-size: 16px; line-height: 2.1; background: #FCFDFE; }
.eblock-preview .pv-label { font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-bottom: 4px; }
.pv-gap { display: inline-block; font: 700 15px/1.4 var(--font-hand); color: var(--ink); border-bottom: 2px solid var(--ink); padding: 0 6px; background: var(--ink-soft); border-radius: 3px 3px 0 0; }
.pv-gap.is-select::after { content: " ▾"; font-size: 11px; }
.pv-gap.is-bad { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.pv-issues { color: var(--red); font-size: 13.5px; line-height: 1.5; margin-top: 6px; }
.opt-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.opt-row .check { align-items: center; font-size: 13px; color: var(--muted); }
.opt-row .check input { margin: 0; }
.img-drop { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 14px; align-items: start; }
.img-thumb { width: 160px; height: 120px; border: 1px dashed var(--line); border-radius: 6px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center; padding: 6px; }
.img-thumb img { width: 100%; height: 100%; object-fit: contain; }
.insert { position: relative; display: flex; justify-content: center; margin: -4px 0; }
.insert > summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--muted); padding: 2px 10px; border-radius: 999px; }
.insert > summary::-webkit-details-marker { display: none; }
.insert > summary:hover, .insert[open] > summary { color: var(--ink); background: var(--ink-soft); }
.addbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px; border: 2px dashed var(--line); border-radius: var(--radius); margin-top: 14px; }
.addbar .label { margin-right: 6px; }
.addbar-pop { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin: 6px 0; }
.eblock.is-section { border: 2px solid var(--ink); }
.eblock.is-section .eblock-head { background: var(--ink); color: #fff; }
.eblock.is-section .eblock-head .icon-btn { color: #fff; }
.eblock.is-section .eblock-head .icon-btn:hover { color: var(--text); }
.eblock.is-half { border-left: 4px solid #C9D6F4; }
.pair-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.pair-row input:first-child { background: #FFF8DE; }
.pair-row input:nth-child(3) { background: #EAF8F6; }
.pair-eq { color: var(--muted); }
.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.cat-row { display: grid; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 10px; }
.cat-head { display: flex; gap: 6px; align-items: center; }
.cat-head input { font-weight: 600; }
.cat-add { align-self: center; justify-self: start; }
.warn-box { background: var(--amber-soft); border: 1px solid #EBD3A7; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.error-list { background: var(--red-soft); border: 1px solid #EBC6C4; border-radius: var(--radius); padding: 12px 16px 12px 34px; margin: 0 0 16px; color: #7D1F1B; }
.error-list:empty { display: none; }

/* ------------------------------------------------------------ Einzelabgabe */
.sub-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-start; margin-bottom: 18px; }
.sub-head > div:first-child { flex: 1 1 320px; }
.sub-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.sub-layout .sheet { margin: 0; }
.facts { display: grid; gap: 10px; margin: 0; }
.facts div { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 14.5px; border-bottom: 1px solid var(--line-soft); padding-bottom: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

/* ------------------------------------------------------------ Beamer */
.is-beamer { background: #fff; }
.beamer { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; text-align: center; padding: 3vh 4vw; }
.beamer-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.beamer-top .muted { font-size: 18px; }
.beamer-main { display: grid; place-items: center; align-content: center; gap: 2.5vh; }
.beamer h1 { font-size: clamp(30px, 4.6vw, 64px); margin: 0; text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; text-underline-offset: 12px; }
.beamer-qr svg { width: min(52vh, 78vw); height: auto; display: block; }
.beamer-url { font: 700 clamp(22px, 3.2vw, 44px)/1.2 var(--font-hand); color: var(--ink); overflow-wrap: anywhere; }
.beamer-steps { font-size: clamp(16px, 1.6vw, 22px); color: var(--muted); margin: 0; }

/* ------------------------------------------------------------ Zugangskarten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card { background: var(--paper); border: 1.5px dashed #9AA5B4; border-radius: 6px; padding: 16px 18px; display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 14px; break-inside: avoid; page-break-inside: avoid; }
.card-app { font: 700 15px var(--font-hand); color: var(--muted); margin-bottom: 6px; }
.card-name { font: 700 21px/1.2 var(--font-hand); margin-bottom: 6px; }
.card-write { font-size: 13px; color: var(--muted); border-bottom: 1px solid #9AA5B4; padding-bottom: 14px; margin-bottom: 10px; }
.card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: baseline; }
.card dt { font-size: 13px; color: var(--muted); }
.card dd { margin: 0; font: 600 18px ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; overflow-wrap: anywhere; }
.card .card-url { font-size: 12.5px; color: var(--muted); margin-top: 10px; overflow-wrap: anywhere; }
.card-qr svg { width: 96px; height: 96px; display: block; }

/* ------------------------------------------------------------ Kleine Bildschirme */
@media (max-width: 960px) {
  .editor-layout, .sub-layout { grid-template-columns: 1fr; }
  .editor-aside { position: static; }
}
@media (max-width: 760px) {
  h1 { font-size: 26px; }
  .page { padding: 20px 14px 70px; }
  .topbar { position: static; }
  .topbar-inner { padding: 8px 14px; gap: 4px 10px; flex-wrap: wrap; min-height: 56px; }
  .topnav { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .is-student .topnav { width: auto; margin-left: auto; }
  .topnav a { padding: 6px 10px; white-space: nowrap; }
  .topnav form { margin-left: auto; }
  .brand small { display: none; }
  .who { display: none; }
  .sheet, .sheet.is-wide { padding: 26px 14px 36px; }
  .sheet::before { display: none; }
  .sheet-title { font-size: 26px; }
  .ws-no { position: static; display: inline-grid; margin-bottom: 6px; width: 28px; height: 28px; }
  .ws-flow { grid-template-columns: 1fr; }
  .pairs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; gap: 10px; }
  .pcard { font-size: 15.5px; min-height: 58px; }
  .stone-l { flex-basis: 70px; }
  .ws-tab { padding-right: 10px; font-size: 14px; }
  .ws-cloze { font-size: 17px; }
  .submit-bar-inner { flex-wrap: wrap; gap: 8px 14px; }
  .progress-track { width: 120px; }
  .save-state { order: 3; width: 100%; }
  .share { grid-template-columns: 1fr; }
  .current-task { grid-template-columns: 1fr; }
  .accounts-new { grid-template-columns: 1fr; }
  .task-item { grid-template-columns: 1fr; }
  .analysis li { grid-template-columns: 1fr; }
  .free-list li { grid-template-columns: 1fr; gap: 2px; }
  .heft-new[open] { grid-column: 1 / -1; }
  .img-drop { grid-template-columns: 1fr; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 16px; }
  .heft-name { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .pcard { transform: none !important; }
}

/* ------------------------------------------------------------ Drucken */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .topbar, .no-print, .flashes, .submit-bar, .skip { display: none !important; }
  .page { padding: 0; max-width: none; }
  .cards { grid-template-columns: 1fr 1fr; gap: 0; }
  .card { border-radius: 0; margin: -0.75px; }
  .sheet { box-shadow: none; }
}
