/* ── Design Tokens ── */
:root, [data-theme='light'] {
  --font-display: 'Plus Jakarta Sans', 'Helvetica Neue', sans-serif;
  --font-body: 'General Sans', 'Helvetica Neue', sans-serif;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem; --space-20: 5rem; --space-24: 6rem;
  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --content-narrow: 640px; --content-default: 960px; --content-wide: 1200px;

  /* Education palette — warm, approachable */
  --color-bg: #f5f5f0;
  --color-surface: #ffffff;
  --color-surface-2: #fafaf7;
  --color-surface-offset: #eeeee8;
  --color-divider: #e0dfd8;
  --color-border: #d2d0c8;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b60;
  --color-text-faint: #a5a59c;
  --color-text-inverse: #ffffff;
  --color-primary: #1a6b4e;
  --color-primary-hover: #145a40;
  --color-primary-active: #0e4833;
  --color-primary-light: #e8f5ee;
  --color-primary-highlight: #d0ead9;
  --color-success: #2d7a2d;
  --color-success-light: #e6f5e6;
  --color-error: #c53030;
  --color-error-light: #fde8e8;
  --color-warning: #d69e2e;
  --color-accent: #2563eb;
  --color-accent-light: #e8f0fe;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
}

[data-theme='dark'] {
  --color-bg: #141413;
  --color-surface: #1c1c1a;
  --color-surface-2: #222220;
  --color-surface-offset: #1a1a18;
  --color-divider: #2a2a28;
  --color-border: #3a3a36;
  --color-text: #e8e8e0;
  --color-text-muted: #9a9a90;
  --color-text-faint: #6a6a60;
  --color-text-inverse: #1a1a1a;
  --color-primary: #4ead7a;
  --color-primary-hover: #3d9868;
  --color-primary-active: #2f8458;
  --color-primary-light: #1a2e24;
  --color-primary-highlight: #243830;
  --color-success: #4ead4e;
  --color-success-light: #1a2e1a;
  --color-error: #f56565;
  --color-error-light: #2e1a1a;
  --color-warning: #ecc94b;
  --color-accent: #5b8def;
  --color-accent-light: #1a2540;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #141413;
    --color-surface: #1c1c1a;
    --color-surface-2: #222220;
    --color-surface-offset: #1a1a18;
    --color-divider: #2a2a28;
    --color-border: #3a3a36;
    --color-text: #e8e8e0;
    --color-text-muted: #9a9a90;
    --color-text-faint: #6a6a60;
    --color-text-inverse: #1a1a1a;
    --color-primary: #4ead7a;
    --color-primary-hover: #3d9868;
    --color-primary-active: #2f8458;
    --color-primary-light: #1a2e24;
    --color-primary-highlight: #243830;
    --color-success: #4ead4e;
    --color-success-light: #1a2e1a;
    --color-error: #f56565;
    --color-error-light: #2e1a1a;
    --color-warning: #ecc94b;
    --color-accent: #5b8def;
    --color-accent-light: #1a2540;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  }
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; scroll-padding-top: var(--space-16); }
body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a, button, input, select, textarea {
  transition: color var(--transition-interactive), background var(--transition-interactive),
    border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
h1, h2, h3, h4 { line-height: 1.2; font-family: var(--font-display); }
::selection { background: rgba(26, 107, 78, 0.2); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex; align-items: center; gap: var(--space-4);
}
.logo { display: flex; align-items: center; gap: var(--space-3); }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); white-space: nowrap; }
.nav { display: flex; gap: var(--space-1); margin-left: auto; }
.nav-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 500;
  color: var(--color-text-muted);
}
.nav-btn:hover { color: var(--color-text); background: var(--color-surface-offset); }
.nav-btn.active { color: var(--color-primary); background: var(--color-primary-light); font-weight: 600; }
.theme-toggle {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  margin-left: var(--space-2);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { color: var(--color-text); background: var(--color-surface-offset); }

/* ── Mobile Nav ── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
  padding: var(--space-2) var(--space-4) max(var(--space-2), env(safe-area-inset-bottom));
  justify-content: space-around;
}
.mobile-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: var(--text-xs); color: var(--color-text-muted);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
}
.mobile-nav-btn.active { color: var(--color-primary); }
.mobile-nav-btn svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
  .nav { display: none; }
  .mobile-nav { display: flex; }
  body { padding-bottom: 72px; }
}

/* ── Main ── */
.main {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Hero ── */
.hero { text-align: center; padding: var(--space-12) 0 var(--space-16); }
.hero-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-4);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-sm); font-weight: 600;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
}
.hero h1 { font-size: var(--text-2xl); font-weight: 800; margin-bottom: var(--space-4); }
.hero-sub { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 600px; margin: 0 auto var(--space-8); }
.hero-actions { display: flex; gap: var(--space-4); justify-content: center; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; border: none;
}
.btn-primary {
  background: var(--color-primary); color: var(--color-text-inverse);
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-offset); }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.btn-back {
  background: none; color: var(--color-text-muted); padding: var(--space-2) 0;
  font-size: var(--text-sm); margin-bottom: var(--space-6);
}
.btn-back:hover { color: var(--color-primary); }

/* ── Stats Grid ── */
.exam-overview { margin-bottom: var(--space-16); }
.exam-overview h2 { font-size: var(--text-xl); margin-bottom: var(--space-8); text-align: center; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
}
.stat-number { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; color: var(--color-primary); }
.stat-label { font-size: var(--text-sm); font-weight: 600; margin-top: var(--space-1); }
.stat-detail { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }

/* ── Topic Bars ── */
.topics-overview { margin-bottom: var(--space-16); }
.topics-overview h2 { font-size: var(--text-xl); margin-bottom: var(--space-8); text-align: center; }
.topic-bars { display: flex; flex-direction: column; gap: var(--space-3); }
.topic-bar-item {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
}
.topic-bar-item:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.topic-bar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-2); }
.topic-bar-name { font-size: var(--text-sm); font-weight: 600; }
.topic-bar-count { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.topic-bar-track { height: 6px; background: var(--color-surface-offset); border-radius: var(--radius-full); overflow: hidden; }
.topic-bar-fill { height: 100%; background: var(--color-primary); border-radius: var(--radius-full); min-width: 4px; }

/* ── Tips ── */
.tips-section { margin-bottom: var(--space-16); }
.tips-section h2 { font-size: var(--text-xl); margin-bottom: var(--space-8); text-align: center; }
.tips-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); }
.tip-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}
.tip-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-sm);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}
.tip-card h3 { font-size: var(--text-sm); font-weight: 700; margin-bottom: var(--space-2); }
.tip-card p { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; }

/* ── Study View ── */
.study-header { text-align: center; margin-bottom: var(--space-8); }
.study-header h1 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.study-header p { color: var(--color-text-muted); font-size: var(--text-sm); }

.study-topic-card {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-3);
  cursor: pointer;
}
.study-topic-card:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.study-topic-num {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-sm);
  border-radius: var(--radius-md);
}
.study-topic-info { flex: 1; }
.study-topic-info h3 { font-size: var(--text-sm); font-weight: 600; }
.study-topic-meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.study-topic-arrow { color: var(--color-text-faint); flex-shrink: 0; }

/* ── Study Content ── */
.study-content h2 {
  font-size: var(--text-xl); margin-bottom: var(--space-6);
  padding-bottom: var(--space-4); border-bottom: 2px solid var(--color-primary);
}
.study-section {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}
.study-section h3 {
  font-size: var(--text-lg); font-weight: 700;
  margin-bottom: var(--space-4);
  color: var(--color-primary);
}
.study-section ul {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: var(--space-3);
}
.study-section ul li {
  padding-left: var(--space-5);
  position: relative;
  font-size: var(--text-sm);
  line-height: 1.7;
  max-width: none;
}
.study-section ul li::before {
  content: '';
  position: absolute; left: 0; top: 10px;
  width: 6px; height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
}
.study-section ul li ul { margin-top: var(--space-2); gap: var(--space-2); }
.study-section ul li ul li::before { width: 4px; height: 4px; background: var(--color-text-muted); }
.study-section strong { color: var(--color-text); }
.key-point {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-sm); font-weight: 500;
  color: var(--color-primary);
}

/* ── Quiz View ── */
.quiz-options { max-width: 500px; margin: var(--space-8) auto 0; }
.quiz-option-group { margin-bottom: var(--space-6); }
.quiz-option-group label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-3); }
.quiz-btn-group { display: flex; gap: var(--space-2); }
.quiz-count-btn {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 600;
  background: var(--color-surface);
  color: var(--color-text);
}
.quiz-count-btn:hover { border-color: var(--color-primary); }
.quiz-count-btn.active { background: var(--color-primary); color: var(--color-text-inverse); border-color: var(--color-primary); }
.quiz-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  appearance: auto;
}

/* Quiz Progress */
.quiz-progress-bar {
  height: 6px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.quiz-status {
  display: flex; justify-content: space-between;
  font-size: var(--text-xs); color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* Quiz Question */
.quiz-topic-tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-xs); font-weight: 600;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}
.quiz-question-text {
  font-size: var(--text-lg); font-weight: 600;
  margin-bottom: var(--space-6);
  line-height: 1.5;
}
.quiz-choices { display: flex; flex-direction: column; gap: var(--space-3); }
.quiz-choice {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--color-primary); background: var(--color-primary-light); }
.quiz-choice.correct { border-color: var(--color-success); background: var(--color-success-light); color: var(--color-success); }
.quiz-choice.incorrect { border-color: var(--color-error); background: var(--color-error-light); color: var(--color-error); }
.quiz-choice:disabled { cursor: default; opacity: 0.85; }

.quiz-explanation {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.7;
}
.quiz-explanation.correct { background: var(--color-success-light); border-left: 3px solid var(--color-success); }
.quiz-explanation.incorrect { background: var(--color-error-light); border-left: 3px solid var(--color-error); }

.quiz-nav { margin-top: var(--space-6); display: flex; justify-content: flex-end; }

/* Quiz Results */
.results-card {
  max-width: 600px; margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  text-align: center;
}
.results-card h2 { font-size: var(--text-xl); margin-bottom: var(--space-6); }
.results-score { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; color: var(--color-text); }
.results-percentage { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800; margin: var(--space-2) 0 var(--space-4); }
.results-percentage.pass { color: var(--color-success); }
.results-percentage.fail { color: var(--color-error); }
.results-message { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-8); }
.results-actions { display: flex; gap: var(--space-4); justify-content: center; flex-wrap: wrap; margin-top: var(--space-8); }

/* Results Breakdown */
.results-breakdown { text-align: left; margin-top: var(--space-8); }
.results-breakdown h3 { font-size: var(--text-sm); font-weight: 700; margin-bottom: var(--space-4); text-align: center; }
.breakdown-list { display: flex; flex-direction: column; gap: var(--space-3); }
.breakdown-item { }
.breakdown-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-1); }
.breakdown-name { font-size: var(--text-xs); font-weight: 500; }
.breakdown-score { font-size: var(--text-xs); font-weight: 700; }
.breakdown-score.pass { color: var(--color-success); }
.breakdown-score.fail { color: var(--color-error); }
.breakdown-bar { height: 6px; background: var(--color-surface-offset); border-radius: var(--radius-full); overflow: hidden; }
.breakdown-fill { height: 100%; border-radius: var(--radius-full); }
.breakdown-fill.pass { background: var(--color-success); }
.breakdown-fill.fail { background: var(--color-error); }

/* ── Flashcards ── */
.flashcard-header { text-align: center; margin-bottom: var(--space-8); }
.flashcard-header h1 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.flashcard-header p { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-6); }
.flashcard-controls {
  display: flex; gap: var(--space-3); justify-content: center; align-items: center; flex-wrap: wrap;
}
.flashcard-controls .quiz-select { width: auto; min-width: 200px; }

