/* 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; }
}

/* ---------- App-Ansicht „Korrekturtisch“: Rotstift auf Papier, eine Spalte wie eine Telefon-App ---------- */
nav.main a.nav-app { color: var(--bad); }
nav.main a.nav-app.active { color: var(--bad); }
body.ap-mode { background:
  radial-gradient(1200px 500px at 50% -120px, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
  repeating-linear-gradient(0deg, transparent 0 31px, color-mix(in srgb, var(--line) 55%, transparent) 31px 32px), var(--bg); }
body.ap-mode .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
.ap { max-width: 720px; margin: 0 auto; padding-bottom: 110px; }
.ap > * { animation: ap-rise .45s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes ap-rise { from { opacity: 0; transform: translateY(10px); } }
.ap > .ap-dock { animation: none; }
.ap h1 { font-size: 2.1rem; margin: 2px 0 4px; }
.ap .ap-sec { font-size: 1.05rem; font-family: var(--font); font-weight: 700; margin: 26px 0 10px; }
.ap .btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.ap-kicker { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ap-small { font-size: .86rem; }
.ap-wide { width: 100%; justify-content: center; padding: 13px 16px; font-size: 1rem; margin-top: 12px; border-radius: 12px; }
.ap-foot { text-align: center; font-size: .85rem; margin-top: 26px; }

.ap-hello { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0 18px; }
.ap-hello p { margin: 0; }
.ap-ringbox { position: relative; width: 88px; height: 88px; flex: none; }
.ap-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ap-ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ap-ring .track { stroke: var(--line); }
.ap-ring .ink { stroke: var(--bad); transition: stroke-dasharray .8s ease; }
.ap-ring-n { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 1.5rem; font-weight: 650; }
.ap-ring-n small { font-size: .75rem; color: var(--muted); font-family: var(--font); margin-left: 1px; }
.ap-ring-n { grid-auto-flow: column; align-content: center; justify-content: center; }

.ap-next { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--ink); color: var(--bg);
  border-radius: 18px; padding: 20px 22px; box-shadow: 0 10px 30px -12px rgba(28, 34, 41, .45); position: relative; overflow: hidden; }
.ap-next::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--bad) 70%, transparent); transform: rotate(-12deg); opacity: .5; }
.ap-next:hover { text-decoration: none; transform: translateY(-1px); }
.ap-next .ap-kicker { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.ap-next h3 { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin: 4px 0 2px; color: var(--bg); }
.ap-next p { margin: 0; color: color-mix(in srgb, var(--bg) 72%, transparent); font-size: .92rem; }
.ap-next.calm { background: var(--surface); color: var(--ink); border: 1px dashed var(--line-strong); box-shadow: none; }
.ap-next.calm h3 { color: var(--ink); }
.ap-next.calm p, .ap-next.calm .ap-kicker { color: var(--muted); }
.ap-arrow { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem;
  background: var(--bad); color: var(--surface); position: relative; z-index: 1; transition: transform .2s; }
.ap-next:hover .ap-arrow { transform: translateX(3px); }

.ap-stacks { display: grid; gap: 18px; }
.ap-stack { display: block; position: relative; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); transition: transform .2s; }
.ap-stack::before, .ap-stack::after { content: ""; position: absolute; left: 10px; right: 10px; height: 100%; bottom: -5px; z-index: -1;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.ap-stack::after { left: 20px; right: 20px; bottom: -10px; z-index: -2; transform: rotate(-.6deg); }
.ap-stack:hover { text-decoration: none; transform: translateY(-2px) rotate(-.2deg); }
.ap-stack h3 { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; margin: 3px 0 10px; }
.ap-stack-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ap-avg { font-family: var(--serif); color: var(--bad); font-size: 1.6rem; font-weight: 650; line-height: 1; white-space: nowrap; }
.ap-avg small { font-size: .8rem; margin-right: 2px; color: var(--muted); font-family: var(--font); }
.ap-avg.big { font-size: 2.4rem; }
.ap-seg { display: flex; gap: 3px; height: 8px; }
.ap-seg span { border-radius: 99px; min-width: 6px; }
.ap-seg .ok { background: var(--ok); }
.ap-seg .warn { background: var(--warn); }
.ap-seg .run { background: var(--accent); animation: ap-pulse 1.2s ease-in-out infinite; }
.ap-seg .open { background: var(--line); }
@keyframes ap-pulse { 50% { opacity: .45; } }
.ap-legend { font-size: .82rem; margin-top: 8px; }
.ap-empty { text-align: center; padding: 26px 12px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 14px; }

.ap-bar { padding: 4px 0 14px; }
.ap-bar .row { align-items: center; }
.ap-back { font-size: .9rem; font-weight: 600; display: inline-block; margin-bottom: 6px; }

.ap-spiegel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px 12px; box-shadow: var(--shadow); }
.ap-spiegel-head { display: flex; justify-content: space-between; align-items: flex-start; }
.ap-spiegel-head p { margin: 2px 0 0; font-size: .86rem; }
.ap-bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 150px; align-items: end; margin-top: 12px; }
.ap-barcol { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.ap-barcol b { font-family: var(--serif); font-size: 1.1rem; }
.ap-barcol .num { font-size: .8rem; min-height: 1em; }
.ap-col-bar { width: 100%; max-width: 52px; min-height: 3px; border-radius: 8px 8px 3px 3px; background: var(--accent);
  transform-origin: bottom; animation: ap-grow .7s cubic-bezier(.2, .7, .2, 1) both; animation-delay: .2s; }
.ap-col-bar.low { background: var(--bad); }
@keyframes ap-grow { from { transform: scaleY(0); } }

.ap-list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.ap-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: inherit; border-bottom: 1px solid var(--line); }
.ap-row:last-child { border-bottom: 0; }
.ap-row:hover { text-decoration: none; background: var(--surface-2); }
.ap-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ap-row-main .muted { font-size: .84rem; }
.ap-avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); letter-spacing: .02em; }

