/* ============================================================
   Mathetrainer 5A – Stylesheet
   ============================================================ */

:root {
  --bg: #f5f6fb;
  --bg-grad:
    radial-gradient(1100px 520px at 8% -12%, #e3e8ff 0%, transparent 58%),
    radial-gradient(900px 480px at 102% -6%, #fde8f3 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 115%, #e6fbf5 0%, transparent 60%);
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef0f7;
  --topbar: rgba(255, 255, 255, 0.82);
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #8a94a6;
  --line: #e4e7ee;
  --line-strong: #cfd5e1;
  --accent: #5146e5;
  --accent-2: #8b3df0;
  --accent-ink: #3b32c9;
  --accent-soft: #eef0ff;
  --ok: #067a5b;
  --ok-soft: #e9fbf3;
  --ok-line: #9be3c9;
  --bad: #c92a2a;
  --bad-soft: #fef1f1;
  --bad-line: #f5b5b5;
  --warn: #a15c07;
  --warn-soft: #fff8e6;
  --warn-line: #f2d38b;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 2px 6px rgba(16, 24, 40, 0.05), 0 18px 40px -24px rgba(16, 24, 40, 0.28);
  --shadow-lg: 0 30px 70px -40px rgba(16, 24, 40, 0.45);
  --radius: 18px;
  --radius-lg: 24px;
}

html[data-theme="dark"] {
  --bg: #0a0f1e;
  --bg-grad:
    radial-gradient(1100px 520px at 6% -10%, #1c2350 0%, transparent 60%),
    radial-gradient(900px 480px at 100% -8%, #3a1636 0%, transparent 55%),
    radial-gradient(900px 600px at 50% 115%, #0d2f2b 0%, transparent 62%);
  --surface: #121829;
  --surface-2: #0e1424;
  --surface-3: #1a2238;
  --topbar: rgba(10, 15, 30, 0.82);
  --ink: #e8ebf5;
  --ink-2: #a5aec4;
  --ink-3: #6f7a94;
  --line: #222c46;
  --line-strong: #34405e;
  --accent: #8f8bff;
  --accent-2: #c084fc;
  --accent-ink: #b9b6ff;
  --accent-soft: #1c2146;
  --ok: #3ddc9a;
  --ok-soft: #0f2c25;
  --ok-line: #1f6b52;
  --bad: #ff8080;
  --bad-soft: #33161a;
  --bad-line: #7d3134;
  --warn: #f2c063;
  --warn-soft: #2b2413;
  --warn-line: #6b5424;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.25), 0 18px 40px -24px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 70px -40px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.22; letter-spacing: -0.015em; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 3.2vw, 2.15rem); }
h2 { font-size: clamp(1.25rem, 2.1vw, 1.5rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent-ink); }
b, strong { font-weight: 700; }
button { font-family: inherit; }
::selection { background: var(--accent); color: #fff; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 22px 90px;
  outline: none;
}
.muted { color: var(--ink-2); }
.small { font-size: .84rem; }
.tiny { font-size: .76rem; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.noscript { padding: 20px; }

/* ------------------------------- Topbar ------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 11px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  border-radius: 12px;
  padding: 2px;
}
.brand-logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 8px 18px -8px var(--accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-text small { color: var(--ink-3); font-size: .72rem; letter-spacing: .02em; }

.nav { display: flex; gap: 2px; margin-left: auto; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.nav-btn {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 7px 14px; border-radius: 9px; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover { color: var(--ink); background: var(--surface-3); }
.nav-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.streak-chip {
  font-size: .82rem; font-weight: 600; color: var(--warn);
  background: var(--warn-soft); border: 1px solid var(--warn-line);
  padding: 4px 10px; border-radius: 99px;
}
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 10px; cursor: pointer; font-size: 1rem;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }

/* ------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 10px 17px; font-size: .93rem; font-weight: 600;
  cursor: pointer; text-decoration: none; color: var(--ink);
  background: var(--surface-2);
  transition: transform .14s ease, box-shadow .14s ease, background .14s, border-color .14s, opacity .14s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 22px -12px var(--accent);
}
.btn-primary:hover { box-shadow: 0 14px 28px -12px var(--accent); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok); color: #fff; }
.btn.big { padding: 13px 22px; font-size: 1rem; border-radius: 14px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ------------------------------- Cards ------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.pad { padding: 24px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 34px 0 14px; }
.section-head h2 { margin: 0; }
.section-head .muted { font-size: .86rem; }

/* ------------------------------- Hero ------------------------------- */
.hero { display: grid; grid-template-columns: 1.4fr .85fr; gap: 18px; margin-bottom: 10px; }
.hero-main {
  position: relative; overflow: hidden;
  padding: 34px 34px 30px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero-main::before {
  content: ""; position: absolute; inset: auto -80px -140px auto;
  width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 68%);
  pointer-events: none;
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 5px 11px; border-radius: 99px; margin-bottom: 14px;
}
.hero-main h1 { margin-bottom: 10px; max-width: 22ch; }
.hero-main p.lead { color: var(--ink-2); font-size: 1.02rem; max-width: 46ch; margin-bottom: 22px; }
.hero-main .btn-row { position: relative; z-index: 1; }

.hero-side { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; }
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { width: 92px; height: 92px; flex: 0 0 92px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: url(#ringGrad); transition: stroke-dashoffset .7s ease; }
.ring-center { position: relative; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.02rem; }
.ring-wrap .meta strong { display: block; font-size: .95rem; }
.ring-wrap .meta span { color: var(--ink-2); font-size: .82rem; }

.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; }
.mini-stat b { display: block; font-size: 1.15rem; line-height: 1.2; }
.mini-stat span { font-size: .75rem; color: var(--ink-3); }

/* ------------------------------- Themen ------------------------------- */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.topic-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.topic-top { display: flex; align-items: center; gap: 11px; }
.topic-top > span:last-child { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.topic-icon {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: hsl(var(--hue, 250) 85% 95%);
  color: hsl(var(--hue, 250) 60% 38%);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem; font-weight: 700;
}
html[data-theme="dark"] .topic-icon {
  background: hsl(var(--hue, 250) 55% 18%);
  color: hsl(var(--hue, 250) 80% 76%);
}
.topic-name { display: block; font-weight: 700; font-size: .98rem; line-height: 1.25; }
.topic-comp { display: block; font-size: .7rem; color: var(--ink-3); letter-spacing: .04em; }
.topic-desc { display: block; font-size: .82rem; color: var(--ink-2); min-height: 2.5em; }
.topic-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.topic-foot .bar { flex: 1; }
.topic-count { font-size: .75rem; color: var(--ink-3); white-space: nowrap; }

/* ------------------------------- Bars ------------------------------- */
.bar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s ease; }
.bar.ok > i { background: linear-gradient(90deg, var(--ok), #38c9a0); }

/* ------------------------------- Schnellstart ------------------------------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.quick-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 17px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); cursor: pointer; text-align: left;
  color: inherit; font: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.quick-icon { font-size: 1.35rem; line-height: 1.2; }
.quick-card b { display: block; font-size: .94rem; }
.quick-card span { font-size: .8rem; color: var(--ink-2); }

/* ------------------------------- Task ------------------------------- */
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.dots i.on { background: var(--accent); }

.task-card { padding: 26px 28px; }
.prompt { font-size: 1.12rem; line-height: 1.62; margin: 16px 0 18px; }
.prompt .sub { display: block; margin-top: 6px; font-size: .88rem; color: var(--ink-2); font-weight: 400; }
.prompt code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

.hint-box {
  margin: 0 0 16px; padding: 11px 15px;
  background: var(--warn-soft); border: 1px solid var(--warn-line);
  border-radius: 12px; color: var(--ink-2); font-size: .88rem;
}
.hint-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--ink-3);
  font-size: .82rem; cursor: pointer; padding: 0 0 10px;
}
.hint-toggle:hover { color: var(--ink); }

/* Optionen */
.options { display: grid; gap: 9px; }
.options.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option {
  display: flex; gap: 12px; align-items: flex-start;
  width: 100%; padding: 13px 15px;
  border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--surface); color: inherit; font: inherit; text-align: left;
  cursor: pointer; transition: border-color .14s, background .14s, box-shadow .14s;
}
.option:hover:not(:disabled):not(.locked) { border-color: var(--accent); background: var(--accent-soft); }
.option.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option .key {
  flex: 0 0 25px; width: 25px; height: 25px;
  display: grid; place-items: center;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: .76rem; font-weight: 700; color: var(--ink-2);
}
.option.is-selected .key { background: var(--accent); border-color: var(--accent); color: #fff; }
.option .txt { flex: 1; padding-top: 1px; }
.option:disabled, .option.locked { cursor: default; }
.option.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.option.is-correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.is-wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.option-flag { font-size: .8rem; font-weight: 700; }

/* Zuordnung */
.match-list { display: grid; gap: 9px; }
.match-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 1fr);
  gap: 12px; align-items: center;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2);
}
.match-left { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.match-left .key {
  flex: 0 0 24px; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 7px; background: var(--surface); border: 1px solid var(--line);
  font-size: .74rem; color: var(--ink-3); font-weight: 700;
}
.match-row select {
  width: 100%; padding: 8px 10px; border-radius: 9px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.match-row select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.match-row.ok { border-color: var(--ok-line); background: var(--ok-soft); }
.match-row.bad { border-color: var(--bad-line); background: var(--bad-soft); }
.match-row .solution-note { grid-column: 1 / -1; font-size: .8rem; color: var(--ok); font-weight: 600; }

/* Lückentext */
.cloze { line-height: 2.15; font-size: 1.05rem; }
.blank-input, .open-input {
  padding: 5px 9px; border-radius: 9px;
  border: 1.5px solid var(--line-strong); border-bottom: 2px solid var(--accent);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  text-align: center;
}
.blank-input { min-width: 4.5ch; width: var(--w, 8ch); }
.blank-input:focus, .open-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.blank-input.ok, .open-input.ok { border-color: var(--ok); background: var(--ok-soft); }
.blank-input.bad, .open-input.bad { border-color: var(--bad); background: var(--bad-soft); }
.blank-input:disabled, .open-input:disabled { opacity: 1; }
.blank-sel { padding: 5px 8px; border-radius: 9px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: .92rem; }
.blank-sel.ok { border-color: var(--ok); background: var(--ok-soft); }
.blank-sel.bad { border-color: var(--bad); background: var(--bad-soft); }

/* Offene Antwort */
.open-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 6px; }
.open-input {
  font-size: 1.15rem; padding: 11px 15px; min-width: 220px; max-width: 100%;
  text-align: left; border-radius: 12px;
}
.unit { font-weight: 700; color: var(--ink-2); }

/* Halboffen (Felder) */
.step-list { display: grid; gap: 11px; }
.step-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2);
}
.step-row .lbl { font-size: .93rem; }
.step-row .lbl b { display: block; font-size: .74rem; color: var(--ink-3); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.step-row.ok { border-color: var(--ok-line); background: var(--ok-soft); }
.step-row.bad { border-color: var(--bad-line); background: var(--bad-soft); }
.step-row.ok .open-input { border-color: var(--ok); background: var(--ok-soft); }
.step-row.bad .open-input { border-color: var(--bad); background: var(--bad-soft); }
.step-row .open-input { min-width: 120px; font-size: 1rem; padding: 8px 12px; }

/* ------------------------------- Feedback ------------------------------- */
.feedback {
  margin-top: 20px; padding: 16px 18px; border-radius: 15px;
  border: 1px solid var(--line); background: var(--surface-2);
  animation: pop .22s ease both;
}
.feedback.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.feedback.partial { background: var(--warn-soft); border-color: var(--warn-line); }
.feedback.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.feedback-head { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 6px; }
.feedback.ok .feedback-head { color: var(--ok); }
.feedback.partial .feedback-head { color: var(--warn); }
.feedback.bad .feedback-head { color: var(--bad); }
.feedback-icon { font-size: 1.15rem; }
.feedback .solution { color: var(--ink-2); font-size: .93rem; }
.feedback .solution b { color: var(--ink); }

/* ------------------------------- Practice chrome ------------------------------- */
.practice-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.practice-bar .bar { flex: 1; min-width: 120px; }
.counter { font-size: .82rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.scorechip { font-size: .82rem; font-weight: 700; color: var(--ok); }
.filter-select {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .86rem;
}
.task-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; align-items: center; }
.kbd-hint { font-size: .74rem; color: var(--ink-3); margin-left: auto; }
kbd {
  font-family: inherit; font-size: .72rem; padding: 1px 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2); color: var(--ink-2);
}

/* ------------------------------- Summary ------------------------------- */
.summary-card { text-align: center; padding: 40px 30px; }
.summary-emoji { font-size: 3rem; line-height: 1; margin-bottom: 10px; }
.summary-score { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; }
.summary-card .btn-row { justify-content: center; margin-top: 22px; }

/* ------------------------------- Merkblatt ------------------------------- */
.theory-intro { padding: 24px 26px; margin-bottom: 18px; }
.theory-grid { display: grid; gap: 12px; }
.theory-card { overflow: hidden; }
.theory-card > summary {
  list-style: none; cursor: pointer; padding: 17px 22px;
  display: flex; align-items: center; gap: 12px; font-weight: 700;
}
.theory-card > summary::-webkit-details-marker { display: none; }
.theory-card > summary:hover { background: var(--surface-2); }
.theory-card > summary .chev { margin-left: auto; color: var(--ink-3); transition: transform .2s; }
.theory-card[open] > summary .chev { transform: rotate(90deg); }
.theory-card .body { padding: 0 22px 22px; }
.theory-card h4 { margin: 16px 0 6px; font-size: .92rem; color: var(--accent-ink); letter-spacing: .01em; }
.theory-card ul { margin: 0 0 4px; padding-left: 20px; }
.theory-card li { margin-bottom: 5px; color: var(--ink-2); font-size: .92rem; }
.theory-card li b { color: var(--ink); }
.formula-box {
  background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 15px; margin: 10px 0;
  font-size: .95rem;
}
.formula-box div { margin: 3px 0; }

/* Zahlenmengen-Diagramm */
.venn { display: grid; place-items: center; padding: 18px 8px 8px; }
.venn-r {
  position: relative; border: 2px solid hsl(258 60% 62%); border-radius: 22px;
  padding: 34px 26px 24px; min-width: min(100%, 520px);
  background: hsl(258 80% 97%);
}
.venn-q { position: relative;
  border: 2px solid hsl(205 65% 58%); border-radius: 16px; padding: 30px 22px 20px;
  background: hsl(205 80% 96%);
}
.venn-z { position: relative;
  border: 2px solid hsl(160 55% 45%); border-radius: 12px; padding: 26px 18px 16px;
  background: hsl(160 60% 95%);
}
.venn-n { position: relative;
  border: 2px solid hsl(28 75% 55%); border-radius: 9px; padding: 20px 14px 12px;
  background: hsl(28 90% 95%); text-align: center;
}
html[data-theme="dark"] .venn-r { background: hsl(258 40% 14%); }
html[data-theme="dark"] .venn-q { background: hsl(205 45% 14%); }
html[data-theme="dark"] .venn-z { background: hsl(160 35% 12%); }
html[data-theme="dark"] .venn-n { background: hsl(28 40% 13%); }
.venn-label {
  position: absolute; top: 6px; left: 12px;
  font-weight: 800; font-size: .84rem; line-height: 1.55;
  background: var(--surface); border: 1px solid currentColor;
  border-radius: 7px; padding: 0 7px;
}
.venn-r > .venn-label { color: hsl(258 60% 52%); }
.venn-q > .venn-label { color: hsl(205 65% 45%); }
.venn-z > .venn-label { color: hsl(160 55% 35%); }
.venn-n > .venn-label { color: hsl(28 75% 42%); }
html[data-theme="dark"] .venn-r > .venn-label { color: hsl(258 80% 76%); }
html[data-theme="dark"] .venn-q > .venn-label { color: hsl(205 80% 72%); }
html[data-theme="dark"] .venn-z > .venn-label { color: hsl(160 60% 62%); }
html[data-theme="dark"] .venn-n > .venn-label { color: hsl(28 85% 66%); }
.venn-note { font-size: .8rem; color: var(--ink-3); text-align: center; margin-top: 10px; }

/* ------------------------------- Prüfung ------------------------------- */
.exam-bar .bar { flex: 1; min-width: 90px; }
.exam-bar {
  position: sticky; top: 61px; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px 16px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; }
.timer.warn { color: var(--bad); }
.palette { display: flex; flex-wrap: wrap; gap: 5px; }
.pal-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); font-size: .78rem; font-weight: 700;
  cursor: pointer; transition: .12s;
}
.pal-btn:hover { border-color: var(--accent); }
.pal-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pal-btn.done { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.pal-btn.current.done { background: var(--accent); color: #fff; }
.exam-intro { padding: 32px; }
.exam-rules { display: grid; gap: 10px; margin: 18px 0 24px; }
.exam-rule { display: flex; gap: 12px; align-items: flex-start; font-size: .93rem; color: var(--ink-2); }
.exam-rule .ico { flex: 0 0 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); }

.result-hero { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; padding: 30px; }
.result-score {
  width: 132px; height: 132px; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background: var(--surface-2); border: 8px solid var(--surface-3);
  position: relative;
}
.result-score strong { display: block; font-size: 1.7rem; line-height: 1; }
.result-score span { font-size: .72rem; color: var(--ink-3); }
.result-score.pass { border-color: var(--ok); background: var(--ok-soft); }
.result-score.fail { border-color: var(--bad); background: var(--bad-soft); }
.review-list { display: grid; gap: 10px; margin-top: 18px; }
.review-item { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.review-item > summary { list-style: none; cursor: pointer; padding: 13px 16px; display: flex; align-items: center; gap: 12px; }
.review-item > summary::-webkit-details-marker { display: none; }
.review-item > summary:hover { background: var(--surface-2); }
.review-item .idx { flex: 0 0 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font-size: .76rem; font-weight: 700; color: var(--ink-3); }
.review-item .q { flex: 1; min-width: 0; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-item .body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.review-item .line { font-size: .88rem; margin-top: 10px; }
.review-item .line b.lb { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; display: block; }
.review-item .given { color: var(--bad); }
.review-item .right { color: var(--ok); }

/* ------------------------------- Dialog / Import ------------------------------- */
dialog {
  border: none; padding: 0; border-radius: 20px;
  width: min(700px, 93vw); max-height: 90vh;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog::backdrop { background: rgba(10, 16, 32, .45); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 1.12rem; }
.dialog-head .icon-btn { margin-left: auto; }
.dialog-body { padding: 18px 22px; overflow: auto; max-height: calc(90vh - 140px); }
.dialog-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.dialog-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.field-label { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-2); margin: 6px 0 6px; letter-spacing: .02em; }
.import-text {
  width: 100%; min-height: 170px; resize: vertical;
  padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  font-family: "Cascadia Code", Consolas, "Courier New", monospace; font-size: .82rem; line-height: 1.5;
}
.import-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.import-msg { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: .86rem; }
.import-msg.ok { background: var(--ok-soft); border: 1px solid var(--ok-line); color: var(--ok); }
.import-msg.bad { background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad); }
.schema { margin-top: 14px; font-size: .86rem; }
.schema summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.schema pre {
  margin: 10px 0 0; padding: 14px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: .74rem; line-height: 1.55; color: var(--ink-2);
}

/* ------------------------------- Toast ------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--surface);
  padding: 10px 18px; border-radius: 99px; font-size: .86rem; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 80;
  max-width: min(90vw, 520px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------- Footer ------------------------------- */
.foot { margin-top: 46px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: .78rem; color: var(--ink-3); }
.foot button { border: 0; background: transparent; color: var(--ink-3); font-size: .78rem; cursor: pointer; text-decoration: underline; padding: 0; }
.foot button:hover { color: var(--bad); }

/* ------------------------------- Mathe-Typografie ------------------------------- */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; margin: 0 .14em; font-size: .92em; }
.frac .num { border-bottom: 1.4px solid currentColor; padding: 0 .2em; }
.frac .den { padding: 0 .2em; }
.sqrtwrap { white-space: nowrap; }
.sqrt { border-top: 1.3px solid currentColor; padding: 0 .14em 0 .04em; margin-left: -.04em; }
sup { font-size: .72em; line-height: 0; }
.math { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; }

/* ------------------------------- Gamification ------------------------------- */
.level-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 99px; padding: 3px 10px 3px 3px;
  cursor: pointer; font: inherit; color: var(--ink);
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.level-chip:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.level-chip[hidden] { display: none; }
.level-chip .lv {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-radius: 99px; padding: 2px 9px;
  font-size: .72rem; font-weight: 800; letter-spacing: .02em;
}
.level-chip .xp { font-size: .72rem; font-weight: 700; color: var(--ink-2); }

.level-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.level-block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.level-block-head strong { font-size: .9rem; }
.level-block-head .muted { margin-left: auto; font-size: .76rem; }
.level-block .bar { margin-bottom: 6px; }

.stage-pill {
  flex: 0 0 auto;
  font-size: .66rem; font-weight: 800; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2); white-space: nowrap;
}

.xp-gain {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 5px 12px; border-radius: 99px;
  background: var(--ok-soft); border: 1px solid var(--ok-line);
  color: var(--ok); font-weight: 800; font-size: .86rem;
  animation: pop .25s ease both;
}
.levelup-banner {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; padding: 12px 16px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--warn-soft));
  border: 1px solid var(--warn-line);
  font-weight: 700; font-size: .92rem;
  animation: pop .3s ease both;
}
.levelup-banner .big { font-size: 1.3rem; }