.flashcard-area {
  display: flex; align-items: center; justify-content: center; gap: var(--space-4);
  min-height: 300px;
  margin-bottom: var(--space-4);
}
.flashcard-arrow {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.flashcard-arrow:hover { color: var(--color-text); border-color: var(--color-primary); }

.flashcard {
  width: 100%; max-width: 500px;
  min-height: 280px;
  perspective: 1000px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative; width: 100%; min-height: 280px;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.flashcard-inner.flipped { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute; top: 0; left: 0; right: 0;
  min-height: 280px;
  backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 2px solid var(--color-divider);
  border-radius: var(--radius-xl);
  text-align: center;
}
.flashcard-back { transform: rotateY(180deg); background: var(--color-primary-light); border-color: var(--color-primary); }
.fc-topic-label { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-4); }
.fc-term { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; }
.fc-definition { font-size: var(--text-sm); line-height: 1.8; color: var(--color-text); max-width: 420px; }

.flashcard-counter { text-align: center; font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 500; }

/* ── Responsive ── */
/* ── Smart Practice Button ── */
.quiz-start-btns {
  display: flex; gap: var(--space-3); margin-top: var(--space-6); flex-wrap: wrap;
}
.quiz-start-btns .btn { flex: 1; min-width: 160px; }
.btn-smart {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  background: linear-gradient(135deg, var(--color-accent), #7c3aed);
  color: #fff;
  border: none;
}
.btn-smart:hover { filter: brightness(1.08); }
.btn-smart svg { flex-shrink: 0; }

.smart-hint {
  font-size: var(--text-xs); color: var(--color-text-muted);
  text-align: center; margin-top: var(--space-4); line-height: 1.6;
}

/* ── Smart & Missed Tags (Quiz Questions) ── */
.smart-tag {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem; font-weight: 700;
  margin-left: var(--space-2);
  vertical-align: middle;
}
.missed-tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  background: var(--color-error-light);
  color: var(--color-error);
  font-size: var(--text-xs); font-weight: 600;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
}

/* ── Smart Suggestion (Results Card) ── */
.smart-suggestion {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-sm); line-height: 1.6;
  color: var(--color-text);
}
.smart-suggestion strong { color: var(--color-accent); }

/* ── Mastery Badges (Study Topic List) ── */
.mastery-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem; font-weight: 700;
  margin-left: var(--space-2);
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.mastery-badge.mastered { background: var(--color-success-light); color: var(--color-success); }
.mastery-badge.passing { background: var(--color-primary-light); color: var(--color-primary); }
.mastery-badge.needs-work { background: #fef3c7; color: #92400e; }
.mastery-badge.weak { background: var(--color-error-light); color: var(--color-error); }
[data-theme='dark'] .mastery-badge.needs-work { background: #422006; color: var(--color-warning); }

/* ── Progress Dashboard ── */
.progress-header { text-align: center; margin-bottom: var(--space-8); }
.progress-header h1 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.progress-header p { color: var(--color-text-muted); font-size: var(--text-sm); }

.progress-empty {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
}
.progress-empty h2 { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.progress-empty p { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: var(--space-6); }

.progress-overview { margin-bottom: var(--space-6); }
.progress-readiness { margin-bottom: var(--space-8); }
.progress-topics { margin-bottom: var(--space-8); }
.progress-weak { margin-bottom: var(--space-8); }
.progress-history { margin-bottom: var(--space-4); }
.progress-actions { text-align: center; }

.section-sub {
  font-size: var(--text-sm); color: var(--color-text-muted);
  margin-bottom: var(--space-6); line-height: 1.5;
}

.progress-topics h2, .progress-weak h2, .progress-history h2 {
  font-size: var(--text-lg); margin-bottom: var(--space-6);
  padding-bottom: var(--space-3); border-bottom: 2px solid var(--color-divider);
}

/* ── Readiness Card ── */
.readiness-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}
.readiness-card.ready { border-color: var(--color-success); }
.readiness-card.close { border-color: var(--color-warning); }
.readiness-card.not-ready { border-color: var(--color-error); }

.readiness-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-4);
}
.readiness-header h3 { font-size: var(--text-sm); font-weight: 700; }
.readiness-score {
  font-family: var(--font-display); font-size: var(--text-xl);
  font-weight: 800;
}
.readiness-card.ready .readiness-score { color: var(--color-success); }
.readiness-card.close .readiness-score { color: var(--color-warning); }
.readiness-card.not-ready .readiness-score { color: var(--color-error); }

.readiness-bar {
  height: 10px; background: var(--color-surface-offset);
  border-radius: var(--radius-full); overflow: hidden;
  margin-bottom: var(--space-2); position: relative;
}
.readiness-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 0.6s ease;
}
.readiness-card.ready .readiness-fill { background: var(--color-success); }
.readiness-card.close .readiness-fill { background: var(--color-warning); }
.readiness-card.not-ready .readiness-fill { background: var(--color-error); }

.readiness-threshold {
  font-size: var(--text-xs); color: var(--color-text-faint);
  text-align: right; margin-bottom: var(--space-3);
}
.readiness-msg {
  font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6;
}

/* ── Mastery Grid (Progress) ── */
.mastery-grid {
  display: flex; flex-direction: column; gap: var(--space-3);
}
.mastery-item {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.mastery-item-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-2);
}
.mastery-item-title { font-size: var(--text-sm); font-weight: 600; }
.mastery-item-pct {
  font-family: var(--font-display); font-size: var(--text-sm);
  font-weight: 800;
}
.mastery-item.mastered .mastery-item-pct { color: var(--color-success); }
.mastery-item.passing .mastery-item-pct { color: var(--color-primary); }
.mastery-item.needs_work .mastery-item-pct { color: var(--color-warning); }
.mastery-item.weak .mastery-item-pct { color: var(--color-error); }
.mastery-item.not_started .mastery-item-pct { color: var(--color-text-faint); }

.mastery-item-bar {
  height: 6px; background: var(--color-surface-offset);
  border-radius: var(--radius-full); overflow: hidden;
  margin-bottom: var(--space-2);
}
.mastery-item-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 0.5s ease;
}
.mastery-item-fill.mastered { background: var(--color-success); }
.mastery-item-fill.passing { background: var(--color-primary); }
.mastery-item-fill.needs_work { background: var(--color-warning); }
.mastery-item-fill.weak { background: var(--color-error); }
.mastery-item-fill.not_started { background: var(--color-surface-offset); }

.mastery-item-footer {
  display: flex; justify-content: space-between; align-items: center;
}
.mastery-level-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.02em;
}
.mastery-level-badge.mastered { background: var(--color-success-light); color: var(--color-success); }
.mastery-level-badge.passing { background: var(--color-primary-light); color: var(--color-primary); }
.mastery-level-badge.needs_work { background: #fef3c7; color: #92400e; }
.mastery-level-badge.weak { background: var(--color-error-light); color: var(--color-error); }
.mastery-level-badge.not_started { background: var(--color-surface-offset); color: var(--color-text-faint); }
[data-theme='dark'] .mastery-level-badge.needs_work { background: #422006; color: var(--color-warning); }

.mastery-item-detail {
  font-size: var(--text-xs); color: var(--color-text-muted);
}

/* ── Weak Questions List ── */
.weak-questions-list {
  display: flex; flex-direction: column; gap: var(--space-3);
}
.weak-q-item {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.weak-q-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-2);
}
.weak-q-topic {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--color-primary);
}
.weak-q-accuracy {
  font-size: var(--text-xs); font-weight: 700;
  color: var(--color-error);
}
.weak-q-text {
  font-size: var(--text-sm); font-weight: 500;
  line-height: 1.5; margin-bottom: var(--space-2);
}
.weak-q-answer {
  font-size: var(--text-xs); color: var(--color-text-muted);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
}

/* ── History List ── */
.history-list {
  display: flex; flex-direction: column; gap: var(--space-2);
}
.history-item {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
}
.history-date {
  font-size: var(--text-xs); color: var(--color-text-muted);
  min-width: 120px;
}
.history-score {
  font-size: var(--text-sm); font-weight: 600;
  flex: 1;
}
.history-pct {
  font-family: var(--font-display);
  font-size: var(--text-sm); font-weight: 800;
}
.history-pct.pass { color: var(--color-success); }
.history-pct.fail { color: var(--color-error); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: var(--space-6) var(--space-4); }
  .hero { padding: var(--space-8) 0 var(--space-10); }
  .hero h1 { font-size: clamp(1.5rem, 1rem + 3vw, 2.5rem); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .tips-grid { grid-template-columns: 1fr; }
  .flashcard { max-width: 100%; }
  .flashcard-front, .flashcard-back { padding: var(--space-6); min-height: 240px; }
  .flashcard-area { gap: var(--space-2); }
  .results-card { padding: var(--space-6); }
  .quiz-start-btns { flex-direction: column; }
  .quiz-start-btns .btn { min-width: 100%; }
  .history-item { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
  .history-date { min-width: auto; }
  .readiness-score { font-size: var(--text-lg); }
}

/* ── Auth Button ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.auth-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.auth-btn:hover {
  background: var(--color-surface-2);
  border-color: var(--color-primary);
}
.auth-btn.logged-in {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
  min-width: 36px;
  justify-content: center;
}
.auth-btn.logged-in svg { display: none; }
.auth-btn.logged-in:hover {
  background: var(--color-primary-hover);
}

/* ── Auth Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modalOverlayIn 0.2s ease-out;
}
@keyframes modalOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-card {
  background: var(--color-surface);
  border-radius: 1.25rem;
  padding: 0;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 25px 60px -12px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
  overflow: hidden;
  animation: modalCardIn 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes modalCardIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
[data-theme='dark'] .modal-card {
  box-shadow: 0 25px 60px -12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}
.modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-interactive);
  z-index: 2;
}
.modal-close:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
  transform: scale(1.05);
}

/* ── Access Denied Overlay ── */
.access-denied-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: var(--space-4);
  backdrop-filter: blur(6px);
}
.access-denied-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-8) var(--space-6);
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: accessDeniedIn 0.3s ease-out;
}
@keyframes accessDeniedIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.access-denied-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-error-light);
  color: var(--color-error);
}
.access-denied-card h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}
.access-denied-msg {
  color: var(--color-text);
  font-size: var(--text-base);
  margin-bottom: var(--space-2);
  line-height: 1.5;
}
.access-denied-msg strong {
  color: var(--color-error);
  word-break: break-all;
}
.access-denied-sub {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  line-height: 1.5;
}
/* Auth modal header area */
#auth-form-area {
  padding: var(--space-8) var(--space-6) var(--space-6);
}
#auth-form-area h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.auth-sub {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  line-height: 1.4;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.auth-input {
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--color-divider);
  border-radius: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.auth-input::placeholder {
  color: var(--color-text-faint);
}
.auth-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,107,78,0.12);
  background: var(--color-surface);
}
[data-theme='dark'] .auth-input:focus {
  box-shadow: 0 0 0 3px rgba(26,107,78,0.25);
}
.auth-error {
  color: var(--color-error);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: 0.5rem;
  background: var(--color-error-light);
  line-height: 1.4;
}
.auth-submit {
  width: 100%;
  margin-top: var(--space-2);
  padding: 0.875rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 0.75rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  letter-spacing: 0.01em;
}
.auth-submit:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,107,78,0.3);
}
.auth-submit:active:not(:disabled) {
  background: var(--color-primary-active);
  transform: translateY(0);
}
.auth-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.auth-toggle {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.auth-toggle a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}
.auth-toggle a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* Auth profile view */
#auth-profile {
  padding: var(--space-8) var(--space-6) var(--space-6);
}
.auth-profile-info {
  text-align: center;
  margin-bottom: var(--space-6);
}
.auth-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 auto var(--space-3);
  box-shadow: 0 4px 14px rgba(26,107,78,0.25);
  letter-spacing: 0.02em;
}
.auth-user-email {
  font-size: var(--text-base);
  color: var(--color-text);
  font-weight: 500;
}
.auth-sync-status {
  font-size: var(--text-xs);
  color: var(--color-primary);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}
.auth-sync-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  display: inline-block;
}

/* ── Streak Banner (Home) ── */
.streak-banner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-surface));
  border: 1px solid var(--color-primary-highlight);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-6);
}
[data-theme='dark'] .streak-banner {
  background: linear-gradient(135deg, rgba(26,107,78,0.15), var(--color-surface));
  border-color: rgba(26,107,78,0.3);
}
.streak-fire { font-size: 2rem; line-height: 1; }
.streak-info { display: flex; align-items: baseline; gap: var(--space-2); }
.streak-count {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
}
.streak-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.streak-today {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── Review Prompts (Home) ── */
.review-prompts {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.review-prompts-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--color-warning);
}
.review-prompt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.review-prompt-item:hover {
  background: var(--color-surface-2);
}
.review-prompt-topic {
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.review-prompt-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: block;
}
.review-prompt-urgency {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-warning);
  white-space: nowrap;
}

