/* ── RESET & VARIABLES ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #1a56db;
  --primary-light: #ebf5ff;
  --primary-dark:  #1e40af;
  --success:       #057a55;
  --success-light: #ecfdf5;
  --warning:       #b45309;
  --warning-light: #fffbeb;
  --danger:        #b91c1c;
  --danger-light:  #fef2f2;
  --purple:        #7e3af2;
  --purple-light:  #f5f3ff;
  --gray-50:       #f7f6f2;   /* warm white */
  --gray-100:      #f0eeea;
  --gray-200:      #e5e2dc;
  --gray-400:      #9e9b94;
  --gray-600:      #4b4843;
  --gray-800:      #1c1a17;
  --white:         #ffffff;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:     0 12px 24px rgba(0,0,0,.09), 0 4px 8px rgba(0,0,0,.05);
  --shadow-card:   0 2px 8px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.04);
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-xl:     20px;
  --header-h:      56px;
  --nav-h:         66px;
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: var(--font); border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ── SVG ICON BASE ─────────────────────────────────────────────────────── */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

/* ── HEADER ────────────────────────────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  gap: 12px;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  white-space: nowrap;
}
.logo-icon { width: 1.35rem; height: 1.35rem; }
.header-title {
  flex: 1;
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-400);
  text-align: center;
}
.header-actions { display: flex; gap: 8px; }

/* ── MAIN / SCREENS ────────────────────────────────────────────────────── */
#app-main {
  padding-top: var(--header-h);
  padding-bottom: var(--nav-h);
  min-height: 100dvh;
}
.screen { display: none; }
.screen.active { display: block; }
.screen-content {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

/* ── BOTTOM NAV ────────────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-bottom: 4px;
  padding-top: 2px;
  color: var(--gray-400);
  -webkit-tap-highlight-color: transparent;
  border-top: 3px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav-item.active {
  color: var(--gray-800);
  border-top-color: var(--primary);
}
.nav-icon { width: 1.4rem; height: 1.4rem; display: block; }
.nav-label { font-size: .62rem; font-weight: 700; letter-spacing: .03em; }

/* ── SECTION TITLE ─────────────────────────────────────────────────────── */
.section-title {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gray-400);
  margin: 20px 0 10px;
}

