/* ─── Variables & Reset ───────────────────────────────────────────────────── */
:root {
  --black:  #1a1a1a;
  --red:    #CC0000;
  --gold:   #FFCC00;
  --gold-d: #c9a000;
  --white:  #FFFFFF;
  --bg:     #f5f5f5;
  --card:   #FFFFFF;
  --border: #e0e0e0;
  --text:   #222222;
  --muted:  #666666;
  --green:  #1e7e34;
  --green-bg: #d4edda;
  --red-bg:   #f8d7da;
  --blue:   #0066cc;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: var(--font); }
a { color: var(--blue); }

/* ─── App Shell ───────────────────────────────────────────────────────────── */
#app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Top Bar ─────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--black);
  color: var(--white);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-flag { font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 1.1rem;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.15); }

/* ─── German flag accent strip ──────────────────────────────────────────── */
.flag-strip {
  height: 5px;
  background: linear-gradient(to right, var(--black) 33.3%, var(--red) 33.3%, var(--red) 66.6%, var(--gold) 66.6%);
}

/* ─── Main Content ────────────────────────────────────────────────────────── */
.view { flex: 1; padding: 16px; }

/* ─── Home Screen ─────────────────────────────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: 24px 0 20px;
}
.home-hero h1 { font-size: 1.5rem; font-weight: 700; color: var(--black); }
.home-hero p { color: var(--muted); margin-top: 4px; font-size: 0.9rem; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.mode-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s, box-shadow 0.2s;
}
.mode-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.mode-card .icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.mode-card .label { font-weight: 700; font-size: 0.95rem; color: var(--black); display: block; }
.mode-card .desc { font-size: 0.78rem; color: var(--muted); margin-top: 4px; line-height: 1.3; }

.stats-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stats-card h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 12px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.stat-label { font-size: 0.9rem; color: var(--text); }
.stat-value { font-weight: 600; font-size: 0.9rem; }
.mini-bar { height: 6px; background: var(--border); border-radius: 3px; flex: 1; margin: 0 10px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--gold-d); border-radius: 3px; transition: width 0.4s; }

/* ─── Section Header ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gold);
}
.section-header .back-btn {
  background: none;
  border: none;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text);
  transition: background 0.15s;
}
.section-header .back-btn:hover { background: var(--border); }
.section-header h2 { font-size: 1.1rem; font-weight: 700; flex: 1; }

/* ─── Question Card ───────────────────────────────────────────────────────── */
.q-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}
.q-card-head {
  background: var(--black);
  color: var(--white);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}
