:root {
  --bg: #f5f6fb; --card: #fff; --ink: #1f2340; --muted: #6b7194; --line: #e4e6f2;
  --brand: #4f46e5; --brand-ink: #fff; --brand-soft: #eef0ff;
  --good: #16a34a; --good-soft: #e7f8ed; --bad: #dc2626; --bad-soft: #fdecec; --warn: #d97706; --warn-soft: #fff4de;
  --c-Deutsch: #e5484d; --c-Mathe: #3b82f6; --c-Englisch: #10b981; --c-Latein: #a855f7;
  --radius: 16px; --shadow: 0 1px 2px rgba(31,35,64,.06), 0 6px 20px rgba(31,35,64,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131f; --card: #1b1d2e; --ink: #eceefc; --muted: #9aa0c4; --line: #2b2e46;
    --brand: #818cf8; --brand-ink: #12131f; --brand-soft: #25284a;
    --good: #4ade80; --good-soft: #17301f; --bad: #f87171; --bad-soft: #3a1c1f; --warn: #fbbf24; --warn-soft: #3a2f14;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.hide { display: none !important; }

/* Layout */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: .6rem 16px; padding-top: max(.6rem, env(safe-area-inset-top)); display: flex; align-items: center; gap: .75rem; }
.top .brand { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.top .brand img { width: 28px; height: 28px; border-radius: 8px; }
.top .who { margin-left: auto; text-align: right; font-size: .85rem; line-height: 1.2; }
.nav { display: flex; gap: .25rem; overflow-x: auto; padding: .5rem 16px; background: var(--card); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.nav button { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: .5rem .9rem; border-radius: 999px; cursor: pointer; }
.nav button[aria-current="true"] { background: var(--brand-soft); color: var(--brand); }
main { max-width: 980px; margin: 0 auto; padding: 16px 16px 4rem; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row-flex { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .card + .grid, .grid + .card, h2 + .card { margin-top: 12px; }
.section-title { margin: 1.4rem 0 .6rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; margin: .7rem 0 .25rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: .65rem .8rem; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; padding: .45rem .6rem; border-radius: 10px; margin: 0; cursor: pointer; }
.check:hover { background: var(--brand-soft); }
.check input { width: 1.15rem; height: 1.15rem; flex: none; accent-color: var(--brand); }
.checks { max-height: 18rem; overflow: auto; border: 1.5px solid var(--line); border-radius: 12px; padding: .25rem; }
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: .65rem 1.1rem; background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.btn:hover { filter: brightness(1.08); } .btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.big { padding: .9rem 1.6rem; font-size: 1.1rem; border-radius: 14px; }
.btn.sm { padding: .35rem .7rem; font-size: .85rem; border-radius: 10px; }
.error { color: var(--bad); background: var(--bad-soft); padding: .55rem .8rem; border-radius: 10px; margin: .75rem 0 0; }
.hint { background: var(--brand-soft); border-radius: 12px; padding: .7rem .9rem; font-size: .92rem; }

/* Chips & Status */
.chip { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; color: #fff; background: var(--muted); white-space: nowrap; }
.s-Deutsch { background: var(--c-Deutsch); } .s-Mathe { background: var(--c-Mathe); } .s-Englisch { background: var(--c-Englisch); } .s-Latein { background: var(--c-Latein); }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 8px; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.b-open { background: var(--warn-soft); color: var(--warn); } .b-over { background: var(--bad-soft); color: var(--bad); }
.b-good { background: var(--good-soft); color: var(--good); } .b-mid { background: var(--warn-soft); color: var(--warn); } .b-low { background: var(--bad-soft); color: var(--bad); }
.pills { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.pill { border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .88rem; font-weight: 600; padding: .3rem .8rem; border-radius: 999px; cursor: pointer; }
.pill[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* Dashboard */
.tile { text-align: center; } .tile .n { font-size: 2rem; font-weight: 800; line-height: 1.1; } .tile .l { color: var(--muted); font-size: .85rem; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; } .bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.subj { display: grid; grid-template-columns: 5.5rem 1fr auto; gap: .75rem; align-items: center; padding: .4rem 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; }
button.item { cursor: pointer; } button.item:hover { border-color: var(--brand); }
.item .grow { flex: 1; min-width: 0; } .item .t { font-weight: 700; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tr.ok td:first-child { color: var(--good); } tr.no td:first-child { color: var(--bad); } td.num { white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* Login */
.center { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.login { width: min(420px, 100%); } .login img { width: 64px; height: 64px; border-radius: 18px; display: block; margin: 0 auto 1rem; }
.login h1 { text-align: center; }

/* Modal & Toast */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(15,17,35,.55); display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal[hidden] { display: none; }
.modal .sheet { width: min(640px, 100%); max-height: 92svh; overflow: auto; background: var(--card); border-radius: 20px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 150%); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; font-weight: 600; transition: transform .25s, opacity .25s; z-index: 50; max-width: 90vw; opacity: 0; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Kinder: Aufgabenkarten */
.hello { font-size: 1.6rem; font-weight: 800; } .streak { background: var(--warn-soft); color: var(--warn); font-weight: 700; border-radius: 999px; padding: .2rem .8rem; }
.task { border-left: 8px solid var(--muted); display: flex; align-items: center; gap: 1rem; }
.task.s-Deutsch { border-left-color: var(--c-Deutsch); background: var(--card); } .task.s-Mathe { border-left-color: var(--c-Mathe); background: var(--card); }
.task.s-Englisch { border-left-color: var(--c-Englisch); background: var(--card); } .task.s-Latein { border-left-color: var(--c-Latein); background: var(--card); }
.task .grow { flex: 1; } .task h3 { margin: 0 0 .15rem; } .task.done { opacity: .7; }

/* Test-Ansicht */
.run { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow: auto; display: flex; flex-direction: column; padding: max(16px, env(safe-area-inset-top)) 16px 24px; }
.run .wrap { width: min(640px, 100%); margin: 0 auto; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 1rem; }
.run .head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--muted); font-weight: 600; }
.prompt { font-size: clamp(1.7rem, 6vw, 2.6rem); font-weight: 800; text-align: center; padding: 1.4rem .5rem; overflow-wrap: anywhere; }
.prompt.long { font-size: clamp(1.15rem, 4vw, 1.5rem); text-align: left; font-weight: 700; }
.qlabel { text-align: center; color: var(--muted); font-weight: 600; }
.timer { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--good); transform-origin: left; border-radius: 999px; }
.timer.warn > i { background: var(--warn); } .timer.danger > i { background: var(--bad); }
.secs { font-size: 1.5rem; font-weight: 800; color: var(--ink); min-width: 2.5rem; text-align: right; }
.answer { font-size: 1.4rem; text-align: center; padding: .9rem; }
.opts { display: grid; gap: 10px; } .opt { text-align: left; font: inherit; font-size: 1.1rem; font-weight: 600; padding: .9rem 1rem; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.opt:hover:not(:disabled) { border-color: var(--brand); } .opt.right { border-color: var(--good); background: var(--good-soft); } .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { text-align: center; font-size: 1.3rem; font-weight: 800; padding: 1rem; border-radius: 14px; }
.feedback.ok { background: var(--good-soft); color: var(--good); } .feedback.no { background: var(--bad-soft); color: var(--bad); }
.feedback small { display: block; font-size: 1rem; font-weight: 600; color: var(--ink); margin-top: .2rem; }
.score { font-size: 4rem; font-weight: 900; text-align: center; line-height: 1; }
.stars { text-align: center; font-size: 2.2rem; letter-spacing: .3rem; }
@media (max-width: 520px) { .subj { grid-template-columns: 4.6rem 1fr auto; } .task { flex-wrap: wrap; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

.speak { border: 0; background: var(--brand-soft); border-radius: 999px; width: 2.4rem; height: 2.4rem; font-size: 1.2rem; cursor: pointer; vertical-align: middle; margin-left: .5rem; }
.speak:hover { filter: brightness(.95); } .speak.small { width: 1.9rem; height: 1.9rem; font-size: 1rem; }
