/* Examwerk – Design-Tokens & Komponenten
   Leitlinien: Aurora-Hintergrund, Glas nur auf der Bedienebene (Kopf-/Tab-Leiste, Sheets),
   ruhige Inhaltsflächen, 44px-Touchziele, WCAG-AA-Kontraste, Hell/Dunkel, reduzierte Bewegung. */

:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f4f6fa;
  --text: #0f172a;          /* 17.1:1 auf Weiß */
  --text-2: #475569;        /* 7.6:1 auf Weiß */
  --text-3: #64748b;        /* 4.8:1 auf Weiß */
  --line: rgba(15, 23, 42, .10);
  --line-strong: rgba(15, 23, 42, .18);
  --surface: rgba(255, 255, 255, .88);
  --surface-solid: #ffffff;
  --surface-2: rgba(241, 245, 249, .9);
  --accent: #4f46e5;        /* 6.3:1 auf Weiß */
  --accent-2: #0e7490;      /* 5.4:1 auf Weiß */
  --accent-soft: rgba(79, 70, 229, .10);
  --on-accent: #ffffff;
  --signal: #b45309;
  --ok: #15803d;   --ok-bg: #dcfce7;
  --warn: #a16207; --warn-bg: #fef9c3;
  --bad: #b91c1c;  --bad-bg: #fee2e2;
  --info: #4338ca; --info-bg: #e0e7ff;
  --neutral-bg: #e2e8f0;

  --glass: rgba(255, 255, 255, .66);
  --glass-edge: rgba(255, 255, 255, .75);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 28px -8px rgba(67, 56, 202, .18);
  --shadow-lift: 0 2px 4px rgba(15, 23, 42, .06), 0 18px 40px -12px rgba(67, 56, 202, .30);
  --glow: 0 0 40px rgba(79, 70, 229, .25);

  --r-sm: 10px; --r: 16px; --r-lg: 22px;
  /* ruhiger Hintergrund: fast neutral mit zartem Indigo-Hauch */
  --blob-1: #c7d2fe; --blob-2: #e0e7ff; --blob-3: #f1f5f9; --blob-4: #dbeafe;
  --blob-opacity: .7;
  --dots-opacity: .035;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060914;
    --text: #e8ebf4;
    --text-2: #aab3c8;
    --text-3: #8b95ad;
    --line: rgba(226, 232, 240, .10);
    --line-strong: rgba(226, 232, 240, .2);
    --surface: rgba(17, 22, 40, .86);
    --surface-solid: #111628;
    --surface-2: rgba(30, 37, 61, .85);
    --accent: #8b8cf9;
    --accent-2: #22d3ee;
    --accent-soft: rgba(139, 140, 249, .16);
    --on-accent: #0b0d1a;
    --signal: #fbbf24;
    --ok: #4ade80;   --ok-bg: rgba(74, 222, 128, .14);
    --warn: #facc15; --warn-bg: rgba(250, 204, 21, .14);
    --bad: #f87171;  --bad-bg: rgba(248, 113, 113, .15);
    --info: #a5b4fc; --info-bg: rgba(165, 180, 252, .15);
    --neutral-bg: rgba(148, 163, 184, .16);
    --glass: rgba(14, 18, 34, .62);
    --glass-edge: rgba(255, 255, 255, .10);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -10px rgba(0, 0, 0, .6);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 20px 44px -12px rgba(99, 102, 241, .35);
    --glow: 0 0 44px rgba(139, 140, 249, .35);
    --blob-1: #312e81; --blob-2: #1e1b4b; --blob-3: #0f172a; --blob-4: #1e3a8a;
    --blob-opacity: .55;
    --dots-opacity: .04;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
