/* ==========================================================================
   TOEIC MASTER - PREMIUM PRACTICE WEB APPLICATION
   Design System & Modern CSS Styles
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Color Palette - Vibrant Modern Slate / Indigo / Orange */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.12);
  --primary-glow: rgba(37, 99, 235, 0.35);

  --accent-orange: #f97316;
  --accent-orange-hover: #ea580c;
  --accent-orange-light: rgba(249, 115, 22, 0.12);

  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);

  /* Light Theme Tokens */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.85);
  
  --border-subtle: #e2e8f0;
  --border-focus: #94a3b8;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens */
[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-card: #151d2f;
  --bg-card-subtle: #1e293b;
  --bg-glass: rgba(21, 29, 47, 0.88);

  --border-subtle: #243049;
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.3);
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

html, body {
  overflow-x: clip;
  max-width: 100%;
  position: relative;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   HEADER / TOP NAVBAR
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-info h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-orange-light);
  color: var(--accent-orange);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.exam-select-dropdown {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.exam-select-dropdown:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.exam-select-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Audio Player Floating Bar in Header */
.header-audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.header-audio-player.playing {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.audio-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.audio-btn.primary {
  background: var(--primary);
  color: #fff;
}

.audio-btn.primary:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.audio-track-info {
  display: flex;
  flex-direction: column;
  min-width: 140px;
  max-width: 220px;
}

.audio-track-title {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-timeline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.audio-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.audio-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.audio-speed-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  color: var(--text-secondary);
}

/* Header Action Tools */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-study-hub {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-study-hub:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.45);
  color: #fff;
}

.mode-desc {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.timer-box.warning {
  color: var(--danger);
  border-color: var(--danger);
  animation: pulse-danger 1s infinite alternate;
}

@keyframes pulse-danger {
  from { box-shadow: 0 0 5px rgba(239, 68, 68, 0.2); }
  to { box-shadow: 0 0 15px rgba(239, 68, 68, 0.6); }
}

.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-submit {
  background: linear-gradient(135deg, var(--accent-orange), #ea580c);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
  transition: var(--transition);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
}

/* ==========================================================================
   EXAM SELECTOR BAR (3 CHẾ ĐỘ THI & HỌC MẤT GỐC BANNER)
   ========================================================================== */
.exam-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 24px;
  flex-wrap: wrap;
}

.exam-mode-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.exam-bar-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
}

.exam-pill-btn {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-subtle);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.exam-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.exam-pill-btn.active {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-shuffle-random {
  background: linear-gradient(135deg, #ec4899, #8b5cf6) !important;
  color: #fff !important;
  font-weight: 800 !important;
  border: none !important;
  box-shadow: 0 3px 12px rgba(236, 72, 153, 0.4) !important;
  transition: all 0.2s ease !important;
}

.btn-shuffle-random:hover {
  transform: translateY(-1px) scale(1.04) !important;
  box-shadow: 0 6px 18px rgba(236, 72, 153, 0.55) !important;
}

.btn-study-hub-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 3px 12px rgba(245, 158, 11, 0.4);
  transition: var(--transition);
  animation: pulse-study 2.5s infinite;
}

.btn-study-hub-banner:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.55);
  color: #fff;
}

@keyframes pulse-study {
  0%, 100% { box-shadow: 0 3px 12px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 4px 18px rgba(245, 158, 11, 0.7); }
}

/* ==========================================================================
   PART NAVIGATION & OVERALL PROGRESS
   ========================================================================== */
.part-nav-container {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 24px 0 24px;
}

.part-nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
}

.part-nav-tabs::-webkit-scrollbar {
  display: none;
}

.part-tab {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.part-tab:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
}

.part-tab.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.part-badge-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
}

.part-tab.active .part-badge-count {
  background: var(--primary);
  color: #fff;
}

/* Overall Progress Indicator Bar */
.overall-progress-bar {
  width: 100%;
  height: 3px;
  background: var(--border-subtle);
  position: relative;
}

.overall-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-orange));
  width: 0%;
  transition: width 0.3s ease;
}

/* ==========================================================================
   MAIN CONTENT GRID
   ========================================================================== */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.exam-area {
  min-width: 0;
}

/* Part Header Card */
.part-banner-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.part-banner-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--primary), var(--accent-orange));
}

.part-banner-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.part-banner-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Group Question Card */
.question-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.question-group-card:hover {
  border-color: var(--border-focus);
}

/* Audio Player inside Question Group */
.group-audio-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card-subtle);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.audio-wave-anim {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.audio-wave-bar {
  width: 3px;
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  transition: height 0.2s ease;
}

.playing .audio-wave-bar:nth-child(1) { animation: wave 0.8s infinite 0.1s; }
.playing .audio-wave-bar:nth-child(2) { animation: wave 0.8s infinite 0.2s; }
.playing .audio-wave-bar:nth-child(3) { animation: wave 0.8s infinite 0.3s; }
.playing .audio-wave-bar:nth-child(4) { animation: wave 0.8s infinite 0.4s; }

@keyframes wave {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

/* Image Display inside Question */
.group-image-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-subtle);
}

.group-image {
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  transition: transform 0.2s ease;
}

.group-image:hover {
  transform: scale(1.01);
}

.image-zoom-hint {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Split View for Part 7 (Passage on Left, Questions on Right) */
.part7-split-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.passage-sticky-panel {
  position: sticky;
  top: 140px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-subtle);
  padding: 8px;
}

.passage-sticky-panel img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
}

.passage-text-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
  font-size: 14.5px;
  line-height: 1.8;
  white-space: pre-line;
}

