:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --ink: #1f2430;
  --ink-2: #5b6170;
  --line: #e2ded4;
  --brand: #2f6fdf;
  --brand-ink: #ffffff;
  --brand-soft: #e3ecfc;
  --ok: #1f9d55;
  --ok-soft: #dcf3e5;
  --warn: #c98a00;
  --warn-soft: #fbf0d3;
  --bad: #d64545;
  --bad-soft: #fbe2e2;
  --muted-soft: #ecebe7;
  --de: #e8590c;
  --ma: #2f6fdf;
  --en: #7048e8;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 0; border-radius: 12px; padding: .65em 1.1em;
  background: var(--brand); color: var(--brand-ink); font-weight: 600;
  text-decoration: none; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: .4em .75em; font-size: .875rem; border-radius: 9px; }

.err { color: var(--bad); font-weight: 600; }

/* ============ Schüler ============ */

.kid { font-size: 20px; min-height: 100dvh; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(440px, 100%); background: var(--surface); border-radius: 28px;
  padding: 36px 28px; box-shadow: var(--shadow); text-align: center;
}
.login-card .logo { font-size: 72px; line-height: 1; }
.login-card h1 { margin: 12px 0 4px; font-size: 2rem; }
.code-input {
  width: 100%; margin: 20px 0 12px; padding: 14px; text-align: center;
  font-size: 2.2rem; font-weight: 700; letter-spacing: .25em; text-transform: uppercase;
  border: 3px solid var(--line); border-radius: 16px; background: var(--surface);
}
.code-input:focus { outline: none; border-color: var(--brand); }
.btn.big { width: 100%; font-size: 1.35rem; padding: 16px; border-radius: 16px; }
.teacher-link { position: fixed; right: 16px; bottom: 12px; font-size: .9rem; color: var(--ink-2); }
.scan-video { width: 100%; border-radius: 16px; margin-top: 12px; background: #000; }

.kid-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; max-width: 900px; margin: 0 auto;
}
.kid-top h1 { margin: 0; font-size: 1.6rem; }
.kid-main { max-width: 900px; margin: 0 auto; padding: 8px 16px 40px; }

.subject-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 12px; }
.subject-tile {
  border: 0; border-radius: 26px; padding: 26px 20px; text-align: left; color: #fff;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; min-height: 200px;
  transition: transform .1s;
}
.subject-tile:active { transform: scale(.98); }
.subject-tile .ico { font-size: 56px; line-height: 1; }
.subject-tile .name { font-size: 1.6rem; font-weight: 800; }
.subject-tile .state { font-size: 1.05rem; opacity: .95; margin-top: auto; }
.subject-tile .bar { height: 10px; background: rgba(255, 255, 255, .35); border-radius: 99px; overflow: hidden; }
.subject-tile .bar > i { display: block; height: 100%; background: #fff; border-radius: 99px; }
.subject-tile.deutsch { background: var(--de); }
.subject-tile.mathe { background: var(--ma); }
.subject-tile.englisch { background: var(--en); }
.subject-tile.done { filter: saturate(.55); }

.quiz-top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; max-width: 900px; margin: 0 auto; }
.quiz-top .title { font-weight: 800; font-size: 1.2rem; white-space: nowrap; }
.progress { flex: 1; height: 14px; background: var(--muted-soft); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }

