/* Maßstab – Oberfläche. Papierton, Tinte, Rotstift sparsam. Farben als Tokens, Dunkelmodus inklusive. */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1c2229;
  --muted: #5d6873;
  --line: #e2ddd2;
  --line-strong: #cfc8b9;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef6;
  --ok: #2d7a4c;
  --ok-soft: #e4f2e9;
  --warn: #9a6a12;
  --warn-soft: #fbf0d9;
  --bad: #ad2a22;
  --bad-soft: #f9e3e1;
  --bound: #1d6b84;
  --bound-soft: #e0f0f5;
  --teacher: #5a3e9e;
  --teacher-soft: #ece6f7;
  --rule: #5d6873;
  --rule-soft: #ecebe8;
  --mark: #fff1a8;
  --shadow: 0 1px 2px rgba(28, 34, 41, .06), 0 4px 16px rgba(28, 34, 41, .05);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181d; --surface: #1c2128; --surface-2: #20262e; --ink: #e6e9ec; --muted: #9aa5b1;
    --line: #2d343d; --line-strong: #3b444f; --accent: #7fb0e0; --accent-ink: #0d1620; --accent-soft: #1d2d3d;
    --ok: #6cc391; --ok-soft: #173024; --warn: #e2b456; --warn-soft: #33290f; --bad: #f08a80; --bad-soft: #3a1c1a;
    --bound: #69c1db; --bound-soft: #12303a; --teacher: #b9a2f0; --teacher-soft: #2a2140; --rule: #a7b0ba;
    --rule-soft: #2a2f36; --mark: #5a4d12; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #14181d; --surface: #1c2128; --surface-2: #20262e; --ink: #e6e9ec; --muted: #9aa5b1;
  --line: #2d343d; --line-strong: #3b444f; --accent: #7fb0e0; --accent-ink: #0d1620; --accent-soft: #1d2d3d;
  --ok: #6cc391; --ok-soft: #173024; --warn: #e2b456; --warn-soft: #33290f; --bad: #f08a80; --bad-soft: #3a1c1a;
  --bound: #69c1db; --bound-soft: #12303a; --teacher: #b9a2f0; --teacher-soft: #2a2140; --rule: #a7b0ba;
  --rule-soft: #2a2f36; --mark: #5a4d12; --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; margin-top: 1.5rem; }
h3 { font-size: 1.02rem; font-weight: 650; }
h4 { font-size: .9rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .86em; }
.num { font-variant-numeric: tabular-nums; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); }
.brand b { font-family: var(--serif); font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; }
.brand span { font-size: .78rem; color: var(--muted); }
.brand:hover { text-decoration: none; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 550; font-size: .93rem; }
nav.main a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
nav.main a:hover { text-decoration: none; color: var(--ink); }
.sim-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line);
  text-align: center; font-size: .86rem; padding: 6px 16px; font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 22px 16px 80px; }
.crumbs { font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.lede { color: var(--muted); max-width: 72ch; }

/* Flächen */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* Steuerelemente */
button, .btn { font: inherit; font-weight: 600; font-size: .92rem; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 6px 8px; }
button.danger { color: var(--bad); }
button.small { padding: 4px 10px; font-size: .84rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
textarea.answer { font-family: var(--serif); font-size: 1.02rem; min-height: 140px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
label { display: block; font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); font-size: .92rem; }
.check input { width: auto; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* Abzeichen */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: .78rem; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent; }
.b-stabil { background: var(--ok-soft); color: var(--ok); }
.b-knapp { background: var(--warn-soft); color: var(--warn); }
.b-unsicher, .b-fehler { background: var(--bad-soft); color: var(--bad); }
.b-uebernommen { background: var(--bound-soft); color: var(--bound); }
.b-regel { background: var(--rule-soft); color: var(--rule); }
.b-lehrkraft { background: var(--teacher-soft); color: var(--teacher); }
.b-neutral { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.b-ki { background: var(--accent-soft); color: var(--accent); }
.b-lehrkraft_bestaetigt, .b-lehrkraft_korrigiert { background: var(--teacher-soft); color: var(--teacher); }
.b-abgeloest { background: var(--rule-soft); color: var(--muted); text-decoration: line-through; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Punkte / Note */
.scorebox { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.score { font-family: var(--serif); font-size: 2.1rem; font-weight: 650; line-height: 1; }
.score small { font-size: 1rem; color: var(--muted); font-family: var(--font); font-weight: 500; }
.grade { font-family: var(--serif); font-size: 2.1rem; font-weight: 650; border: 2px solid var(--bad); color: var(--bad);
  border-radius: 50%; width: 56px; height: 56px; display: inline-flex; align-items: center; justify-content: center; transform: rotate(-6deg); }
.grade.provisional { border-style: dashed; }

/* Bewertung */
.task { margin-top: 18px; }
.task-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.answer-box { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: 8px; padding: 12px 14px; font-family: var(--serif); font-size: 1.02rem; white-space: pre-wrap; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.crit { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.crit + .crit { margin-top: 10px; }
.crit.attn { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.crit.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.crit-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.crit-title { font-weight: 650; }
.level-pill { font-weight: 700; }
.votes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.vote { font-size: .78rem; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; color: var(--muted); background: var(--surface-2); }
.vote.diff { border-color: var(--warn); color: var(--warn); }
.quote { font-family: var(--serif); border-left: 2px solid var(--ok); padding-left: 10px; margin: 6px 0; }
.quote.unverified { border-left-color: var(--bad); }
.flags { margin: 6px 0 0; padding-left: 18px; color: var(--bad); font-size: .88rem; }
.decision { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: grid; gap: 8px;
  grid-template-columns: minmax(140px, 200px) 1fr auto; align-items: start; }
@media (max-width: 700px) { .decision { grid-template-columns: 1fr; } }
details > summary { cursor: pointer; color: var(--accent); font-size: .88rem; font-weight: 600; }
details[open] > summary { margin-bottom: 6px; }

/* Horizont */
.levels { width: 100%; font-size: .88rem; }
.levels td:first-child { white-space: nowrap; font-weight: 650; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: .8rem; color: var(--muted); }
.editor-task { border: 1px solid var(--line-strong); border-radius: 10px; padding: 14px; margin-bottom: 14px; background: var(--surface-2); }
.editor-crit { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; background: var(--surface); }
.editor-level { display: grid; grid-template-columns: 110px 140px 70px 1fr 1fr 32px; gap: 6px; margin-bottom: 6px; }
@media (max-width: 900px) { .editor-level { grid-template-columns: 1fr 1fr; } }

/* Bilder */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 140px; height: 190px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; background: var(--surface-2); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* Abschrift-Vergleich */
.diff { font-family: var(--serif); font-size: .98rem; line-height: 1.7; }
.diff .del { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; padding: 0 2px; border-radius: 3px; }
.diff .ins { background: var(--ok-soft); color: var(--ok); padding: 0 2px; border-radius: 3px; }

/* Messlabor */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi b { display: block; font-family: var(--serif); font-size: 1.5rem; font-weight: 650; }
.kpi span { font-size: .8rem; color: var(--muted); }
.progress { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.chart { width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Hinweise */
.notice { border-radius: 10px; padding: 10px 14px; font-size: .92rem; border: 1px solid var(--line); background: var(--surface-2); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); color: var(--ink); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.notice.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-size: .92rem; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--muted); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
pre.raw { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; max-height: 420px; font-size: .8rem; white-space: pre-wrap; }

@media print {
  .topbar, .sim-banner, .noprint, .decision, details { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
