:root {
  --bg: #f4f3fb;
  --card: #ffffff;
  --text: #2d3436;
  --muted: #8a8a9e;
  --primary: #6c5ce7;
  --ok: #00b894;
  --no: #e74c3c;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(60, 50, 120, 0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
#app { min-height: 100%; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 18px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.screen.center { align-items: center; justify-content: center; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  background: #ecebf6;
  color: var(--text);
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary.big { padding: 18px; font-size: 19px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.icon { background: transparent; font-size: 22px; padding: 6px 12px; width: auto; }

/* ---------- Hero / Header ---------- */
.hero { text-align: center; margin-top: 8px; }
.hero h1 { font-size: 34px; margin: 8px 0; }
.hero p { color: var(--muted); margin: 0; font-size: 18px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar .who { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.section-title { text-align: center; margin: 4px 0; }

/* ---------- Profile ---------- */
.profile-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px;
}
.profile-card {
  border: none; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border-bottom: 5px solid var(--c, var(--primary));
  transition: transform .08s;
}
.profile-card:active { transform: scale(.95); }
.profile-card.add { color: var(--muted); font-size: 30px; border-bottom-color: #ddd; justify-content: center; }
.avatar { font-size: 40px; line-height: 1; }
.avatar.sm { font-size: 22px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 18%, #fff); border-radius: 50%; }
.pname { font-weight: 700; font-size: 15px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.text-input {
  padding: 16px; font-size: 18px; border: 2px solid #e3e1f0; border-radius: var(--radius);
  background: #fff; outline: none;
}
.text-input:focus { border-color: var(--primary); }
.center-text { text-align: center; letter-spacing: 6px; font-size: 26px; }
.label { font-weight: 700; color: var(--muted); font-size: 14px; margin-top: 4px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid #e3e1f0; background: #fff; border-radius: 999px;
  padding: 9px 14px; font-size: 15px; cursor: pointer; font-weight: 600;
}
.chip.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.chip.color { width: 38px; height: 38px; border-radius: 50%; padding: 0; }
.chip.color.on { outline: 3px solid var(--text); outline-offset: 2px; }
.opt { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Kategorien ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.cat-card {
  position: relative; border: none; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  border-bottom: 5px solid var(--c); transition: transform .08s;
}
.cat-card:active { transform: scale(.95); }
.cat-emoji { font-size: 38px; }
.cat-label { font-weight: 700; font-size: 16px; }
.badge {
  position: absolute; top: 10px; right: 10px; background: var(--c);
  color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
}

/* ---------- Quiz ---------- */
.quiz { gap: 22px; }
.progress { flex: 1; height: 10px; background: #e3e1f0; border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--primary); transition: width .3s; }
.counter { font-weight: 700; color: var(--muted); min-width: 44px; text-align: right; }
.question-area { text-align: center; margin-top: 24px; }
.question { font-size: clamp(38px, 12vw, 60px); font-weight: 800; }
.hint-btn { margin-top: 14px; border: none; background: #fff6db; color: #b08900; padding: 8px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; }
.hint { margin-top: 12px; color: var(--muted); font-size: 16px; }
.answer-form { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.answer-input {
  text-align: center; font-size: 40px; font-weight: 800; padding: 18px;
  border: 3px solid #e3e1f0; border-radius: var(--radius); outline: none;
}
.answer-input:focus { border-color: var(--primary); }
.feedback { text-align: center; font-size: 22px; font-weight: 700; min-height: 30px; opacity: 0; transition: opacity .15s; }
.feedback.show { opacity: 1; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--no); }
.feedback small { color: var(--muted); font-weight: 600; }
.big-emoji { font-size: 26px; }
.big-emoji.huge { font-size: 80px; }

/* ---------- Summary ---------- */
.summary { gap: 14px; }
.summary h2 { margin: 0; font-size: 26px; }
.ring {
  --p: 0;
  width: 140px; height: 140px; border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), #e3e1f0 0);
  display: grid; place-items: center; margin: 8px 0;
}
.ring span { width: 104px; height: 104px; background: var(--bg); border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 800; }
.muted { color: var(--muted); }
.wrong-list { width: 100%; display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.wrong-item { display: flex; justify-content: space-between; background: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); }
.wrong-item b { color: var(--ok); }

/* ---------- Loader ---------- */
.loader { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
.spinner {
  width: 46px; height: 46px; border: 5px solid #e3e1f0; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard ---------- */
.dash { gap: 14px; }
.dash-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tab { white-space: nowrap; border: 2px solid #e3e1f0; background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.tab.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi { background: var(--card); border-radius: 14px; padding: 12px 6px; text-align: center; box-shadow: var(--shadow); }
.kpi-val { font-size: 19px; font-weight: 800; }
.kpi-lbl { font-size: 11px; color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-title { font-weight: 800; margin-bottom: 14px; }
/* Vertikaler Abstand zwischen den Karten/Blöcken im Eltern-Bereich */
#parentBody, #dashBody { display: flex; flex-direction: column; gap: 18px; }
.days { display: flex; gap: 4px; align-items: flex-end; height: 90px; overflow-x: auto; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 22px; flex: 1; }
.day-bar { height: 70px; width: 100%; display: flex; align-items: flex-end; }
.day-fill { width: 100%; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--ok) calc(var(--a) * 1%), var(--no)); }
.day-lbl { font-size: 9px; color: var(--muted); transform: rotate(-45deg); white-space: nowrap; }
.cat-row { display: grid; grid-template-columns: 1fr; gap: 4px; margin-bottom: 14px; }
.cat-name { font-weight: 700; }
.cat-meter { height: 10px; background: #eee; border-radius: 999px; overflow: hidden; }
.cat-meter-fill { height: 100%; background: var(--primary); }
.cat-stat { font-size: 13px; color: var(--muted); }
.hard-row, .rec-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0eff8; font-size: 15px; }
.hard-row:last-child, .rec-row:last-child { border-bottom: none; }
.hard-q { flex: 1; font-weight: 600; }
.hard-stat { color: var(--muted); font-size: 13px; }
.hard-stat.bad { color: var(--no); font-weight: 700; }
.rec-q { flex: 1; }
.rec-a { color: var(--muted); }
.rec-a b { color: var(--text); }
.rec-t { font-size: 12px; color: var(--muted); min-width: 48px; text-align: right; }

/* ---------- Gamification ---------- */
.mini-stats { font-size: 11px; color: var(--muted); font-weight: 700; }
.gam-header { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.gam-top { display: flex; align-items: center; gap: 10px; }
.level-badge { background: var(--primary); color: #fff; font-weight: 800; padding: 4px 10px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.xp-bar { position: relative; flex: 1; height: 18px; background: #e3e1f0; border-radius: 999px; overflow: hidden; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #a29bfe, #6c5ce7); transition: width .4s; }
.xp-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #4b3fae; }
.coins, .streak { font-weight: 700; white-space: nowrap; font-size: 15px; }
.goal { display: flex; flex-direction: column; gap: 3px; }
.goal-bar { height: 8px; background: #e3e1f0; border-radius: 999px; overflow: hidden; }
.goal-fill { height: 100%; background: var(--ok); transition: width .4s; }
.goal-txt { font-size: 12px; color: var(--muted); }
.hub-actions { display: flex; gap: 10px; }
.pill { flex: 1; border: none; background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 12px; font-weight: 700; font-size: 15px; cursor: pointer; }
.pill:active { transform: scale(.96); }

/* +XP / Feedback */
.review-tag { display: inline-block; background: #fff6db; color: #b08900; font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; margin-bottom: 10px; }
.fb-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.mini-btn { border: none; background: #ecebf6; color: var(--text); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 14px; cursor: pointer; }
.mini-btn.primary { background: var(--primary); color: #fff; }
.mini-btn.rej { background: #ffe3e0; color: var(--no); }
.explain { margin-top: 12px; background: #f3f1ff; border-radius: 12px; padding: 12px 14px; font-size: 15px; color: var(--text); font-weight: 500; line-height: 1.4; text-align: left; }

/* Summary-Belohnungen */
.gain-row { display: flex; gap: 12px; justify-content: center; margin: 4px 0; }
.gain { font-weight: 800; padding: 6px 14px; border-radius: 999px; }
.gain.xp { background: #efe9ff; color: #6c5ce7; }
.gain.coin { background: #fff6db; color: #b08900; }
.levelup { font-size: 22px; font-weight: 800; color: var(--primary); margin: 10px 0; animation: pop .4s; }
.new-badge { background: #fff; box-shadow: var(--shadow); border-radius: 12px; padding: 10px 14px; margin: 6px 0; font-weight: 600; animation: pop .4s; }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }

/* Abzeichen-Galerie */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 12px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.badge-card.locked { opacity: .55; filter: grayscale(.6); }
.b-emoji { font-size: 34px; }
.b-label { font-weight: 800; font-size: 15px; }
.b-desc { font-size: 12px; color: var(--muted); }

/* Shop */
.coins-big { text-align: center; font-size: 22px; font-weight: 800; color: #b08900; }
.reward-card { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 10px 0; }
.r-emoji { font-size: 28px; }
.r-label { flex: 1; font-weight: 700; }
.redeem { white-space: nowrap; }
.pending-row { background: #fff; border-radius: 12px; padding: 10px 14px; margin: 6px 0; box-shadow: var(--shadow); }

/* Eltern-Verwaltung */
.seg { display: flex; gap: 6px; background: #e3e1f0; border-radius: 999px; padding: 4px; }
.seg-btn { flex: 1; border: none; background: transparent; border-radius: 999px; padding: 10px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg-btn.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.gam-card { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 8px; }
.gc { font-size: 14px; color: var(--muted); }
.gc b { color: var(--text); font-size: 17px; }
.badge-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge-chip { background: #f0eff8; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; opacity: .6; }
.badge-chip.has { background: #efe9ff; color: #6c5ce7; opacity: 1; }
.redemption-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0eff8; font-size: 14px; }
.red-actions { display: flex; gap: 6px; }
.reward-edit-row { display: flex; gap: 6px; margin: 6px 0; }
.reward-edit-row .ri { border: 2px solid #e3e1f0; border-radius: 10px; padding: 8px; font-size: 14px; outline: none; }
.reward-edit-row .emoji { width: 48px; text-align: center; }
.reward-edit-row .label { flex: 1; min-width: 0; }
.reward-edit-row .cost { width: 72px; }
.card .text-input { margin-bottom: 4px; }
.card .btn { margin-top: 8px; }

/* Coach-Karte (Hub) */
.coach-card { background: linear-gradient(135deg, #efe9ff, #e6f7f1); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.coach-head { font-weight: 800; font-size: 15px; }
.coach-msg { font-size: 16px; line-height: 1.4; min-height: 22px; }
.coach-go { align-self: flex-start; margin-top: 2px; }

/* KI-Lernanalyse (Eltern) */
.analysis-hint { font-size: 13px; margin: 8px 0 0; }
.analysis-summary { font-size: 16px; line-height: 1.45; font-weight: 500; margin: 0 0 12px; }
.problem { border-left: 4px solid #ccc; background: #faf9ff; border-radius: 0 10px 10px 0; padding: 10px 12px; margin: 8px 0; }
.problem-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.problem-detail { font-size: 14px; color: #555; margin-top: 4px; line-height: 1.4; }
.sev-chip { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.sev-high { border-left-color: var(--no); } .sev-high .sev-chip { background: #ffe3e0; color: var(--no); }
.sev-mid { border-left-color: #e6a700; } .sev-mid .sev-chip { background: #fff3cf; color: #b08900; }
.sev-low { border-left-color: #b8b6c8; } .sev-low .sev-chip { background: #eceaf5; color: #777; }
.reco { margin-top: 12px; }
.reco-title { font-weight: 800; margin-bottom: 6px; }
.reco ul { margin: 0; padding-left: 20px; }
.reco li { margin: 4px 0; line-height: 1.4; }
.analysis-enc { margin: 12px 0 0; font-weight: 600; color: var(--ok); }
.analysis-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; font-size: 12px; }