/* ── Exam Timer Bar ── */
.exam-timer-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}
.exam-timer-icon { color: var(--color-primary); display: flex; }
.exam-timer-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  min-width: 80px;
}
.exam-timer-track {
  flex: 1;
  height: 6px;
  background: var(--color-surface-offset);
  border-radius: 3px;
  overflow: hidden;
}
.exam-timer-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 1s linear;
}
.exam-timer-bar.warning .exam-timer-text { color: var(--color-warning); }
.exam-timer-bar.warning .exam-timer-fill { background: var(--color-warning); }
.exam-timer-bar.danger .exam-timer-text { color: var(--color-error); }
.exam-timer-bar.danger .exam-timer-fill { background: var(--color-error); }

/* ── Exam Sim Button ── */
.btn-exam {
  background: var(--color-accent);
  color: white;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.btn-exam:hover { background: #1d4ed8; }

/* ── Weak Area Button ── */
.btn-weak-area {
  background: linear-gradient(135deg, #d97706, #dc2626);
  color: white;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: none;
}
.btn-weak-area:hover { filter: brightness(1.08); }
.btn-weak-area svg { flex-shrink: 0; }

.weak-area-hint {
  font-size: var(--text-xs); color: var(--color-text-muted);
  text-align: center; margin-top: var(--space-2); line-height: 1.6;
}

/* ── Retest Missed Button ── */
.btn-retest {
  background: var(--color-warning);
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  border: none;
  font-weight: 600;
}
.btn-retest:hover { filter: brightness(1.08); }
.btn-retest svg { flex-shrink: 0; }
.results-retest { margin-top: var(--space-5); }

/* ── Weak Topics Chips (Results) ── */
.results-weak-topics {
  margin-top: var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: var(--color-error-light);
  border-left: 3px solid var(--color-error);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.results-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  color: var(--color-error);
}
.results-section-header h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  margin: 0;
  color: var(--color-error);
}
.weak-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.weak-topic-chip {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  background: rgba(197, 48, 48, 0.12);
  color: var(--color-error);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}
[data-theme='dark'] .weak-topic-chip {
  background: rgba(245, 101, 101, 0.15);
}
.weak-topic-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 0;
}

/* ── Missed Stats (Results) ── */
.results-missed-stats {
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
}
.missed-stats-row {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
}
.missed-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}
.missed-stat-num {
  font-size: var(--text-lg);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
}
.missed-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.missed-stats-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-top: var(--space-3);
}

/* ── Recommendation Card (Results) ── */
.results-recommendation {
  margin-top: var(--space-6);
}
.recommendation-card {
  padding: var(--space-5);
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-highlight);
  border-radius: var(--radius-lg);
}
.recommendation-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.recommendation-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.recommendation-text h4 {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.recommendation-label {
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  margin: var(--space-1) 0 0;
}
.recommendation-reason {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 var(--space-4);
}
.recommendation-card .btn {
  width: 100%;
}

/* ── Timed Tag ── */
.timed-tag {
  display: inline-block;
  padding: 1px 8px;
  background: var(--color-accent);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  vertical-align: middle;
  margin-left: var(--space-2);
}

/* ── Results Time ── */
.results-time {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-top: var(--space-3);
}
.results-time-stat {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
}

/* ── Leitner Stats ── */
.leitner-stats {
  margin-bottom: var(--space-6);
}
.leitner-boxes {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.leitner-box-item {
  text-align: center;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-width: 72px;
}
.leitner-box-item.mastered {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
[data-theme='dark'] .leitner-box-item.mastered {
  background: rgba(26,107,78,0.15);
}
.leitner-box-count {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}
.leitner-box-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}
.leitner-box-desc {
  font-size: 0.625rem;
  color: var(--color-text-faint);
  margin-top: 2px;
}
.leitner-due-notice {
  text-align: center;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-warning);
}

/* ── Flashcard Leitner Actions ── */
.leitner-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.btn-leitner-miss {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 2px solid var(--color-error);
  border-radius: var(--radius-lg);
  background: var(--color-error-light);
  color: var(--color-error);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.btn-leitner-miss:hover {
  background: var(--color-error);
  color: white;
}
.btn-leitner-know {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 2px solid var(--color-success);
  border-radius: var(--radius-lg);
  background: var(--color-success-light);
  color: var(--color-success);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.btn-leitner-know:hover {
  background: var(--color-success);
  color: white;
}
.fc-box-label {
  display: inline-block;
  padding: 2px 8px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}
.fc-mode-btns {
  display: flex;
  gap: var(--space-2);
}
.fc-mode-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.fc-due-badge {
  display: inline-block;
  background: var(--color-warning);
  color: white;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 0.625rem;
  font-weight: 700;
  margin-left: 4px;
}

/* ── Streak Dashboard (Progress) ── */
.streak-dashboard {
  margin-bottom: var(--space-8);
}
.streak-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.streak-stat-card {
  text-align: center;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.streak-stat-num {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
}
.streak-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.streak-calendar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.streak-cal-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  font-weight: 500;
}
.streak-cal-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 3px;
}
.streak-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-surface-offset);
  transition: background var(--transition-interactive);
}
.streak-cal-day.studied {
  background: var(--color-primary);
}
.streak-cal-num {
  font-size: 0.5625rem;
  color: var(--color-text-faint);
  font-weight: 500;
}
.streak-cal-day.studied .streak-cal-num {
  color: var(--color-text-inverse);
}

/* ── Mobile Responsive Additions ── */
@media (max-width: 640px) {
  .streak-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .streak-cal-grid {
    grid-template-columns: repeat(10, 1fr);
  }
  .leitner-boxes {
    gap: var(--space-2);
  }
  .leitner-box-item {
    min-width: 56px;
    padding: var(--space-2) var(--space-3);
  }
  .leitner-actions {
    gap: var(--space-2);
  }
  .btn-leitner-miss, .btn-leitner-know {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }
  .streak-banner {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }
  .streak-today {
    margin-left: 0;
    width: 100%;
  }
  .exam-timer-bar {
    flex-wrap: wrap;
  }
  .fc-mode-btns {
    flex-wrap: wrap;
  }
  .review-prompt-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
  .header-actions {
    gap: var(--space-1);
  }
  .auth-btn span {
    display: none;
  }
  .auth-btn.logged-in span {
    display: inline;
  }
  .quiz-start-btns {
    flex-direction: column;
  }
  .results-time {
    flex-direction: column;
    align-items: center;
  }
}


/* ══════════════════════════════════════════
   Admin Dashboard
   ══════════════════════════════════════════ */

/* Nav admin button accent */
.nav-admin-btn {
  color: var(--color-warning) !important;
  font-weight: 600;
}
.nav-admin-btn.active {
  color: var(--color-warning) !important;
  border-color: var(--color-warning) !important;
}
.mobile-admin-btn {
  color: var(--color-warning) !important;
}
.mobile-admin-btn.active {
  color: var(--color-warning) !important;
}

/* Header */
.admin-header {
  margin-bottom: var(--space-6);
}
.admin-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-1);
}
.admin-sub {
  color: var(--color-text-muted);
  font-size: var(--text-base);
}
.admin-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}
.admin-badge svg { flex-shrink: 0; }

/* Add User Form */
/* ── Admin Tabs ── */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-divider);
  margin-bottom: var(--space-6);
  margin-top: var(--space-2);
}
.admin-tab {
  background: none;
  border: none;
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-interactive), border-color var(--transition-interactive);
  min-height: 44px;
}
.admin-tab:hover { color: var(--color-text); }
.admin-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.admin-add-form {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.admin-add-form h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-3);
}
.admin-form-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.admin-input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
  font-family: inherit;
}
.admin-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}
.admin-form-row .admin-input {
  flex: 1;
  min-width: 180px;
}
.admin-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6b60' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.admin-select:focus {
  outline: none;
  border-color: var(--color-primary);
}
.admin-form-error {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-error-light);
  color: var(--color-error);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.admin-form-success {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-success-light);
  color: var(--color-success);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

/* Search & Filter Controls */
.admin-controls {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.admin-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.admin-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}
.admin-search {
  padding-left: 32px !important;
  width: 100%;
}

/* Desktop Table */
.admin-table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.admin-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  white-space: nowrap;
}
.admin-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
  white-space: nowrap;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-row-inactive td { opacity: 0.55; }
.admin-cell-email {
  font-weight: 500;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-cell-actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.admin-you-tag {
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--text-xs);
}
.admin-no-actions {
  color: var(--color-text-faint);
}

/* Role & Status Badges */
.role-badge, .status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.role-owner {
  background: var(--color-warning);
  color: #fff;
}
.role-admin {
  background: var(--color-accent);
  color: #fff;
}
.role-member {
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}
.status-active {
  background: var(--color-success-light);
  color: var(--color-success);
}
.status-inactive {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* Action Buttons */
.admin-action-btn {
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.admin-action-btn:hover {
  background: var(--color-surface-offset);
}
.admin-action-warn {
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.admin-action-warn:hover {
  background: rgba(214, 158, 46, 0.08);
}
.admin-action-success {
  color: var(--color-success);
  border-color: var(--color-success);
}
.admin-action-success:hover {
  background: var(--color-success-light);
}
.admin-action-danger {
  color: var(--color-error);
  border-color: var(--color-error);
}
.admin-action-danger:hover {
  background: var(--color-error-light);
}

/* Loading & Empty States */
.admin-loading, .admin-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

/* Mobile Cards (hidden on desktop) */
.admin-cards { display: none; }

.admin-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.admin-card-inactive { opacity: 0.55; }
.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
  flex-wrap: wrap;
}
.admin-card-email {
  font-weight: 600;
  font-size: var(--text-sm);
  word-break: break-all;
}
.admin-card-badges {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}
.admin-card-meta {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  margin-bottom: var(--space-3);
}
.admin-card-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}
.admin-card-actions .admin-action-btn {
  flex: 1;
  min-width: 0;
  text-align: center;
}

/* Responsive: Mobile Admin */
@media (max-width: 768px) {
  .admin-table-wrap { display: none !important; }
  .admin-cards { display: block !important; }
  .admin-form-row {
    flex-direction: column;
  }
  .admin-form-row .admin-input,
  .admin-form-row .admin-select,
  .admin-form-row .btn {
    width: 100%;
  }
  .admin-controls {
    flex-direction: column;
  }
  .admin-header h1 {
    font-size: var(--text-xl);
  }
}

/* ── Review Answers ── */
.review-answers-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.review-item {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  border-left: 4px solid var(--color-divider);
}
.review-item.correct {
  border-left-color: var(--color-success);
}
.review-item.incorrect {
  border-left-color: var(--color-error);
}
.review-item-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}
.review-item-num {
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-xs);
  flex-shrink: 0;
}
.review-item-status {
  font-weight: 600;
}
.review-item.correct .review-item-status { color: var(--color-success); }
.review-item.incorrect .review-item-status { color: var(--color-error); }
.review-item-topic {
  color: var(--color-text-muted);
  margin-left: auto;
}
.review-item-question {
  font-weight: 500;
  margin-bottom: var(--space-3);
  line-height: 1.5;
}
.review-item-choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.review-choice {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  line-height: 1.4;
}
.review-choice.correct-answer {
  background: var(--color-success-light, rgba(34, 139, 34, 0.1));
  color: var(--color-success);
  font-weight: 600;
}
.review-choice.wrong-answer {
  background: var(--color-error-light);
  color: var(--color-error);
  font-weight: 500;
  text-decoration: line-through;
  opacity: 0.85;
}
.review-item-explanation {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
}