/* Erfolge-Seite */
.ach-hero {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 26px; align-items: center;
  padding: 30px; margin-bottom: 16px;
}
.level-badge {
  width: 108px; height: 108px; flex: 0 0 108px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 18px 34px -20px var(--accent);
}
.level-badge span { font-size: .64rem; letter-spacing: .22em; opacity: .8; font-weight: 700; }
.level-badge strong { font-size: 2.3rem; line-height: 1.05; }
.level-main h1 { margin: 2px 0 4px; }
.level-main .bar { margin-top: 12px; }
.level-facts { display: flex; gap: 18px; }
.level-facts div { text-align: center; }
.level-facts b { display: block; font-size: 1.25rem; line-height: 1.2; }
.level-facts span { font-size: .7rem; color: var(--ink-3); }

.player-card { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.player-card .field { flex: 1; min-width: 200px; }
.player-input {
  width: 100%; padding: 10px 13px; border-radius: 10px;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1rem;
}
.player-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.stage-card {
  display: flex; flex-direction: column; gap: 9px;
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.stage-head { display: flex; align-items: center; gap: 10px; }
.stage-head .topic-icon { width: 36px; height: 36px; flex-basis: 36px; font-size: 1rem; border-radius: 11px; }
.stage-head b { display: block; font-size: .9rem; line-height: 1.2; }
.stage-head .small { font-size: .72rem; color: var(--ink-3); }
.stage-badge {
  margin-left: auto; font-size: .68rem; font-weight: 800;
  padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap;
}
.stage-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.stage-steps i { height: 7px; border-radius: 99px; background: var(--surface-3); }
.stage-steps i.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.stage-next { font-size: .74rem; color: var(--ink-3); }

.board-shell { overflow: hidden; }
.board-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 12px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.board-tab {
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  padding: 7px 13px; border-radius: 9px; font: inherit; font-size: .86rem;
  font-weight: 600; cursor: pointer;
}
.board-tab:hover { color: var(--ink); }
.board-tab.active { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.board-table { display: flex; flex-direction: column; }
.board-row {
  display: grid;
  grid-template-columns: 44px minmax(110px, 1.4fr) 116px 62px 70px 50px 90px;
  gap: 10px; align-items: center;
  padding: 11px 18px; border-bottom: 1px solid var(--line);
  font-size: .86rem;
}
.board-row.head {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); background: var(--surface-2); font-weight: 700;
}
.board-row:last-child { border-bottom: 0; }
.board-row.me { background: var(--accent-soft); }
.board-rank { font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.board-rank .medal { font-size: 1.05rem; }
.board-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-points { font-weight: 700; font-variant-numeric: tabular-nums; }
.board-time, .board-lvl, .board-date { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .79rem; }
.board-empty { padding: 34px 20px; text-align: center; color: var(--ink-3); font-size: .9rem; }
.board-source { padding: 11px 18px; font-size: .73rem; color: var(--ink-3); border-top: 1px solid var(--line); background: var(--surface-2); }

.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.rules-grid div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rules-grid b { display: block; font-size: 1.02rem; color: var(--accent-ink); }
.rules-grid span { font-size: .77rem; color: var(--ink-2); }

.result-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.result-tags .badge { font-size: .78rem; padding: 4px 11px; }
.result-tags .xp { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.result-tags .rank { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }

.summary-xp {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 6px 0 2px; padding: 6px 14px; border-radius: 99px;
  background: var(--ok-soft); border: 1px solid var(--ok-line);
  color: var(--ok); font-weight: 800;
}

/* ------------------------------- Turnier-/Erfolgs-Mobil ------------------------------- */
@media (max-width: 900px) {
  .ach-hero { grid-template-columns: auto 1fr; }
  .ach-hero .level-facts { grid-column: 1 / -1; justify-content: center; }
}
@media (max-width: 760px) {
  .level-chip { display: none; }
  .board-row { grid-template-columns: 34px minmax(80px, 1fr) 84px 56px; gap: 7px; padding: 10px 12px; }
  .board-row .c-time, .board-row .c-lvl, .board-row .c-date { display: none; }
  .board-row.head { font-size: .62rem; }
  .ach-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 24px 18px; }
  .level-facts { gap: 24px; }
  .player-card { align-items: stretch; }
  .player-card .btn { width: 100%; }
}
@media (max-width: 420px) {
  .board-row { grid-template-columns: 30px minmax(70px, 1fr) 84px; }
  .board-row .c-percent { display: none; }
}

/* ------------------------------- Animationen ------------------------------- */
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-3px); } 40%, 60% { transform: translateX(3px); } }
.shake { animation: shake .4s; }
.fade-in { animation: pop .25s ease both; }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-main { padding: 28px 24px; }
}
@media (max-width: 760px) {
  .wrap { padding: 20px 15px 70px; }
  .topbar-inner { padding: 9px 14px; gap: 10px; }
  .brand-text small { display: none; }
  .nav { margin-left: 0; }
  .nav-btn { padding: 7px 10px; font-size: .84rem; }
  .streak-chip { display: none !important; }
  .options.two-col { grid-template-columns: 1fr; }
  .task-card { padding: 20px 17px; }
  .match-row { grid-template-columns: 1fr; gap: 7px; }
  .step-row { grid-template-columns: 1fr; }
  .step-row .open-input { width: 100%; }
  .result-hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .exam-bar { top: 56px; }
  .brand-text strong { font-size: .95rem; }
}
@media (max-width: 640px) {
  .brand-text { display: none; }
  .topbar-inner { gap: 8px; padding: 8px 12px; }
  .nav { margin-left: 0; padding: 3px; min-width: 0; }
  .nav-btn { padding: 6px 9px; font-size: .82rem; }
  .topbar-right { margin-left: auto; gap: 6px; flex: 0 0 auto; }
  .icon-btn { width: 34px; height: 34px; }
  .wrap { padding: 16px 13px 70px; }
  .practice-bar { gap: 8px; }
  .practice-bar .filter-select { flex: 1 1 130px; min-width: 0; max-width: 100%; }
  .practice-bar .bar { order: 6; }
}

@media (max-width: 520px) {
  .nav { gap: 0; padding: 3px; }
  .nav-btn { padding: 6px 8px; font-size: .8rem; }
  .hero-main h1 { font-size: 1.5rem; }
  .prompt { font-size: 1.03rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ------------------------------- Druck ------------------------------- */
@media print {
  .topbar, .task-actions, .practice-bar, .exam-bar, .foot, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .task-card { box-shadow: none; border-color: #ccc; }
}




