/* ============================================================================
   VWL Lernquiz — Styles (minimalistisch, im Stil von openai.com)
   ============================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #ffffff;
  --bg-soft:   #f7f7f8;
  --bg-soft2:  #f0f0f1;
  --line:      #e3e3e6;
  --line-2:    #d4d4d8;
  --ink:       #0d0d0d;
  --ink-2:     #3a3a40;
  --muted:     #6b6b73;
  --accent:    #0d0d0d;
  --accent-h:  #2a2a2a;
  --accent-ink:#ffffff;
  --ok:        #128a4f;
  --ok-bg:     #ecfdf3;
  --ok-line:   #aee7c4;
  --bad:       #c0392b;
  --bad-bg:    #fdecea;
  --bad-line:  #f3c0ba;
  --warn-bg:   #fff8e6;
  --warn-line: #f3e0a8;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
}

:root[data-theme="dark"] {
  --bg:        #0f1012;
  --bg-soft:   #17181b;
  --bg-soft2:  #202126;
  --line:      #2a2b31;
  --line-2:    #3b3c44;
  --ink:       #f1f1f3;
  --ink-2:     #c3c3cb;
  --muted:     #8a8b93;
  --accent:    #f1f1f3;
  --accent-h:  #d9d9dd;
  --accent-ink:#0d0d0d;
  --ok:        #3ecf8e;
  --ok-bg:     #112a1e;
  --ok-line:   #235c3e;
  --bad:       #f87171;
  --bad-bg:    #2c1515;
  --bad-line:  #5e2a2a;
  --warn-bg:   #2a2410;
  --warn-line: #574712;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.45);
}

/* Sanfter Übergang beim Themenwechsel */
body, .card, .question-card, .quiz-top, .option, .type-card, .breakdown,
.stat-box, .badge, .btn, .matrix td, .matrix th, .feedback, .luecke-select,
.option-mark, .cell-mark, .theme-toggle {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

/* Theme-Umschalter */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 50;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--bg-soft);
  color: var(--ink); font-size: 1.05rem; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.theme-toggle:hover { background: var(--bg-soft2); border-color: var(--muted); }
.theme-toggle:active { transform: translateY(1px); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(1rem, 4vw, 3rem) 1rem;
}

/* ---- Screens ---- */
.screen { display: none; width: 100%; max-width: 720px; }
.screen.active { display: block; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Cards ---- */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 2.75rem);
  box-shadow: var(--shadow);
}

/* ---- Start ---- */
.brand {
  font-weight: 700; letter-spacing: -.02em; font-size: .95rem;
  color: var(--muted); margin-bottom: 1.25rem;
}
.brand span { margin: 0 .35rem; color: var(--line-2); }
.start-card h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700;
  letter-spacing: -.025em; line-height: 1.15; margin-bottom: .9rem;
}
.lead { color: var(--ink-2); font-size: 1.02rem; }
.start-card .lead { margin-bottom: 1.75rem; }

.type-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem;
  margin-bottom: 1.75rem;
}
.type-card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem .6rem; text-align: center;
}
.type-num { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; }
.type-name { font-size: .82rem; font-weight: 600; margin-top: .15rem; }
.type-desc { font-size: .72rem; color: var(--muted); margin-top: .1rem; }

.shuffle-toggle {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: .92rem; color: var(--ink-2); cursor: pointer; margin-bottom: 1.5rem;
  user-select: none;
}
.shuffle-toggle input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); cursor: pointer; }

.start-actions { display: flex; flex-direction: column; gap: 1rem; }
.start-filters { display: flex; flex-wrap: wrap; gap: .5rem; }

.footnote { color: var(--muted); font-size: .8rem; margin-top: 1.25rem; text-align: center; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; font-size: .95rem; font-weight: 600; cursor: pointer;
  padding: .7rem 1.3rem; border-radius: 10px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-h); }
.btn-lg { padding: .9rem 1.5rem; font-size: 1rem; }
.btn-ghost { background: var(--bg); color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--bg-soft); border-color: var(--ink-2); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: #fbddd8; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .9rem; margin-top: 1rem; font-family: inherit; padding: .4rem;
}
.link-btn:hover { color: var(--ink); }