/* ── BÜCHER GRID ───────────────────────────────────────────────────────── */
.buecher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.buch-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all .18s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.buch-card:active { transform: scale(.97); }
.buch-card.active {
  border-color: var(--buch-color, var(--primary));
  background: linear-gradient(145deg, var(--buch-bg, var(--primary-light)), var(--white));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--buch-color, var(--primary)) 20%, transparent),
              var(--shadow-card);
}
.buch-abbr {
  font-size: .65rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: .06em;
  align-self: flex-start;
  margin-bottom: 2px;
}
.buch-name {
  font-size: .82rem;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1.2;
}
.buch-count { font-size: .65rem; color: var(--gray-400); font-weight: 500; }
.buch-progress-bar {
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.buch-progress-fill { height: 100%; border-radius: 2px; transition: width .5s ease; }
.buch-pct {
  font-size: .65rem;
  font-weight: 800;
  color: var(--buch-color, var(--primary));
  text-align: right;
}

/* ── HOME HERO ─────────────────────────────────────────────────────────── */
.home-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-xl);
  padding: 20px;
  color: white;
  box-shadow: 0 8px 28px rgba(26,86,219,.28);
  margin-bottom: 16px;
  transition: background .4s, box-shadow .4s;
}
.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.hero-book-badge {
  font-size: .75rem;
  font-weight: 800;
  background: rgba(255,255,255,.18);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: .03em;
}
.hero-streak-badge {
  font-size: .8rem;
  font-weight: 700;
  background: rgba(255,255,255,.18);
  padding: 4px 10px;
  border-radius: 20px;
}
.hero-center { margin-bottom: 18px; }
.hero-due-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.hero-due-num {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
}
.hero-due-lbl {
  font-size: .875rem;
  font-weight: 600;
  opacity: .85;
}
.hero-progress-track {
  height: 6px;
  background: rgba(255,255,255,.2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.hero-progress-fill {
  height: 100%;
  background: rgba(255,255,255,.7);
  border-radius: 3px;
  transition: width .6s ease;
}
.hero-progress-meta {
  font-size: .7rem;
  opacity: .7;
  font-weight: 500;
}
.hero-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.hero-btn-primary {
  background: rgba(255,255,255,.95);
  color: var(--primary-dark);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: .9rem;
  font-weight: 800;
  text-align: center;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.hero-btn-primary:active { transform: scale(.97); opacity: .9; }
.hero-btn-secondary {
  background: rgba(255,255,255,.18);
  color: white;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.hero-btn-secondary:active { background: rgba(255,255,255,.28); }

/* ── QUICK ACTIONS (fallback / used in other screens) ──────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 4px;
}
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-weight: 700;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.action-btn:active { transform: scale(.97); }
.action-btn.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(26,86,219,.3);
}
.action-btn.primary:hover { background: var(--primary-dark); }
.action-btn.secondary {
  background: var(--primary-light);
  color: var(--primary);
}
.action-btn.large { padding: 16px 24px; font-size: 1rem; width: 100%; }
.action-icon { font-size: 1.1rem; }

/* ── KATEGORIE LIST ────────────────────────────────────────────────────── */
.kategorie-list { display: flex; flex-direction: column; gap: 8px; }
.kat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-card);
  border-left: 4px solid transparent;
  transition: transform .15s;
}
.kat-card:active { transform: scale(.99); }
.kat-abbr {
  font-size: .6rem;
  font-weight: 900;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .04em;
}
.kat-info { flex: 1; min-width: 0; }
.kat-name { font-size: .875rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kat-sub { font-size: .68rem; color: var(--gray-400); margin-top: 2px; }
.kat-bar-wrap { width: 60px; }
.kat-pct { font-size: .7rem; font-weight: 800; text-align: right; margin-bottom: 3px; }
.kat-bar { height: 5px; border-radius: 3px; background: var(--gray-100); overflow: hidden; }
.kat-bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }

/* ── DUE LIST ──────────────────────────────────────────────────────────── */
.due-list { display: flex; gap: 8px; flex-wrap: wrap; }
.due-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--warning);
  cursor: pointer;
}

/* ── FILTER BARS ───────────────────────────────────────────────────────── */
.filter-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-600);
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.filter-chip.active {
  background: var(--primary);
  color: white;
}

/* ── FILTER SCROLL FADE ────────────────────────────────────────────────── */
.filter-bar.has-overflow {
  -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
  mask-image: linear-gradient(to right, black 80%, transparent 100%);
}

/* ── DECK PROGRESS ─────────────────────────────────────────────────────── */
.deck-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.deck-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}
.deck-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .4s ease;
}
.deck-counter { font-size: .75rem; font-weight: 700; color: var(--gray-400); white-space: nowrap; }
.due-only-btn {
  font-size: .68rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: var(--gray-100);
  color: var(--gray-400);
  white-space: nowrap;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.due-only-btn.active {
  background: var(--warning-light);
  border-color: #fcd34d;
  color: var(--warning);
}
.due-only-btn:disabled { opacity: .4; cursor: default; }

/* ── FLASHCARD ─────────────────────────────────────────────────────────── */
.flashcard-wrap {
  perspective: 1200px;
  margin-bottom: 16px;
}
.flashcard {
  width: 100%;
  min-height: 290px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 290px;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4, 0, .2, 1);
}
.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  inset: 0;
  min-height: 290px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