.ap-grade { font-family: var(--serif); font-weight: 650; color: var(--bad); border: 2px solid var(--bad); border-radius: 50%;
  width: 52px; height: 52px; display: inline-grid; place-items: center; font-size: 1.5rem; transform: rotate(-8deg); flex: none;
  border-top-color: transparent; }
.ap-grade.prov { border-style: dashed; border-top-color: var(--bad); }
.ap-grade.sm { width: 36px; height: 36px; font-size: 1.05rem; border-width: 1.5px; }
.ap-grade.xl { width: 78px; height: 78px; font-size: 2.3rem; border-width: 2.5px; }
.ap-grade.ghost { border-color: transparent; }

.ap-steps { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.ap-steps::before { content: ""; position: absolute; left: 10%; right: 10%; top: 16px; height: 2px; background: var(--line); }
.ap-steps li { position: relative; text-align: center; }
.ap-steps button { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; color: var(--muted); width: 100%; }
.ap-steps button:disabled { cursor: default; }
.ap-steps button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ap-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-strong);
  font-weight: 700; font-size: .85rem; color: var(--muted); }
.ap-steps li.done .ap-dot { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.ap-steps li.cur .ap-dot { border-color: var(--bad); color: var(--bad); box-shadow: 0 0 0 5px color-mix(in srgb, var(--bad) 14%, transparent); }
.ap-steps li.cur button, .ap-steps li.done button { color: var(--ink); }
.ap-steps li.avail .ap-dot { border-color: var(--ink); color: var(--ink); }

.ap-panel > * + * { margin-top: 12px; }
.ap-pages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.ap-pages img { height: 150px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; scroll-snap-align: start; box-shadow: var(--shadow); }
.ap-task { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.ap-task.attn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); box-shadow: inset 4px 0 0 var(--warn); }
.ap-task textarea { margin-top: 8px; }
.ap-cta { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.ap-cta p { margin: 0; }
.ap-working { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.ap-pen { width: 120px; height: 10px; border-radius: 99px; background: linear-gradient(90deg, transparent, var(--bad), transparent);
  background-size: 200% 100%; animation: ap-write 1.4s linear infinite; margin-bottom: 8px; }
@keyframes ap-write { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.ap-score { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.ap-pts { font-family: var(--serif); font-size: 1.7rem; font-weight: 650; }

.ap-progress { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.ap-progress span { display: block; height: 100%; background: var(--bad); transition: width .3s; }
.ap-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 18px 16px;
  box-shadow: 0 14px 40px -18px rgba(28, 34, 41, .35); animation: ap-in .3s cubic-bezier(.2, .7, .2, 1) both; transition: transform .22s, opacity .22s; }
@keyframes ap-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.ap-card.out-ok { transform: translateX(-60px) rotate(-4deg); opacity: 0; }
.ap-card.out-skip { transform: translateX(60px) rotate(4deg); opacity: 0; }
.ap-card h3 { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin: 6px 0 2px; }
.ap-card-top { align-items: center; }
.ap-answer { max-height: 220px; overflow: auto; margin: 10px 0; border-radius: 10px; }
.ap-answer .answer-box { margin: 0; }
.ap-why { font-size: .9rem; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.ap-why p { margin: 6px 0 0; }
.ap-vote { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.ap-vote.diff { background: var(--warn); }
.ap-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 12px 0 10px; }
.ap-levels button { flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border-radius: 12px; position: relative; text-align: left; }
.ap-levels button.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface-2); }
.ap-kbd { font-family: var(--mono); font-size: .7rem; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; }
.ap-ai { position: absolute; top: 8px; right: 8px; font-size: .66rem; font-weight: 800; letter-spacing: .06em; color: var(--accent);
  background: var(--accent-soft); border-radius: 99px; padding: 1px 6px; }
.ap-done { text-align: center; padding: 36px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ap-check { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; color: var(--ok);
  border: 3px solid var(--ok); transform: rotate(-8deg); animation: ap-stamp .4s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes ap-stamp { from { transform: scale(1.6) rotate(-20deg); opacity: 0; } }

.ap-zettel { position: relative; background:
  repeating-linear-gradient(0deg, transparent 0 27px, color-mix(in srgb, var(--accent) 16%, transparent) 27px 28px), var(--surface);
  border: 1px solid var(--line); border-radius: 4px; padding: 22px 22px 22px 48px; box-shadow: 0 16px 40px -20px rgba(28, 34, 41, .4);
  transform: rotate(-.4deg); font-family: var(--serif); line-height: 28px; }
.ap-zettel::before { content: ""; position: absolute; left: 32px; top: 0; bottom: 0; width: 1.5px; background: color-mix(in srgb, var(--bad) 55%, transparent); }
.ap-zettel h2 { margin: 0; font-size: 1.6rem; }
.ap-zettel h4 { font-family: var(--font); margin: 14px 0 0; }
.ap-zettel ul { margin: 0; padding-left: 18px; }
.ap-zettel p { margin: 0; }
.ap-draft { font-family: var(--font); font-size: .74rem; font-weight: 700; letter-spacing: .03em; line-height: 1.4; color: var(--bad);
  border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; margin-bottom: 12px; transform: rotate(.4deg); }
.ap-zettel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.ap-zrow { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--line-strong); }

.ap-dock { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line);
  box-shadow: 0 10px 30px -10px rgba(28, 34, 41, .35); }
.ap-dock a { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 76px; padding: 6px 10px; border-radius: 999px;
  color: var(--muted); font-size: .74rem; font-weight: 650; }
.ap-dock a:hover { text-decoration: none; color: var(--ink); }
.ap-dock a.on { color: var(--ink); background: var(--surface-2); }
.ap-ico { font-size: 1.05rem; line-height: 1.1; }
.ap-fab { width: 62px; height: 62px; border-radius: 50%; padding: 0; justify-content: center; flex-direction: column; gap: 0;
  background: var(--bad); border-color: var(--bad); color: var(--surface); margin: -18px 4px 0; box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--bad) 70%, transparent); }
.ap-fab:hover { border-color: var(--bad); filter: brightness(1.06); }
.ap-fab span { font-size: 1.7rem; line-height: 1; font-weight: 400; }
.ap-fab small { color: inherit; font-size: .6rem; font-weight: 700; letter-spacing: .04em; }

.ap-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 18, 22, .42); display: flex; align-items: flex-end; justify-content: center;
  animation: ap-fade .18s both; }
