:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --card2: #f1ede4;
  --line: #e6e0d4;
  --text: #22252b;
  --muted: #6f7582;
  --accent: #ff8a3d;
  --accent-ink: #ffffff;
  --ok: #2fb872;
  --ok-bg: #e5f7ed;
  --bad: #ec5b5b;
  --bad-bg: #fdecec;
  --mid: #f2b01e;
  --mathe: #3d7bfd;
  --deutsch: #ef5c6c;
  --sach: #22a86a;
  --englisch: #8a5cf6;
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.4 ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 17px; }
[hidden] { display: none !important; }
#app { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 30px); }

/* Kopfzeile */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 28px; box-shadow: 0 2px 8px rgba(0,0,0,.06); flex: none; border: 0; }
.top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pill { background: var(--card); border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: 15px; box-shadow: 0 2px 8px rgba(0,0,0,.05); white-space: nowrap; }
.icon-btn { background: var(--card); border: 0; border-radius: 14px; width: 44px; height: 44px; font-size: 20px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.05); flex: none; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mt { margin-top: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h1 { font-size: 30px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 0 0 10px; }
.sec { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 10px; }

/* Karten */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.hero { background: linear-gradient(135deg, #ff9b52, #ff7a45); color: #fff; }
.hero .muted { color: rgba(255,255,255,.85); }
.bar { height: 12px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.hero .bar { background: rgba(255,255,255,.3); }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.hero .bar > i { background: #fff; }

/* Buttons */
.btn { border: 0; border-radius: 18px; padding: 16px 20px; font-weight: 800; font-size: 18px; background: var(--card2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 #d9692a; }
.btn.white { background: #fff; color: #e2662c; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.btn.ok { background: var(--ok); color: #fff; box-shadow: 0 4px 0 #22915a; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 14px; font-size: 15px; border-radius: 12px; box-shadow: none; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn[disabled] { opacity: .45; }

/* Fächer */
.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subj { border: 0; border-radius: var(--radius); padding: 18px 14px; color: #fff; text-align: left; min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 5px 0 rgba(0,0,0,.14); }
.subj .emo { font-size: 36px; }
.subj b { font-size: 20px; }
.subj small { opacity: .9; font-size: 13px; }
.subj:active { transform: translateY(3px); box-shadow: none; }

/* Themenliste */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.li { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; width: 100%; text-align: left; }
.li:last-child { border-bottom: 0; }
.li .sub { font-size: 13px; color: var(--muted); }
.li .emo { font-size: 26px; width: 36px; text-align: center; flex: none; }
.stars { letter-spacing: 1px; font-size: 15px; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.chip.focus { background: #fff1e6; color: #e2662c; }

/* Übung */
.q-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.q-card { background: var(--card); border-radius: var(--radius); padding: 22px 18px; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.q-text { font-size: 22px; font-weight: 700; line-height: 1.35; overflow-wrap: break-word; word-break: break-word; hyphens: auto; }
.q-text .hl { background: #fff1b8; border-radius: 6px; padding: 0 4px; }
.q-sub { color: var(--muted); font-size: 15px; margin-top: 8px; }
.calc { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 26px; font-weight: 700; text-align: right; display: inline-block; line-height: 1.3; margin: 10px auto 0; padding: 8px 16px; background: var(--card2); border-radius: 12px; }
.calc .line { border-top: 3px solid var(--text); }
.opts { display: grid; gap: 10px; }
.opts.two { grid-template-columns: 1fr 1fr; }
.opt { background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 16px; font-size: 19px; font-weight: 700; text-align: center; box-shadow: 0 3px 0 var(--line); }
.opt:active { transform: translateY(2px); box-shadow: none; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); box-shadow: 0 3px 0 var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 3px 0 var(--bad); }
.ans { width: 100%; font-size: 28px; font-weight: 800; text-align: center; padding: 16px; border-radius: 18px; border: 3px solid var(--line); background: var(--card); outline: none; }
.ans:focus { border-color: var(--accent); }
.ans.right { border-color: var(--ok); background: var(--ok-bg); }
.ans.wrong { border-color: var(--bad); background: var(--bad-bg); }
.feedback { border-radius: 18px; padding: 14px 16px; margin: 12px 0; font-size: 16px; }
.feedback.ok { background: var(--ok-bg); color: #16734a; }
.feedback.bad { background: var(--bad-bg); color: #a3333a; }
.feedback b { font-size: 18px; }
.speak { font-size: 44px; width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--card2); margin: 6px auto 0; display: flex; align-items: center; justify-content: center; }
.readtext { background: #fffaf0; border-radius: 16px; padding: 14px; font-size: 17px; line-height: 1.55; margin-bottom: 14px; border: 2px solid #f4e6c8; }
.chart-wrap svg { width: 100%; height: auto; }

/* Info / Merksatz */
.merk { background: #fff8e8; border: 2px solid #f6dfa8; border-radius: 18px; padding: 14px 16px; font-size: 16px; line-height: 1.5; }
.merk b { color: #b26a00; }

/* Ergebnis */
.big-stars { font-size: 56px; letter-spacing: 6px; margin: 10px 0; }
.big-stars span { display: inline-block; animation: pop .5s both; }
.big-stars span:nth-child(2) { animation-delay: .2s; }
.big-stars span:nth-child(3) { animation-delay: .4s; }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.3); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i { position: absolute; top: -40px; font-size: 26px; font-style: normal; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge { background: var(--card); border-radius: 16px; padding: 10px 4px; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.badge .e { font-size: 28px; display: block; }
.badge.off { opacity: .35; filter: grayscale(1); }

/* Wochenleiste */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: 12px; font-weight: 700; }
.days div { background: var(--card2); border-radius: 12px; padding: 8px 0; color: var(--muted); }
.days .on { background: var(--ok); color: #fff; }
.days .today { outline: 3px solid var(--accent); }

/* Formulare */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.inp { width: 100%; background: var(--card2); border: 2px solid transparent; border-radius: 14px; padding: 13px 14px; outline: none; }
.inp:focus { border-color: var(--accent); }
.seg { display: flex; background: var(--card2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 11px; padding: 10px 4px; font-weight: 700; font-size: 15px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { font-size: 30px; background: var(--card2); border: 3px solid transparent; border-radius: 16px; padding: 6px 0; }
.avatars button.on { border-color: var(--accent); background: #fff1e6; }
.pin { display: flex; gap: 12px; justify-content: center; margin: 18px 0; }
.pin i { width: 18px; height: 18px; border-radius: 50%; background: var(--line); }
.pin i.on { background: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.keypad button { font-size: 26px; font-weight: 700; padding: 14px 0; border-radius: 18px; border: 0; background: var(--card); box-shadow: 0 3px 0 var(--line); }
.hint { background: #fff1e6; border-radius: 16px; padding: 12px 14px; font-size: 15px; color: #8a4a1d; }
.okbox { background: var(--ok-bg); border-radius: 16px; padding: 12px 14px; font-size: 15px; color: #16734a; }

/* Sheet & Toast */
#sheet-wrap { position: fixed; inset: 0; z-index: 50; }
#sheet-backdrop { position: absolute; inset: 0; background: rgba(20,20,30,.45); }
#sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 18px calc(var(--safe-b) + 24px); max-width: 640px; margin: 0 auto; animation: up .25s ease-out; }
#sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 14px); z-index: 95; background: var(--text); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 700; font-size: 15px; max-width: 90vw; text-align: center; }

/* Tabellen Elternbereich */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl td { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.tbl td:last-child { text-align: right; white-space: nowrap; }

/* ================= Kinder-Design v2 (freundlicher, aufgeräumter) ================= */
@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka-latin-500-normal.woff2') format('woff2'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka-latin-700-normal.woff2') format('woff2'); font-weight: 700 900; font-display: swap; }
:root { --bg: #fff5e8; --mathe: #4c8dff; --deutsch: #ff6b7d; --sach: #2ec27e; --englisch: #9b6bff; --radius: 26px; }
html, body { background: #fff5e8; }
body {
  font-family: 'Fredoka', ui-rounded, "SF Pro Rounded", -apple-system, sans-serif; font-weight: 500; font-size: 18px;
  background: radial-gradient(#ffe0bd 1.6px, transparent 1.7px) 0 0 / 24px 24px, linear-gradient(180deg, #fff8ee, #fdeedd) fixed;
}
b, strong, h1, h2, .btn, .opt, .pill { font-weight: 600; }
h1 { font-weight: 700; }
.card { box-shadow: 0 4px 0 rgba(0,0,0,.05); }

/* Kopfzeile */
.k-top { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: #fff; font-size: 22px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 rgba(0,0,0,.08); flex: none; }
.round-btn.av { font-size: 28px; }
.round-btn.lock { font-size: 16px; opacity: .55; width: 38px; height: 38px; }
.pill { background: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.06); }

/* Buddy mit Sprechblase */
.buddy { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 18px; }
.buddy-av { font-size: 54px; line-height: 1; flex: none; animation: float 3s ease-in-out infinite; filter: drop-shadow(0 6px 6px rgba(0,0,0,.12)); }
.buddy.big .buddy-av { font-size: 76px; }
.bubble { position: relative; background: #fff; border-radius: 24px 24px 24px 6px; padding: 14px 16px; font-size: 18px; line-height: 1.4; box-shadow: 0 4px 0 rgba(0,0,0,.06); flex: 1; }
.bubble .btn.sm { display: inline-flex; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.jump { animation: jump .8s ease-out 2; display: inline-block; font-size: 90px; }
@keyframes jump { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-24px) scale(1.1); } }

/* Großer Start-Button mit Fortschritt */
.go-btn { position: relative; overflow: hidden; width: 100%; border: 0; border-radius: 28px; background: linear-gradient(135deg, #ff9d4d, #ff6f3c); color: #fff; padding: 20px; margin-bottom: 14px; box-shadow: 0 6px 0 #d9542a; }
.go-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9542a; }
.go-fill { position: absolute; left: 0; bottom: 0; height: 8px; background: #ffe066; border-radius: 0 8px 8px 0; transition: width .5s; }
.go-txt { position: relative; display: block; font-size: 28px; font-weight: 700; }
.go-txt small { display: block; font-size: 15px; font-weight: 500; opacity: .9; margin-top: 2px; }

/* Kleine Extra-Buttons */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip-btn { border: 0; background: #fff; border-radius: 99px; padding: 10px 16px; font: inherit; font-size: 16px; box-shadow: 0 3px 0 rgba(0,0,0,.07); }
.chip-btn b { background: #ff6f3c; color: #fff; border-radius: 99px; padding: 0 8px; margin-left: 4px; font-size: 14px; }

/* Fächer-Kacheln */
.subjects2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.subj2 { border: 0; border-radius: 28px; padding: 18px 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; font: inherit; box-shadow: 0 6px 0 rgba(0,0,0,.14); }
.subj2 .emo { font-size: 50px; line-height: 1.1; }
.subj2 b { font-size: 21px; }
.subj2 small { font-size: 14px; background: rgba(255,255,255,.25); border-radius: 99px; padding: 2px 10px; }
.subj2:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.14); }
.s-mathe { background: var(--mathe); } .s-deutsch { background: var(--deutsch); } .s-sach { background: var(--sach); } .s-englisch { background: var(--englisch); }

/* Fach-Kopf & Themen-Kacheln */
.subj-head { border-radius: 28px; color: #fff; padding: 20px; text-align: center; margin-bottom: 16px; box-shadow: 0 6px 0 rgba(0,0,0,.12); }
.subj-head .emo { font-size: 54px; display: block; }
.subj-head h1 { margin-bottom: 8px; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ttile { position: relative; border: 0; background: #fff; border-radius: 22px; padding: 16px 10px 12px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; font: inherit; font-size: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.07); min-height: 128px; }
.ttile .emo { font-size: 36px; }
.ttile b { font-weight: 600; line-height: 1.2; }
.ttile .stars { color: #f5b50a; font-size: 17px; letter-spacing: 2px; }
.ttile .pin { position: absolute; top: 8px; right: 10px; font-size: 16px; }
.ttile:active { transform: translateY(3px); box-shadow: none; }
.tgrid.small3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ttile.mini { min-height: 0; padding: 10px 6px; font-size: 13px; box-shadow: none; border: 3px solid transparent; }
.ttile.mini .emo { font-size: 24px; }
.ttile.g { border-color: var(--ok); background: var(--ok-bg); } .ttile.y { border-color: var(--mid); background: #fff6db; } .ttile.r { border-color: var(--bad); background: var(--bad-bg); }
.topic-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.topic-head .emo { font-size: 60px; }
.topic-head h1 { font-size: 26px; }
.stars.big { color: #f5b50a; font-size: 22px; letter-spacing: 3px; }

/* Quiz */
.q-top { margin-bottom: 10px; }
.qbar .bar { height: 16px; background: #fff; box-shadow: inset 0 2px 0 rgba(0,0,0,.05); }
.qbar.s-mathe, .qbar.s-deutsch, .qbar.s-sach, .qbar.s-englisch { background: none; }
.s-mathe .bar > i { background: var(--mathe); } .s-deutsch .bar > i { background: var(--deutsch); } .s-sach .bar > i { background: var(--sach); } .s-englisch .bar > i { background: var(--englisch); }
.q-chip { display: inline-block; background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.q-card { border-radius: 28px; box-shadow: 0 4px 0 rgba(0,0,0,.06); }
.q-text { font-size: 23px; font-weight: 600; }
.opt { border-radius: 22px; font-size: 20px; font-weight: 600; padding: 18px 12px; border-width: 3px; box-shadow: 0 4px 0 var(--line); }
.ans { border-radius: 22px; }
.fb-space { height: 240px; }
.fb-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 18px 18px calc(var(--safe-b) + 18px); border-radius: 28px 28px 0 0; max-height: 70vh; overflow-y: auto; animation: up .25s ease-out; max-width: 640px; margin: 0 auto; box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
.fb-panel.ok { background: #dff7e9; color: #13653f; }
.fb-panel.bad { background: #ffe8e6; color: #9a2b31; }
.fb-av { font-size: 46px; animation: jump .6s ease-out 1; display: inline-block; }
.fb-title { font-size: 24px; font-weight: 700; }
.why { margin: 10px 0; font-size: 16px; } .why summary { cursor: pointer; font-weight: 600; }
.why-open { margin: 10px 0 12px; font-size: 16px; background: rgba(255,255,255,.55); border-radius: 16px; padding: 10px 12px; }
.fb-panel .btn { margin-top: 6px; }

/* Ergebnis */
.result { text-align: center; padding: 20px 0 10px; }
.result h1 { font-size: 30px; }
.res-score { font-size: 22px; margin: 0 0 10px; }
.res-score b { font-size: 32px; }
