/* Core 1 lernen — Designsystem
   Ruhige, kontrastreiche Oberfläche mit großer Schrift: die Seite wird über
   Wochen täglich benutzt, oft auf dem Tablet. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --border: #dcdad2;
  --border-strong: #c3c0b5;
  --text: #23241f;
  --text-muted: #6a6a61;
  --accent: #2f6f4e;
  --accent-soft: #e3efe7;
  --accent-text: #1f4e37;
  --danger: #a9382c;
  --danger-soft: #f6e4e1;
  --warn: #8a6212;
  --warn-soft: #f7edd6;
  --info: #2c5d86;
  --info-soft: #e2ecf5;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 18px -8px rgb(0 0 0 / 0.14);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.06), 0 20px 42px -18px rgb(0 0 0 / 0.28);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #1e2024;
    --surface-2: #262a2f;
    --border: #333840;
    --border-strong: #464d57;
    --text: #e8e8e4;
    --text-muted: #9aa0a8;
    --accent: #6ec295;
    --accent-soft: #1e3329;
    --accent-text: #9ddcba;
    --danger: #e58a7c;
    --danger-soft: #3a2320;
    --warn: #ddb257;
    --warn-soft: #362c17;
    --info: #85b6dd;
    --info-soft: #1b2b38;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 18px -8px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.4), 0 20px 42px -18px rgb(0 0 0 / 0.7);
  }
}

* {
  box-sizing: border-box;
}

/* Das hidden-Attribut muss gewinnen. Eigene Regeln wie `#topbar { display: flex }`
   sind spezifischer als die Browser-Vorgabe `[hidden] { display: none }` und
   würden ein ausgeblendetes Element sonst wieder sichtbar machen. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 0.4em;
  letter-spacing: -0.015em;
}
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.15rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem); }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
a { color: var(--accent-text); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: 0.75rem 1rem;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Kopfzeile ---------- */

#topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem clamp(0.75rem, 3vw, 1.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: var(--text-muted); font-size: 0.75rem; }

#mainnav {
  display: flex;
  gap: 0.2rem;
  flex: 1 1 100%;
  order: 3;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
#mainnav::-webkit-scrollbar { display: none; }

#mainnav a {
  padding: 0.42rem 0.7rem;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}
#mainnav a:hover { background: var(--surface-2); color: var(--text); }
#mainnav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

.streak {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-soft);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.usermenu { position: relative; }
.usermenu summary {
  list-style: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 600;
  text-transform: uppercase;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem;
  min-width: 190px;
  z-index: 30;
}
.usermenu-panel p { margin: 0 0 0.6rem; font-weight: 600; }

@media (min-width: 900px) {
  #mainnav { flex: 1; order: 0; }
}

/* ---------- Grundlayout ---------- */

#main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.1rem, 3vw, 2rem) clamp(0.85rem, 3vw, 1.5rem) 5rem;
}
#main:focus { outline: none; }

.loading { color: var(--text-muted); padding: 3rem 0; text-align: center; }

.page-head { margin-bottom: 1.6rem; }
.page-head p { color: var(--text-muted); margin: 0; max-width: 62ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  box-shadow: var(--shadow);
}

.stack { display: grid; gap: 1.1rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); }

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 550;
  padding: 0.62rem 1.1rem;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-text); border-color: var(--accent-text); }
@media (prefers-color-scheme: dark) {
  .btn-primary { color: #10231a; }
  .btn-primary:hover:not(:disabled) { background: var(--accent-text); }
}

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-quiet { border-color: transparent; background: var(--surface-2); }
.btn-lg { font-size: 1.05rem; padding: 0.8rem 1.5rem; min-height: 52px; }
.btn-block { width: 100%; }

/* ---------- Formulare ---------- */

label { display: block; font-weight: 550; margin-bottom: 0.3rem; font-size: 0.95rem; }

input[type="text"], input[type="password"], select {
  font: inherit;
  width: 100%;
  padding: 0.65rem 0.8rem;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
}
input:focus-visible, select:focus-visible { border-color: var(--accent); }

.field { margin-bottom: 1rem; }
.hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.3rem; }