.ap-backdrop.out { opacity: 0; transition: opacity .18s; }
@keyframes ap-fade { from { opacity: 0; } }
.ap-sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); animation: ap-up .26s cubic-bezier(.2, .8, .2, 1) both; }
.ap-sheet > * + * { margin-top: 10px; }
.ap-sheet h2 { margin-top: 2px; }
@keyframes ap-up { from { transform: translateY(40px); opacity: .4; } }
.ap-grip { width: 42px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 0 auto 8px; }
.ap-spinbox { text-align: center; padding: 30px; }
.ap-pick { display: grid; gap: 8px; }
.ap-pick button { flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: 12px; text-align: left; }
.ap-pick button span { font-weight: 500; font-size: .84rem; }
.ap-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.ap-toggle button { border: 0; background: transparent; border-radius: 999px; padding: 6px 16px; color: var(--muted); }
.ap-toggle button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.ap-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 14px; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: 16px; background: var(--surface); cursor: pointer; color: var(--ink); font-size: .95rem; }
.ap-drop:hover { border-color: var(--bad); }
.ap-drop[hidden], .ap-sheet [hidden] { display: none; }
.ap-drop .muted { font-weight: 500; font-size: .84rem; }
.ap-drop-ico { font-size: 2rem; color: var(--bad); line-height: 1; }
.ap-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ap-shots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.ap-shot { position: relative; }
.ap-shot img { width: 64px; height: 84px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.ap-shot i { position: absolute; bottom: 4px; right: 4px; background: var(--ink); color: var(--bg); font-style: normal; font-size: .7rem;
  border-radius: 99px; padding: 0 6px; }

@media (max-width: 560px) {
  .ap h1 { font-size: 1.7rem; }
  .ap-steps button > span:last-child { font-size: .64rem; }
  .ap-dot { width: 28px; height: 28px; font-size: .78rem; }
  .ap-steps::before { top: 13px; }
  .ap-zettel { padding-left: 36px; transform: none; }
  .ap-zettel::before { left: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .ap > *, .ap-card, .ap-col-bar, .ap-sheet, .ap-backdrop, .ap-check { animation: none !important; }
  .ap-pen, .ap-seg .run { animation: none !important; }
}
@media print {
  body.ap-mode { background: #fff; }
  .ap-dock, .ap-steps, .ap-bar .ap-back { display: none !important; }
  .ap-zettel { transform: none; box-shadow: none; background: #fff; color: #000; }
}
