/* Lernomat – Gestaltung
   Warme, ruhige Grundfarben; Karten und Profile in klaren, freundlichen Tönen.
   Große Tippflächen (mind. 44 px) für Kinderhände. */

:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --panel-soft: #fbf9f5;
  --ink: #1d1b16;
  --muted: #69655c;
  --line: #e6e0d5;
  --primary: #2f6fde;
  --primary-ink: #ffffff;
  --primary-soft: #e8efff;
  --danger: #c23b36;
  --danger-soft: #fdecea;
  --ok: #2f8a3b;
  --ok-soft: #e6f4e3;
  --warn-soft: #fff4d6;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(29, 27, 22, .06), 0 4px 14px rgba(29, 27, 22, .06);
  --shadow-lg: 0 10px 40px rgba(29, 27, 22, .18);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Boxen 1–5: von „neu“ (warm) zu „sitzt“ (grün) */
  --b1: #e5534b; --b1s: #fde9e7;
  --b2: #ec8a2e; --b2s: #fdefe0;
  --b3: #d9ad1f; --b3s: #fbf3d2;
  --b4: #2fa592; --b4s: #dff4f0;
  --b5: #3f9636; --b5s: #e4f3df;
}

/* Kartenfarben: Hintergrund, Rand/Akzent, Text */
.c-blue   { --cbg: #e8f0fc; --cbd: #4a86d8; --ctx: #123e73; }
.c-teal   { --cbg: #e0f4f0; --cbd: #2f9e8b; --ctx: #0d4a40; }
.c-green  { --cbg: #e9f5dc; --cbd: #5e9a2a; --ctx: #274b0c; }
.c-yellow { --cbg: #fdf4d3; --cbd: #cf9f10; --ctx: #574003; }
.c-orange { --cbg: #fdebdc; --cbd: #e07a2e; --ctx: #6b3208; }
.c-red    { --cbg: #fce7e6; --cbd: #d9534f; --ctx: #7a1e1c; }
.c-pink   { --cbg: #fce6f0; --cbd: #d65a95; --ctx: #6e1d44; }
.c-purple { --cbg: #eeeafd; --cbd: #7c64d6; --ctx: #35237a; }
.c-gray   { --cbg: #efeee9; --cbd: #8a877f; --ctx: #34332f; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; margin-top: .3em; }
p { margin: 0 0 .75em; }
a { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.1rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.big { font-size: 1.15rem; }
.center { text-align: center; }
.grow { flex: 1; }
.sr, .offscreen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 2rem; text-align: center; }

/* ---------- Layout ---------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.narrow-page { max-width: 560px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; margin-bottom: 8px;
}
.center-screen {
  min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px 16px;
}
.center-screen .logo { width: 72px; height: 72px; }
.narrow { max-width: 420px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.button-row.end { justify-content: flex-end; margin-top: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two-col { grid-template-columns: 1fr; } }
.foot { margin-top: 28px; text-align: center; }
.section { margin-top: 1.6rem; }

/* ---------- Marke ---------- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo { width: 56px; height: 56px; flex: none; }
.brand.small .logo { width: 34px; height: 34px; }
.brand h1 { margin: 0; }
.brand p { margin: 2px 0 0; }
.wordmark { font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #2a63c7; }
.btn.ghost { background: var(--panel); }
.btn.ghost:hover { border-color: #cfc7b8; background: var(--panel-soft); }
.btn.link { border: 0; background: none; color: var(--primary); padding: 8px 6px; min-height: 40px; font-weight: 600; }
.btn.link.back { padding-left: 0; }
.btn.small { min-height: 38px; padding: 7px 13px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.file-btn { cursor: pointer; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 1.5px solid var(--line); border-radius: 50%; background: var(--panel);
  font-size: 1.15rem; color: var(--ink); cursor: pointer;
}
:focus-visible { outline: 3px solid rgba(47, 111, 222, .45); outline-offset: 2px; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 650; font-size: .92rem; margin: 12px 0 0; }
.label { font-weight: 650; font-size: .92rem; margin: 14px 0 6px; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; min-height: 46px;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 222, .18); }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin: 12px 0 0; font-size: .92rem; }
.pin-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pin-input { font-size: 2rem !important; letter-spacing: .6em; text-align: center; margin: 14px 0 4px; }

/* ---------- Flächen ---------- */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 14px 0; }
.panel.subtle { background: var(--panel-soft); box-shadow: none; border: 1.5px dashed var(--line); }
.banner { border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0; font-size: .92rem; }
.banner.warn { background: var(--warn-soft); color: #5c4400; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: #efece6; color: var(--muted);
}
.pill.b1 { background: var(--b1s); color: #9d2620; }
.pill.b2 { background: var(--b2s); color: #8a4308; }
.pill.b3 { background: var(--b3s); color: #6a5000; }
.pill.b4 { background: var(--b4s); color: #0f5a4d; }
.pill.b5 { background: var(--b5s); color: #235a1c; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: #6a5000; font-size: .75rem; font-weight: 700; }

/* ---------- Anmeldung ---------- */
.auth { max-width: 440px; margin: 0 auto; padding: max(40px, env(safe-area-inset-top)) 16px 40px; }
.auth .brand { margin-bottom: 18px; }

/* ---------- Einrichtung ---------- */
.setup-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.setup-row input { margin-top: 0; }
.avatar-select { width: 72px; flex: none; margin-top: 0; font-size: 1.4rem; padding: 6px; text-align: center; }

/* ---------- Profilauswahl ---------- */
.hello { display: flex; align-items: center; gap: 12px; margin: 14px 0 16px; }
.kid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.kid-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 12px 18px; border-radius: 22px; cursor: pointer;
  background: var(--cbg); border: 2px solid transparent; color: var(--ctx);
  font: inherit; box-shadow: var(--shadow); transition: transform .1s ease, border-color .15s ease;
}
.kid-tile:hover { border-color: var(--cbd); }
.kid-tile:active { transform: scale(.97); }
.kid-name { font-size: 1.25rem; font-weight: 800; }
.kid-meta { font-size: .92rem; }
.kid-tile .streak { position: absolute; top: 10px; right: 12px; font-size: .85rem; font-weight: 700; }
.avatar { display: inline-grid; place-items: center; font-size: 1.3rem; line-height: 1; }
.avatar.lg { font-size: 1.8rem; width: 48px; height: 48px; border-radius: 50%; background: var(--cbg, #efece6); }
.avatar.xl { font-size: 3.4rem; }
.avatar.xxl { font-size: 4.6rem; }
.parents-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 26px; }
.parent-chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 6px 14px 6px 10px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); font: inherit; font-weight: 600; cursor: pointer;
}
.parent-chip .lock { font-size: .8rem; opacity: .7; }
.streak { font-weight: 750; color: #b4520e; }
.streak.big { font-size: 1.05rem; }

/* ---------- Kind: Übersicht ---------- */
.hero {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
  padding: 26px 22px; border-radius: 24px; border: 2px solid var(--cbd);
  background: var(--cbg); color: var(--ctx); text-align: left; font: inherit;
}
.hero p { margin: 0; }
.hero.action { cursor: pointer; box-shadow: var(--shadow); transition: transform .1s ease; }
.hero.action:active { transform: scale(.98); }
.hero-big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.hero-cta { font-size: 1.15rem; font-weight: 750; }
.deck-list { display: flex; flex-direction: column; gap: 10px; }
.deck-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  border: 1.5px solid transparent; text-align: left; font: inherit; color: inherit;
}
.deck-row.clickable { cursor: pointer; }
.deck-row.clickable:hover { border-color: var(--line); }
.deck-dot { width: 14px; height: 40px; border-radius: 7px; background: var(--cbd); flex: none; }
.deck-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.deck-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { font-size: 1.6rem; color: #b5ae9f; }
.boxbar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: #efece6; margin-top: 4px; }
.boxbar .seg { height: 100%; }
.seg.b1 { background: var(--b1); } .seg.b2 { background: var(--b2); } .seg.b3 { background: var(--b3); }
.seg.b4 { background: var(--b4); } .seg.b5 { background: var(--b5); }

/* ---------- Lernen ---------- */
.learn .topbar { gap: 14px; }
.progress { flex: 1; height: 10px; background: #e7e2d8; border-radius: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 6px; transition: width .3s ease; }
.count { min-width: 44px; text-align: right; }
.learn-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 2px 12px; }
.flashcard {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  width: 100%; min-height: min(56vh, 460px); padding: 28px 22px;
  border-radius: 26px; border: 3px solid var(--cbd); background: var(--cbg); color: var(--ctx);
  font: inherit; text-align: center; cursor: pointer; box-shadow: var(--shadow);
  animation: pop .22s ease;
}
.flashcard:disabled { cursor: default; opacity: 1; }
.flashcard.back { animation: flip .28s ease; }
.fc-label { font-size: .8rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.fc-text { font-weight: 750; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.3; }
.fc-text.short { font-size: 2.3rem; }
.fc-text.mid { font-size: 1.7rem; }
.fc-text.long { font-size: 1.3rem; }
.fc-text.xl-long { font-size: 1.1rem; font-weight: 650; }
.fc-hint { font-size: .9rem; opacity: .7; }
.fc-question { font-size: .95rem; opacity: .75; border-top: 1.5px solid var(--cbd); padding-top: 10px; max-width: 90%; }
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.answer-row.placeholder { grid-template-columns: 1fr; }
.btn.answer { flex-direction: column; gap: 2px; min-height: 76px; font-size: 1.2rem; font-weight: 800; border-width: 2px; }
.btn.answer small { font-size: .78rem; font-weight: 600; opacity: .85; }
.btn.answer.wrong { background: var(--danger-soft); border-color: #e6817c; color: #8f231f; }
.btn.answer.right { background: var(--ok-soft); border-color: #7cbf73; color: #1f5a19; }
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes flip { from { transform: perspective(900px) rotateY(80deg); } to { transform: none; } }
.done h1 { font-size: 2rem; margin: 0; }
.done .btn { min-width: 220px; }

/* ---------- Elternbereich ---------- */
.who { display: flex; align-items: center; gap: 10px; }
.who > div { display: flex; flex-direction: column; line-height: 1.2; }
.tabs {
  display: flex; gap: 4px; padding: 4px; margin: 6px 0 12px;
  background: #ece7de; border-radius: 14px; overflow-x: auto;
}
.tab {
  flex: 1 1 auto; min-height: 40px; padding: 8px 6px; border: 0; border-radius: 10px;
  background: transparent; font: inherit; font-size: .9rem; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); font: inherit; font-weight: 650; cursor: pointer;
}
.chip.active { border-color: var(--primary); background: var(--primary-soft); color: #173f86; }
.deck-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; }
.deck-head h2 { margin: 0; flex: 1; }
.box-section { margin: 18px 0; }
.box-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-row {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 6px 0; padding: 12px 14px;
  background: var(--panel); border: 1.5px solid transparent; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.card-row:hover { border-color: var(--line); }
.swatch { width: 12px; height: 34px; border-radius: 6px; background: var(--cbd); flex: none; }
.card-texts { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.card-front, .card-back { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-front { font-weight: 650; }
.due { flex: none; }
.profile-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 4px; border: 0;
  border-bottom: 1px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.profile-row:last-child { border-bottom: 0; }
.profile-row .grow { display: flex; flex-direction: column; }
.preview-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; max-height: 420px; overflow: auto; }
.preview-item {
  display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-weight: 400; cursor: pointer;
}
.preview-item input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
.preview-item > span { display: flex; flex-direction: column; }
.preview-item.off { opacity: .55; }
.prompt-box { margin: 8px 0; }
.prompt-box summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.prompt-box pre {
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px; font-size: .82rem; max-height: 300px; overflow: auto;
}

/* Farb- und Bildauswahl */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-opt { margin: 0; position: relative; cursor: pointer; }
.swatch-opt input { position: absolute; opacity: 0; }
.swatch-opt span[aria-hidden] {
  display: block; width: 38px; height: 38px; border-radius: 50%;
  background: var(--cbg); border: 3px solid var(--cbd);
}
.swatch-opt input:checked + span { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.swatch-opt input:focus-visible + span { outline: 3px solid rgba(47, 111, 222, .45); outline-offset: 3px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.avatar-opt { margin: 0; cursor: pointer; }
.avatar-opt input { position: absolute; opacity: 0; }
.avatar-opt span { display: grid; place-items: center; height: 48px; font-size: 1.7rem; border-radius: 12px; border: 2px solid transparent; background: var(--panel-soft); }
.avatar-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.avatar-opt input:focus-visible + span { outline: 3px solid rgba(47, 111, 222, .45); }

/* ---------- FAQ ---------- */
details.faq { background: var(--panel); border-radius: var(--radius-sm); box-shadow: var(--shadow); margin: 8px 0; }
details.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 650; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: '›'; font-size: 1.4rem; line-height: 1; color: #b5ae9f; transition: transform .2s ease; }
details.faq[open] summary::after { transform: rotate(90deg); }
.faq-body { padding: 0 16px 14px; color: #3c3a34; line-height: 1.6; }

/* ---------- Dialog ---------- */
#modal[hidden] { display: none; }
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(29, 27, 22, .42);
  display: flex; align-items: flex-end; justify-content: center; padding: 12px;
  animation: fade .15s ease;
}
@media (min-width: 640px) { .backdrop { align-items: center; } }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100dvh - 24px); overflow: auto;
  background: var(--panel); border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 22px 20px max(20px, env(safe-area-inset-bottom));
  animation: rise .2s ease;
}
.modal.shake { animation: shake .35s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: .6; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- Meldungen & Laden ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 480px); padding: 12px 18px; border-radius: 14px;
  background: #22211d; color: #fff; font-weight: 600; box-shadow: var(--shadow-lg);
  transition: transform .2s ease, opacity .2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #8f231f; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid #e2dccf; border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Build-Wort unten auf jeder Seite */
.build { text-align: center; font-size: .75rem; color: #a39d90; margin: 18px 0 max(10px, env(safe-area-inset-bottom)); }
