:root {
  --accent: #6d5cf6;
  --bg: #f4f3fb;
  --card: #ffffff;
  --text: #1d1b2e;
  --muted: #6c6a80;
  --line: #e6e4f0;
  --good: #16a34a;
  --good-bg: #e8f8ee;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --meh: #b7791f;
  --meh-bg: #fdf5e3;
  --shadow: 0 1px 2px rgba(20, 16, 60, .06), 0 6px 20px rgba(20, 16, 60, .06);
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12111a; --card: #1d1c28; --text: #f1f0f7; --muted: #a3a1b5; --line: #2e2c3d;
    --good-bg: #12301f; --bad-bg: #3a1717; --meh-bg: #3a2e12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 17px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

.page {
  max-width: 720px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 96px) calc(env(safe-area-inset-left) + 16px);
}
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.sec { font-size: 1.05rem; margin: 26px 4px 10px; }
.note { color: var(--muted); font-size: .9rem; margin: 4px 0 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; font-weight: 650; border-radius: 14px;
  padding: 12px 18px; min-height: 48px; transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.btn.good { background: var(--good); }
.btn.bad { background: var(--bad); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid currentColor; }
.btn.sm { min-height: 38px; padding: 6px 14px; font-size: .9rem; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn.big { min-height: 60px; font-size: 1.15rem; border-radius: 18px; }
.btn.cta { flex-direction: column; gap: 0; margin-top: 16px; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn small { font-weight: 500; font-size: .85rem; opacity: .9; }
.link { color: var(--accent); font-weight: 600; padding: 10px; display: block; margin: 6px auto 0; font-size: .95rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; background: var(--card); box-shadow: var(--shadow); flex: none; }
.icon-btn.sm { width: 30px; height: 30px; font-size: .85rem; box-shadow: none; background: transparent; color: var(--muted); }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row > * { flex: 1; }
.stack { display: grid; gap: 10px; margin-top: 22px; width: 100%; }

/* Home */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hello { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mascot-sm { font-size: 2.6rem; line-height: 1; }
.hi { font-size: 1.4rem; font-weight: 750; }
.sub { color: var(--muted); font-size: .95rem; }
.pills { display: flex; gap: 6px; flex: none; }
.pill { background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 6px 12px; font-weight: 700; color: var(--muted); }
.pill.fire { color: #ea580c; }
.goal { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.goal-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.goal-text .muted { font-size: .85rem; margin-top: 4px; }
.xpbar, .bar { display: block; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 6px; }
.xpbar i, .bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.bar i { background: var(--c, var(--accent)); }

.ring .ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring .ring-fg { fill: none; stroke: var(--c, var(--accent)); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring text { font-size: 14px; font-weight: 750; fill: var(--text); }

.exam {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin-top: 12px;
  background: color-mix(in srgb, var(--c) 12%, var(--card)); border: 1.5px solid color-mix(in srgb, var(--c) 40%, transparent);
  border-radius: 16px; padding: 12px 14px;
}
.exam-ic { font-size: 1.6rem; }
.exam span { display: flex; flex-direction: column; }
.exam small { color: var(--muted); font-size: .85rem; }

.hint { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); font-size: .92rem; }
.hint span { flex: 1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 2px; border-top: 4px solid var(--c); transition: transform .08s; }
.tile:active { transform: scale(.97); }
.t-top { display: flex; justify-content: space-between; align-items: flex-start; }
.t-icon { font-size: 1.8rem; }
.t-name { font-weight: 700; margin-top: 4px; hyphens: manual; -webkit-hyphens: manual; overflow-wrap: anywhere; }
.t-meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.badge-n { background: var(--c); color: #fff; font-weight: 700; font-size: .78rem; border-radius: 99px; padding: 2px 8px; }

/* Fach */
.bar-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; min-height: 40px; }
.subj-hero, .level { display: flex; align-items: center; gap: 16px; }
.subj-hero > div, .level > div { display: flex; flex-direction: column; }
.subj-hero span, .level span { color: var(--muted); font-size: .9rem; }
.subj-hero .ring-fg { stroke: var(--c); }
.exam-tag { color: var(--c) !important; font-weight: 650; margin-top: 4px; }
.subj-hero + .row .btn:not(.ghost) { background: var(--c); }
.subj-hero + .row .btn.ghost { color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.topics { display: grid; gap: 10px; }
.topic { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; }
.tp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tp-main small { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.topic .btn { background: var(--c); }

/* Lernrunde */
.session { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 16px) 0 calc(env(safe-area-inset-left) + 16px); }
.s-head { display: flex; align-items: center; gap: 12px; }
.prog { flex: 1; height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--c); border-radius: inherit; transition: width .35s ease; }
.xp { font-weight: 750; color: #d97706; min-width: 52px; text-align: right; }
.qwrap { flex: 1; padding: 22px 0 300px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 650; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 5px 12px; border-radius: 99px; }
.chip .new { color: #d97706; }
.q { font-size: 1.35rem; font-weight: 650; line-height: 1.4; margin: 18px 2px 22px; }
.q b { color: var(--c); }
.blank { display: inline-block; min-width: 3.2em; border-bottom: 3px solid var(--c); margin: 0 3px; transform: translateY(-3px); }
.opts { display: grid; gap: 10px; }
.opts.two { grid-template-columns: 1fr 1fr; }
.opt { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; min-height: 56px; text-align: left; font-weight: 600; box-shadow: var(--shadow); transition: transform .08s, border-color .15s; }
.opts.two .opt { text-align: center; font-size: 1.15rem; }
.opt:active { transform: scale(.98); }
.opt.ok { border-color: var(--good); background: var(--good-bg); }
.opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.opt.dim { opacity: .5; }
.ans { display: flex; gap: 10px; }
.inwrap { flex: 1; position: relative; display: flex; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.inwrap:focus-within { border-color: var(--c); }
.inwrap input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 1.15rem; padding: 14px 16px; }
.unit { padding-right: 14px; color: var(--muted); font-weight: 600; }
.ans .btn { background: var(--c); }
.accents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.accents button { min-width: 40px; height: 40px; border-radius: 10px; background: var(--card); box-shadow: var(--shadow); font-size: 1.1rem; }
.reveal { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); border-left: 5px solid var(--c); font-size: 1.05rem; }
.session .row .btn { min-height: 54px; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; max-width: 720px; margin: 0 auto;
  background: var(--card); border-radius: 24px 24px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .15);
  padding: 18px calc(env(safe-area-inset-right) + 18px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 18px);
  border-top: 5px solid var(--good); animation: up .22s ease-out; max-height: 75vh; overflow-y: auto;
}
.sheet.bad { border-top-color: var(--bad); }
.sheet.meh { border-top-color: var(--meh); }
.sheet .btn { margin-top: 14px; background: var(--c); min-height: 54px; font-size: 1.1rem; }
.fb-title { font-size: 1.2rem; font-weight: 750; }
.sheet.good .fb-title { color: var(--good); }
.sheet.bad .fb-title { color: var(--bad); }
.sheet.meh .fb-title { color: var(--meh); }
.fb-given { color: var(--muted); margin-top: 6px; }
.fb-ans { margin-top: 6px; font-size: 1.05rem; }
.fb-x { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: .95rem; color: var(--text); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Zusammenfassung & Start */
.center-page, .onboard { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: calc(env(safe-area-inset-top) + 40px); max-width: 520px; }
.mascot-big { font-size: 5.5rem; line-height: 1; margin-bottom: 12px; }
.bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.welcome { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); margin: 16px 0 6px; }
.stats3, .stats4 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-top: 20px; }
.stats4 { grid-template-columns: repeat(2, 1fr); margin-top: 12px; }
@media (min-width: 560px) { .stats4 { grid-template-columns: repeat(4, 1fr); } }
.stats3 > div, .stats4 > div { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 8px; display: flex; flex-direction: column; text-align: center; }
.stats3 b, .stats4 b { font-size: 1.4rem; }
.stats3 span, .stats4 span { color: var(--muted); font-size: .82rem; }
.banner { width: 100%; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--card)); font-weight: 600; }
.banner.good { background: var(--good-bg); color: var(--good); }

.field { display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%; margin-top: 18px; }
.field > span:first-child { font-weight: 650; font-size: .95rem; }
.field input:not([type=file]):not([type=checkbox]), .field select { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 1rem; outline: none; width: 100%; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 10px; }
.field.inline > span:first-child { font-weight: 600; }
.dwrap { display: flex; align-items: center; gap: 4px; }
.dwrap input { width: auto !important; padding: 8px 10px !important; }
.form .field:first-child { margin-top: 0; }
.pickrow { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { width: 52px; height: 52px; border-radius: 16px; font-size: 1.8rem; background: var(--card); border: 2px solid var(--line); }
.pick.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.swatch { width: 40px; height: 40px; border-radius: 50%; background: var(--sw); border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--line); }
.swatch.on { box-shadow: 0 0 0 3px var(--sw); }
.onboard .btn { margin-top: 28px; }
.form + .sec, .form + .form { margin-top: 14px; }
section.form + section.form { margin-top: 14px; }
label.btn { cursor: pointer; }

/* Erfolge */
.week { display: flex; align-items: flex-end; gap: 8px; height: 170px; }
.wcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.wbar { width: 100%; max-width: 38px; min-height: 4px; border-radius: 8px 8px 4px 4px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.wbar.full { background: var(--accent); }
.wcol small { font-size: .75rem; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.bdg { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; opacity: .45; filter: grayscale(1); }
.bdg.on { opacity: 1; filter: none; }
.bdg span { font-size: 2rem; }
.bdg b { font-size: .9rem; }
.bdg small { color: var(--muted); font-size: .75rem; }

.exam-set { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; background: var(--card); box-shadow: var(--shadow); border-radius: 16px; padding: 8px 8px 8px 14px; font-weight: 600; font-size: .95rem; }
.exam-set input { border: 2px solid var(--line); background: var(--bg); border-radius: 12px; padding: 8px 10px; font-size: 1rem; outline: none; }
.exam-set input:focus { border-color: var(--c); }

/* Eigene Aufgaben / Fotoscan */
.two-tools { margin-top: 12px; }
.two-tools .test-btn { margin-top: 0; padding: 10px; }
.modegrid { display: grid; gap: 10px; }
.center-col { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.xpbar.ocr { width: 100%; height: 12px; }
.xpbar.ocr i { background: var(--c); }
.rows-head { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 8px; font-size: .8rem; font-weight: 700; color: var(--muted); padding: 0 4px; margin-top: 8px; }
.rows-head span:first-child { grid-column: 2; }
.rows { display: grid; gap: 8px; margin-top: 6px; }
.vrow { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 8px; align-items: center; }
.vrow input:not([type=checkbox]) { min-width: 0; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px; font-size: 1rem; outline: none; }
.vrow input:focus { border-color: var(--c); }
.vrow input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--c); }
.vrow.off input:not([type=checkbox]) { opacity: .4; text-decoration: line-through; }
.tokens p { margin: 0 0 10px; line-height: 2.1; }
.tok { padding: 3px 6px; border-radius: 8px; background: var(--bg); font-size: 1rem; border: 1.5px solid transparent; }
.tok.on { background: color-mix(in srgb, var(--c) 18%, var(--card)); border-color: var(--c); font-weight: 700; color: var(--c); }
.btn:disabled { opacity: .4; }

/* Probearbeit */
.test-btn { flex-direction: column; gap: 0; margin-top: 12px; background: var(--card) !important; color: var(--text); border: 2px dashed var(--c); box-shadow: var(--shadow); }
.test-btn small { color: var(--muted); }
.durgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dur { border: 2px solid var(--line); border-radius: 16px; padding: 12px; text-align: left; display: flex; flex-direction: column; background: var(--card); }
.dur b { font-size: 1.15rem; }
.dur small { color: var(--muted); font-size: .8rem; }
.dur.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--card)); }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: .95rem; }
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--c); flex: none; }
.t-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 12px; margin: calc(-1 * env(safe-area-inset-top) - 16px) -16px 14px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.t-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.t-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-title small { color: var(--muted); font-size: .8rem; }
.timer { font-weight: 800; font-variant-numeric: tabular-nums; background: var(--card); box-shadow: var(--shadow); padding: 6px 12px; border-radius: 99px; }
.timer.low { color: #fff; background: var(--bad); }
.tlist { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 14px; }
.tq { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; border-left: 5px solid var(--line); }
.tq.ok { border-left-color: var(--good); }
.tq.bad { border-left-color: var(--bad); }
.tq.meh { border-left-color: var(--meh); }
.tq-h { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tq .q { font-size: 1.1rem; margin: 8px 0 12px; }
.tq .q.sm { font-size: 1rem; margin-bottom: 6px; }
.tq .opt { box-shadow: none; min-height: 48px; padding: 10px 14px; }
.opt.sel { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--card)); }
.result-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 10px; }
.grade { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: #888; }
.grade.big { width: 110px; height: 110px; font-size: 3.4rem; margin-bottom: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.grade.g1 { background: #16a34a; } .grade.g2 { background: #65a30d; } .grade.g3 { background: #ca8a04; }
.grade.g4 { background: #ea580c; } .grade.g5 { background: #dc2626; } .grade.g6 { background: #991b1b; }

/* Navigation */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center; gap: 4px;
  background: color-mix(in srgb, var(--card) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
}
.tabbar button { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); padding: 4px; border-radius: 12px; font-weight: 600; }
.tabbar button span { font-size: 1.35rem; filter: grayscale(.6); opacity: .8; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on span { filter: none; opacity: 1; }

/* Toast & Konfetti */
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); transform: translate(-50%, -20px); opacity: 0; z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: .95rem; transition: all .3s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: translateX(40px) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { .bounce { animation: none; } * { transition: none !important; } }
