/* ==========================================================================
   ISTQB CT-GenAI Master - Quiz Styles (Faithfully matching user photo reference)
   ========================================================================== */

.quiz-view-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* --------------------------------------------------------------------------
   1. QUIZ DASHBOARD / MENU SCREEN
   -------------------------------------------------------------------------- */
.quiz-menu {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.menu-hero {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.08));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.menu-hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.menu-hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 650px;
  margin: 0 auto 20px auto;
}

.menu-mode-toggle {
  display: inline-flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.mode-btn {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

.section-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.grid-chapters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chapter-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.chapter-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ch-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
}

.ch-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chapter-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.35;
}

.chapter-card-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
  flex: 1;
}

.chapter-card-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-subtle);
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

/* Mock exam cards */
.grid-mock {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.mock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.mock-card:hover {
  border-color: #8b5cf6;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.mock-badge {
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  width: fit-content;
  margin-bottom: 8px;
}

/* Quick special buttons */
.quick-modes {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-mode-card {
  flex: 1;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition-fast);
}

.quick-mode-card:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.qm-icon {
  font-size: 1.6rem;
}

.qm-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.qm-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   2. QUIZ ACTIVE PLAY SCREEN (Direct reproduction of user image)
   -------------------------------------------------------------------------- */
.quiz-active {
  display: none;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 32px;
  position: relative;
  min-height: 540px;
}

.quiz-active.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

/* Quiz Active Top Bar */
.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quiz-top-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
}

.quiz-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-top-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.quiz-top-btn:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.quiz-top-btn.bookmarked {
  color: #f59e0b;
}

/* Segmented / Progress Bar */
.quiz-progress-track {
  width: 100%;
  height: 5px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 18px;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Score / Counter bar */
.quiz-meta-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-counter {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 6px;
}

/* Red / Green badges matching user photo */
.badge-score-wrong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: #fecaca;
  color: #b91c1c;
  font-size: 0.85rem;
  font-weight: 700;
}

[data-theme="dark"] .badge-score-wrong {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.badge-score-correct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: #bbf7d0;
  color: #15803d;
  font-size: 0.85rem;
  font-weight: 700;
}

[data-theme="dark"] .badge-score-correct {
  background: rgba(16, 185, 129, 0.25);
  color: #86efac;
}

/* Question Statement */
.quiz-question-box {
  margin-bottom: 26px;
}

.question-text-vn {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.6;
  margin-bottom: 8px;
}

.question-text-en {
  font-size: 0.98rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
  display: block;
}

.multi-select-note {
  display: inline-block;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   OPTIONS LIST (Matching User Reference)
   -------------------------------------------------------------------------- */
.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 30px;
}

.option-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  position: relative;
  user-select: none;
}

.option-card:hover:not(.answered) {
  background: var(--bg-card-hover);
  border-color: var(--primary-border);
  transform: translateX(2px);
}

.option-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.option-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

.option-text-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.option-text-vn {
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.45;
}

.option-text-en {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* User Choice Badge */
.user-choice-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
  width: fit-content;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  text-transform: uppercase;
}

.user-choice-wrong {
  background: #ef4444;
  color: #ffffff;
  border: 1px solid #dc2626;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
  animation: glowRedBadge 1.4s infinite alternate;
}

[data-theme="dark"] .user-choice-wrong {
  background: #dc2626;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
}

.user-choice-correct {
  background: #10b981;
  color: #ffffff;
  border: 1px solid #059669;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
  animation: glowGreenBadge 1.4s infinite alternate;
}

[data-theme="dark"] .user-choice-correct {
  background: #059669;
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.7);
}

.user-choice-exam {
  background: #3b82f6;
  color: #ffffff;
  border: 1px solid #2563eb;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
  animation: glowBlueBadge 1.4s infinite alternate;
}

[data-theme="dark"] .user-choice-exam {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.7);
}