/* ── Flashcard Progress (Progress Page) ── */
.fc-progress-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.fc-box-progress {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.fc-box-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 120px;
  gap: var(--space-3);
}
.fc-box-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
}
.fc-box-bar-wrap {
  flex: 1;
  width: 100%;
  max-width: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.fc-box-bar {
  width: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}
.fc-box-col:last-child .fc-box-bar {
  background: var(--color-success);
}
.fc-box-count {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--color-text);
  margin-top: var(--space-1);
}
.fc-box-name {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}
@media (max-width: 600px) {
  .fc-progress-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Dark Mode Polish ── */
[data-theme='dark'] .quiz-choice {
  background: var(--color-surface-2);
  border-color: var(--color-border);
}
[data-theme='dark'] .quiz-choice:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-primary);
}
[data-theme='dark'] .quiz-choice.correct {
  background: var(--color-success-light);
  border-color: var(--color-success);
}
[data-theme='dark'] .quiz-choice.incorrect {
  background: var(--color-error-light);
  border-color: var(--color-error);
}
[data-theme='dark'] .review-item {
  background: var(--color-surface-2);
}
[data-theme='dark'] .review-choice {
  background: var(--color-surface-offset);
}
[data-theme='dark'] .review-choice.correct-answer {
  background: var(--color-success-light);
  color: var(--color-success);
}
[data-theme='dark'] .review-choice.wrong-answer {
  background: var(--color-error-light);
  color: var(--color-error);
}
[data-theme='dark'] .stat-card {
  background: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme='dark'] .flashcard-card {
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}
[data-theme='dark'] .fc-box-progress {
  background: var(--color-surface-2);
}
[data-theme='dark'] .progress-readiness {
  background: var(--color-surface);
}
[data-theme='dark'] .admin-table th {
  background: var(--color-surface-2);
}
[data-theme='dark'] .admin-table td {
  border-color: var(--color-border);
}
[data-theme='dark'] .admin-input,
[data-theme='dark'] .admin-select {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  color: var(--color-text);
}
[data-theme='dark'] .quiz-setup-card {
  background: var(--color-surface);
}
[data-theme='dark'] .study-content {
  background: var(--color-surface);
}
[data-theme='dark'] .topic-card {
  background: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme='dark'] .topic-card:hover {
  border-color: var(--color-primary);
}

/* ════════════════════════════════════════════════════════
   P3 UI LAYER — Exam Countdown, Readiness Card,
   Section Scoring, Account / Email Toggle
   ════════════════════════════════════════════════════════ */

/* ── P3: Exam Date Banner ── */
#p3-exam-banner {
  max-width: var(--content-default);
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-4);
}

.p3-exam-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* Unset state — neutral prompt */
.p3-exam-banner--unset {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* Set state — green branded */
.p3-exam-banner--set {
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-highlight);
  color: var(--color-primary);
  justify-content: space-between;
}

.p3-exam-banner__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.p3-exam-banner__text {
  flex: 1;
}

.p3-exam-banner__btn {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive);
  white-space: nowrap;
}

.p3-exam-banner__btn:hover {
  background: var(--color-primary-hover);
}

.p3-exam-banner__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.p3-exam-banner__label {
  font-weight: 700;
  font-size: var(--text-sm);
}

.p3-exam-banner__sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.p3-exam-banner--set .p3-exam-banner__sub {
  color: var(--color-primary);
  opacity: 0.8;
}

.p3-exam-banner__edit {
  background: none;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--color-primary);
  flex-shrink: 0;
  transition: background var(--transition-interactive);
}

.p3-exam-banner__edit:hover {
  background: var(--color-primary-highlight);
}

/* Dark mode overrides */
[data-theme='dark'] .p3-exam-banner--unset {
  background: var(--color-surface-2);
  border-color: var(--color-border);
}

[data-theme='dark'] .p3-exam-banner--set {
  background: var(--color-primary-light);
  border-color: var(--color-primary-highlight);
}

/* Mobile */
@media (max-width: 720px) {
  #p3-exam-banner {
    padding: 0 var(--space-3);
    margin-bottom: var(--space-3);
  }
  .p3-exam-banner {
    flex-wrap: wrap;
  }
  .p3-exam-banner--set {
    gap: var(--space-2);
  }
}

/* ── P3: Exam Date Modal ── */
.p3-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.p3-modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.p3-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-divider);
}

.p3-modal__title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.p3-modal__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-interactive);
}

.p3-modal__close:hover {
  color: var(--color-text);
}

.p3-modal__body {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.p3-modal__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.p3-modal__date-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--color-surface-2);
  color: var(--color-text);
  transition: border-color var(--transition-interactive);
  box-sizing: border-box;
}

.p3-modal__date-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.p3-modal__hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin: 0;
}

.p3-modal__footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface-2);
}

.p3-modal__btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive);
}

.p3-modal__btn-primary:hover {
  background: var(--color-primary-hover);
}

.p3-modal__btn-ghost {
  background: none;
  color: var(--color-error);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive);
}

.p3-modal__btn-ghost:hover {
  background: var(--color-error-light);
}

[data-theme='dark'] .p3-modal {
  background: var(--color-surface);
}

[data-theme='dark'] .p3-modal__date-input {
  background: var(--color-surface-offset);
  border-color: var(--color-border);
  color: var(--color-text);
}

@media (max-width: 720px) {
  .p3-modal {
    max-width: 100%;
    margin: 0 var(--space-2);
  }
  .p3-modal__header,
  .p3-modal__body,
  .p3-modal__footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}

/* ── P3: Readiness Card ── */
.p3-readiness-card {
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: 2px solid transparent;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
}

.p3-readiness-card__top {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

.p3-readiness-card__score {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  font-family: var(--font-display);
  min-width: 80px;
  text-align: center;
}

.p3-readiness-card__status-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.p3-readiness-card__status {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.p3-readiness-card__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.p3-readiness-card__msg {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 0;
}

.p3-readiness-card__factors {
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-3);
}

.p3-readiness-card__factors-toggle {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.p3-readiness-card__factors-toggle:hover {
  color: var(--color-text);
}

.p3-readiness-card__factors-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 0;
  line-height: 1.7;
}

.p3-readiness-card__actions {
  margin: var(--space-4) 0 0;
  padding-left: var(--space-5);
  list-style: disc;
  font-size: var(--text-sm);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Status color variants */
.p3-ready--ready {
  border-color: var(--color-success);
  background: linear-gradient(135deg, var(--color-surface), var(--color-success-light));
}
.p3-ready--ready .p3-readiness-card__score,
.p3-ready--ready .p3-readiness-card__status {
  color: var(--color-success);
}

.p3-ready--close {
  border-color: var(--color-accent);
  background: linear-gradient(135deg, var(--color-surface), var(--color-accent-light));
}
.p3-ready--close .p3-readiness-card__score,
.p3-ready--close .p3-readiness-card__status {
  color: var(--color-accent);
}

.p3-ready--warming {
  border-color: var(--color-warning);
  background: linear-gradient(135deg, var(--color-surface), rgba(214,158,46,0.1));
}
.p3-ready--warming .p3-readiness-card__score,
.p3-ready--warming .p3-readiness-card__status {
  color: var(--color-warning);
}

.p3-ready--not-ready {
  border-color: var(--color-error);
  background: linear-gradient(135deg, var(--color-surface), var(--color-error-light));
}
.p3-ready--not-ready .p3-readiness-card__score,
.p3-ready--not-ready .p3-readiness-card__status {
  color: var(--color-error);
}

[data-theme='dark'] .p3-readiness-card {
  background: var(--color-surface);
}

[data-theme='dark'] .p3-ready--ready {
  background: linear-gradient(135deg, var(--color-surface), var(--color-success-light));
}
[data-theme='dark'] .p3-ready--close {
  background: linear-gradient(135deg, var(--color-surface), var(--color-accent-light));
}
[data-theme='dark'] .p3-ready--not-ready {
  background: linear-gradient(135deg, var(--color-surface), var(--color-error-light));
}
[data-theme='dark'] .p3-ready--warming {
  background: linear-gradient(135deg, var(--color-surface), rgba(236,201,75,0.08));
}

@media (max-width: 720px) {
  .p3-readiness-card {
    padding: var(--space-4);
  }
  .p3-readiness-card__score {
    font-size: 2.5rem;
    min-width: 60px;
  }
}

/* ── P3: Section-Level Scoring ── */
.p3-sections-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.p3-section-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-interactive);
}

.p3-section-bar--warn {
  border-color: rgba(197, 48, 48, 0.35);
}

.p3-section-bar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.p3-section-bar__name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}

.p3-section__warn {
  margin-left: var(--space-1);
  font-size: 0.9rem;
}

.p3-section-bar__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.p3-section__pill {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px var(--space-2);
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.p3-section--strong {
  background: var(--color-success-light);
  color: var(--color-success);
}

.p3-section--passing {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.p3-section--weak {
  background: var(--color-error-light);
  color: var(--color-error);
}

.p3-section-bar__pct {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}

.p3-section-bar__detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.p3-section-bar__track {
  position: relative;
  height: 8px;
  background: var(--color-surface-offset);
  border-radius: 99px;
  overflow: visible;
}

.p3-section-bar__fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.p3-section-bar__fill.p3-section--strong {
  background: var(--color-success);
}
.p3-section-bar__fill.p3-section--passing {
  background: var(--color-accent);
}
.p3-section-bar__fill.p3-section--weak {
  background: var(--color-error);
}

/* 70% threshold line */
.p3-section-bar__threshold {
  position: absolute;
  top: -4px;
  left: 70%;
  width: 2px;
  height: 16px;
  background: var(--color-warning);
  border-radius: 1px;
  opacity: 0.7;
}

[data-theme='dark'] .p3-section-bar {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme='dark'] .p3-section-bar--warn {
  border-color: rgba(245, 101, 101, 0.35);
}

[data-theme='dark'] .p3-section-bar__track {
  background: var(--color-surface-offset);
}

@media (max-width: 720px) {
  .p3-section-bar {
    padding: var(--space-3) var(--space-4);
  }
  .p3-section-bar__header {
    gap: var(--space-2);
  }
  .p3-section-bar__detail {
    display: none;
  }
}

/* ── P3: Account / Email Toggle Section ── */
.p3-account-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-top: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.p3-account-section h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
  color: var(--color-text);
}

.p3-account-section__email {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-4);
}

.p3-account-section__hint {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  margin: 0 0 var(--space-4);
}

.p3-account-section__row {
  display: flex;
  align-items: flex-start;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-divider);
}

/* Toggle label layout */
.p3-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.p3-toggle-label__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text);
  flex: 1;
}

.p3-toggle-label__hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 400;
}

/* Hide native checkbox */
.p3-toggle-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Custom toggle switch */
.p3-toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: 99px;
  flex-shrink: 0;
  transition: background var(--transition-interactive);
  cursor: pointer;
}

.p3-toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--transition-interactive);
}

.p3-toggle-checkbox:checked + .p3-toggle-switch {
  background: var(--color-primary);
}

.p3-toggle-checkbox:checked + .p3-toggle-switch::after {
  transform: translateX(20px);
}

.p3-toggle-checkbox:disabled + .p3-toggle-switch {
  opacity: 0.4;
  cursor: not-allowed;
}

.p3-toggle-label:has(.p3-toggle-checkbox:disabled) {
  cursor: not-allowed;
  opacity: 0.65;
}

.p3-account-feedback {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 500;
}

[data-theme='dark'] .p3-account-section {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme='dark'] .p3-toggle-switch {
  background: var(--color-border);
}

[data-theme='dark'] .p3-toggle-switch::after {
  background: var(--color-text);
}

@media (max-width: 720px) {
  .p3-account-section {
    padding: var(--space-4);
  }
}

/* ── P3: Progress section containers spacing ── */
.progress-sections,
.progress-account {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: 0 var(--space-4);
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .progress-sections,
  .progress-account {
    padding: 0 var(--space-3);
  }
}

/* === Phase 4: Mnemonic Generator === */

/* ── Quiz screen: memory-aid button below wrong-answer explanation ── */
.quiz-mnemonic-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: var(--space-3);
  padding: 7px 14px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-highlight);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}

.quiz-mnemonic-btn:hover {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
}

.quiz-mnemonic-btn:active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

[data-theme='dark'] .quiz-mnemonic-btn {
  background: #1a2e24;
  color: #4ead7a;
  border-color: #2a4a38;
}

[data-theme='dark'] .quiz-mnemonic-btn:hover {
  background: #2a4a38;
  border-color: #4ead7a;
}

/* ── Progress tab: memory-aid link on mastery rows ── */
.mastery-mnemonic-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-highlight);
  border-radius: 20px;
  font-size: 11.5px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
  white-space: nowrap;
  flex-shrink: 0;
}

.mastery-mnemonic-btn:hover {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
}

[data-theme='dark'] .mastery-mnemonic-btn {
  background: #1a2e24;
  color: #4ead7a;
  border-color: #2a4a38;
}

[data-theme='dark'] .mastery-mnemonic-btn:hover {
  background: #2a4a38;
}

