:root {
  --magenta: #e20074;
  --magenta-dark: #b8005e;
  --pink: #ff5fa2;
  --rose-50: #fff6fa;
  --rose-100: #ffe8f2;
  --rose-200: #ffd0e4;
  --rose-300: #ffb0d0;
  --ink: #3b1830;
  --ink-soft: #7a5470;
  --card: #ffffff;
  --ok: #138a5a;
  --ok-bg: #e5f7ee;
  --bad: #c62848;
  --bad-bg: #fde8ec;
  --warn-bg: #fff4dc;
  --warn-border: #f0c25a;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(226, 0, 116, .10), 0 1px 3px rgba(59, 24, 48, .06);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--rose-200), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--rose-100), transparent 60%),
    var(--rose-50);
  -webkit-font-smoothing: antialiased;
}
/* Notch, Dynamic Island und Home-Indicator freihalten */
#app {
  max-width: 760px; margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(48px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}
button { font: inherit; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
/* 16px verhindert das automatische Hineinzoomen von iOS beim Tippen */
input, textarea { font: inherit; font-size: 16px; color: inherit; }
body.noscroll { overflow: hidden; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 24px;
  font-weight: 700; font-size: 1rem;
  background: linear-gradient(135deg, var(--magenta), var(--pink));
  color: #fff;
  box-shadow: 0 6px 16px rgba(226, 0, 116, .28);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--rose-100); color: var(--magenta-dark); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.muted { color: var(--ink-soft); }
.tiny { font-size: .82rem; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--magenta); display: flex; gap: 8px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--ink-soft); padding: 6px 8px; border-radius: 8px; }
.linkbtn { min-height: 44px; }
.linkbtn:active { background: var(--rose-100); color: var(--magenta-dark); }

.bar { height: 12px; background: var(--rose-100); border-radius: 999px; overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; transition: width .6s ease; }
.bar .m { background: linear-gradient(90deg, var(--magenta), var(--pink)); }
.bar .l { background: var(--rose-300); }

/* ---------- Login ---------- */
.login { max-width: 400px; margin: 10vh auto 0; text-align: center; }
.login .logo { font-size: 3rem; margin-bottom: 4px; }
.login form { display: grid; gap: 12px; margin-top: 16px; text-align: left; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.field input {
  border: 2px solid var(--rose-200); border-radius: 12px; padding: 12px 14px; background: #fff;
}
.field input:focus { border-color: var(--pink); outline: none; }
.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }

/* ---------- Dashboard ---------- */
.hero { background: linear-gradient(135deg, var(--magenta), var(--pink)); color: #fff; }
.hero .muted { color: rgba(255, 255, 255, .85); }
.hero .points { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.hero .points small { font-size: 1rem; font-weight: 600; opacity: .85; }
.hero .bar { background: rgba(255, 255, 255, .3); margin: 14px 0 12px; }
.hero .bar .m { background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: rgba(255, 255, 255, .2); border-radius: 999px; padding: 6px 12px; font-size: .88rem; font-weight: 600; }

.surprise {
  position: relative; overflow: hidden;
  display: flex; gap: 16px; align-items: center;
  border: 2px dashed var(--rose-300);
}
.surprise .gift { font-size: 2.6rem; animation: wiggle 3s ease-in-out infinite; }
.surprise.unlocked { border: 2px solid var(--magenta); background: linear-gradient(135deg, #fff, var(--rose-100)); }
.surprise::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .7) 50%, transparent 70%);
  transform: translateX(-100%); animation: shimmer 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } 95% { transform: rotate(-6deg); } }