/* Card Front */
.flashcard-front {
  background: var(--white);
  align-items: center;
  justify-content: center;
  text-align: center;
}
.card-kategorie {
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 4px 11px;
  border-radius: 12px;
  margin-bottom: 18px;
  align-self: flex-start;
}
.card-para-num {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 10px;
  letter-spacing: -.02em;
}
.card-para-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 24px;
  line-height: 1.3;
}
.card-hint {
  font-size: .68rem;
  color: var(--gray-400);
  margin-top: auto;
}
.card-rechtsart {
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  margin-top: 8px;
}

/* Card Back */
.flashcard-back {
  background: var(--white);
  transform: rotateY(180deg);
  overflow: auto;
}
.card-back-title {
  font-size: .9rem;
  font-weight: 800;
  color: var(--gray-600);
  margin-bottom: 12px;
}

/* ── MERKSATZ — pädagogischer Anker ────────────────────────────────────── */
.card-merksatz {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 14px 14px 16px;
  margin-bottom: 14px;
  position: relative;
}
.card-merksatz::before {
  content: 'Merksatz';
  display: block;
  font-size: .58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--primary);
  opacity: .75;
  margin-bottom: 6px;
}
.card-merksatz-text {
  font-size: .95rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.5;
}
.card-summary {
  font-size: .85rem;
  line-height: 1.65;
  color: var(--gray-600);
  margin-bottom: 12px;
}
.card-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
}
.keyword-chip {
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
}

/* ── RATING BUTTONS ────────────────────────────────────────────────────── */
.rating-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  font-size: .78rem;
  font-weight: 800;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.rating-btn:active { transform: scale(.94); }
.rating-btn .icon { width: 1.5rem; height: 1.5rem; }
.rating-interval { font-size: .65rem; font-weight: 600; opacity: .65; letter-spacing: .02em; }

.card-quiz-marker {
  font-size: .68rem;
  font-weight: 700;
  color: #c2410c;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 20px;
  padding: 3px 10px;
  margin-top: 4px;
}
.rating-btn.hard   { background: var(--danger-light);   color: var(--danger); }
.rating-btn.medium { background: var(--warning-light);  color: var(--warning); }
.rating-btn.easy   { background: var(--success-light);  color: var(--success); }