.qcard {
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow);
  padding: 28px 22px; text-align: center; max-width: 860px; margin: 8px auto 0;
}
.qprompt { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 1.55rem; font-weight: 700; margin: 0; }
.qhint { color: var(--ink-2); margin: 6px 0 0; font-size: 1.05rem; }
.qimage { font-size: 88px; line-height: 1.15; margin: 18px 0 6px; word-break: break-word; }
.qimage img { max-width: 100%; max-height: 260px; border-radius: 16px; }
.qtext {
  display: inline-block; margin: 18px auto 4px; padding: 16px 22px; max-width: 100%;
  font-size: 1.7rem; font-weight: 600; background: var(--surface-2); border-radius: 18px; text-align: left; white-space: pre-wrap;
}
.qtext.short { font-size: 2.4rem; text-align: center; letter-spacing: .02em; }
.speak { border: 0; background: var(--brand-soft); color: var(--brand); border-radius: 50%; width: 46px; height: 46px; font-size: 22px; flex: none; }
.listen-btn {
  margin: 20px auto 6px; border: 0; background: var(--brand); color: #fff; border-radius: 999px;
  padding: 18px 34px; font-size: 1.5rem; font-weight: 700; display: inline-flex; gap: 12px; align-items: center;
  box-shadow: 0 6px 18px rgba(47, 111, 223, .35);
}
.listen-btn.playing { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

.options { display: grid; gap: 14px; margin-top: 22px; grid-template-columns: repeat(2, 1fr); }
.options.emoji { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.options.long { grid-template-columns: 1fr; }
.opt {
  border: 3px solid var(--line); background: var(--surface); border-radius: 20px;
  padding: 18px 12px; font-size: 1.45rem; font-weight: 700; min-height: 76px; transition: transform .08s;
}
.options.emoji .opt { font-size: 56px; padding: 10px; min-height: 110px; }
.opt:active { transform: scale(.97); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }

.answer-input {
  width: min(460px, 100%); margin-top: 24px; padding: 16px; text-align: center;
  font-size: 2rem; font-weight: 700; border: 3px solid var(--line); border-radius: 18px;
}
.answer-input:focus { outline: none; border-color: var(--brand); }

.order-line {
  min-height: 78px; margin-top: 22px; padding: 12px; border: 3px dashed var(--line); border-radius: 20px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center;
}
.order-pool { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; min-height: 60px; }
.chip { border: 0; border-radius: 14px; padding: 12px 18px; font-size: 1.4rem; font-weight: 700; background: var(--warn-soft); }
.order-line .chip { background: var(--brand-soft); }

.qactions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.qactions .btn { font-size: 1.3rem; padding: 14px 28px; border-radius: 16px; }

.cheer { text-align: center; padding: 50px 16px; }
.cheer .big-emoji { font-size: 110px; line-height: 1; }
.cheer h2 { font-size: 2rem; margin: 16px 0 8px; }
.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.thumb { position: fixed; inset: 0; display: grid; place-items: center; font-size: 140px; pointer-events: none; }

@media (max-width: 560px) {
  .kid { font-size: 18px; }
  .qimage { font-size: 70px; }
  .options:not(.emoji) { grid-template-columns: 1fr; }
  .qtext.short { font-size: 2rem; }
}

/* ============ Lehrkraft ============ */

.admin { font-size: 15px; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 56px;
}
.topbar .brand { font-weight: 800; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.topbar nav a {
  text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: 9px; white-space: nowrap; font-weight: 600;
}
.topbar nav a.active, .topbar nav a:hover { background: var(--surface-2); color: var(--ink); }
.view { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.view h1 { font-size: 1.5rem; margin: 0 0 4px; }
.view h2 { font-size: 1.15rem; margin: 28px 0 10px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.panel + .panel { margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .v { font-size: 1.7rem; font-weight: 800; }
.kpi .l { color: var(--ink-2); font-size: .85rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf9f6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.cell-subj { min-width: 170px; }
.cell-subj .row1 { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; margin-bottom: 5px; }
.minibar { height: 8px; background: var(--muted-soft); border-radius: 99px; overflow: hidden; display: flex; }
.minibar > i { display: block; height: 100%; }
.minibar .c { background: var(--ok); }
.minibar .w { background: var(--bad); }
.minibar .s { background: #b9b5aa; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.pill.offen { background: var(--muted-soft); color: var(--ink-2); }
.pill.laeuft { background: var(--brand-soft); color: var(--brand); }
.pill.fertig { background: var(--ok-soft); color: var(--ok); }
.pill.beendet { background: var(--warn-soft); color: #8a5d00; }
.pill.grade { background: #efe9fd; color: #5b3cc4; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c9c5ba; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.res { font-weight: 800; }
.res.ok { color: var(--ok); }
.res.bad { color: var(--bad); }
.res.skip { color: var(--ink-2); }
tr.r-bad td { background: #fff8f8; }

.heat { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 64px; }
.heat.h-good { background: var(--ok-soft); color: #15703c; }
.heat.h-mid { background: var(--warn-soft); color: #7a5300; }
.heat.h-bad { background: var(--bad-soft); color: #a52b2b; }
.heat.h-none { color: #b3afa5; font-weight: 400; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 90px; gap: 10px; align-items: center; font-size: .9rem; }
.bar-row .track { height: 12px; background: var(--muted-soft); border-radius: 99px; overflow: hidden; }
.bar-row .track > i { display: block; height: 100%; border-radius: 99px; }
.fill-good { background: var(--ok); }
.fill-mid { background: var(--warn); }
.fill-bad { background: var(--bad); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 120px 1fr 70px; } }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; font-weight: 600; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--bad-soft); color: #a52b2b; border-radius: 99px; padding: 3px 10px; font-size: .82rem; font-weight: 600; }
.tag.ok { background: var(--ok-soft); color: #15703c; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.input, textarea.input, select.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; letter-spacing: .08em; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.notice { background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }

.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth { width: min(400px, 100%); }
.auth h1 { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow);
}

/* Login-Karten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  background: #fff; border: 2px dashed #bdb8ac; border-radius: 14px; padding: 14px; text-align: center; break-inside: avoid;
}
.card .cname { font-size: 1.35rem; font-weight: 800; margin-bottom: 6px; }
.card .qr svg { width: 170px; height: 170px; }
.card .ccode { font-size: 1.5rem; margin-top: 4px; }
.card .curl { font-size: .72rem; color: var(--ink-2); word-break: break-all; }

@media print {
  body { background: #fff; }
  .topbar, .no-print { display: none !important; }
  .view { padding: 0; max-width: none; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: 8mm; }
  .card { page-break-inside: avoid; }
}