.q-num { font-weight: 700; }
.q-cat { color: #ccc; font-size: 0.75rem; }
.q-dynamic-badge {
  background: var(--gold);
  color: var(--black);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.q-card-body { padding: 16px; }
.q-de {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 14px;
  color: var(--black);
}
.q-de .lang-tag { font-size: 0.7rem; font-weight: 700; color: var(--muted); margin-right: 6px; vertical-align: middle; }

/* ─── Options (Learn Mode) ─────────────────────────────────────────────────── */
.options-learn { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.options-learn li {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  transition: background 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.options-learn li .opt-letter {
  font-weight: 700;
  color: var(--muted);
  min-width: 18px;
  font-size: 0.8rem;
}
.options-learn li.correct {
  border-color: var(--green);
  background: var(--green-bg);
}
.options-learn li.correct .opt-letter { color: var(--green); }
.opt-de { flex: 1; }
.opt-en { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 2px; font-style: italic; }

/* ─── Options (Practice/Mock) ──────────────────────────────────────────────── */
.options-practice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.opt-btn {
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 12px 10px;
  font-size: 0.9rem;
  text-align: left;
  line-height: 1.3;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 52px;
}
.opt-btn:not(:disabled):hover { border-color: var(--gold); background: #fffdf0; }
.opt-btn .opt-letter { font-weight: 700; color: var(--muted); font-size: 0.8rem; min-width: 16px; }
.opt-btn.selected { border-color: var(--blue); background: #e8f0fb; }
.opt-btn.correct  { border-color: var(--green); background: var(--green-bg); }
.opt-btn.wrong    { border-color: var(--red); background: var(--red-bg); }
.opt-btn.reveal-correct { border-color: var(--green); background: var(--green-bg); }
.opt-btn:disabled { cursor: default; }

/* ─── Reveal / Explanation ───────────────────────────────────────────────── */
.reveal-block {
  border-top: 1.5px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
}
.q-en {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 10px;
  font-style: italic;
}
.explanation {
  background: #f9f9f9;
  border-left: 3px solid var(--gold-d);
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
}
.explanation .exp-label {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gold-d);
  margin-bottom: 4px;
  display: block;
}
.dynamic-warning {
  background: #fff8e1;
  border: 1.5px solid var(--gold);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #5a4000;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.image-note {
  background: #e8f0fb;
  border: 1.5px solid var(--blue);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #003d7a;
  margin-bottom: 10px;
}
.q-image {
  margin: 0 0 12px;
  text-align: center;
}
.q-image img {
  max-width: 100%;
  max-height: 320px;
  border: 1px solid var(--border, #d6d6d6);
  border-radius: 8px;
  background: #fff;
}

/* ─── Navigation Controls ────────────────────────────────────────────────── */
.nav-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
}
.btn-nav {
  border: none;
  background: var(--black);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-nav:hover:not(:disabled) { background: #333; }
.btn-nav:disabled { background: #ccc; cursor: default; }
.btn-primary {
  border: none;
  background: var(--gold-d);
  color: var(--black);
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--gold); transform: translateY(-1px); }
.btn-secondary {
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.btn-secondary:hover { border-color: var(--gold-d); background: #fffdf0; }
.btn-danger {
  border: 2px solid var(--red);
  background: transparent;
  color: var(--red);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-danger:hover { background: var(--red-bg); }
.progress-text { font-size: 0.85rem; color: var(--muted); text-align: center; }

/* ─── Progress Bar ───────────────────────────────────────────────────────── */
.progress-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--gold-d), var(--gold));
  border-radius: 4px;
  transition: width 0.4s;
}

/* ─── Score Badge ────────────────────────────────────────────────────────── */
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--black);
  border-radius: var(--radius);
  color: var(--white);
}
.score-num { font-size: 1.1rem; font-weight: 700; }
.score-label { font-size: 0.8rem; color: #ccc; }

/* ─── Category Filter ────────────────────────────────────────────────────── */
.filter-bar {
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.filter-select {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: var(--font);
  background: var(--card);
  color: var(--text);
}
.filter-select:focus { outline: none; border-color: var(--gold-d); }
.jump-input {
  width: 64px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: var(--font);
  background: var(--card);
  color: var(--text);
}
.jump-input:focus { outline: none; border-color: var(--gold-d); }
.btn-jump {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font);
  background: var(--gold);
  color: #1a1a1a;
  cursor: pointer;
}
.btn-jump:hover { background: var(--gold-d); }

/* ─── Mock Test Timer ─────────────────────────────────────────────────────── */
.mock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--black);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.mock-timer {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mock-timer.warning { color: var(--gold); }
.mock-timer.danger { color: #ff6b6b; }
.mock-progress { font-size: 0.85rem; color: #ccc; }

.mock-nav-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
}
.mock-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mock-dot.answered { border-color: var(--gold-d); background: #fffdf0; }
.mock-dot.current  { border-color: var(--black); background: var(--black); color: var(--white); }

/* ─── Results Screen ──────────────────────────────────────────────────────── */
.results-hero {
  text-align: center;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.results-score {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--black);
  line-height: 1;
}
.results-denom { font-size: 1.2rem; color: var(--muted); }
.results-verdict {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 8px 0;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
}
.verdict-pass { background: var(--green-bg); color: var(--green); }
.verdict-fail { background: var(--red-bg); color: var(--red); }
.results-meta { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.review-item.correct-item { border-left-color: var(--green); }
.review-item.wrong-item   { border-left-color: var(--red); }
.review-item .rq-num { font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.review-item .rq-de { font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }
.review-item .rq-ans { font-size: 0.82rem; display: flex; gap: 8px; flex-wrap: wrap; }
.rq-ans .your-ans { color: var(--red); }
.rq-ans .right-ans { color: var(--green); }

/* ─── Learn Mode specific ────────────────────────────────────────────────── */
.learned-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.learned-toggle input { accent-color: var(--gold-d); width: 16px; height: 16px; }

/* ─── Toast notifications ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.88rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 2.5rem; display: block; margin-bottom: 12px; }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 16px 16px 24px;
  line-height: 1.5;
}

/* ─── Keyboard focus ─────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .mode-grid { grid-template-columns: 1fr; }
  .options-practice { grid-template-columns: 1fr; }
  .results-actions { flex-direction: column; }
  .results-actions button { width: 100%; }
}