/* Status Badges on the right */
.option-status-badge {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   GLOWING HIGHLIGHT ON SELECTED CARD (Phát sáng rực rỡ khi chọn)
   -------------------------------------------------------------------------- */
.option-card.user-selected {
  position: relative;
  z-index: 5;
  transform: translateY(-2px);
}

/* 1. When user selected WRONG answer (Glowing Red) */
.option-card.user-selected.incorrect-selected {
  border: 3px solid #ef4444 !important;
  background: #fff5f5 !important;
  outline: 2px solid rgba(239, 68, 68, 0.4);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.35), 0 0 28px rgba(239, 68, 68, 0.5), 0 6px 16px rgba(239, 68, 68, 0.2) !important;
  animation: glowRed 1.4s infinite alternate !important;
}

[data-theme="dark"] .option-card.user-selected.incorrect-selected {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #f87171 !important;
  outline-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.45), 0 0 32px rgba(239, 68, 68, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5) !important;
}

.option-card.user-selected.incorrect-selected .option-letter {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.7);
}

.option-card.incorrect-selected .option-status-badge.badge-incorrect {
  display: inline-flex;
  background: #fecaca;
  color: #b91c1c;
  font-weight: 700;
}

[data-theme="dark"] .option-card.incorrect-selected .option-status-badge.badge-incorrect {
  background: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

/* 2. When user selected CORRECT answer (Glowing Green) */
.option-card.user-selected.correct-answer {
  border: 3px solid #10b981 !important;
  background: #f0fdf4 !important;
  outline: 2px solid rgba(16, 185, 129, 0.4);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.35), 0 0 28px rgba(16, 185, 129, 0.5), 0 6px 16px rgba(16, 185, 129, 0.2) !important;
  animation: glowGreen 1.4s infinite alternate !important;
}

[data-theme="dark"] .option-card.user-selected.correct-answer {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: #34d399 !important;
  outline-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.45), 0 0 32px rgba(16, 185, 129, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5) !important;
}

.option-card.user-selected.correct-answer .option-letter {
  background: #10b981;
  color: white;
  border-color: #059669;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.7);
}

/* Correct Answer Normal State (Non-selected, shown for reference) */
.option-card.correct-answer:not(.user-selected) {
  background: #f0fdf4 !important;
  border: 1.5px solid #4ade80 !important;
}

[data-theme="dark"] .option-card.correct-answer:not(.user-selected) {
  background: rgba(16, 185, 129, 0.1) !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
}

.option-card.correct-answer .option-status-badge.badge-correct {
  display: inline-flex;
  background: #bbf7d0;
  color: #15803d;
  font-weight: 700;
}

[data-theme="dark"] .option-card.correct-answer .option-status-badge.badge-correct {
  background: rgba(16, 185, 129, 0.35);
  color: #bbf7d0;
}

/* 3. In Exam Mode or Pending Multi-Select (Glowing Blue) */
.option-card.user-selected.selected-exam,
.option-card.user-selected.pending-selected {
  border: 3px solid #3b82f6 !important;
  background: rgba(59, 130, 246, 0.08) !important;
  outline: 2px solid rgba(59, 130, 246, 0.4);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35), 0 0 28px rgba(59, 130, 246, 0.5), 0 6px 16px rgba(59, 130, 246, 0.15) !important;
  animation: glowBlue 1.4s infinite alternate !important;
}

[data-theme="dark"] .option-card.user-selected.selected-exam,
[data-theme="dark"] .option-card.user-selected.pending-selected {
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: #60a5fa !important;
  outline-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.45), 0 0 32px rgba(59, 130, 246, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5) !important;
}

.option-card.user-selected.selected-exam .option-letter,
.option-card.user-selected.pending-selected .option-letter {
  background: #3b82f6;
  color: white;
  border-color: #2563eb;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.7);
}

/* Keyframe animations for glowing pulses */
@keyframes glowRed {
  0% {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25), 0 0 14px rgba(239, 68, 68, 0.35);
  }
  100% {
    box-shadow: 0 0 0 7px rgba(239, 68, 68, 0.55), 0 0 36px rgba(239, 68, 68, 0.75);
  }
}

