/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e6e5e0;
  --border: #e0dfda;
  --border-strong: #cbc9c2;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #706f6a;
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-soft: #e7f0fc;
  --btn-bg: #2a78d6;
  --btn-bg-hover: #256abf;
  --on-accent: #ffffff;
  --good: #0ca30c;  --good-ink: #006300;  --good-soft: #e5f5e5;
  --warn: #fab219;  --warn-ink: #7a4f00;  --warn-soft: #fff3d6;
  --bad: #d03b3b;   --bad-ink: #a32727;   --bad-soft: #fbe9e9;
  --neutral: #c9c8c2;
  /* Ordinale Blau-Rampe: Erklärungsstufen und Karteikasten-Fächer */
  --l1: #86b6ef; --l2: #2a78d6; --l3: #104281;
  --f0: #86b6ef; --f1: #5598e7; --f2: #3987e5; --f3: #256abf; --f4: #184f95; --f5: #0d366b;
  --shadow: 0 1px 2px rgba(20, 20, 18, .05), 0 4px 16px rgba(20, 20, 18, .06);
  --shadow-lg: 0 2px 4px rgba(20, 20, 18, .06), 0 12px 32px rgba(20, 20, 18, .10);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2d2d2a;
    --border: #31312e; --border-strong: #4a4a44;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #9b9a90;
    --accent: #3987e5; --accent-strong: #86b6ef; --accent-soft: #1a2a3e;
    --btn-bg: #256abf; --btn-bg-hover: #2a78d6; --on-accent: #ffffff;
    --good-ink: #6fd46f; --good-soft: #15301a;
    --warn-ink: #fab219; --warn-soft: #33290f;
    --bad-ink: #f08a8a;  --bad-soft: #3a1d1d;
    --neutral: #4c4c47;
    --l1: #256abf; --l2: #5598e7; --l3: #b7d3f6;
    --f0: #184f95; --f1: #256abf; --f2: #2a78d6; --f3: #5598e7; --f4: #86b6ef; --f5: #b7d3f6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2d2d2a;
  --border: #31312e; --border-strong: #4a4a44;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #9b9a90;
  --accent: #3987e5; --accent-strong: #86b6ef; --accent-soft: #1a2a3e;
  --btn-bg: #256abf; --btn-bg-hover: #2a78d6; --on-accent: #ffffff;
  --good-ink: #6fd46f; --good-soft: #15301a;
  --warn-ink: #fab219; --warn-soft: #33290f;
  --bad-ink: #f08a8a;  --bad-soft: #3a1d1d;
  --neutral: #4c4c47;
  --l1: #256abf; --l2: #5598e7; --l3: #b7d3f6;
  --f0: #184f95; --f1: #256abf; --f2: #2a78d6; --f3: #5598e7; --f4: #86b6ef; --f5: #b7d3f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); font-weight: 750; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent-strong); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: #fff; }