.alert {
  padding: 0.75rem 0.95rem;
  border-radius: 11px;
  margin-bottom: 1rem;
  font-size: 0.94rem;
  border: 1px solid;
}
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.alert-ok { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Anmeldung ---------- */

.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(430px, 100%); }
.auth-logo {
  width: 56px; height: 56px; border-radius: 16px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.3rem;
  margin: 0 auto 1rem;
}
.tabs { display: flex; gap: 0.3rem; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 1.3rem; }
.tabs button {
  flex: 1; font: inherit; font-weight: 550; padding: 0.5rem; border: 0;
  border-radius: 9px; background: transparent; color: var(--text-muted); cursor: pointer; min-height: 40px;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Dashboard ---------- */

.hero { display: grid; gap: 1.1rem; grid-template-columns: 1fr; margin-bottom: 1.6rem; }
@media (min-width: 760px) { .hero { grid-template-columns: 1.25fr 1fr; } }

.goal-ring { display: flex; align-items: center; gap: 1.1rem; }
.ring { width: 92px; height: 92px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--surface-2); }
.ring .value { stroke: var(--accent); transition: stroke-dasharray 0.5s ease; }
.ring text { fill: var(--text); font-size: 26px; font-weight: 650; font-family: var(--font); }

.stat-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat {
  background: var(--surface-2); border-radius: var(--radius); padding: 0.8rem 0.9rem;
}
.stat b { display: block; font-size: 1.55rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.83rem; color: var(--text-muted); }

.mode-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.mode {
  display: flex; flex-direction: column; gap: 0.3rem; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem; box-shadow: var(--shadow); transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.mode:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.mode .mode-icon { font-size: 1.5rem; line-height: 1; margin-bottom: 0.35rem; }
.mode strong { font-size: 1.05rem; }
.mode span { font-size: 0.88rem; color: var(--text-muted); }
.mode .badge { align-self: flex-start; margin-top: 0.5rem; }
.mode-primary { border-color: var(--accent); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 65%); }