@keyframes glowGreen {
  0% {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25), 0 0 14px rgba(16, 185, 129, 0.35);
  }
  100% {
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0.55), 0 0 36px rgba(16, 185, 129, 0.75);
  }
}

@keyframes glowBlue {
  0% {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), 0 0 14px rgba(59, 130, 246, 0.35);
  }
  100% {
    box-shadow: 0 0 0 7px rgba(59, 130, 246, 0.55), 0 0 36px rgba(59, 130, 246, 0.75);
  }
}

@keyframes glowRedBadge {
  0% { transform: scale(1); box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
  100% { transform: scale(1.02); box-shadow: 0 0 16px rgba(239, 68, 68, 0.8); }
}

@keyframes glowGreenBadge {
  0% { transform: scale(1); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
  100% { transform: scale(1.02); box-shadow: 0 0 16px rgba(16, 185, 129, 0.8); }
}

@keyframes glowBlueBadge {
  0% { transform: scale(1); box-shadow: 0 0 8px rgba(59, 130, 246, 0.5); }
  100% { transform: scale(1.02); box-shadow: 0 0 16px rgba(59, 130, 246, 0.8); }
}

/* In-Card Explanation Box (Slide down) */
.option-explanation-box {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-color);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-main);
  animation: fadeIn 0.25s ease-out;
}

[data-theme="dark"] .option-explanation-box {
  background: rgba(0, 0, 0, 0.25);
}

.option-card.show-explanation .option-explanation-box {
  display: block;
}