/* ---- Quiz top ---- */
.quiz-top { margin-bottom: 1rem; }
.quiz-meta {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; margin-bottom: .65rem;
}
#q-counter { font-size: .88rem; color: var(--muted); font-weight: 500; }
.meta-badges { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  font-size: .72rem; font-weight: 600; padding: .22rem .6rem; border-radius: 999px;
  border: 1px solid var(--line-2); white-space: nowrap;
}
.badge-type { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge-thema { background: var(--bg-soft); color: var(--ink-2); }
.progress-wrap { height: 6px; background: var(--bg-soft2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .35s ease; }
.score-row { display: flex; gap: 1rem; justify-content: flex-end; margin-top: .55rem; }
.score-correct { color: var(--ok); font-weight: 700; font-size: .9rem; }
.score-wrong { color: var(--bad); font-weight: 700; font-size: .9rem; }

/* ---- Question card ---- */
.question-card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(1.4rem, 3.5vw, 2.2rem);
  box-shadow: var(--shadow); animation: fade .25s ease;
}
.q-hint { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: .7rem;
  text-transform: uppercase; letter-spacing: .04em; }
.question-text { font-size: 1.12rem; font-weight: 600; line-height: 1.5; margin-bottom: 1.4rem; }

/* ---- Choice options ---- */
.options { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.4rem; }
.option {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: .85rem 1rem; border: 1.5px solid var(--line); border-radius: 11px;
  background: var(--bg); cursor: pointer; transition: border-color .12s, background .12s;
  font-size: .96rem; line-height: 1.45;
}
.option:hover { border-color: var(--line-2); background: var(--bg-soft); }
.option.selected { border-color: var(--accent); background: var(--bg-soft); }
.option-mark {
  flex-shrink: 0; width: 26px; height: 26px; display: flex; align-items: center;
  justify-content: center; font-size: .78rem; font-weight: 700; color: var(--muted);
  border: 1.5px solid var(--line-2); background: var(--bg);
}
.option-mark.circle { border-radius: 50%; }
.option-mark.box { border-radius: 7px; }
.option.selected .option-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.option-text { flex: 1; padding-top: .1rem; }
.option.locked { cursor: default; }
.option.correct { border-color: var(--ok-line); background: var(--ok-bg); }
.option.correct .option-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad-line); background: var(--bad-bg); }
.option.wrong .option-mark { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---- Matrix ---- */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; margin-bottom: 1.4rem; font-size: .9rem; }
.matrix th {
  font-size: .76rem; font-weight: 600; color: var(--ink-2); text-align: center;
  padding: .5rem .35rem; vertical-align: bottom; border-bottom: 1.5px solid var(--line);
}
.matrix th:first-child { text-align: left; }
.matrix td { padding: .35rem; border-bottom: 1px solid var(--line); }
.matrix .row-label { font-weight: 500; color: var(--ink); padding-right: .75rem; line-height: 1.35; }
.matrix .cell { text-align: center; cursor: pointer; }
.matrix .cell:hover .cell-mark { border-color: var(--accent); }
.cell-mark {
  display: inline-block; width: 22px; height: 22px; border: 1.5px solid var(--line-2);
  background: var(--bg); transition: all .12s; vertical-align: middle;
}
.cell-mark.circle { border-radius: 50%; }
.cell-mark.box { border-radius: 6px; }
.matrix .cell.sel .cell-mark { background: var(--accent); border-color: var(--accent); }
.matrix .cell.locked { cursor: default; }
.matrix .cell.correct .cell-mark {
  background: var(--ok); border-color: var(--ok);
  box-shadow: inset 0 0 0 3px var(--bg);
}
.matrix .cell.wrong .cell-mark {
  background: var(--bad); border-color: var(--bad);
  box-shadow: inset 0 0 0 3px var(--bg);
}

/* ---- Lückentext ---- */
.luecke-satz { font-size: 1.08rem; line-height: 2.1; margin-bottom: 1.4rem; }
.luecke-select {
  font-family: inherit; font-size: .95rem; font-weight: 600;
  padding: .3rem .6rem; margin: 0 .2rem; border: 1.5px solid var(--accent);
  border-radius: 8px; background: var(--bg-soft); color: var(--ink); cursor: pointer;
  max-width: 100%;
}
.luecke-select.correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.luecke-select.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.luecke-correct { font-weight: 700; color: var(--ok); margin-left: .4rem; white-space: nowrap; }

/* ---- Feedback ---- */
.feedback { border-radius: 12px; padding: 1rem 1.15rem; margin-bottom: 1.3rem; border: 1.5px solid; }
.feedback.correct-fb { background: var(--ok-bg); border-color: var(--ok-line); }
.feedback.wrong-fb { background: var(--bad-bg); border-color: var(--bad-line); }
.fb-head { font-weight: 700; font-size: .98rem; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; }
.correct-fb .fb-head { color: var(--ok); }
.wrong-fb .fb-head { color: var(--bad); }
.fb-sol { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.fb-hinweis {
  margin-top: .7rem; padding: .6rem .8rem; background: var(--warn-bg);
  border: 1px solid var(--warn-line); border-radius: 8px;
  font-size: .87rem; color: var(--ink-2); line-height: 1.5;
}
.fb-glossar {
  margin-top: .7rem; padding: .6rem .8rem; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: .89rem; color: var(--ink-2); line-height: 1.55;
}
.fb-glossar strong { color: var(--ink); }
.fb-text { margin-top: .7rem; font-size: .9rem; color: var(--ink-2); line-height: 1.55; }

.btn-row { display: flex; gap: .6rem; justify-content: flex-end; }

/* ---- Results ---- */
.results-card { text-align: center; }
.result-emoji { font-size: 3rem; margin-bottom: .5rem; }
.results-card h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .4rem; }
.results-card .lead { margin-bottom: 1.6rem; }
.stat-row { display: flex; gap: .75rem; justify-content: center; margin-bottom: 1.75rem; }
.stat-box {
  flex: 1; max-width: 150px; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem .5rem;
}
.stat-num { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; }
.stat-num.ok { color: var(--ok); }
.stat-num.bad { color: var(--bad); }
.stat-num.accent { color: var(--accent); }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-top: .15rem; }

.breakdown {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.15rem; margin-bottom: 1rem; text-align: left;
}
.bd-title { font-size: .76rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }
.bd-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .55rem; }
.bd-row:last-child { margin-bottom: 0; }
.bd-label { flex: 1.3; font-size: .85rem; color: var(--ink-2); }
.bd-bar-wrap { flex: 1.5; height: 8px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; }
.bd-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s ease; }
.bd-val { font-size: .82rem; font-weight: 700; min-width: 42px; text-align: right; color: var(--ink); }

.result-actions { display: flex; flex-direction: column; gap: .65rem; align-items: center; margin-top: 1.5rem; }
.result-actions .btn { width: 100%; max-width: 320px; }

/* ---- Responsive ---- */
@media (max-width: 560px) {
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .meta-badges { justify-content: flex-start; }
  .quiz-meta { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .matrix { font-size: .82rem; }
  .matrix th { font-size: .68rem; }
  .cell-mark { width: 20px; height: 20px; }
  .luecke-satz { line-height: 2.3; }
}