body.student { font-size: 17px; }
a { color: var(--accent); }
img, svg { max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Aurora-Hintergrund ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora::after { /* feines Punktraster für Tiefe */
  content: ""; position: absolute; inset: 0; opacity: var(--dots-opacity);
  background-image: radial-gradient(currentColor 1px, transparent 1px); background-size: 22px 22px; color: var(--text);
}
.aurora i {
  position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(110px);
  opacity: var(--blob-opacity); will-change: transform; animation: drift 34s var(--ease) infinite alternate;
}
.aurora i:nth-child(1) { background: var(--blob-1); top: -22vmax; left: -14vmax; }
.aurora i:nth-child(2) { background: var(--blob-2); top: 18vh; right: -24vmax; animation-duration: 40s; animation-delay: -8s; }
.aurora i:nth-child(3) { background: var(--blob-3); bottom: -34vmax; left: 18vw; animation-duration: 28s; animation-delay: -14s; }
.aurora i:nth-child(4) { background: var(--blob-4); bottom: -10vmax; right: 30vw; width: 36vmax; height: 36vmax; opacity: calc(var(--blob-opacity) * .6); animation-duration: 36s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); }
  100% { transform: translate3d(-4vmax, 7vmax, 0) scale(.95); }
}

/* ---------- Glas (nur Bedienebene) ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow);
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .aurora { display: none; }
}

/* ---------- Kopfleiste ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-left)); min-height: 60px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -.02em; text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #06b6d4); box-shadow: 0 4px 14px -4px rgba(79,70,229,.6); }
.brand-mark svg { width: 18px; height: 18px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 15px; transition: background .2s var(--ease), color .2s; }
.nav a:hover { background: var(--accent-soft); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; }
.topbar .spacer { flex: 1; }
.user-pill { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }

/* Tab-Leiste unten auf schmalen Bildschirmen */
.tabbar { display: none; }
@media (max-width: 760px) {
  .topbar .nav { display: none; }
  .user-pill .who { display: none; }
  .tabbar {
    display: flex; position: fixed; z-index: 30; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
    border-radius: 24px; padding: 6px; justify-content: space-around;
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 50px; justify-content: center; border-radius: 18px; text-decoration: none; color: var(--text-2); font-size: 12px; font-weight: 600; }
  .tabbar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
  .tabbar svg { width: 22px; height: 22px; }
  main.page { padding-bottom: 110px; }
}