.modules { display: grid; gap: 10px; margin: 12px 0 16px; }
.module {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
  border: 2px solid var(--rose-200); border-radius: 14px; padding: 12px 14px; background: #fff; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.module:has(input:checked) { border-color: var(--magenta); background: var(--rose-50); }
.module input { width: 22px; height: 22px; accent-color: var(--magenta); }
.module .name { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.module .bar { height: 8px; margin-top: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.seg { display: flex; background: var(--rose-100); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 10px 6px; font-weight: 700; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--magenta); box-shadow: 0 2px 8px rgba(226, 0, 116, .15); }

details.how summary { cursor: pointer; font-weight: 700; color: var(--magenta-dark); }
details.how ul { padding-left: 20px; margin: 10px 0 0; line-height: 1.55; }

/* ---------- Quiz ---------- */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tag { background: var(--rose-100); color: var(--magenta-dark); font-weight: 700; font-size: .8rem; padding: 5px 10px; border-radius: 999px; }
.hearts { letter-spacing: 2px; font-size: 1rem; }
.qtext { font-size: 1.2rem; font-weight: 700; line-height: 1.4; margin: 6px 0 4px; }
.hint { font-size: .85rem; color: var(--ink-soft); margin-bottom: 14px; }
.options { display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center;
  text-align: left; width: 100%;
  border: 2px solid var(--rose-200); background: #fff; color: var(--ink);
  border-radius: 14px; padding: 13px 14px; line-height: 1.4;
  transition: border-color .12s, background .12s, transform .08s;
}
.opt:active:not(:disabled) { transform: scale(.99); }
.opt .box {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--rose-300);
  display: grid; place-items: center; font-size: .85rem; font-weight: 800; color: var(--ink-soft);
}
.opt[aria-pressed="true"] { border-color: var(--magenta); background: var(--rose-50); }
.opt[aria-pressed="true"] .box { background: var(--magenta); border-color: var(--magenta); color: #fff; }
.opt:disabled { cursor: default; }
.opt .verdict { font-size: .78rem; font-weight: 700; white-space: nowrap; }
.opt.ok { border-color: var(--ok); background: var(--ok-bg); }
.opt.ok .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.missed { border-color: var(--ok); border-style: dashed; }
.opt.missed .verdict { color: var(--ok); }
.opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.opt.bad .box { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.bad .verdict { color: var(--bad); }
.opt.neutral { opacity: .6; }
.actions { margin-top: 16px; display: flex; gap: 10px; }
.actions .btn { flex: 1; }

.result { border-radius: 14px; padding: 14px 16px; margin: 16px 0 12px; font-weight: 700; display: flex; gap: 10px; align-items: flex-start; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.bad { background: var(--bad-bg); color: var(--bad); }
.result .sub { font-weight: 500; color: var(--ink); font-size: .9rem; margin-top: 2px; }
.explain { background: var(--rose-50); border-left: 4px solid var(--pink); border-radius: 10px; padding: 12px 14px; line-height: 1.5; }
.callout { background: var(--warn-bg); border-left: 4px solid var(--warn-border); border-radius: 10px; padding: 12px 14px; margin-top: 10px; line-height: 1.5; font-size: .93rem; }

/* ---------- KI-Coach ---------- */
.coach { margin-top: 16px; border-top: 2px dashed var(--rose-200); padding-top: 14px; }
.coach h3 { font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.suggest button { border: 1.5px solid var(--rose-300); background: #fff; color: var(--magenta-dark); border-radius: 999px; padding: 7px 12px; font-size: .85rem; font-weight: 600; }
.suggest button:active { background: var(--rose-100); }
.msgs { display: grid; gap: 10px; margin-bottom: 10px; }
.msg { border-radius: 14px; padding: 10px 14px; line-height: 1.55; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { background: var(--magenta); color: #fff; justify-self: end; max-width: 85%; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.ai { background: var(--rose-50); border: 1.5px solid var(--rose-200); border-bottom-left-radius: 4px; }
.msg.ai.err { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.msg.ai > :first-child { margin-top: 0; }
.msg.ai > :last-child { margin-bottom: 0; }
.msg.ai p { margin: 0 0 .6em; }
.msg.ai ul, .msg.ai ol { margin: .3em 0 .6em; padding-left: 1.3em; }
.msg.ai li { margin: .2em 0; }
.msg.ai h1, .msg.ai h2, .msg.ai h3, .msg.ai h4 { font-size: 1rem; margin: .8em 0 .3em; color: var(--magenta-dark); }
.msg.ai strong { color: var(--magenta-dark); }
.msg.ai blockquote { margin: .5em 0; padding: 4px 12px; border-left: 3px solid var(--pink); color: var(--ink-soft); }
.msg.ai code { background: var(--rose-100); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.msg.ai pre { background: var(--rose-100); padding: 10px; border-radius: 8px; overflow-x: auto; }
.msg.ai table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: .5em 0; display: block; overflow-x: auto; }
.msg.ai th, .msg.ai td { border: 1px solid var(--rose-200); padding: 6px 8px; text-align: left; }
.msg.ai th { background: var(--rose-100); }
.msg.ai hr { border: 0; border-top: 1px solid var(--rose-200); }
.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--magenta); }
@keyframes blink { 50% { opacity: 0; } }
.askform { display: flex; gap: 8px; align-items: flex-end; }
.askform textarea {
  flex: 1; resize: none; border: 2px solid var(--rose-200); border-radius: 14px; padding: 11px 14px; min-height: 46px; max-height: 140px; background: #fff;
}
.askform textarea:focus { border-color: var(--pink); outline: none; }
.askform .btn { padding: 12px 16px; }

/* ---------- Zusammenfassung & Overlays ---------- */
.big-emoji { font-size: 3rem; text-align: center; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.summary-grid div { background: var(--rose-50); border-radius: 14px; padding: 12px; text-align: center; }
.summary-grid b { display: block; font-size: 1.5rem; color: var(--magenta); }
.overlay {
  position: fixed; inset: 0; background: rgba(59, 24, 48, .55); z-index: 20;
  display: grid; place-items: center; padding: 16px;
}
.overlay .card { width: min(720px, 100%); max-height: 92vh; overflow: auto; margin: 0; }
.overlay iframe { width: 100%; height: 70vh; border: 0; border-radius: 12px; background: #fff; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; width: 100vw; height: 100vh; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 40; font-weight: 600;
  max-width: calc(100vw - 32px);
}

@media (max-width: 480px) {
  .card { padding: 16px; }
  .qtext { font-size: 1.08rem; }
  .hero .points { font-size: 2.2rem; }
  .summary-grid { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Onboarding ---------- */
.onboard { position: relative; max-width: 440px; text-align: center; padding: 28px 22px 20px; }
.onboard .skip { position: absolute; top: 10px; right: 10px; font-size: .85rem; }
.ob-step { animation: slidein .35s ease; min-height: 250px; }
.ob-icon {
  width: 96px; height: 96px; margin: 8px auto 14px; border-radius: 50%;
  display: grid; place-items: center; font-size: 3rem;
  background: linear-gradient(135deg, var(--rose-100), var(--rose-200));
}
.ob-icon.gift { background: linear-gradient(135deg, var(--magenta), var(--pink)); animation: wiggle 2s ease-in-out infinite; }
.ob-step h2 { font-size: 1.35rem; color: var(--magenta-dark); }
.ob-step p { line-height: 1.6; margin: 0; }
.dots { display: flex; justify-content: center; gap: 8px; margin: 18px 0 4px; }
.dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 999px; background: var(--rose-200); transition: width .25s, background .25s; }
.dots button.on { width: 26px; background: var(--magenta); }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

[hidden] { display: none !important; }
.toplinks { display: flex; flex-wrap: nowrap; white-space: nowrap; }
.brand { min-width: 0; }

@media (hover: hover) {
  .btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(226, 0, 116, .34); }
  .linkbtn:hover { background: var(--rose-100); color: var(--magenta-dark); }
  .opt:hover:not(:disabled) { border-color: var(--rose-300); background: var(--rose-50); }
  .suggest button:hover { background: var(--rose-100); }
}

/* Prüfen/Weiter klebt unten – gut mit dem Daumen erreichbar */
.actions.sticky {
  position: sticky; bottom: 0; z-index: 5;
  margin: 16px -20px -20px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 28%);
  border-radius: 0 0 var(--radius) var(--radius);
}
body.typing .actions.sticky { position: static; } /* Tastatur offen: nichts überdecken */

/* Overlays: dynamische Höhe (Safari-Leisten) und Safe Areas */
.overlay {
  height: 100dvh; overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.overlay .card { max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.overlay iframe { height: 70dvh; }
.toast { bottom: calc(24px + env(safe-area-inset-bottom)); }

/* iPad */
@media (min-width: 700px) {
  #app { max-width: 820px; padding-left: max(32px, env(safe-area-inset-left)); padding-right: max(32px, env(safe-area-inset-right)); }
  .card { padding: 28px; }
  .actions.sticky { margin: 20px -28px -28px; padding-left: 28px; padding-right: 28px; }
  h1 { font-size: 1.9rem; }
  .qtext { font-size: 1.4rem; }
  .opt { padding: 16px 18px; font-size: 1.08rem; }
  .modules { grid-template-columns: 1fr 1fr 1fr; }
  .module { grid-template-columns: 1fr; align-content: start; }
  .module input { justify-self: start; }
  .onboard { max-width: 520px; padding: 36px 32px 28px; }
  .ob-step p { font-size: 1.08rem; }
}

.install { display: flex; gap: 12px; align-items: flex-start; padding: 14px 12px 14px 16px; border: 2px solid var(--rose-200); }
.install-icon { font-size: 1.6rem; }
.install > div { flex: 1; line-height: 1.45; }

/* ---------- Rangliste ---------- */
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ranks li {
  display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 14px; background: var(--rose-50);
}
.ranks li.me { background: var(--rose-100); outline: 2px solid var(--magenta); }
.ranks .rank { font-size: 1.3rem; font-weight: 800; text-align: center; color: var(--ink-soft); }
.ranks .row1 { display: flex; justify-content: space-between; gap: 8px; }
.ranks .pts { font-weight: 800; color: var(--magenta); }
.ranks .bar { height: 6px; margin: 6px 0 4px; background: #fff; }

/* ---------- Neu-Hinweis ---------- */
.news { display: flex; gap: 12px; align-items: flex-start; padding: 14px 12px 14px 16px; border: 2px solid var(--magenta); background: linear-gradient(135deg, #fff, var(--rose-50)); }
.news > div { flex: 1; line-height: 1.5; }

/* ---------- Rollenspiel ---------- */
.roleplay-card { display: flex; gap: 16px; align-items: flex-start; }
.rp-emoji { font-size: 2.4rem; }
.rp-group { font-size: .95rem; color: var(--magenta-dark); margin: 18px 4px 8px; }
.rp-list { display: grid; gap: 10px; }
.rp-item {
  display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; text-align: left;
  width: 100%; padding: 14px; border-radius: 16px; border: 2px solid var(--rose-200); background: #fff; color: var(--ink);
  box-shadow: var(--shadow);
}
.rp-item:active { transform: scale(.99); background: var(--rose-50); }
.rp-icon { font-size: 1.8rem; text-align: center; }
.rp-sit { display: block; margin-top: 4px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rp-facts { display: grid; gap: 10px; margin: 12px 0; }
.rp-facts > div { background: var(--rose-50); border-radius: 12px; padding: 10px 14px; }
.rp-facts b { color: var(--magenta-dark); font-size: .85rem; }
.rp-facts p { margin: 4px 0 0; line-height: 1.5; }
.rp-msgs { margin-bottom: 12px; }
.msg.char { background: #fff; border: 1.5px solid var(--rose-300); border-bottom-left-radius: 4px; max-width: 88%; }
.msg.char .who { display: block; font-size: .75rem; font-weight: 800; color: var(--magenta); margin-bottom: 2px; }
.msg.char .act { color: var(--ink-soft); }
.msg.char.err { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.rp-transcript { margin-top: 14px; }
.rp-transcript summary { cursor: pointer; font-weight: 700; color: var(--magenta-dark); padding: 8px 0; }
@media (hover: hover) { .rp-item:hover { border-color: var(--rose-300); background: var(--rose-50); } }
@media (min-width: 700px) { .rp-list { grid-template-columns: 1fr 1fr; } }