/* Single Question Item */
.single-question-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.single-question-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.q-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.q-number-pill {
  font-size: 13px;
  font-weight: 800;
  background: var(--bg-card-subtle);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.q-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.5;
}

.q-flag-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.q-flag-btn:hover, .q-flag-btn.flagged {
  color: var(--warning);
}

/* Options / Choices List */
.choices-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.choice-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  font-size: 14px;
}

.choice-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(3px);
}

.choice-radio {
  display: none;
}

.choice-indicator {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}

.choice-label.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.choice-label.selected .choice-indicator {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Practice Mode & Result Mode Feedback */
.choice-label.is-correct {
  border-color: var(--success) !important;
  background: var(--success-light) !important;
}

.choice-label.is-correct .choice-indicator {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
}

.choice-label.is-wrong {
  border-color: var(--danger) !important;
  background: var(--danger-light) !important;
}

.choice-label.is-wrong .choice-indicator {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}

/* Explanation & Transcript Accordion */
.transcript-accordion {
  margin-top: 14px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card-subtle);
}

.transcript-header {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.transcript-content {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  white-space: pre-line;
  background: var(--bg-card);
}

.matrix-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 104;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.matrix-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   SIDEBAR - QUESTION PALETTE (200 Questions Matrix)
   ========================================================================== */
.sidebar-matrix {
  position: sticky;
  top: 130px;
  max-height: calc(100vh - 150px);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.matrix-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.matrix-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  font-size: 11px;
  text-align: center;
}

.stat-chip {
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  font-weight: 700;
}

.stat-chip.answered { color: var(--primary); }
.stat-chip.unanswered { color: var(--text-muted); }
.stat-chip.flagged { color: var(--warning); }

.matrix-filter-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.matrix-filter-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--border-subtle);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
}

.matrix-filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.matrix-grid-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.matrix-part-section {
  margin-bottom: 14px;
}

.matrix-part-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.matrix-buttons-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.q-matrix-btn {
  height: 32px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
}

.q-matrix-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.08);
}

.q-matrix-btn.answered {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.q-matrix-btn.flagged::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.q-matrix-btn.correct {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
}

.q-matrix-btn.wrong {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}

/* ==========================================================================
   FLOATING BOTTOM BAR
   ========================================================================== */
.floating-bottom-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 6px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

.nav-jump-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.nav-jump-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ==========================================================================
   RESULT & SCORE MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 32px;
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.result-score-hero {
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-orange-light));
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
}

.score-number {
  font-size: 56px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: 8px;
}

.score-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.score-box {
  background: var(--bg-card-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-subtle);
}

.score-box-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}

.part-breakdown-list {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.part-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

/* Lightbox Modal */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.lightbox-close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.lightbox-close-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   RESPONSIVENESS (Mobile & Tablet)
   ========================================================================== */
@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  
  .sidebar-matrix {
    position: fixed;
    right: -360px;
    top: 0;
    bottom: 0;
    width: 320px;
    max-height: 100vh;
    z-index: 105;
    border-radius: 0;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar-matrix.open {
    right: 0;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
  }

  .part7-split-view {
    grid-template-columns: 1fr;
  }

  .passage-sticky-panel {
    position: static;
    max-height: 400px;
  }

  .app-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
    justify-content: space-between;
  }

  .brand-section {
    order: 1;
    flex-shrink: 0;
  }

  .header-actions {
    order: 2;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .header-audio-player {
    display: flex !important;
    width: 100%;
    order: 3;
    padding: 6px 10px;
    gap: 6px;
    justify-content: space-between;
  }

  .audio-track-info {
    flex: 1;
    min-width: 0;
  }

  .audio-btn, .audio-speed-btn {
    flex-shrink: 0;
  }
}

@media (max-width: 640px) {
  .app-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 6px 8px;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  .brand-logo {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .brand-info h1 {
    font-size: 13px;
    gap: 4px;
  }

  .brand-badge {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

  .btn-study-hub {
    padding: 5px 8px;
    font-size: 11px;
    gap: 3px;
  }

  .btn-study-hub span {
    display: none; /* Just 🎓 icon on mobile */
  }

  .toggle-switch-wrapper {
    padding: 4px 8px;
    font-size: 11px;
  }

  .mode-desc {
    display: none; /* Hide extra mode description text on phones */
  }

  .audio-shortcut-hint {
    display: none !important; /* Hide spacebar hint on mobile */
  }

  .timer-box {
    font-size: 11.5px;
    padding: 3px 6px;
    gap: 4px;
  }

  .timer-box svg {
    width: 13px;
    height: 13px;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn-submit {
    padding: 5px 8px;
    font-size: 11px;
  }

  .btn-submit span {
    display: none; /* Icon only for submit on mobile */
  }

  .mobile-only {
    display: flex !important;
  }

  .part-nav-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding: 6px 8px;
    -webkit-overflow-scrolling: touch;
  }

  .part-nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .part-tab-btn {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
  }

  .choice-label {
    min-height: 48px;
    padding: 10px 12px;
  }

  /* CRITICAL: Keep exam-area with bottom padding so floating bottom bar never occludes content */
  .exam-area {
    padding-bottom: 80px;
  }

  .floating-bottom-bar {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 24px);
    max-width: 420px;
    justify-content: space-between;
  }

  .nav-jump-btn {
    padding: 6px 10px;
    font-size: 11.5px;
  }
}

@media (max-width: 380px) {
  .brand-info h1 {
    font-size: 11.5px;
  }

  #theme-toggle-btn {
    display: flex !important;
  }

  .timer-box {
    padding: 2px 5px;
    font-size: 11px;
  }

  .toggle-switch-wrapper {
    padding: 3px 6px;
    font-size: 10.5px;
  }

  .nav-jump-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}