.exp-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.exp-badge-correct {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

[data-theme="dark"] .exp-badge-correct {
  background: rgba(16, 185, 129, 0.2);
  color: #86efac;
}

.exp-badge-incorrect {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

[data-theme="dark"] .exp-badge-incorrect {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.exp-text-body {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Incorrect preview for "Show all explanations" */
.option-card.incorrect-preview {
  background: #fff5f5 !important;
  border-color: #fed7d7 !important;
}

[data-theme="dark"] .option-card.incorrect-preview {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
}

.opt-lang-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}

.btn-syllabus-link.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* --------------------------------------------------------------------------
   SYLLABUS MAPPING & TIPS DRAWER
   -------------------------------------------------------------------------- */
.quiz-extra-info {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.syllabus-mapping-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.syllabus-mapping-pill strong {
  color: var(--text-main);
}

.extra-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-syllabus-link {
  background: var(--bg-card);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-syllabus-link:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn-tips-toggle {
  background: var(--bg-card);
  border: 1px solid var(--warning-border);
  color: #b45309;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-tips-toggle:hover {
  background: var(--warning-bg);
}

.tips-container {
  display: none;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 0.88rem;
  color: #78350f;
  line-height: 1.55;
  animation: fadeIn 0.2s ease-out;
}

[data-theme="dark"] .tips-container {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
  color: #fde68a;
}

.tips-container.active {
  display: block;
}

/* --------------------------------------------------------------------------
   BOTTOM NAVIGATION CONTROLS (Back / Next)
   -------------------------------------------------------------------------- */
.quiz-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.btn-nav-control {
  min-width: 100px;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.btn-nav-back {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-nav-back:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-nav-back:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-nav-next {
  background: #3b82f6;
  color: white;
}

.btn-nav-next:hover {
  background: #2563eb;
}

/* --------------------------------------------------------------------------
   QUESTION DRAWER / PALETTE
   -------------------------------------------------------------------------- */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px 4px;
}

.palette-btn {
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.palette-btn:hover {
  border-color: var(--primary);
  background: var(--bg-subtle);
}

.palette-btn.current {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.palette-btn.correct {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

[data-theme="dark"] .palette-btn.correct {
  background: rgba(16, 185, 129, 0.25);
  color: #86efac;
  border-color: rgba(16, 185, 129, 0.4);
}

.palette-btn.incorrect {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

[data-theme="dark"] .palette-btn.incorrect {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.palette-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0 0 0;
  border-top: 1px solid var(--border-color);
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   QUIZ RESULT SCREEN
   -------------------------------------------------------------------------- */
.quiz-result {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  box-shadow: var(--shadow-md);
}

.quiz-result.active {
  display: flex;
  animation: fadeIn 0.3s ease-out;
}

.result-score-ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  border: 8px solid var(--border-color);
  font-size: 2.2rem;
  font-weight: 800;
  position: relative;
}

.result-score-ring.passed {
  border-color: #10b981;
  color: #10b981;
}

.result-score-ring.failed {
  border-color: #ef4444;
  color: #ef4444;
}

.score-pct {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.result-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 500px;
  margin-bottom: 28px;
}

.result-stats-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  width: 100%;
  max-width: 540px;
}

.res-stat-card {
  flex: 1;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.res-stat-val {
  font-size: 1.5rem;
  font-weight: 800;
}

.res-stat-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ==========================================================================
   MOBILE & TOUCH OPTIMIZATION FOR QUIZ
   ========================================================================== */
@media (max-width: 768px), (pointer: coarse) and (max-width: 900px) {
  .quiz-view-container {
    padding: 10px 8px 30px 8px;
  }

  /* Chapter Cards on Mobile */
  .menu-hero {
    padding: 20px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
  }

  .menu-hero h1 {
    font-size: 1.35rem;
  }

  .menu-hero p {
    font-size: 0.84rem;
    margin-bottom: 14px;
  }

  .grid-chapters {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chapter-card {
    padding: 14px 16px;
    border-radius: var(--radius-md);
  }

  /* Active Quiz Screen on Mobile */
  .quiz-active {
    padding: 14px 12px;
    border-radius: var(--radius-md);
    box-shadow: none;
    border: 1px solid var(--border-color);
  }

  .quiz-top-bar {
    gap: 8px;
    margin-bottom: 10px;
  }

  .quiz-top-title {
    font-size: 0.88rem;
    line-height: 1.35;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .quiz-top-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .quiz-top-btn {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
  }

  .quiz-meta-bar {
    margin-bottom: 12px;
    font-size: 0.85rem;
  }

  .quiz-counter {
    font-size: 0.95rem;
    font-weight: 800;
  }

  .quiz-question-box {
    font-size: 1.02rem;
    line-height: 1.55;
    padding: 16px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
  }

  /* Options list: Large tap targets for thumbs */
  .quiz-options-list {
    gap: 10px;
    margin-bottom: 16px;
  }

  .quiz-option-card {
    padding: 13px 14px;
    min-height: 52px;
    border-radius: var(--radius-md);
    -webkit-tap-highlight-color: transparent;
  }

  .option-header {
    gap: 10px;
    font-size: 0.93rem;
    line-height: 1.45;
  }

  .option-letter {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.88rem;
    border-radius: 8px;
  }

  .option-exp-box {
    margin-top: 10px;
    padding: 10px 12px;
    font-size: 0.83rem;
    line-height: 1.45;
    border-radius: var(--radius-sm);
  }

  /* Extra Info & Tips */
  .quiz-extra-info {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    align-items: stretch;
  }

  .extra-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .btn-syllabus-link,
  .btn-tips-toggle {
    flex: 1;
    min-width: 110px;
    padding: 8px 10px;
    font-size: 0.78rem;
    justify-content: center;
    border-radius: var(--radius-sm);
  }

  /* Navigation Buttons: Big touch buttons */
  .quiz-bottom-nav {
    display: flex;
    gap: 10px;
    margin-top: 12px;
  }

  .btn-nav-control {
    flex: 1;
    height: 48px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  /* Palette modal sheet on mobile */
  .palette-dialog {
    width: 96vw;
    max-height: 82vh;
    padding: 16px 12px;
    border-radius: var(--radius-lg);
  }

  .palette-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    max-height: 55vh;
  }

  .palette-btn {
    height: 40px;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
  }
}