.tabs { display: flex; gap: 4px; margin-left: auto; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tabs a {
  padding: 6px 12px; border-radius: 9px; color: var(--text-2); text-decoration: none;
  font-size: .92rem; font-weight: 550; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: var(--text-2); }
.icon-btn:hover svg { fill: var(--text); }

.sync-badge {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; flex: none;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.sync-badge svg { width: 18px; height: 18px; fill: var(--text-2); }
.sync-badge:hover { color: var(--text); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); flex: none; }
[data-state="good"] > .sync-dot { background: var(--good); }
[data-state="busy"] > .sync-dot { background: var(--accent); animation: syncPulse 1s ease-in-out infinite alternate; }
[data-state="warn"] > .sync-dot { background: var(--warn); }
[data-state="bad"] > .sync-dot { background: var(--bad); }
@keyframes syncPulse { to { opacity: .3; } }
.storage-warn { background: var(--bad-soft); color: var(--bad-ink); border-bottom: 1px solid var(--bad); padding: 10px 16px; font-size: .88rem; font-weight: 600; text-align: center; }
.storage-warn[hidden] { display: none; }

@media (max-width: 720px) {
  .sync-badge { padding: 0 10px; }
  .sync-badge .sync-label { display: none; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .brand { flex: 1; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tabs a { flex: 1; text-align: center; padding: 7px 4px; font-size: .86rem; }
}

main { padding-top: 28px; padding-bottom: 40px; min-height: 70vh; outline: none; }
.footer { padding-top: 8px; padding-bottom: 32px; color: var(--muted); font-size: .82rem; }

/* ---------- Generic UI ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head p { color: var(--muted); font-size: .85rem; }
.stack { display: grid; gap: 20px; }
.grid-3 { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 920px) { .grid-3 { grid-template-columns: 1fr 1fr; } .grid-3 > :first-child { grid-column: 1 / -1; } }
@media (max-width: 640px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } .grid-3 > :first-child { grid-column: auto; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .94rem; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--on-accent); }
.btn.primary:hover { background: var(--btn-bg-hover); border-color: var(--btn-bg-hover); }
.btn.lg { min-height: 48px; padding: 10px 22px; font-size: 1rem; border-radius: 12px; }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: .85rem; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad-ink); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .badge {
  background: rgba(255, 255, 255, .22); padding: 1px 8px; border-radius: 999px; font-size: .82rem;
  font-variant-numeric: tabular-nums;
}
.btn:not(.primary) .badge { background: var(--surface-3); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.eyebrow { color: var(--accent-strong); font-weight: 650; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.lead { color: var(--text-2); margin-top: 8px; max-width: 60ch; }

/* ---------- Dashboard ---------- */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 20px; }
@media (max-width: 920px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 460px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { color: var(--text-2); font-size: .8rem; font-weight: 600; }
.kpi-value { font-size: 1.75rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 4px; }
.kpi-value small { font-size: .9rem; font-weight: 600; color: var(--muted); margin-left: 5px; }
.kpi-sub { color: var(--muted); font-size: .76rem; margin-top: 2px; }

/* Column chart (Karteikasten / Aktivität) */
.cols { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--border-strong); }
.col { flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; position: relative; min-width: 0; }
.col-bar { position: relative; width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; min-height: 0; transition: height .4s ease; }
.col-val {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 3px;
  font-size: .74rem; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.col-labels { display: flex; gap: 6px; margin-top: 6px; }
.col-labels span { flex: 1; text-align: center; font-size: .72rem; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; }
.cols.thin { gap: 3px; height: 120px; }
.cols.thin .col-bar { max-width: 18px; background: var(--accent); }
.col-hit { position: absolute; inset: 0; cursor: default; }

/* Stacked bar (Erklärungsstufen) */
.stackbar { display: flex; gap: 2px; height: 22px; border-radius: 6px; overflow: hidden; background: var(--surface-2); margin: 6px 0 14px; }
.stackbar > span { display: block; height: 100%; min-width: 0; transition: flex-grow .4s ease; }
.legend { display: grid; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.legend-item .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend-item .lv-name { flex: 1; color: var(--text-2); }
.legend-item .lv-val { font-weight: 650; font-variant-numeric: tabular-nums; }

/* Topic list */
.topics { display: grid; }
.topic-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.topic-row:first-child { border-top: 0; padding-top: 0; }
.topic-name { font-weight: 620; }
.topic-meta { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.topic-meta b { color: var(--text-2); font-weight: 650; }
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.meter-label { display: flex; justify-content: space-between; font-size: .76rem; color: var(--muted); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.topic-actions { display: flex; gap: 6px; }
@media (max-width: 640px) {
  .topic-row { grid-template-columns: 1fr; gap: 8px; }
  .topic-actions .btn { flex: 1; }
}

.tests-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tests-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; }
.tests-list .score { font-weight: 750; font-variant-numeric: tabular-nums; min-width: 3.2em; }
.tests-list .when { color: var(--muted); margin-left: auto; font-size: .8rem; white-space: nowrap; }
.empty { color: var(--muted); font-size: .9rem; padding: 6px 0; }

.howto { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--text-2); font-size: .9rem; }
.howto b { color: var(--text); }
.pill { display: inline-block; padding: 0 7px; border-radius: 6px; font-weight: 700; font-size: .82rem; }
.pill.good { background: var(--good-soft); color: var(--good-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); }

/* ---------- Setup screens ---------- */
.setup { max-width: 820px; margin: 0 auto; display: grid; gap: 20px; }
.setup-head { display: grid; gap: 6px; }
.field-label { font-weight: 650; font-size: .92rem; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field-label .row { gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-group + .chip-group { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.chip-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: .8rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-2); }
.chip-group-head .btn { text-transform: none; letter-spacing: 0; }
.topic-chapter { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); margin: 18px 0 6px; }
.panel-head + .topic-chapter { margin-top: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: .88rem; font-weight: 550; color: var(--text-2);
}
.chip .chip-count { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"]::before {
  content: ""; width: 14px; height: 14px; margin-left: -2px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .modes { grid-template-columns: 1fr 1fr; } }
.mode {
  text-align: left; padding: 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); display: grid; gap: 6px; align-content: start;
}
.mode:hover { border-color: var(--accent); }
.mode[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.mode-desc { font-size: .8rem; color: var(--text-2); line-height: 1.4; }
.lvl-dots { display: inline-flex; gap: 3px; }
.lvl-dots i { width: 7px; height: 7px; border-radius: 2px; background: var(--surface-3); }
.lvl-dots i.on:nth-child(1) { background: var(--l1); }
.lvl-dots i.on:nth-child(2) { background: var(--l2); }
.lvl-dots i.on:nth-child(3) { background: var(--l3); }
.auto-note { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: .86rem; color: var(--text-2); }
.auto-note b { color: var(--text); }

.decks { display: grid; gap: 8px; }
.deck {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.deck[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.deck .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; }
.deck[aria-pressed="true"] .radio { border-color: var(--accent); }
.deck[aria-pressed="true"] .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.deck-text { flex: 1; display: grid; gap: 2px; }
.deck-title { font-weight: 650; }
.deck-desc { font-size: .8rem; color: var(--text-2); }
.deck-count { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }

.select {
  font: inherit; font-size: .9rem; padding: 7px 34px 7px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center / 18px;
  color: var(--text); appearance: none; -webkit-appearance: none;
}
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.start-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.start-bar p { color: var(--text-2); font-size: .9rem; }

/* ---------- Learn session ---------- */
.session { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; }
.session-top { display: flex; align-items: center; gap: 14px; }
.session-top .progress { flex: 1; height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.session-top .progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.session-count { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: .88rem; font-weight: 600; white-space: nowrap; }

.flip { perspective: 1600px; cursor: pointer; border-radius: 20px; }
.flip:focus-visible { outline-offset: 4px; }
.flip-inner {
  display: grid; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .7, .2, 1);
}
.flip[data-flipped="true"] .flip-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 22px 26px 24px; min-height: 340px; display: flex; flex-direction: column;
}
.face.back { transform: rotateY(180deg); }
.face-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.topic-tag { font-weight: 650; color: var(--text-2); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; }
.lvl-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; color: var(--text-2); }
.lvl-badge .pts { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.lvl-meter { display: inline-flex; gap: 2px; }
.lvl-meter i { width: 5px; height: 10px; border-radius: 2px; background: var(--surface-3); }
.lvl-meter i.on { background: var(--accent); }
.front-body { flex: 1; display: grid; place-items: center; text-align: center; padding: 28px 6px; }
.front-q { font-size: clamp(1.3rem, 3.2vw, 1.7rem); font-weight: 700; line-height: 1.3; max-width: 30ch; }
.face-hint { text-align: center; color: var(--muted); font-size: .82rem; }
.face-hint kbd, .kbd {
  font: 600 .75rem/1 var(--font); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2);
}
.back-q { font-weight: 650; color: var(--text-2); font-size: .95rem; margin: 14px 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.answer { font-size: 1.06rem; line-height: 1.6; flex: 1; }
.answer b { font-weight: 700; }
.answer-level { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; }
.answer-level .sw { width: 10px; height: 10px; border-radius: 3px; }
.back-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.src { font-size: .78rem; color: var(--muted); }
.peek { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 8px; }
.peek button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: .78rem; font-weight: 650; color: var(--text-2); cursor: pointer; }
.peek button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.rate { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rate-btn {
  display: grid; justify-items: center; gap: 4px; padding: 12px 8px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow); font-weight: 650;
  border-top-width: 4px;
}
.rate-btn svg { width: 22px; height: 22px; }
.rate-btn small { font-weight: 500; color: var(--muted); font-size: .74rem; }
.rate-btn.bad { border-top-color: var(--bad); } .rate-btn.bad svg { fill: var(--bad); }
.rate-btn.warn { border-top-color: var(--warn); } .rate-btn.warn svg { fill: var(--warn); }
.rate-btn.good { border-top-color: var(--good); } .rate-btn.good svg { fill: var(--good); }
.rate-btn.bad:hover { background: var(--bad-soft); }
.rate-btn.warn:hover { background: var(--warn-soft); }
.rate-btn.good:hover { background: var(--good-soft); }
.rate-wait { text-align: center; color: var(--muted); font-size: .88rem; padding: 18px 0; }

/* Summary */
.summary { max-width: 640px; margin: 0 auto; text-align: center; display: grid; gap: 18px; }
.summary-icon { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); }
.summary-icon svg { width: 30px; height: 30px; fill: var(--accent); }
.summary-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.summary-stat { padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.summary-stat .v { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.summary-stat .l { font-size: .8rem; color: var(--text-2); display: flex; align-items: center; justify-content: center; gap: 6px; }
.summary-stat .l svg { width: 14px; height: 14px; }
.summary .row { justify-content: center; }

/* ---------- Test ---------- */
.quiz { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; }
.quiz-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px 24px; display: grid; gap: 18px; }
.quiz-q { font-size: clamp(1.15rem, 2.8vw, 1.4rem); font-weight: 700; line-height: 1.35; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: .98rem; line-height: 1.4;
}
.option:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.option .key {
  flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .82rem;
}
.option .opt-text { flex: 1; }
.option .mark { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 700; }
.option .mark svg { width: 18px; height: 18px; }
.option[disabled] { cursor: default; }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.correct .key { background: var(--good); color: #fff; }
.option.correct .mark { color: var(--good-ink); } .option.correct .mark svg { fill: var(--good-ink); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .key { background: var(--bad); color: #fff; }
.option.wrong .mark { color: var(--bad-ink); } .option.wrong .mark svg { fill: var(--bad-ink); }
.option.dim { opacity: .55; }
.explain { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); font-size: .95rem; line-height: 1.55; }
.explain-head { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.explain-head.good { color: var(--good-ink); } .explain-head.bad { color: var(--bad-ink); }
.explain-head svg { width: 16px; height: 16px; fill: currentColor; }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.score-ring { width: 140px; height: 140px; margin: 0 auto; position: relative; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--surface-3); }
.score-ring .ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.score-ring .ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-ring .ring-label b { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.score-ring .ring-label span { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.review { text-align: left; display: grid; gap: 10px; }
.review-item { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: .9rem; }
.review-item .rq { font-weight: 650; margin-bottom: 6px; }
.review-item .ra { display: flex; gap: 8px; align-items: baseline; color: var(--text-2); }
.review-item .ra svg { width: 14px; height: 14px; flex: none; transform: translateY(2px); }
.review-item .ra.bad svg { fill: var(--bad-ink); }
.review-item .ra.good svg { fill: var(--good-ink); }
.review-item .ra.bad span { text-decoration: line-through; text-decoration-color: var(--bad); }

/* ---------- Browse ---------- */
.browse-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 18px 0; }
.search {
  flex: 1; min-width: 200px; font: inherit; font-size: .95rem; padding: 9px 14px 9px 38px; border-radius: 10px;
  border: 1px solid var(--border-strong); color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888'%3E%3Cpath d='M15.5 14h-.8l-.3-.3A6.5 6.5 0 1 0 9.5 16a6.5 6.5 0 0 0 4.2-1.6l.3.3v.8l5 5 1.5-1.5-5-5zm-6 0a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E") no-repeat 12px center / 18px;
}
.browse-group { margin-top: 26px; }
.browse-group h2 { margin-bottom: 10px; display: flex; align-items: baseline; gap: 10px; }
.browse-group h2 span { color: var(--muted); font-weight: 500; font-size: .85rem; }
.card-row { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.card-row summary {
  list-style: none; cursor: pointer; padding: 12px 16px; display: flex; gap: 12px; align-items: center; font-weight: 600;
}
.card-row summary::-webkit-details-marker { display: none; }
.card-row summary::before {
  content: ""; width: 8px; height: 8px; flex: none; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s; margin-right: 2px;
}
.card-row[open] summary::before { transform: rotate(45deg); }
.card-row .cq { flex: 1; }
.status { font-size: .74rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.status.due { background: var(--accent-soft); color: var(--accent-strong); }
.card-body { padding: 0 16px 16px 38px; display: grid; gap: 12px; }
.lvl-block { border-left: 3px solid var(--l2); padding: 2px 0 2px 12px; font-size: .94rem; }
.lvl-block.l0 { border-color: var(--l1); } .lvl-block.l2 { border-color: var(--l3); }
.lvl-block h3 { font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); margin-bottom: 3px; }
.card-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); }
.card-facts b { color: var(--text-2); font-weight: 650; }

.card-row.is-hidden summary .cq { color: var(--muted); }
.card-row.is-hidden { background: var(--surface-2); border-style: dashed; }
.status.off { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.btn.icon-only { padding: 4px 8px; }
.browse-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .86rem; }
.session-foot { display: flex; justify-content: center; }
.session-foot .btn { color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; margin-top: 8px; line-height: 1.45; }
.hint a, .lead a { color: var(--accent-strong); }

/* ---------- Data / settings ---------- */
.data-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.data-row p { color: var(--text-2); font-size: .88rem; max-width: 56ch; }
.data-row-sep { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.sync-status {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); font-size: .9rem; color: var(--text-2); margin-bottom: 18px;
}
.sync-grid { gap: 24px; }
.code-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.code-box code {
  font: 700 1.02rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong);
  color: var(--text); user-select: all;
}
.code-input {
  flex: 1; min-width: 180px; font: 600 .95rem ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  text-transform: uppercase;
}
.code-input::placeholder { text-transform: none; color: var(--muted); }

/* ---------- Dialog ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 10, 9, .45); backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 22px; display: grid; gap: 16px;
}
.modal h2 { font-size: 1.15rem; }
.modal-body { display: grid; gap: 12px; font-size: .94rem; color: var(--text-2); }
.modal-body b { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; }
.opt input { margin-top: 3px; accent-color: var(--accent); }
.opt .select { margin: 4px 0; padding-top: 4px; padding-bottom: 4px; font-size: .85rem; }
.opt-check { border-style: dashed; }
.dlg-warn { padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad-ink); font-size: .85rem; font-weight: 600; }
.dlg-q { font-weight: 650; color: var(--text); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { filter: brightness(.92); }

/* ---------- Toast & tooltip ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 650; font-size: .92rem;
  box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  padding: 7px 10px; border-radius: 8px; font-size: .8rem; line-height: 1.35; max-width: 240px;
}
#tip.show { opacity: 1; }
#tip b { font-variant-numeric: tabular-nums; }

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

/* ---------- Hinweis auf der alten Adresse ---------- */
.move-note {
  background: var(--accent-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 14px;
  text-align: center;
}
.move-note a { color: var(--accent-strong); font-weight: 600; }