/* ── DECK DONE ─────────────────────────────────────────────────────────── */
.deck-done, .quiz-done {
  text-align: center;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.done-icon { font-size: 3rem; color: var(--primary); }
.done-icon .icon { width: 3rem; height: 3rem; }
.done-title { font-size: 1.25rem; font-weight: 800; }
.done-sub { font-size: .875rem; color: var(--gray-600); }

/* ── RELATED SECTION ───────────────────────────────────────────────────── */
.related-section { padding: 12px 0; }
.related-label {
  font-size: .62rem;
  font-weight: 800;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 8px;
}
.related-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.related-chip {
  background: var(--primary-light);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
}
.related-chip:active { background: var(--primary); color: white; }

/* ── QUIZ ──────────────────────────────────────────────────────────────── */
.quiz-score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 10px;
}
.quiz-remaining { color: var(--gray-400); font-weight: 600; }
.quiz-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 14px;
  min-height: 120px;
  position: relative;
}
.quiz-diff-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 10px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.quiz-scenario {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--gray-800);
  font-weight: 500;
}
.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.quiz-answer-btn {
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  background: var(--white);
  border: 2px solid var(--gray-200);
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}
.quiz-answer-btn:active { transform: scale(.99); }
.quiz-answer-btn:disabled { cursor: default; }
.quiz-answer-btn.correct {
  background: var(--success-light);
  border-color: #6ee7b7;
  color: var(--success);
}
.quiz-answer-btn.wrong {
  background: var(--danger-light);
  border-color: #fca5a5;
  color: var(--danger);
}
.quiz-answer-btn.dimmed { opacity: .4; }
.answer-num {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* Quiz Explanation */
.quiz-explanation {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}
.explanation-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.explanation-icon { width: 1.5rem; height: 1.5rem; flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; }
.explanation-icon.icon-correct { color: var(--success); }
.explanation-icon.icon-wrong   { color: var(--danger); }
.explanation-text { font-size: .875rem; line-height: 1.65; color: var(--gray-600); }

/* Merksatz-Verstärker im Quiz */
.quiz-merksatz-hint {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px 10px 14px;
  margin-bottom: 14px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.5;
}
.quiz-merksatz-hint::before {
  content: 'Merksatz: ';
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .7;
  display: block;
  margin-bottom: 4px;
}

.quiz-final-score { font-size: 2.2rem; font-weight: 900; color: var(--primary); }
.quiz-start-wrap { text-align: center; padding: 16px 0; }
.quiz-count-hint { font-size: .8rem; color: var(--gray-400); margin-top: 10px; font-weight: 500; }

/* ── STATISTICS ────────────────────────────────────────────────────────── */
.stats-header {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}
.stats-overall {
  flex: 1;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.stats-big-num { font-size: 2.5rem; font-weight: 900; line-height: 1; }
.stats-big-lbl { font-size: .75rem; opacity: .85; margin-top: 4px; }
.stats-streak-box {
  width: 100px;
  background: linear-gradient(135deg, #ff6b35, #f7931e);
  color: white;
  border-radius: var(--radius-lg);
  padding: 18px 12px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.stats-streak-num { font-size: 1.4rem; font-weight: 800; }
.stats-streak-lbl { font-size: .65rem; opacity: .85; margin-top: 4px; }

/* Streak Calendar */
.streak-calendar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.cal-day {
  width: calc((100% - 65px) / 14);
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--gray-100);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .55rem;
  color: var(--gray-400);
  font-weight: 700;
}
.cal-day.active { background: var(--primary); color: white; }
.cal-day.today { box-shadow: 0 0 0 2px var(--primary); }

/* Stats bars */
.stats-bars { display: flex; flex-direction: column; gap: 10px; }
.stats-bar-item {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
}
.stats-bar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stats-bar-name { font-size: .85rem; font-weight: 700; }
.stats-bar-pct { font-size: .8rem; font-weight: 800; }
.stats-bar-track { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.stats-bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }

/* Weak list */
.weak-list { display: flex; flex-direction: column; gap: 6px; }
.weak-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.weak-item:active { opacity: .8; }
.weak-num {
  font-size: .9rem;
  font-weight: 900;
  color: var(--primary);
  min-width: 44px;
  white-space: nowrap;
}
.weak-title { font-size: .8rem; font-weight: 600; flex: 1; }
.weak-score { font-size: .7rem; color: var(--danger); font-weight: 700; }

/* Export / Import / Reset */
.stats-footer { margin-top: 24px; text-align: center; padding-bottom: 8px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stats-io-btns { display: flex; gap: 8px; }
.io-btn {
  font-size: .82rem;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.io-btn:active { background: var(--primary); color: white; }
.reset-btn {
  font-size: .75rem;
  color: var(--gray-400);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-weight: 600;
}

/* ── MODAL ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
  animation: fadeIn .15s ease;
}
.modal-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--gray-800);
  margin-bottom: 10px;
}
.modal-body {
  font-size: .875rem;
  line-height: 1.6;
  color: var(--gray-600);
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 700;
  transition: all .15s;
}
.modal-btn.cancel {
  background: var(--gray-100);
  color: var(--gray-600);
}
.modal-btn.cancel:hover { background: var(--gray-200); }
.modal-btn.danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 2px 8px rgba(185,28,28,.3);
}
.modal-btn.danger:hover { opacity: .9; }

/* ── TOAST ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--gray-800);
  color: white;
  font-size: .85rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 20px;
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── DIFFICULTY BADGES ─────────────────────────────────────────────────── */
.diff-einfach { background: var(--success-light); color: var(--success); }
.diff-mittel   { background: var(--warning-light); color: var(--warning); }
.diff-experte  { background: var(--danger-light);  color: var(--danger); }

/* ── EMPTY STATE ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; color: var(--primary); }
.empty-state .empty-icon .icon { width: 2.5rem; height: 2.5rem; }
.empty-state p { font-size: .875rem; }

/* ── KEYBOARD HINT ─────────────────────────────────────────────────────── */
.keyboard-hint {
  display: none;
  font-size: .65rem;
  color: var(--gray-400);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: .02em;
}
@media (hover: hover) and (pointer: fine) {
  .keyboard-hint { display: block; }
}

/* ── ANIMATIONS ────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen.active .screen-content { animation: fadeIn .22s ease; }

@keyframes pulseScale {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

/* ── SAFE AREA (iPhone notch) ──────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  #app-main   { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ── DESKTOP ADJUSTMENTS ───────────────────────────────────────────────── */
@media (min-width: 600px) {
  .screen-content { padding: 20px 24px; }
  .flashcard { min-height: 320px; }
  .flashcard-inner { min-height: 320px; }
  .flashcard-face { min-height: 320px; }
  .hero-due-num { font-size: 3.8rem; }
}

/* ── DARK MODE ─────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --gray-50:       #0d0f14;
    --gray-100:      #1a1d24;
    --gray-200:      #272b35;
    --gray-400:      #6b7280;
    --gray-600:      #9ca3af;
    --gray-800:      #f1f3f6;
    --white:         #161921;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
    --shadow-md:     0 4px 12px rgba(0,0,0,.4),  0 2px 4px rgba(0,0,0,.25);
    --shadow-lg:     0 12px 24px rgba(0,0,0,.45), 0 4px 8px rgba(0,0,0,.25);
    --shadow-card:   0 2px 8px rgba(0,0,0,.3),   0 0 0 1px rgba(255,255,255,.05);
    --primary-light: #1e3a5f;
    --success-light: #052e16;
    --warning-light: #431a07;
    --danger-light:  #450a0a;
    --purple-light:  #2e1065;
  }

  /* Header & Nav */
  #app-header  { border-bottom-color: var(--gray-200); }
  #bottom-nav  { border-top-color: var(--gray-200); }

  /* Flashcard back: Merksatz-Gradient */
  .card-merksatz {
    background: linear-gradient(135deg, #1e2d4a, #162035);
    border-left-color: var(--primary);
  }
  .card-merksatz-text { color: #93c5fd; }
  .card-merksatz::before { color: #60a5fa; }

  /* Quiz Merksatz hint */
  .quiz-merksatz-hint {
    background: linear-gradient(135deg, #1e2d4a, #162035);
    color: #93c5fd;
  }

  /* Hero buttons on colored background: stay legible */
  .hero-btn-primary {
    background: rgba(255,255,255,.12);
    color: #ffffff;
  }
  .hero-btn-secondary {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.25);
  }

  /* Filter chips */
  .filter-chip         { background: var(--gray-100); color: var(--gray-600); }
  .filter-chip.active  { background: var(--primary);  color: #fff; }

  /* Quiz answer buttons */
  .quiz-answer-btn { background: var(--gray-100); border-color: var(--gray-200); color: var(--gray-800); }
  .quiz-answer-btn.correct { background: #052e16; border-color: #166534; color: #86efac; }
  .quiz-answer-btn.wrong   { background: #450a0a; border-color: #991b1b; color: #fca5a5; }

  /* Difficulty badges */
  .diff-einfach { background: #052e16; color: #86efac; }
  .diff-mittel  { background: #431a07; color: #fdba74; }
  .diff-experte { background: #450a0a; color: #fca5a5; }

  /* Streak calendar */
  .cal-day        { background: var(--gray-100); color: var(--gray-400); }
  .cal-day.active { background: var(--primary);  color: #fff; }
  .cal-day.today  { box-shadow: 0 0 0 2px var(--primary); }

  /* Modal overlay */
  .modal-overlay { background: rgba(0,0,0,.7); }
  .modal-box     { background: var(--white); }
}