/* ---------- Layout ---------- */
main.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }
main.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 22px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 0 0 4px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(28px, 4vw, 38px); font-weight: 800; }
h1.gradient { background: linear-gradient(120deg, var(--text) 10%, var(--accent) 60%, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 22px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.tiny { font-size: 13px; color: var(--text-3); }
p { margin: 0 0 12px; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------- Inhaltsflächen ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.card.pad-lg { padding: 28px; }
.card.tight { padding: 14px 16px; }
.card h2 + p, .card h3 + p { margin-top: 6px; }
a.card, button.card { display: block; text-align: left; text-decoration: none; color: inherit; cursor: pointer; width: 100%; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
a.card:hover, button.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
a.card:active, button.card:active { transform: scale(.985); }
.card.highlight { box-shadow: var(--shadow), var(--glow); }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* Einblenden beim Laden */
.reveal > * { animation: rise .45s var(--ease) both; }
.reveal > *:nth-child(2) { animation-delay: 50ms; }
.reveal > *:nth-child(3) { animation-delay: 100ms; }
.reveal > *:nth-child(4) { animation-delay: 150ms; }
.reveal > *:nth-child(5) { animation-delay: 200ms; }
.reveal > *:nth-child(n+6) { animation-delay: 250ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--surface-solid); --b-fg: var(--text); --b-line: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--b-line);
  background: var(--b-bg); color: var(--b-fg); font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform .18s var(--ease), box-shadow .2s var(--ease), background .2s; white-space: nowrap; overflow: hidden;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary {
  --b-fg: #fff; border-color: transparent;
  background: linear-gradient(135deg, #4f46e5, #0e7490); box-shadow: 0 6px 20px -6px rgba(79, 70, 229, .6);
}
.btn.primary::after { /* Lichtlauf */
  content: ""; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
}
.btn.primary:hover::after { transform: translateX(120%); transition: transform .7s var(--ease); }
.btn.primary:hover { box-shadow: 0 10px 28px -8px rgba(79, 70, 229, .7), var(--glow); }
.btn.ghost { --b-bg: transparent; --b-line: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--text); box-shadow: none; }
.btn.danger { --b-fg: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.icon { width: 44px; padding: 0; }
.btn.large { min-height: 56px; padding: 0 28px; font-size: 17px; }
.btn.block { width: 100%; }

/* ---------- Formulare ---------- */
label.field { display: block; }
.field > span { display: block; font-weight: 650; font-size: 14px; margin-bottom: 6px; }
.field > small { display: block; color: var(--text-3); font-size: 13px; margin-top: 6px; }
input[type="text"], input[type="number"], input[type="search"], input:not([type]), textarea, select {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-solid); transition: border-color .2s, box-shadow .2s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 14px; min-height: 260px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.code-input { font-family: var(--mono); font-size: 26px !important; letter-spacing: .25em; text-align: center; text-transform: uppercase; }

.dropzone {
  position: relative; display: grid; place-items: center; text-align: center; gap: 6px; padding: 26px 18px; min-height: 130px;
  border: 2px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); cursor: pointer; transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone > svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone .file-name { font-weight: 650; color: var(--text); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; user-select: none; }
.switch input { appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--neutral-bg); position: relative; transition: background .25s var(--ease); cursor: pointer; flex: none; border: 1px solid var(--line); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .25s var(--spring); }
.switch input:checked { background: #22c55e; }
.switch input:checked::after { transform: translateX(20px); }

.segmented { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--neutral-bg); gap: 2px; flex-wrap: wrap; }
.segmented button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 650; font-size: 14px; color: var(--text-2); cursor: pointer; transition: background .2s, color .2s; }
.segmented button[aria-selected="true"] { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

/* ---------- Chips & Status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.busy::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--accent-soft); }
td .name { font-weight: 650; }

/* ---------- Kennzahlen ---------- */
.stat { padding: 16px 18px; }
.stat .value { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .label { font-size: 13px; color: var(--text-2); font-weight: 600; }

/* Verständnis-Ring (Signatur des Protokolls) */
.ring { --p: 0; --c: var(--accent); width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; position: relative; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--neutral-bg) 0); box-shadow: 0 0 40px -6px color-mix(in srgb, var(--c) 45%, transparent); }
.ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface-solid); }
.ring > div { position: relative; text-align: center; }
.ring .value { font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ring .label { font-size: 12px; color: var(--text-2); font-weight: 650; margin-top: 2px; }

/* ---------- Scratch-Blöcke ---------- */
.blocks-view { overflow-x: auto; padding: 12px; border-radius: var(--r); background: #f9f9fb; border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .blocks-view { background: #1b2034; } }
.blocks-view svg { max-width: none; display: block; }
.blocks-view .sb-src { margin: 0; font-family: var(--mono); font-size: 13px; white-space: pre; color: var(--text-2); }
.sprite-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 14px 0 8px; }
.scripts { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.scripts > .blocks-view { flex: 0 1 auto; max-width: 100%; }

/* ---------- Fragen ---------- */
.q-card { padding: 22px; }
.q-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.q-num { font-size: 13px; font-weight: 750; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.q-prompt { font-size: 19px; font-weight: 650; line-height: 1.4; margin: 4px 0 14px; letter-spacing: -.01em; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 14px; min-height: 56px; padding: 14px 16px; border-radius: 14px;
  border: 1.5px solid var(--line-strong); background: var(--surface-solid); cursor: pointer; text-align: left; width: 100%;
  transition: border-color .2s, background .2s, transform .15s var(--ease);
}
.option:hover { border-color: var(--accent); }
.option:active { transform: scale(.99); }
.option .key { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 750; font-size: 14px; background: var(--neutral-bg); color: var(--text-2); transition: background .2s, color .2s; }
.option[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option[aria-checked="true"] .key { background: var(--accent); color: var(--on-accent); }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.correct .key { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .key { background: var(--bad); color: #fff; }
.option.static { cursor: default; }
.option.static:hover { border-color: var(--line-strong); }
.option.static.correct:hover { border-color: var(--ok); }
.option.static.wrong:hover { border-color: var(--bad); }

.answer-box { padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; }

/* Fortschritt */
.progress { height: 8px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #06b6d4); position: relative; transition: width .4s var(--ease); }
.progress > i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: shimmer 2s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots button { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--surface-solid); font-weight: 700; font-size: 13px; cursor: pointer; color: var(--text-2); }
.dots button.answered { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.dots button[aria-current="step"] { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }

.timer { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 700; font-size: 18px; padding: 8px 16px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.timer svg { width: 18px; height: 18px; }
.timer.low { color: var(--bad); animation: glowpulse 1s ease-in-out infinite; }
@keyframes glowpulse { 50% { box-shadow: 0 0 0 4px var(--bad-bg); } }

/* ---------- Sheet / Dialog ---------- */
dialog.sheet {
  border: 0; padding: 0; border-radius: 26px; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
  color: var(--text); background: var(--glass); overflow: auto;
}
dialog.sheet.wide { width: min(920px, calc(100vw - 24px)); }
dialog.sheet::backdrop { background: rgba(6, 9, 20, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: sheetin .32s var(--spring); }
@keyframes sheetin { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px 12px; }
.sheet-body { padding: 4px 22px 22px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }

/* Toasts */
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: max(24px, env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 16px; font-weight: 600; font-size: 15px; animation: rise .3s var(--spring); display: flex; gap: 10px; align-items: center; }
.toast svg { width: 20px; height: 20px; flex: none; }
.chip svg { width: 14px; height: 14px; }
.toast.bad { color: var(--bad); }
.toast.ok { color: var(--ok); }
@media (max-width: 760px) { .toasts { bottom: 100px; } }

/* Leere Zustände */
.empty { text-align: center; padding: 48px 20px; }
.empty > svg { width: 54px; height: 54px; color: var(--accent); margin-bottom: 10px; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-screen { min-height: calc(100dvh - 60px); display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(460px, 100%); text-align: center; }
.auth-card .brand-mark { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 18px; }
.auth-card .brand-mark svg { width: 34px; height: 34px; }

.big-code { font-family: var(--mono); font-size: clamp(34px, 9vw, 52px); font-weight: 800; letter-spacing: .14em; text-align: center; padding: 14px; border-radius: var(--r); background: var(--accent-soft); color: var(--accent); }
.qr-box { background: #fff; border-radius: var(--r); padding: 14px; display: grid; place-items: center; }
.qr-box svg { width: 100%; height: auto; max-width: 420px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 600; }

ul.clean { list-style: none; padding: 0; margin: 0; }
ul.bullets { margin: 6px 0 0; padding-left: 20px; }
ul.bullets li + li { margin-top: 4px; }

.callout { padding: 14px 16px; border-radius: 14px; background: var(--info-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.callout.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

.copy-line { display: flex; gap: 8px; align-items: center; }
.copy-line input { font-family: var(--mono); font-size: 14px; }

/* Konfetti / Erfolg */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.burst i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 1.6s var(--ease) forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .2; } }

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .aurora i { animation: none; }
}

/* ---------- Druck (Protokoll, QR-Karten) ---------- */
@media print {
  :root { --surface: #fff; --surface-2: #f6f7f9; --text: #000; --text-2: #333; --text-3: #555; }
  body { background: #fff; font-size: 12pt; }
  .aurora, .topbar, .tabbar, .no-print, .toasts { display: none !important; }
  main.page { padding: 0; max-width: none; }
  .card, .table-wrap { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .q-card { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .ring { box-shadow: none; }
  .ring::before { background: #fff; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }

.qr-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.qr-card { border: 1px dashed var(--line-strong); border-radius: 14px; padding: 14px; text-align: center; background: var(--surface-solid); break-inside: avoid; }
.qr-card svg { width: 150px; height: 150px; }
.qr-card .code { font-family: var(--mono); font-weight: 800; font-size: 20px; letter-spacing: .12em; }
@media print { .qr-cards { grid-template-columns: repeat(3, 1fr); } .qr-card { border-color: #999; } }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 640px) {
  main.page { padding: 18px 14px 110px; }
  .page-head .segmented { width: 100%; flex-wrap: nowrap; }
  .page-head .segmented button { flex: 1; padding: 0 8px; }
  .grid.stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 22px; }
  .stat .label { font-size: 12px; line-height: 1.25; }
  .hide-sm { display: none; }
  th, td { padding: 10px 12px; }
  .card { padding: 16px; }
  .card.pad-lg { padding: 20px; }
  .q-prompt { font-size: 18px; }
  .ring { width: 108px; height: 108px; }
  .ring .value { font-size: 28px; }
}
[hidden] { display: none !important; }

/* ---------- Reihenfolge-Puzzle ---------- */
.parsons { display: grid; gap: 10px; }
.parsons-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--surface-solid); cursor: grab; transition: box-shadow .2s, transform .15s var(--ease); }
.parsons-item:hover { box-shadow: var(--shadow); }
.parsons-item.dragging { opacity: .5; transform: scale(.98); }
.parsons-pos { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 750; font-size: 14px; background: var(--accent-soft); color: var(--accent); }
.parsons-code { flex: 1; min-width: 0; }
.parsons-code .blocks-view { padding: 6px; background: transparent; border: 0; }
.parsons-btns { display: flex; flex-direction: column; gap: 6px; }
.btn.icon.small { width: 40px; min-height: 40px; }

/* ---------- Klassenübersicht ---------- */
.heat { font-variant-numeric: tabular-nums; font-weight: 700; text-align: center; border-radius: 10px; padding: 6px 4px; min-width: 52px; }
.heat.h0 { background: var(--bad-bg); color: var(--bad); }
.heat.h1 { background: var(--warn-bg); color: var(--warn); }
.heat.h2 { background: var(--ok-bg); color: var(--ok); }
.heat.none { color: var(--text-3); font-weight: 500; }
table.matrix th.rot { white-space: nowrap; font-size: 12px; text-transform: none; letter-spacing: 0; }
table.matrix td, table.matrix th { padding: 8px 10px; }
table.matrix tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--line-strong); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--text-2); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } }
.ai-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--info); background: var(--info-bg); border-radius: 999px; padding: 2px 8px; }
.ai-badge svg { width: 12px; height: 12px; }
@media print { .page-break { break-before: page; } }
.inline-ico { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- Namensauswahl (Klassenliste) ---------- */
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.name-chip { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--surface-solid); font-weight: 600; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.name-chip:hover { border-color: var(--accent); }
.name-chip[aria-checked="true"], .name-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.name-chip[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Prüfungsmodus ---------- */
.lock-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(6, 9, 20, .72); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.lock-screen .card { max-width: 460px; text-align: center; }
.lock-screen svg.big { width: 56px; height: 56px; color: var(--bad); }
.chip.locked { background: var(--bad-bg); color: var(--bad); }
.callout.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }

/* ---------- Vorschau ---------- */
.preview-banner { padding: 8px 16px; background: var(--warn-bg); color: var(--text); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 14px; }
.callout > svg, .callout > span > svg { width: 18px; height: 18px; vertical-align: -3px; flex: none; }
.parsons { grid-template-columns: minmax(0, 1fr); }
.parsons-item { min-width: 0; }
.parsons-code { overflow-x: auto; }
.parsons { padding: 0; margin: 0; list-style: none; }
.parsons-code svg { max-width: 100% !important; height: auto; }

/* ---------- Hinweis „Neue Version“ ---------- */
.update-bar { position: fixed; z-index: 120; top: 72px; left: 12px; right: 12px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 18px; font-weight: 600; font-size: 15px; width: max-content; max-width: calc(100vw - 24px); animation: rise .3s var(--spring); }
.update-bar > svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

/* ---------- Live-Hinweis (statisch, ohne Dauerbewegung) ---------- */
.live-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ok); }
.live-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px var(--ok-bg); }

/* ---------- Vorschau: Kachelübersicht ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
button.tile { display: flex; flex-direction: column; gap: 8px; text-align: left; font: inherit; color: inherit; padding: 16px; min-height: 280px; }
.tile-head { display: flex; align-items: center; gap: 8px; }
.tile-num { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; background: var(--accent); color: var(--on-accent); flex: none; }
.tile-concept { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.tile-prompt { font-weight: 650; line-height: 1.35; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile-thumb { position: relative; flex: 1; min-height: 96px; max-height: 130px; overflow: hidden; border-radius: 12px; background: #f9f9fb; border: 1px solid var(--line); padding: 8px;
  -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile-thumb { background: #1b2034; } }
.tile-thumb .blocks-view { padding: 0; border: 0; background: transparent; overflow: hidden; }
.tile-thumb.text { -webkit-mask-image: none; mask-image: none; background: var(--surface-2); }
.tile-options { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); list-style: upper-alpha; }
.tile-options li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-solution { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--ok-bg); color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-open { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent); margin-top: auto; }
.tile-open svg { width: 16px; height: 16px; }
.preview-sheet .sheet-body .q-card { box-shadow: none; }
.preview-banner .segmented button { min-height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------- E-Mail-Versand ---------- */
.mail-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; padding: 2px; }
.mail-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-solid); cursor: pointer; }
.mail-row.disabled { opacity: .6; cursor: default; }
.mail-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.mail-name { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.mail-name .tiny { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Musterlösung ---------- */
.sol-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.sol-nav { position: sticky; top: 84px; padding: 16px; display: grid; gap: 12px; }
.sol-nav-title { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.sol-nav-list { display: grid; gap: 2px; }
.sol-nav-item { text-align: left; border: 0; background: transparent; min-height: 40px; padding: 0 12px; border-radius: 10px; font-weight: 600; color: var(--text-2); cursor: pointer; font-size: 15px; }
.sol-nav-item:hover { background: var(--accent-soft); color: var(--text); }
.sol-nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.sol-nav-actions { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.sol-nav-actions .btn { justify-content: flex-start; }
.sol-section { scroll-margin-top: 84px; padding: 24px; display: grid; gap: 16px; }
.sol-head { display: flex; align-items: center; gap: 12px; }
.sol-head h2 { font-size: 20px; }
.sol-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.sol-icon svg { width: 20px; height: 20px; }
.sol-lead { font-size: 18px; line-height: 1.55; margin: 0; max-width: 75ch; }
.sol-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.sol-stat { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: grid; }
.sol-stat strong { font-family: var(--font-display); font-size: 26px; font-weight: 800; line-height: 1.1; }
.sol-stat span { font-size: 13px; color: var(--text-2); font-weight: 600; }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.req-list li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); line-height: 1.45; }
.req-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--accent); color: var(--on-accent); }
.prose p { margin: 0 0 12px; max-width: 75ch; line-height: 1.65; font-size: 16px; }
.prose p:last-child { margin-bottom: 0; }
.setup-box { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--info-bg); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.setup-box > svg { width: 22px; height: 22px; color: var(--info); }
.setup-box p { margin: 4px 0 0; }
.tab-count { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.script-grid { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.script-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface-solid); padding: 10px; max-width: 100%; }
.script-card .blocks-view { border: 0; padding: 4px; }
.script-label { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 2px 4px 6px; }
.sol-code { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-family: var(--mono); font-size: 13.5px; line-height: 1.55; overflow-x: auto; white-space: pre; }
.sol-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.concept-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.concept-chips .chip { font-size: 14px; padding: 6px 12px; }
.mistake-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mistake-list li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); line-height: 1.45; }
.mistake-list svg { width: 18px; height: 18px; color: var(--warn); margin-top: 2px; }
.sol-editbar { position: sticky; top: 72px; z-index: 5; }
@media (max-width: 900px) {
  .sol-layout { grid-template-columns: 1fr; }
  .sol-nav { position: sticky; top: 60px; z-index: 6; display: flex; align-items: center; gap: 8px; padding: 8px; overflow-x: auto; border-radius: 16px; }
  .sol-nav-title, .sol-nav > .tiny { display: none; }
  .sol-nav-list { display: flex; gap: 4px; }
  .sol-nav-item { white-space: nowrap; min-height: 36px; font-size: 14px; }
  .sol-nav-actions { display: flex; border-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 8px; }
  .sol-nav-actions .btn { white-space: nowrap; }
  .sol-section { padding: 18px; }
}
.sol-layout > *, .sol-content { min-width: 0; }
@media (max-width: 640px) {
  .page-head .segmented { overflow-x: auto; scrollbar-width: none; }
  .page-head .segmented button { flex: 0 0 auto; padding: 0 12px; }
}