/* ── Saved Memory Aids section (Progress tab) ── */
.mn-saved-wrapper {
  max-width: var(--content-default);
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-4);
  width: 100%;
  box-sizing: border-box;
}

.mn-saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: background var(--transition-interactive);
  margin-bottom: var(--space-2);
}

.mn-saved-header:hover {
  background: var(--color-surface-2);
}

.mn-saved-chevron {
  font-size: 12px;
  color: var(--color-text-muted);
  transition: transform 200ms ease;
}

[data-theme='dark'] .mn-saved-header {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.mn-saved-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.mn-saved-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

.mn-saved-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.mn-saved-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.mn-saved-concept {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.3;
}

.mn-saved-topic {
  font-size: var(--text-xs);
  color: var(--color-primary);
  margin-top: 2px;
  font-weight: 500;
}

.mn-saved-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.mn-saved-open-btn,
.mn-saved-del-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--color-text-muted);
  transition: background var(--transition-interactive), color var(--transition-interactive);
}

.mn-saved-open-btn:hover { background: var(--color-primary-light); color: var(--color-primary); }
.mn-saved-del-btn:hover  { background: var(--color-error-light); color: var(--color-error); border-color: #f7c6c6; }

[data-theme='dark'] .mn-saved-open-btn,
[data-theme='dark'] .mn-saved-del-btn {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

[data-theme='dark'] .mn-saved-item {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme='dark'] .mn-saved-concept { color: var(--color-text); }

.mn-saved-mnemonic {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  padding: var(--space-1) 0;
  border-top: 1px solid var(--color-divider);
}

.mn-saved-mnemonic:first-of-type { border-top: none; padding-top: 0; }

.mn-saved-mnemonic strong {
  color: var(--color-text);
  font-weight: 600;
}

[data-theme='dark'] .mn-saved-mnemonic { color: var(--color-text-muted); border-top-color: var(--color-divider); }
[data-theme='dark'] .mn-saved-mnemonic strong { color: var(--color-text); }

@media (max-width: 720px) {
  .mn-saved-wrapper {
    padding: 0 var(--space-3);
  }

  .mastery-item-footer {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .mastery-mnemonic-btn {
    font-size: 11px;
  }
}

/* ================================================================ */
/* === Phase 4: Spanish mode ====================================== */
/* ================================================================ */

/* ── Language Toggle Button ─────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-sm, 0.8rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
  white-space: nowrap;
  line-height: 1;
}

.lang-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light, rgba(26, 107, 78, 0.08));
}

.lang-toggle.lang-es-active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light, rgba(26, 107, 78, 0.1));
  font-weight: 700;
}

.lang-toggle svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.lang-toggle-label {
  min-width: 18px;
  text-align: center;
}

[data-theme='dark'] .lang-toggle {
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

[data-theme='dark'] .lang-toggle:hover,
[data-theme='dark'] .lang-toggle.lang-es-active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(26, 107, 78, 0.15);
}

/* ── Beta Banner ────────────────────────────────────────────────── */
.es-beta-banner {
  position: sticky;
  top: 0;
  z-index: 90;
  background: linear-gradient(90deg, #1a6b4e 0%, #2e8b6a 100%);
  color: #fff;
  text-align: center;
  font-size: var(--text-sm, 0.82rem);
  font-weight: 500;
  padding: 8px 16px;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── EN Badge (untranslated content marker) ─────────────────────── */
.en-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f59e0b;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  vertical-align: middle;
  cursor: help;
  line-height: 1.4;
}

/* ── i18n Toast ─────────────────────────────────────────────────── */
.i18n-toast {
  position: fixed;
  bottom: 80px;    /* above mobile nav */
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-surface, #fff);
  color: var(--color-text, #111);
  border: 1.5px solid var(--color-border, #e5e7eb);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: var(--text-sm, 0.85rem);
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  max-width: 90vw;
  text-align: center;
}

.i18n-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

[data-theme='dark'] .i18n-toast {
  background: var(--color-surface-dark, #1f2937);
  color: var(--color-text, #f9fafb);
  border-color: var(--color-border, #374151);
}

/* ── Responsive: hide toggle label on very small screens ────────── */
@media (max-width: 380px) {
  .lang-toggle-label {
    display: none;
  }
  .lang-toggle {
    padding: 6px 8px;
  }
}
/* ================================================================ */
/* === End Phase 4 =============================================== */
/* ================================================================ */

/* ================================================================ */
/* === Phase 5: Confidence Capture ================================ */
/* ================================================================ */

/* ─ Confidence picker ──────────────────────────────────────────── */
.confidence-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2, 8px);
  margin: var(--space-3, 12px) 0 var(--space-2, 8px);
  animation: conf-fade-in 0.18s ease;
}

@keyframes conf-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.conf-prompt {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--color-text-muted, #6b7280);
  text-transform: uppercase;
}

.conf-btn-row {
  display: flex;
  gap: var(--space-2, 8px);
  justify-content: center;
}

.conf-btn {
  padding: 8px 20px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
  outline: none;
}

.conf-btn:hover {
  transform: translateY(-1px);
}

.conf-btn--guess {
  background: var(--color-surface, #f3f4f6);
  color: var(--color-text, #374151);
  border-color: var(--color-border, #d1d5db);
}

.conf-btn--maybe {
  background: #fef3c7;
  color: #92400e;
  border-color: #fbbf24;
}

.conf-btn--sure {
  background: #d1fae5;
  color: #065f46;
  border-color: #34d399;
}

.conf-btn.selected {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
  transform: scale(1.05);
}

.conf-btn--guess.selected {
  background: var(--color-border, #d1d5db);
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.4);
}

.conf-btn--maybe.selected {
  background: #fde68a;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.5);
}

.conf-btn--sure.selected {
  background: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.5);
}

.conf-skip {
  font-size: 0.78rem;
  color: var(--color-text-muted, #9ca3af);
  text-decoration: none;
  margin-top: var(--space-1, 4px);
}

.conf-skip:hover {
  text-decoration: underline;
  color: var(--color-text, #6b7280);
}

/* Dark mode: confidence picker */
[data-theme='dark'] .conf-btn--guess {
  background: #374151;
  color: #d1d5db;
  border-color: #4b5563;
}

[data-theme='dark'] .conf-btn--maybe {
  background: #451a03;
  color: #fde68a;
  border-color: #d97706;
}

[data-theme='dark'] .conf-btn--sure {
  background: #064e3b;
  color: #6ee7b7;
  border-color: #059669;
}

[data-theme='dark'] .conf-btn--guess.selected {
  background: #4b5563;
}

[data-theme='dark'] .conf-btn--maybe.selected {
  background: #78350f;
}

[data-theme='dark'] .conf-btn--sure.selected {
  background: #065f46;
}

/* ─ Confidence toast ────────────────────────────────────────── */
.conf-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1f2937;
  color: #f9fafb;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  max-width: 340px;
  text-align: center;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.conf-toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ─ Calibration card (Progress tab) ────────────────────────── */
.progress-calibration {
  margin-bottom: var(--space-6, 24px);
}

.calibration-card {
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  padding: var(--space-5, 20px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.calibration-card--locked {
  opacity: 0.85;
}

.calibration-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text, #111827);
  margin-bottom: 2px;
}

.calibration-card__sub {
  font-size: 0.82rem;
  color: var(--color-text-muted, #6b7280);
  margin-bottom: var(--space-4, 16px);
}

.calibration-card__unlock {
  font-size: 0.88rem;
  color: var(--color-text-muted, #6b7280);
  margin-bottom: var(--space-4, 16px);
}

/* Bars */
.calibration-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-4, 16px);
}

.calibration-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr 44px 100px;
  align-items: center;
  gap: var(--space-2, 8px);
}

.calibration-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text, #374151);
}

.calibration-bar-track {
  height: 14px;
  background: var(--color-surface-secondary, #f3f4f6);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--color-border, #e5e7eb);
}

.calibration-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
  background: var(--color-border, #d1d5db);
}

.calibration-bar-row.calibration-bar--green .calibration-bar-fill {
  background: #34d399;
}

.calibration-bar-row.calibration-bar--amber .calibration-bar-fill {
  background: #fbbf24;
}

.calibration-bar-row.calibration-bar--red .calibration-bar-fill {
  background: #f87171;
}

.calibration-bar-pct {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text, #374151);
  text-align: right;
  min-width: 36px;
}

.calibration-bar-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.calibration-bar--green .calibration-bar-pill {
  background: #d1fae5;
  color: #065f46;
}

.calibration-bar--amber .calibration-bar-pill {
  background: #fef3c7;
  color: #92400e;
}

.calibration-bar--red .calibration-bar-pill {
  background: #fee2e2;
  color: #991b1b;
}

.calibration-takeaway {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text, #374151);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  background: var(--color-surface-secondary, #f9fafb);
  border-radius: var(--radius, 8px);
  margin-bottom: var(--space-4, 16px);
  border-left: 3px solid var(--color-border, #d1d5db);
}

/* Settings row */
.calibration-settings-row {
  border-top: 1px solid var(--color-border, #e5e7eb);
  padding-top: var(--space-3, 12px);
  margin-top: var(--space-2, 8px);
}

.calibration-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--color-text-muted, #6b7280);
  cursor: default;
}

.calibration-toggle-btn {
  padding: 4px 14px;
  border-radius: 999px;
  border: 2px solid var(--color-border, #d1d5db);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--color-surface, #f3f4f6);
  color: var(--color-text-muted, #9ca3af);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.calibration-toggle-btn--on {
  background: #d1fae5;
  color: #065f46;
  border-color: #34d399;
}

/* Dark mode: calibration card */
[data-theme='dark'] .calibration-card {
  background: var(--color-surface-dark, #1f2937);
  border-color: var(--color-border-dark, #374151);
}

[data-theme='dark'] .calibration-card__title {
  color: #f9fafb;
}

[data-theme='dark'] .calibration-card__sub,
[data-theme='dark'] .calibration-card__unlock {
  color: #9ca3af;
}

[data-theme='dark'] .calibration-bar-label,
[data-theme='dark'] .calibration-bar-pct {
  color: #d1d5db;
}

[data-theme='dark'] .calibration-bar-track {
  background: #374151;
  border-color: #4b5563;
}

[data-theme='dark'] .calibration-bar--green .calibration-bar-pill {
  background: #064e3b;
  color: #6ee7b7;
}

[data-theme='dark'] .calibration-bar--amber .calibration-bar-pill {
  background: #451a03;
  color: #fde68a;
}

[data-theme='dark'] .calibration-bar--red .calibration-bar-pill {
  background: #7f1d1d;
  color: #fca5a5;
}

[data-theme='dark'] .calibration-takeaway {
  background: #111827;
  color: #d1d5db;
  border-left-color: #4b5563;
}

[data-theme='dark'] .calibration-settings-row {
  border-color: #374151;
}

[data-theme='dark'] .calibration-toggle-label {
  color: #9ca3af;
}

[data-theme='dark'] .calibration-toggle-btn {
  background: #374151;
  color: #9ca3af;
  border-color: #4b5563;
}

[data-theme='dark'] .calibration-toggle-btn--on {
  background: #064e3b;
  color: #6ee7b7;
  border-color: #059669;
}

/* Responsive: stack bar grid at narrow widths */
@media (max-width: 720px) {
  .calibration-bar-row {
    grid-template-columns: 52px 1fr 40px;
    grid-template-rows: auto auto;
  }

  .calibration-bar-pill {
    grid-column: 2 / 4;
    text-align: left;
  }
}

@media (max-width: 400px) {
  .conf-btn {
    padding: 7px 13px;
    font-size: 0.82rem;
  }
}

/* ================================================================ */
/* === End Phase 5 =============================================== */
/* ================================================================ */

/* ================================================================ */
/* === Phase 5: Pearson VUE Simulator ============================= */
/* ================================================================ */

/* ── P5: Home Card (Simulator Launch) ────────────────────────────── */
#p5-exam-sim-card {
  margin: var(--space-8) 0 var(--space-4);
}

.p5-sim-resume {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: #1e40af;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

[data-theme='dark'] .p5-sim-resume {
  background: rgba(37,99,235,0.12);
  border-color: rgba(96,165,250,0.3);
  color: #93c5fd;
}

.p5-resume-link {
  background: none;
  border: none;
  color: #2563eb;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}

[data-theme='dark'] .p5-resume-link {
  color: #60a5fa;
}

.p5-sim-card {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  background: linear-gradient(135deg, #0f1f3d 0%, #1e3a5f 60%, #1d4ed8 100%);
  border: 1px solid rgba(96,165,250,0.25);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6);
  box-shadow: 0 4px 20px rgba(30, 58, 95, 0.25);
}

.p5-sim-card__icon {
  flex-shrink: 0;
}

.p5-sim-card__content {
  flex: 1;
  min-width: 0;
}

.p5-sim-card__title {
  color: #e0f2fe;
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-2);
  line-height: 1.3;
}

.p5-sim-card__desc {
  color: #94c3e8;
  font-size: var(--text-sm);
  margin: 0 0 var(--space-3);
  line-height: 1.5;
}

.p5-sim-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.p5-sim-meta-badge {
  background: rgba(96,165,250,0.15);
  border: 1px solid rgba(96,165,250,0.3);
  color: #93c5fd;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.p5-sim-card__action {
  flex-shrink: 0;
}

.p5-sim-start-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}

.p5-sim-start-btn:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 16px rgba(37,99,235,0.45);
  transform: translateY(-1px);
}

.p5-sim-start-btn:active {
  transform: translateY(0);
}

@media (max-width: 720px) {
  .p5-sim-card {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-4);
  }
  .p5-sim-card__action {
    width: 100%;
  }
  .p5-sim-start-btn {
    width: 100%;
    text-align: center;
  }
}

/* ── Exam Sim Overlay — CSS Isolation Reset ──────────────────────── */
body.exam-sim-active {
  overflow: hidden;
}

#exam-sim-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  font-family: 'General Sans', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1a1a2e;
  overflow: hidden;
}

/* Full reset inside simulator */
.exam-sim * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
  line-height: 1;
}

.exam-sim {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: #f4f6f9;
}

/* ── Dark mode inside simulator ──────────────────────────────────── */
[data-theme='dark'] #exam-sim-overlay {
  background: #0d1117;
}

[data-theme='dark'] .exam-sim {
  background: #0d1117;
  color: #e6edf3;
}

/* ── Top Bar ─────────────────────────────────────────────────────── */
.exam-sim__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e3a5f;
  color: #e0f2fe;
  padding: 0 24px;
  height: 56px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.exam-sim__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exam-sim__title-main {
  font-size: 14px;
  font-weight: 700;
  color: #e0f2fe;
  letter-spacing: 0.01em;
}

.exam-sim__title-sub {
  font-size: 11px;
  color: #93c5fd;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.exam-sim__topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.exam-sim__timer {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 6px 12px;
  color: #e0f2fe;
  font-family: 'Courier New', 'Roboto Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  min-width: 100px;
  justify-content: center;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.exam-sim__timer--warning {
  background: rgba(239,68,68,0.2) !important;
  border-color: rgba(239,68,68,0.5) !important;
  color: #fca5a5 !important;
  animation: es-pulse 1s ease-in-out infinite;
}

@keyframes es-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.exam-sim__close-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #93c5fd;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.exam-sim__close-btn:hover {
  background: rgba(239,68,68,0.2);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.3);
}

/* ── Progress Bar ────────────────────────────────────────────────── */
.exam-sim__progress-bar {
  position: relative;
  height: 6px;
  background: #d1d8e0;
  flex-shrink: 0;
  overflow: hidden;
}

[data-theme='dark'] .exam-sim__progress-bar {
  background: #1c2435;
}

.exam-sim__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: width 0.3s ease;
}

.exam-sim__progress-label {
  position: absolute;
  right: 12px;
  top: -20px;
  font-size: 11px;
  color: #6b7280;
  letter-spacing: 0.04em;
}

/* ── Body / Question Area ────────────────────────────────────────── */
.exam-sim__body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  display: flex;
  justify-content: center;
}

@media (max-width: 720px) {
  .exam-sim__body {
    padding: 20px 16px;
  }
}

/* ── Question Layout ─────────────────────────────────────────────── */
.exam-sim__question-wrap {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.exam-sim__question-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.exam-sim__qnum {
  font-size: 13px;
  font-weight: 600;
  color: #4b6080;
  letter-spacing: 0.02em;
}

[data-theme='dark'] .exam-sim__qnum {
  color: #7ea0c4;
}

.exam-sim__topic-tag {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}

[data-theme='dark'] .exam-sim__topic-tag {
  background: rgba(37,99,235,0.15);
  border-color: rgba(96,165,250,0.3);
  color: #60a5fa;
}

.exam-sim__flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 2px 8px;
}

[data-theme='dark'] .exam-sim__flag-badge {
  background: rgba(217,119,6,0.15);
  border-color: rgba(252,211,77,0.3);
  color: #fbbf24;
}

.exam-sim__question-text {
  font-size: 20px;
  font-weight: 500;
  color: #111827;
  line-height: 1.65;
  letter-spacing: -0.01em;
}

[data-theme='dark'] .exam-sim__question-text {
  color: #e6edf3;
}

/* ── Choices ─────────────────────────────────────────────────────── */
.exam-sim__choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exam-sim__choice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: #fff;
  border: 2px solid #d1d8e0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  line-height: 1.6;
  font-size: 17px;
  color: #1a1a2e;
  user-select: none;
}

[data-theme='dark'] .exam-sim__choice {
  background: #161b22;
  border-color: #30363d;
  color: #e6edf3;
}

.exam-sim__choice:hover {
  border-color: #2563eb;
  background: #f0f6ff;
  box-shadow: 0 1px 6px rgba(37,99,235,0.1);
}

[data-theme='dark'] .exam-sim__choice:hover {
  border-color: #3b82f6;
  background: rgba(37,99,235,0.08);
}

.exam-sim__choice--selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

[data-theme='dark'] .exam-sim__choice--selected {
  border-color: #3b82f6;
  background: rgba(37,99,235,0.15);
  box-shadow: 0 0 0 1px #3b82f6;
}

.exam-sim__choice-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #9ca3af;
  background: #fff;
  flex-shrink: 0;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, background 0.12s;
  position: relative;
}

.exam-sim__choice--selected .exam-sim__choice-radio {
  border-color: #2563eb;
  background: #2563eb;
}

.exam-sim__choice--selected .exam-sim__choice-radio::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
}

[data-theme='dark'] .exam-sim__choice-radio {
  background: #161b22;
  border-color: #4b5563;
}

[data-theme='dark'] .exam-sim__choice--selected .exam-sim__choice-radio {
  border-color: #3b82f6;
  background: #3b82f6;
}

.exam-sim__choice-letter {
  font-weight: 700;
  color: #4b6080;
  font-size: 15px;
  min-width: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

[data-theme='dark'] .exam-sim__choice-letter {
  color: #7ea0c4;
}

.exam-sim__choice--selected .exam-sim__choice-letter {
  color: #2563eb;
}

[data-theme='dark'] .exam-sim__choice--selected .exam-sim__choice-letter {
  color: #60a5fa;
}

.exam-sim__choice-text {
  flex: 1;
}

/* ── Bottom Navigation Bar ───────────────────────────────────────── */
.exam-sim__bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-top: 1px solid #d1d8e0;
  padding: 14px 24px;
  flex-shrink: 0;
  gap: 12px;
}

[data-theme='dark'] .exam-sim__bottombar {
  background: #161b22;
  border-color: #30363d;
}

.exam-sim__bottom-left,
.exam-sim__bottom-center,
.exam-sim__bottom-right {
  display: flex;
  align-items: center;
}

.exam-sim__bottom-left { justify-content: flex-start; flex: 1; }
.exam-sim__bottom-center { justify-content: center; flex: 1; }
.exam-sim__bottom-right { justify-content: flex-end; flex: 1; }

.exam-sim__nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e3a5f;
  color: #e0f2fe;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
}

.exam-sim__nav-btn:hover:not(:disabled) {
  background: #2563eb;
}

.exam-sim__nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.exam-sim__flag-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: #6b7280;
  border: 2px solid #d1d8e0;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.exam-sim__flag-btn:hover {
  border-color: #d97706;
  color: #d97706;
  background: #fffbeb;
}

.exam-sim__flag-btn--active {
  border-color: #d97706;
  color: #d97706;
  background: #fffbeb;
}

[data-theme='dark'] .exam-sim__flag-btn {
  border-color: #30363d;
  color: #8b949e;
}

[data-theme='dark'] .exam-sim__flag-btn:hover,
[data-theme='dark'] .exam-sim__flag-btn--active {
  border-color: #fcd34d;
  color: #fbbf24;
  background: rgba(217,119,6,0.1);
}

/* ── Review Grid ─────────────────────────────────────────────────── */
.exam-sim__review-wrap {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.exam-sim__review-title {
  font-size: 24px;
  font-weight: 700;
  color: #1e3a5f;
}

[data-theme='dark'] .exam-sim__review-title {
  color: #93c5fd;
}

.exam-sim__review-sub {
  font-size: 15px;
  color: #4b6080;
  line-height: 1.5;
  margin-top: -12px;
}

[data-theme='dark'] .exam-sim__review-sub {
  color: #7ea0c4;
}

.exam-sim__review-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #4b6080;
  align-items: center;
}

[data-theme='dark'] .exam-sim__review-legend {
  color: #8b949e;
}

.es-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.es-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.es-legend-dot--answered { background: #22c55e; }
.es-legend-dot--unanswered { background: #d1d8e0; }
.es-legend-flag { color: #d97706; flex-shrink: 0; }

/* 15 columns × 9 rows grid */
.exam-sim__review-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 5px;
}

@media (max-width: 720px) {
  .exam-sim__review-grid {
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
  }
}

.es-grid-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #d1d8e0;
  border-radius: 5px;
  background: #f4f6f9;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.1s;
  padding: 2px;
  overflow: hidden;
  font-family: inherit;
}

.es-grid-cell:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
  transform: scale(1.08);
}

.es-grid-cell--answered {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

[data-theme='dark'] .es-grid-cell--answered {
  background: rgba(34,197,94,0.15);
  border-color: rgba(34,197,94,0.4);
  color: #4ade80;
}

.es-grid-cell--flagged {
  border-color: #d97706;
}

.es-grid-cell--flagged.es-grid-cell--answered {
  border-color: #d97706;
}

.es-grid-cell--current {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

[data-theme='dark'] .es-grid-cell {
  background: #1c2435;
  border-color: #30363d;
  color: #8b949e;
}

[data-theme='dark'] .es-grid-cell:hover {
  border-color: #3b82f6;
  background: rgba(37,99,235,0.12);
  color: #60a5fa;
}

.es-cell-flag {
  position: absolute;
  top: 2px;
  right: 2px;
  color: #d97706;
  pointer-events: none;
}

.es-grid-cell span {
  position: relative;
  z-index: 1;
}

.exam-sim__review-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
}

[data-theme='dark'] .exam-sim__review-actions {
  border-color: #30363d;
}

/* ── Shared Button Styles (Simulator-scoped) ─────────────────────── */
.exam-sim__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 24px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.exam-sim__btn:active { transform: translateY(1px); }

.exam-sim__btn--primary {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.exam-sim__btn--primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}

.exam-sim__btn--secondary {
  background: #f4f6f9;
  color: #1e3a5f;
  border: 1.5px solid #d1d8e0;
}

.exam-sim__btn--secondary:hover {
  background: #e8edf5;
  border-color: #b0bec8;
}

[data-theme='dark'] .exam-sim__btn--secondary {
  background: #1c2435;
  color: #93c5fd;
  border-color: #30363d;
}

[data-theme='dark'] .exam-sim__btn--secondary:hover {
  background: #263045;
}

.exam-sim__btn--danger {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,0.25);
}

.exam-sim__btn--danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 14px rgba(220,38,38,0.35);
}

/* ── Results Screen ───────────────────────────────────────────────── */
.exam-sim__results-wrap {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.exam-sim__result-banner {
  border-radius: 12px;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.exam-sim__result-banner--pass {
  background: linear-gradient(135deg, #052e16, #14532d);
  border: 1px solid rgba(34,197,94,0.3);
  box-shadow: 0 4px 24px rgba(22,163,74,0.2);
}

.exam-sim__result-banner--fail {
  background: linear-gradient(135deg, #450a0a, #7f1d1d);
  border: 1px solid rgba(239,68,68,0.3);
  box-shadow: 0 4px 24px rgba(239,68,68,0.2);
}

.exam-sim__result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 4px;
}

.exam-sim__result-banner--pass .exam-sim__result-icon {
  background: rgba(34,197,94,0.2);
  color: #4ade80;
  border: 2px solid rgba(34,197,94,0.4);
}

.exam-sim__result-banner--fail .exam-sim__result-icon {
  background: rgba(239,68,68,0.2);
  color: #f87171;
  border: 2px solid rgba(239,68,68,0.4);
}

.exam-sim__result-verdict {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.exam-sim__result-banner--pass .exam-sim__result-verdict { color: #4ade80; }
.exam-sim__result-banner--fail .exam-sim__result-verdict { color: #f87171; }

.exam-sim__result-score {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.exam-sim__result-detail {
  font-size: 14px;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
}

.exam-sim__result-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 14px;
  color: #4b6080;
  padding: 16px 20px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

[data-theme='dark'] .exam-sim__result-meta {
  background: #161b22;
  border-color: #30363d;
  color: #8b949e;
}

.exam-sim__result-meta strong { color: #1e3a5f; }
[data-theme='dark'] .exam-sim__result-meta strong { color: #e0f2fe; }

/* ── Section Bars ────────────────────────────────────────────────── */
.exam-sim__section-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 20px 24px;
}

[data-theme='dark'] .exam-sim__section-bars {
  background: #161b22;
  border-color: #30363d;
}

.exam-sim__section-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.exam-sim__section-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.exam-sim__section-label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

[data-theme='dark'] .exam-sim__section-label {
  color: #d1d8e0;
}

.exam-sim__section-score {
  font-size: 13px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 10px;
}

.exam-sim__section-score.es-result--pass {
  background: #dcfce7;
  color: #166534;
}

.exam-sim__section-score.es-result--fail {
  background: #fee2e2;
  color: #991b1b;
}

[data-theme='dark'] .exam-sim__section-score.es-result--pass {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
}

[data-theme='dark'] .exam-sim__section-score.es-result--fail {
  background: rgba(239,68,68,0.15);
  color: #f87171;
}

.exam-sim__section-track {
  position: relative;
  height: 10px;
  background: #e5e7eb;
  border-radius: 5px;
  overflow: visible;
}

[data-theme='dark'] .exam-sim__section-track {
  background: #1c2435;
}

.exam-sim__section-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}

.exam-sim__section-fill.es-result--pass { background: #22c55e; }
.exam-sim__section-fill.es-result--fail { background: #ef4444; }

.exam-sim__section-threshold {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 16px;
  background: #1e3a5f;
  border-radius: 1px;
}

[data-theme='dark'] .exam-sim__section-threshold {
  background: #93c5fd;
}

/* ── Wrong Answers / Review ──────────────────────────────────────── */
.exam-sim__wrong-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exam-sim__wrong-title {
  font-size: 18px;
  font-weight: 700;
  color: #1e3a5f;
}

[data-theme='dark'] .exam-sim__wrong-title {
  color: #93c5fd;
}

.es-wrong-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.es-wrong-item {
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

[data-theme='dark'] .es-wrong-item {
  background: #161b22;
  border-color: #30363d;
}

.es-wrong-toggle {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: #1a1a2e;
}

[data-theme='dark'] .es-wrong-toggle {
  color: #e6edf3;
}

.es-wrong-toggle:hover {
  background: #f9fafb;
}

[data-theme='dark'] .es-wrong-toggle:hover {
  background: rgba(255,255,255,0.03);
}

.es-wrong-num {
  font-size: 12px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border-radius: 4px;
  padding: 2px 8px;
  flex-shrink: 0;
  margin-top: 2px;
}

[data-theme='dark'] .es-wrong-num {
  background: rgba(37,99,235,0.15);
  color: #60a5fa;
}

.es-wrong-q {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
}

.es-wrong-chevron {
  flex-shrink: 0;
  margin-top: 3px;
  transition: transform 0.2s;
  color: #9ca3af;
}

.es-wrong-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid #e5e7eb;
  flex-direction: column;
  gap: 10px;
}

[data-theme='dark'] .es-wrong-body {
  border-color: #30363d;
}

.es-wrong-body--open {
  display: flex;
}

.es-wrong-body--open + .es-wrong-toggle .es-wrong-chevron,
.es-wrong-toggle:has(+ .es-wrong-body--open) .es-wrong-chevron {
  transform: rotate(180deg);
}

.es-wrong-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
}

.es-wrong-choice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  color: #374151;
  background: #f9fafb;
  line-height: 1.5;
}

[data-theme='dark'] .es-wrong-choice {
  background: #1c2435;
  border-color: #30363d;
  color: #d1d8e0;
}

.es-wrong-choice--correct {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #166534;
}

[data-theme='dark'] .es-wrong-choice--correct {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.35);
  color: #4ade80;
}

.es-wrong-choice--wrong {
  border-color: #ef4444;
  background: #fff1f2;
  color: #991b1b;
}

[data-theme='dark'] .es-wrong-choice--wrong {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.35);
  color: #f87171;
}

.es-wrong-choice-letter {
  font-weight: 700;
  flex-shrink: 0;
  min-width: 16px;
}

.es-wrong-explanation {
  font-size: 13px;
  color: #4b6080;
  line-height: 1.6;
  background: #f0f6ff;
  border-left: 3px solid #2563eb;
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
}

[data-theme='dark'] .es-wrong-explanation {
  background: rgba(37,99,235,0.08);
  color: #94a3b8;
}

.exam-sim__perfect {
  font-size: 16px;
  font-weight: 600;
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 16px 20px;
  text-align: center;
}

[data-theme='dark'] .exam-sim__perfect {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.25);
  color: #4ade80;
}

.exam-sim__result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
}

@media (max-width: 720px) {
  .exam-sim__result-actions {
    flex-direction: column;
  }
  .exam-sim__result-actions .exam-sim__btn {
    width: 100%;
    justify-content: center;
  }
  .exam-sim__review-actions {
    flex-direction: column-reverse;
  }
  .exam-sim__review-actions .exam-sim__btn {
    width: 100%;
    justify-content: center;
  }
  .exam-sim__topbar {
    padding: 0 12px;
    height: 48px;
  }
  .exam-sim__title-main {
    font-size: 12px;
  }
  .exam-sim__title-sub {
    font-size: 10px;
  }
  .exam-sim__timer {
    font-size: 15px;
    padding: 5px 8px;
    min-width: 80px;
  }
  .exam-sim__bottombar {
    padding: 10px 12px;
    gap: 8px;
  }
  .exam-sim__nav-btn {
    padding: 9px 14px;
    font-size: 13px;
  }
  .exam-sim__flag-btn {
    padding: 7px 10px;
    font-size: 12px;
  }
  .exam-sim__question-text {
    font-size: 17px;
  }
  .exam-sim__choice {
    padding: 13px 14px;
    font-size: 15px;
  }
  .exam-sim__result-banner {
    padding: 24px 20px;
  }
  .exam-sim__result-verdict {
    font-size: 28px;
  }
}

/* ================================================================ */
/* === End Phase 5 =============================================== */
/* ================================================================ */

/* === Missed-questions progress hint === */
#weak-area-hint .missed-summary { font-size: 15px; margin-bottom: 8px; }
#weak-area-hint .missed-bands { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
#weak-area-hint .missed-band {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
  border: 1px solid transparent;
}
#weak-area-hint .missed-band--close    { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
#weak-area-hint .missed-band--midway   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
#weak-area-hint .missed-band--untouched{ background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
#weak-area-hint .missed-foot { font-size: 12px; color: #64748b; }
[data-theme='dark'] #weak-area-hint .missed-band--close    { background: #064e3b; color: #a7f3d0; border-color: #047857; }
[data-theme='dark'] #weak-area-hint .missed-band--midway   { background: #78350f; color: #fde68a; border-color: #b45309; }
[data-theme='dark'] #weak-area-hint .missed-band--untouched{ background: #1e293b; color: #cbd5e1; border-color: #475569; }
[data-theme='dark'] #weak-area-hint .missed-foot { color: #94a3b8; }


/* ================================================================ */
/* === Phase 6: Polish =========================================== */
/* ================================================================ */

/* --- FIX 1: Quiz Setup CTA Hierarchy ----------------------------- */
.p6-quiz-cta-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4, 16px);
  margin-top: var(--space-6, 24px);
}

/* Primary CTA — full-width green */
.p6-quiz-primary {
  width: 100%;
  height: 56px;
  font-size: 18px;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg, 12px);
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  letter-spacing: 0.01em;
}
.p6-quiz-primary:hover { background: var(--color-primary-hover); }
.p6-quiz-primary:active { transform: scale(0.99); }

