:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-alt: #faf8f3;
  --text: #2b2b2b;
  --muted: #6b6b6b;
  --primary: #3a5a78;
  --primary-dark: #2c4760;
  --accent: #a6792e;
  --border: #e2ddd2;
  --good: #2e7d4f;
  --bad: #b23a3a;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #1b1f24;
  --surface: #252b32;
  --surface-alt: #2c333b;
  --text: #e8e6e1;
  --muted: #a0a6ad;
  --primary: #6f9bc4;
  --primary-dark: #5683ad;
  --accent: #d6ad5c;
  --border: #3a424b;
  --good: #5cc98a;
  --bad: #e07a7a;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

/* Topbar */
.topbar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 2rem; line-height: 1; }
.topbar h1 { margin: 0; font-size: 1.35rem; }
.subtitle { margin: 0; font-size: 0.85rem; opacity: 0.85; }
.theme-toggle {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.3); }

/* Tabs */
.tabbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 10;
}
.tab {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab:hover { background: var(--surface-alt); color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

/* Layout */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}
.loading { text-align: center; color: var(--muted); padding: 40px; }

h2.view-title { margin: 0 0 4px; font-size: 1.5rem; }
.view-intro { color: var(--muted); margin: 0 0 22px; }

/* Cards / grids */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.topic-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.topic-card .icon { font-size: 2rem; }
.topic-card h3 { margin: 8px 0 4px; font-size: 1.1rem; }
.topic-card p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.topic-card .meta { margin-top: 12px; font-size: 0.78rem; color: var(--accent); font-weight: 600; }

/* Progress bar */
.progress-wrap { margin-top: 10px; }
.progress-track { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--good); height: 100%; width: 0; transition: width 0.4s; }
.progress-label { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

/* Dashboard stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 0.82rem; color: var(--muted); }

/* Buttons */
.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

.topic-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--muted);
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Lerntexte */
.text-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.text-block h3 { margin: 0 0 10px; color: var(--primary); }
.text-block p { white-space: pre-wrap; margin: 0; }

/* Flashcards */
.flashcard-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.flashcard {
  width: 100%;
  max-width: 520px;
  min-height: 240px;
  perspective: 1200px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 240px;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
}
.flashcard-face .tag { position: absolute; top: 12px; left: 16px; font-size: 0.72rem; color: var(--accent); font-weight: 600; }
.flashcard-face .content { font-size: 1.15rem; }
.flashcard-face.back { transform: rotateY(180deg); background: var(--surface-alt); }
.flashcard-hint { color: var(--muted); font-size: 0.82rem; }
.flashcard-counter { color: var(--muted); font-size: 0.9rem; }

/* Quiz */
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  max-width: 640px;
  margin: 0 auto;
}
.quiz-question { font-size: 1.15rem; font-weight: 600; margin: 0 0 16px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  cursor: pointer;
  font-size: 0.98rem;
  color: var(--text);
  transition: all 0.12s;
}
.quiz-option:hover:not(:disabled) { border-color: var(--primary); }
.opt-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-right: 10px; flex: 0 0 auto;
  background: var(--border); color: var(--muted); border-radius: 6px;
  font-size: 0.8rem; font-weight: 700;
}
.quiz-option { display: flex; align-items: center; }
.quiz-option.correct { background: rgba(46, 125, 79, 0.16); border-color: var(--good); }
.quiz-option.wrong { background: rgba(178, 58, 58, 0.14); border-color: var(--bad); }
.quiz-option:disabled { cursor: default; }
.quiz-explain {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  font-size: 0.9rem;
}
.quiz-progress { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; text-align: center; }
.quiz-result { text-align: center; padding: 20px; }
.quiz-result .big { font-size: 2.4rem; font-weight: 700; color: var(--primary); }

/* Notes */
.notes-editor { display: flex; flex-direction: column; gap: 10px; }
textarea.notes-area {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.6;
}
.save-state { font-size: 0.82rem; color: var(--good); height: 1em; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
  padding: 16px;
}

.empty { color: var(--muted); text-align: center; padding: 30px; }
.big-empty { font-size: 1.6rem; line-height: 1.4; }
.big-empty .muted, .muted { color: var(--muted); font-size: 0.9rem; font-weight: 400; }

/* Topbar-Buttons */
.topbar-actions { display: flex; gap: 8px; }

/* Update-Banner */
.update-banner {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 100; display: flex; align-items: center; gap: 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  padding: 8px 10px 8px 18px; max-width: calc(100% - 24px);
}
.update-banner .btn { padding: 8px 16px; border-radius: 999px; }
.update-x {
  background: transparent; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer; padding: 4px 8px; line-height: 1;
}
.update-x:hover { color: var(--text); }

/* Vers des Tages */
.verse-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.verse-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); font-weight: 700; }
.verse-text { margin: 6px 0 2px; font-size: 1.05rem; font-style: italic; }
.verse-ref { margin: 0; font-size: 0.82rem; color: var(--muted); text-align: right; }

/* Streak & Tagesziel */
.learn-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; margin-bottom: 14px; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
}
.chip.goal { flex-direction: column; align-items: stretch; gap: 0; }
.chip-icon { font-size: 1.8rem; }
.chip-num { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.chip-lbl { font-size: 0.78rem; color: var(--muted); }

/* CTA-Buttons */
.cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.btn.big { padding: 16px; font-size: 1.02rem; font-weight: 600; }
.badge {
  display: inline-block; background: var(--accent); color: #fff; border-radius: 999px;
  padding: 1px 9px; font-size: 0.82rem; margin-left: 6px; font-weight: 700;
}

/* 6-Wochen-Plan */
.plan-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 26px; overflow: hidden;
}
.plan-card summary {
  cursor: pointer; padding: 16px 18px; font-weight: 600; display: flex;
  justify-content: space-between; align-items: center; gap: 10px; list-style: none;
}
.plan-card summary::-webkit-details-marker { display: none; }
.plan-card summary::after { content: '▾'; color: var(--muted); transition: transform 0.2s; }
.plan-card[open] summary::after { transform: rotate(180deg); }
.plan-prog { font-size: 0.82rem; color: var(--accent); font-weight: 700; }
.plan-body { padding: 0 18px 14px; }
.plan-week { margin-bottom: 12px; }
.plan-week-title { font-size: 0.82rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.check-item { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; cursor: pointer; }
.check-item input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--good); flex: 0 0 auto; }
.check-item.done span { text-decoration: line-through; color: var(--muted); }

/* Prüfungs-Review */
.review-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px;
}
.review-q { font-weight: 600; margin-bottom: 4px; }
.review-a { font-size: 0.92rem; }
.review-e { font-size: 0.86rem; color: var(--muted); margin-top: 4px; }

@media (max-width: 560px) {
  .topbar h1 { font-size: 1.15rem; }
  .container { padding: 16px 12px 50px; }
  .cta-row { grid-template-columns: 1fr; }
  .learn-row { grid-template-columns: 1fr 1fr; }
}