.badge {
  font-size: 0.78rem; font-weight: 600; padding: 0.16rem 0.55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Fortschrittsbalken ---------- */

.bar { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s; }
.bar.thin { height: 6px; }

.prog-list { display: grid; gap: 0.7rem; }
.prog-row { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.8rem; align-items: center; }
.prog-row .bar { grid-column: 1 / -1; }
.prog-row b { font-weight: 550; font-size: 0.94rem; }
.prog-row span { font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Deckauswahl ---------- */

.deck-picker { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.deck-picker button {
  font: inherit; font-size: 0.9rem; padding: 0.4rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); cursor: pointer;
  min-height: 38px;
}
.deck-picker button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
@media (prefers-color-scheme: dark) { .deck-picker button[aria-pressed="true"] { color: #10231a; } }

/* ---------- Lernkarte ---------- */

.session-bar {
  display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.1rem;
  font-size: 0.9rem; color: var(--text-muted); flex-wrap: wrap;
}
.session-bar .bar { flex: 1; min-width: 120px; }

.flashcard {
  min-height: min(46vh, 340px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2.5rem);
  cursor: pointer;
  user-select: none;
}
.flashcard .fc-front { font-size: clamp(1.9rem, 1.2rem + 3.4vw, 3.1rem); font-weight: 650; letter-spacing: -0.02em; }
.flashcard .fc-hint { color: var(--text-muted); font-size: 0.9rem; margin-top: 1rem; }
.fc-back { border-top: 1px solid var(--border); margin-top: 1.4rem; padding-top: 1.2rem; width: 100%; }
.fc-back .fc-long { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.4rem; }
.fc-back .fc-meaning { color: var(--text-muted); font-size: 1.02rem; max-width: 46ch; margin: 0 auto; }

.rating-row { display: grid; gap: 0.55rem; grid-template-columns: repeat(2, 1fr); margin-top: 1.1rem; }
@media (min-width: 620px) { .rating-row { grid-template-columns: repeat(4, 1fr); } }
.rating-row .btn { flex-direction: column; gap: 0.1rem; padding: 0.6rem; }
.rating-row .btn small { font-weight: 400; font-size: 0.75rem; color: var(--text-muted); }

/* ---------- Quiz ---------- */

.q-prompt { font-size: clamp(1.15rem, 1rem + 0.9vw, 1.5rem); font-weight: 600; white-space: pre-line; margin-bottom: 1.3rem; }
.options { display: grid; gap: 0.6rem; }
.option {
  font: inherit; text-align: left; padding: 0.85rem 1rem; border-radius: var(--radius);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; display: flex; gap: 0.8rem; align-items: flex-start; min-height: 52px;
  transition: border-color 0.12s, background 0.12s;
}
.option:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.option .key {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
}
.option[data-state="correct"] { border-color: var(--accent); background: var(--accent-soft); }
.option[data-state="correct"] .key { background: var(--accent); color: #fff; }
.option[data-state="wrong"] { border-color: var(--danger); background: var(--danger-soft); }
.option[data-state="wrong"] .key { background: var(--danger); color: #fff; }
.option[data-state="chosen"] { border-color: var(--info); background: var(--info-soft); }
.option:disabled { cursor: default; }

.feedback { margin-top: 1.1rem; padding: 0.9rem 1rem; border-radius: var(--radius); font-size: 0.95rem; }
.feedback.ok { background: var(--accent-soft); color: var(--accent-text); }
.feedback.no { background: var(--danger-soft); color: var(--danger); }
.feedback strong { display: block; margin-bottom: 0.2rem; }

/* ---------- Prüfung ---------- */

.exam-bar {
  position: sticky; top: 64px; z-index: 10;
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.6rem 0.9rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}
.timer { font-family: var(--mono); font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer[data-warn="soon"] { color: var(--warn); }
.timer[data-warn="urgent"] { color: var(--danger); }

.qnav { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; margin-top: 1.2rem; }
.qnav button {
  font: inherit; font-size: 0.8rem; aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  padding: 0; min-height: 38px;
}
.qnav button[data-answered="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.qnav button[data-marked="true"] { border-color: var(--warn); box-shadow: inset 0 0 0 1.5px var(--warn); }
.qnav button[aria-current="true"] { outline: 2.5px solid var(--text); outline-offset: 1px; }

.result-hero { text-align: center; padding: 2rem 1rem; }
.result-score { font-size: clamp(3rem, 2rem + 6vw, 5rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.result-hero.pass .result-score { color: var(--accent); }
.result-hero.fail .result-score { color: var(--danger); }

.review-item { border-top: 1px solid var(--border); padding: 1rem 0; }
.review-item:first-child { border-top: 0; }
.review-q { font-weight: 600; white-space: pre-line; margin-bottom: 0.5rem; }
.review-a { font-size: 0.93rem; margin: 0.2rem 0; }
.review-a.given-wrong { color: var(--danger); }
.review-a.right { color: var(--accent-text); }

/* ---------- Zuordnung ---------- */

.match-board { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .match-board { grid-template-columns: 1fr 1fr; } }

.match-col { display: grid; gap: 0.55rem; align-content: start; }
.match-col h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0 0 0.2rem; }

.slot {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  min-height: 58px; display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem;
  background: var(--surface); transition: border-color 0.12s, background 0.12s;
}
.slot .slot-label { font-weight: 600; flex-shrink: 0; }
.slot.over { border-color: var(--accent); background: var(--accent-soft); }
.slot[data-state="correct"] { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.slot[data-state="wrong"] { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }

.chip {
  font: inherit; font-size: 0.95rem; padding: 0.5rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  cursor: grab; touch-action: none; user-select: none; min-height: 44px;
  display: inline-flex; align-items: center; text-align: left;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.chip.dragging { opacity: 0.35; }
.chip.placed { cursor: default; }
.chip-ghost {
  position: fixed; z-index: 999; pointer-events: none; box-shadow: var(--shadow-lg);
  opacity: 0.95; transform: translate(-50%, -50%);
}

/* ---------- Blitzrunde ---------- */

.blitz-timer {
  height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 1.2rem;
}
.blitz-timer > i { display: block; height: 100%; background: var(--accent); }
.blitz-timer[data-low="true"] > i { background: var(--danger); }
.blitz-score { display: flex; gap: 1.5rem; justify-content: center; margin-bottom: 1rem; }
.blitz-score div { text-align: center; }
.blitz-score b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.blitz-score span { font-size: 0.8rem; color: var(--text-muted); }

/* ---------- Statistik ---------- */

.spark { display: flex; align-items: flex-end; gap: 3px; height: 74px; }
.spark div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.spark div[data-empty="true"] { background: var(--surface-2); }

.box-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }
.box-cell { text-align: center; background: var(--surface-2); border-radius: var(--radius); padding: 0.7rem 0.3rem; }
.box-cell b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.box-cell span { font-size: 0.75rem; color: var(--text-muted); }

table.plain { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.plain th { text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 0.4rem 0.5rem; }
table.plain td { padding: 0.5rem; border-top: 1px solid var(--border); }
table.plain td:last-child, table.plain th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Nachschlagen ---------- */

.ref-search { margin-bottom: 1.2rem; }
.ref-group { margin-bottom: 1.8rem; }
.ref-table { width: 100%; border-collapse: collapse; }
.ref-table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 0.4rem 0.6rem; }
.ref-table td { padding: 0.6rem; border-top: 1px solid var(--border); vertical-align: top; }
.ref-table td:first-child { font-weight: 650; white-space: nowrap; }
.ref-table td:nth-child(2) { color: var(--text-muted); }
@media (max-width: 620px) {
  .ref-table, .ref-table tbody, .ref-table tr, .ref-table td { display: block; width: 100%; }
  .ref-table thead { display: none; }
  .ref-table tr { border-top: 1px solid var(--border); padding: 0.6rem 0; }
  .ref-table td { border: 0; padding: 0.1rem 0; }
}

/* ---------- Lernpfad ---------- */

.lesson-list { list-style: none; margin: 1.4rem 0 0; padding: 0; display: grid; gap: 0.6rem; counter-reset: none; }

.lesson-row {
  display: flex; gap: 0.9rem; align-items: flex-start; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 0.95rem 1.1rem; box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.lesson-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.lesson-row.is-read { border-color: var(--accent); background: linear-gradient(120deg, var(--accent-soft), var(--surface) 45%); }

.lesson-num {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-muted); font-weight: 700; font-size: 0.95rem;
}
.lesson-row.is-read .lesson-num { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .lesson-row.is-read .lesson-num { color: #10231a; } }

.lesson-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.lesson-body strong { font-size: 1.06rem; }
.lesson-sub { color: var(--text-muted); font-size: 0.92rem; }
.lesson-sub-big { color: var(--text-muted); font-size: 1.05rem; margin: 0; }
.lesson-meta { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-muted); margin-top: 0.25rem; }

.back-link { display: inline-block; margin-bottom: 0.9rem; font-size: 0.92rem; text-decoration: none; color: var(--text-muted); }
.back-link:hover { color: var(--text); }

/* ---------- Lektionstext ---------- */

.prose { font-size: 1.04rem; line-height: 1.72; }
.prose > p { margin: 0 0 1.15em; max-width: 68ch; }
.prose .lesson-intro {
  font-size: 1.12rem; color: var(--text-muted); border-left: 3px solid var(--accent);
  padding-left: 1rem; margin-bottom: 1.8rem;
}
.prose-h {
  margin: 2.2rem 0 0.9rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
  font-size: 1.28rem;
}
.prose > .prose-h:first-of-type { border-top: 0; padding-top: 0; margin-top: 0.6rem; }

.note {
  display: block; background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 0.9rem 1.1rem; margin: 1.4rem 0; max-width: 68ch;
}
.note strong { display: block; color: var(--accent-text); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.25rem; }
.note span { color: var(--text); font-size: 0.99rem; }

.diagram { margin: 1.8rem 0; }
.diagram-canvas {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(0.7rem, 2vw, 1.3rem); overflow-x: auto;
}
.diagram-canvas svg { min-width: 420px; }
.diagram figcaption { font-size: 0.88rem; color: var(--text-muted); margin-top: 0.55rem; text-align: center; }

.term-list {
  display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.1rem;
  margin: 1.3rem 0; padding: 1rem 1.1rem; background: var(--surface-2); border-radius: var(--radius);
  font-size: 0.96rem;
}
.term-list dt { font-weight: 700; color: var(--accent-text); }
.term-list dd { margin: 0; }
.term-list dd b { display: block; font-weight: 600; }
.term-list dd span { color: var(--text-muted); }
@media (max-width: 620px) {
  .term-list { grid-template-columns: 1fr; gap: 0.2rem; }
  .term-list dt { margin-top: 0.7rem; }
  .term-list dt:first-child { margin-top: 0; }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 11px;
  box-shadow: var(--shadow-lg); z-index: 200; font-size: 0.93rem; max-width: min(92vw, 420px);
}

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty .empty-icon { font-size: 2.4rem; display: block; margin-bottom: 0.5rem; }

kbd {
  font-family: var(--mono); font-size: 0.78rem; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0.05rem 0.35rem;
}

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