/* Secondary row — 2 equal cards */
.p6-quiz-secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3, 12px);
}
@media (max-width: 720px) {
  .p6-quiz-secondary-row { grid-template-columns: 1fr; }
}

.p6-quiz-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1, 4px);
  padding: var(--space-4, 16px);
  background: var(--color-surface, #f9f8f5);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-lg, 12px);
  cursor: pointer;
  text-align: left;
  transition: background 0.18s, box-shadow 0.18s, transform 0.1s;
}
.p6-quiz-card:hover {
  background: var(--color-primary-light, rgba(26,107,78,0.07));
  box-shadow: 0 2px 8px rgba(26,107,78,0.12);
}
.p6-quiz-card:active { transform: scale(0.99); }

.p6-quiz-card-icon {
  color: var(--color-primary);
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}
.p6-quiz-card-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}
.p6-quiz-card-caption {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
  font-weight: 400;
}

/* Tertiary — text link */
.p6-quiz-tertiary {
  text-align: center;
}
.p6-quiz-text-link {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: var(--space-2, 8px) var(--space-3, 12px);
  border-radius: var(--radius-md, 8px);
  text-decoration: none;
  transition: color 0.15s;
}
.p6-quiz-text-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* Dark mode for quiz cards */
[data-theme='dark'] .p6-quiz-card {
  background: var(--color-surface, #1c1b19);
  border-color: var(--color-primary);
}
[data-theme='dark'] .p6-quiz-card:hover {
  background: rgba(79,152,163,0.1);
}
[data-theme='dark'] .p6-quiz-text-link {
  color: var(--color-text-muted);
}
[data-theme='dark'] .p6-quiz-text-link:hover {
  color: var(--color-primary);
}

/* --- FIX 2: Quiz ✓/✗ accessibility icons ------------------------- */
.p6-choice-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 8px;
  vertical-align: middle;
}
.p6-choice-icon--correct svg { color: #16a34a; stroke: #16a34a; }
.p6-choice-icon--wrong   svg { color: #dc2626; stroke: #dc2626; }

[data-theme='dark'] .p6-choice-icon--correct svg { color: #4ade80; stroke: #4ade80; }
[data-theme='dark'] .p6-choice-icon--wrong   svg { color: #f87171; stroke: #f87171; }

/* Ensure quiz-choice inner content is flexed for icon alignment */
.quiz-choice {
  display: flex;
  align-items: flex-start;
  gap: 0;
  text-align: left;
}

/* --- FIX 3: Mobile nav padding ----------------------------------- */
@media (max-width: 720px) {
  .main, .view, .app-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* --- FIX 4: Mnemonic modal title ellipsis ------------------------ */
#mn-header-title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  word-break: normal;
  overflow-wrap: anywhere;
}

/* --- FIX 5: AI tutor FAB tooltip --------------------------------- */
.p6-fab-tooltip {
  position: fixed;
  bottom: 90px;
  right: 80px;
  background: var(--color-text, #28251d);
  color: var(--color-surface, #f9f8f5);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10001;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  animation: p6-tooltip-in 0.25s ease;
}
.p6-fab-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right: none;
  border-left-color: var(--color-text, #28251d);
}
@keyframes p6-tooltip-in {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.p6-fab-tooltip.p6-fade-out {
  animation: p6-tooltip-out 0.3s ease forwards;
}
@keyframes p6-tooltip-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(6px); }
}
[data-theme='dark'] .p6-fab-tooltip {
  background: var(--color-text, #cdccca);
  color: var(--color-surface, #1c1b19);
}
[data-theme='dark'] .p6-fab-tooltip::after {
  border-left-color: var(--color-text, #cdccca);
}

/* --- FIX 6: Tap targets ≥ 40px on mobile ------------------------ */
@media (max-width: 720px) {
  .lang-toggle {
    min-width: 40px;
    min-height: 40px;
  }
  .theme-toggle {
    min-width: 40px;
    min-height: 40px;
  }
  .modal-close {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
  }
  .p3-modal__close {
    min-width: 40px;
    min-height: 40px;
  }
  #mn-close-btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px !important;
    height: 40px !important;
  }
  .mobile-nav-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .mn-saved-chevron {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .streak-cal-day {
    min-width: 28px;
    min-height: 28px;
  }
}

/* === End Phase 6: Polish ======================================= */
/* ================================================================ */

/* ================================================================ */
/* === Phase 6: Progress rebuild ================================== */
/* ================================================================ */

/* ── Gauge wrapper ── */
.p6prog-gauge-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3, 12px);
  padding: var(--space-6, 24px) var(--space-4, 16px) var(--space-4, 16px);
}

.p6prog-gauge-svg {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.10));
}

.p6prog-gauge-score {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
  letter-spacing: -2px;
}

.p6prog-gauge-status {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Status colour tokens */
.p6prog-gauge-status--ready    { color: #437A22; }
.p6prog-gauge-status--close    { color: #01696F; }
.p6prog-gauge-status--warming  { color: #964219; }
.p6prog-gauge-status--not-ready{ color: #A13544; }

/* Gauge arc fill colours */
.p6prog-arc--ready    { stroke: #437A22; }
.p6prog-arc--close    { stroke: #01696F; }
.p6prog-arc--warming  { stroke: #964219; }
.p6prog-arc--not-ready{ stroke: #A13544; }

/* ── Hero card (gauge + tagline) ── */
.p6prog-hero-card {
  background: var(--surface, #F9F8F5);
  border: 1px solid var(--border, #D4D1CA);
  border-radius: var(--radius-lg, 12px);
  padding: var(--space-6, 24px) var(--space-5, 20px);
  margin-bottom: var(--space-4, 16px);
}

.p6prog-hero-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3, 12px);
  text-align: center;
}

.p6prog-tagline {
  font-size: 15px;
  color: var(--text-muted, #7A7974);
  max-width: 420px;
  line-height: 1.5;
}

.p6prog-tagline strong {
  color: var(--text, #28251D);
  font-weight: 600;
}

.p6prog-primary-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary, #01696F);
  color: #fff;
  border: none;
  border-radius: var(--radius, 8px);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
  text-decoration: none;
  margin-top: var(--space-1, 4px);
}

.p6prog-primary-cta:hover {
  background: var(--primary-hover, #0C4E54);
  transform: translateY(-1px);
}

.p6prog-primary-cta:active {
  transform: translateY(0);
}

/* ── Three-column digest grid ── */
.p6prog-digest-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: var(--space-4, 16px);
}

@media (max-width: 960px) {
  .p6prog-digest-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .p6prog-digest-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Digest cards ── */
.p6prog-digest-card {
  background: var(--surface, #F9F8F5);
  border: 1px solid var(--border, #D4D1CA);
  border-radius: var(--radius-lg, 12px);
  padding: var(--space-4, 16px);
  min-width: 0;
}

.p6prog-card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted, #7A7974);
  margin: 0 0 2px;
}

.p6prog-card-subtitle {
  font-size: 13px;
  color: var(--text-muted, #7A7974);
  margin: 0 0 var(--space-3, 12px);
}

/* ── Mini topic rows inside digest cards ── */
.p6prog-mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: default;
}

.p6prog-mini-row--clickable {
  cursor: pointer;
  border-radius: 6px;
  margin: 0 -4px;
  padding: 5px 4px;
  transition: background .12s;
}

.p6prog-mini-row--clickable:hover {
  background: var(--surface-alt, #FBFBF9);
}

.p6prog-mini-row--clickable:hover .p6prog-mini-arrow {
  opacity: 1;
  transform: translateX(0);
}

.p6prog-mini-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #28251D);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p6prog-mini-pct {
  font-size: 13px;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 600;
  color: var(--text, #28251D);
  flex-shrink: 0;
  min-width: 34px;
  text-align: right;
}

.p6prog-mini-bar-wrap {
  width: 60px;
  height: 6px;
  background: var(--border, #D4D1CA);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.p6prog-mini-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}

.p6prog-mini-bar--strong { background: #437A22; }
.p6prog-mini-bar--close  { background: #01696F; }
.p6prog-mini-bar--weak   { background: #A13544; }
.p6prog-mini-bar--amber  { background: #964219; }

.p6prog-mini-arrow {
  font-size: 13px;
  color: var(--text-muted, #7A7974);
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .12s, transform .12s;
}

.p6prog-mini-empty {
  font-size: 13px;
  color: var(--text-faint, #BAB9B4);
  font-style: italic;
  padding: 6px 0;
}

/* Recent activity rows */
.p6prog-activity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border, #D4D1CA);
}

.p6prog-activity-row:last-child {
  border-bottom: none;
}

.p6prog-activity-date {
  font-size: 12px;
  color: var(--text-muted, #7A7974);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p6prog-activity-pct {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  flex-shrink: 0;
}

.p6prog-activity-pct--pass { color: #437A22; }
.p6prog-activity-pct--fail { color: #A13544; }

/* ── All Stats collapser ── */
.p6prog-allstats {
  margin-bottom: var(--space-6, 24px);
}

.p6prog-allstats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3, 12px) var(--space-4, 16px);
  background: var(--surface, #F9F8F5);
  border: 1px solid var(--border, #D4D1CA);
  border-radius: var(--radius-lg, 12px);
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}

.p6prog-allstats-header:hover {
  background: var(--surface-alt, #FBFBF9);
}

.p6prog-allstats-header[aria-expanded='true'] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

.p6prog-allstats-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #28251D);
  display: flex;
  align-items: center;
  gap: 8px;
}

.p6prog-allstats-label small {
  font-weight: 400;
  color: var(--text-muted, #7A7974);
  font-size: 12px;
}

.p6prog-chevron {
  font-size: 13px;
  color: var(--text-muted, #7A7974);
  transition: transform .2s ease;
  flex-shrink: 0;
}

.p6prog-allstats-header[aria-expanded='true'] .p6prog-chevron {
  transform: rotate(180deg);
}

.p6prog-allstats-content {
  background: var(--surface, #F9F8F5);
  border: 1px solid var(--border, #D4D1CA);
  border-top: none;
  border-bottom-left-radius: var(--radius-lg, 12px);
  border-bottom-right-radius: var(--radius-lg, 12px);
  padding: var(--space-4, 16px);
  display: none;
}

.p6prog-allstats-content.p6prog-allstats-content--expanded {
  display: block;
}

/* ── Dark mode parity ── */
[data-theme='dark'] .p6prog-hero-card,
[data-theme='dark'] .p6prog-digest-card,
[data-theme='dark'] .p6prog-allstats-header,
[data-theme='dark'] .p6prog-allstats-content {
  background: var(--surface, #1C1B19);
  border-color: var(--border, #393836);
}

[data-theme='dark'] .p6prog-allstats-header:hover {
  background: var(--surface-alt, #201F1D);
}

[data-theme='dark'] .p6prog-mini-row--clickable:hover {
  background: var(--surface-alt, #201F1D);
}

[data-theme='dark'] .p6prog-tagline {
  color: var(--text-muted, #797876);
}

[data-theme='dark'] .p6prog-tagline strong {
  color: var(--text, #CDCCCA);
}

[data-theme='dark'] .p6prog-gauge-status--ready    { color: #6DAA45; }
[data-theme='dark'] .p6prog-gauge-status--close    { color: #4F98A3; }
[data-theme='dark'] .p6prog-gauge-status--warming  { color: #BB653B; }
[data-theme='dark'] .p6prog-gauge-status--not-ready{ color: #DD6974; }

[data-theme='dark'] .p6prog-arc--ready    { stroke: #6DAA45; }
[data-theme='dark'] .p6prog-arc--close    { stroke: #4F98A3; }
[data-theme='dark'] .p6prog-arc--warming  { stroke: #BB653B; }
[data-theme='dark'] .p6prog-arc--not-ready{ stroke: #DD6974; }

[data-theme='dark'] .p6prog-mini-bar--strong { background: #6DAA45; }
[data-theme='dark'] .p6prog-mini-bar--close  { background: #4F98A3; }
[data-theme='dark'] .p6prog-mini-bar--weak   { background: #DD6974; }
[data-theme='dark'] .p6prog-mini-bar--amber  { background: #BB653B; }

[data-theme='dark'] .p6prog-activity-pct--pass { color: #6DAA45; }
[data-theme='dark'] .p6prog-activity-pct--fail { color: #DD6974; }

[data-theme='dark'] .p6prog-mini-bar-wrap {
  background: var(--border, #393836);
}

[data-theme='dark'] .p6prog-activity-row {
  border-bottom-color: var(--border, #393836);
}

[data-theme='dark'] .p6prog-mini-name,
[data-theme='dark'] .p6prog-mini-pct,
[data-theme='dark'] .p6prog-allstats-label {
  color: var(--text, #CDCCCA);
}

[data-theme='dark'] .p6prog-primary-cta {
  background: var(--primary, #4F98A3);
}

[data-theme='dark'] .p6prog-primary-cta:hover {
  background: var(--primary-hover, #227F8B);
}

/* ── Mobile tweaks ── */
@media (max-width: 720px) {
  .p6prog-gauge-svg {
    width: 140px;
    height: 140px;
  }

  .p6prog-gauge-score {
    font-size: 48px;
  }

  .p6prog-hero-card {
    padding: var(--space-4, 16px);
  }
}

/* ================================================================ */
/* === End Phase 6 ================================================ */
/* ================================================================ */

/* === Phase 6: Today's Focus + Badges === */

/* --- Today's Focus card --- */
.p6focus-card {
  background: var(--color-surface, #F9F8F5);
  border: 1px solid var(--color-border, #D4D1CA);
  border-radius: 16px;
  padding: 24px;
  margin: 16px 0 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.p6focus-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted, #7A7974);
  margin-bottom: 8px;
}
.p6focus-headline {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.35;
  color: var(--text, #28251D);
}
.p6focus-detail {
  color: var(--color-text-secondary, #7A7974);
  margin: 0 0 20px;
  line-height: 1.55;
}
.p6focus-cta {
  display: inline-block;
  background: var(--primary, #01696F);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: filter 0.15s;
}
.p6focus-cta:hover { filter: brightness(1.08); }
.p6focus-secondary {
  margin-top: 16px;
  font-size: 14px;
  color: var(--color-text-secondary, #7A7974);
}
.p6focus-secondary a { color: var(--primary, #01696F); text-decoration: none; }
.p6focus-secondary a:hover { text-decoration: underline; }
.p6focus-show-all {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted, #7A7974);
  text-decoration: none;
  margin: 12px 0 24px;
  cursor: pointer;
}
.p6focus-show-all:hover { color: var(--primary, #01696F); text-decoration: underline; }
[data-theme='dark'] .p6focus-card {
  background: var(--surface, #1C1B19);
  border-color: var(--border, #393836);
}
[data-theme='dark'] .p6focus-headline { color: var(--text, #CDCCCA); }
@media (max-width: 720px) {
  .p6focus-headline { font-size: 18px; }
  .p6focus-cta { width: 100%; text-align: center; display: block; }
}

/* --- Badge taxonomy --- */
.p6badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}
.p6badge--notstarted { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.p6badge--weak       { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.p6badge--needswork  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.p6badge--passing    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.p6badge--mastered   { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

[data-theme='dark'] .p6badge--notstarted { background: #1e293b; color: #cbd5e1; border-color: #475569; }
[data-theme='dark'] .p6badge--weak       { background: #7f1d1d; color: #fecaca; border-color: #b91c1c; }
[data-theme='dark'] .p6badge--needswork  { background: #78350f; color: #fde68a; border-color: #b45309; }
[data-theme='dark'] .p6badge--passing    { background: #1e3a8a; color: #bfdbfe; border-color: #2563eb; }
[data-theme='dark'] .p6badge--mastered   { background: #064e3b; color: #a7f3d0; border-color: #047857; }

/* Badge legend strip */
.p6badge-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 0 4px;
}
@media (max-width: 600px) {
  .p6badge-legend { gap: 6px; }
  .p6badge-legend .p6badge { font-size: 10px; padding: 2px 8px; }
}
/* === End Phase 6: Today's Focus + Badges === */
