/* ============================================
   FreeTheory - Minimalistic Dark Theme
   Clean, professional, responsive design
   ============================================ */

/* CSS Variables */
:root {
  --bg-primary: #0f0f13;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #232330;
  --bg-hover: #2a2a3a;
  --text-primary: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
  --container-max: 1100px;
  --container-narrow: 800px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Legacy compat aliases used in JS inline styles */
  --accent-blue: #6366f1;
  --accent-purple: #818cf8;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --accent-pink: #EC4899;
  --accent-cyan: #06B6D4;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-strong: rgba(255, 255, 255, 0.08);
  --bg-card-hover: var(--bg-hover);
  --border-glass: var(--border);
  --border-glass-strong: var(--border-hover);
  --correct-bg: rgba(34, 197, 94, 0.12);
  --correct-border: rgba(34, 197, 94, 0.4);
  --incorrect-bg: rgba(239, 68, 68, 0.12);
  --incorrect-border: rgba(239, 68, 68, 0.4);
  --selected-bg: var(--accent-glow);
  --selected-border: rgba(99, 102, 241, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg-primary);
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
}

/* NO decorative body::before gradient */

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  background: var(--bg-primary);
}

.loader-content {
  animation: fadeIn 0.5s ease;
}

.loader-icon {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  opacity: 0.8;
}

.loader-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.loader-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.loader-bar {
  width: 180px;
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}

.loader-bar-fill {
  width: 30%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% { width: 0%; margin-left: 0; }
  50% { width: 50%; margin-left: 25%; }
  100% { width: 0%; margin-left: 100%; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.7; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Container & Layout
   ============================================ */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================
   Page Transitions
   ============================================ */
.page {
  animation: fadeIn 0.3s ease;
}

#app {
  transition: opacity 0.15s ease;
}
#app.content-fade-out {
  opacity: 0;
}
#app.content-fade-in {
  opacity: 1;
}

/* ============================================
   Header (sticky app bar)
   ============================================ */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ============================================
   Hero Section (kept for backwards compat, minimal)
   ============================================ */
.hero {
  text-align: center;
  padding: 2rem 1rem 0.5rem;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-weight: 500;
}

.hero-badge .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero h1 span {
  color: var(--accent);
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hero-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ============================================
   Home Header (new simplified)
   ============================================ */
.home-header {
  padding: 1.5rem 0 0.5rem;
}

.home-page {
  padding-bottom: 2rem;
}

/* ============================================
   Search Bar
   ============================================ */
.search-container {
  max-width: 500px;
  margin: 1rem auto 1.5rem;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 400;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* ============================================
   Category Groups
   ============================================ */
.category-groups {
  padding-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-group {
  animation: fadeIn 0.3s ease;
  animation-fill-mode: both;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.category-group:nth-child(1) { animation-delay: 0s; }
.category-group:nth-child(2) { animation-delay: 0.04s; }
.category-group:nth-child(3) { animation-delay: 0.08s; }
.category-group:nth-child(4) { animation-delay: 0.12s; }
.category-group:nth-child(5) { animation-delay: 0.16s; }
.category-group:nth-child(6) { animation-delay: 0.2s; }
.category-group:nth-child(7) { animation-delay: 0.24s; }

.group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
  border-radius: 0;
}

.group-header:hover {
  filter: brightness(1.1);
}

.group-icon {
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.group-info {
  flex: 1;
}

.group-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.group-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.group-toggle {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.group-toggle.expanded {
  transform: rotate(180deg);
}

.group-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  padding: 10px 1rem 1rem;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}

.group-categories.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

/* ============================================
   Category Cards
   ============================================ */
.category-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.category-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.category-card.coming-soon {
  opacity: 0.45;
  cursor: default;
}

.category-card.coming-soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

.category-card-icon {
  font-size: 1.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.category-card-info {
  flex: 1;
  min-width: 0;
}

.category-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.category-card-meta span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.category-card-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-xl);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--accent);
}

.category-card-arrow {
  color: var(--text-muted);
  font-size: 1rem;
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}

.category-card:hover .category-card-arrow {
  color: var(--text-secondary);
  transform: translateX(2px);
}

.coming-soon-badge {
  font-size: 0.62rem;
  padding: 0.1rem 0.45rem;
  background: rgba(107, 114, 128, 0.15);
  border: 1px solid rgba(107, 114, 128, 0.2);
  border-radius: var(--radius-xl);
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================
   Test List Screen
   ============================================ */
.test-list-page {
  padding-bottom: 3rem;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 0;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.page-header-info {
  flex: 1;
}

.page-header-info h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.page-header-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 0.75rem;
}

.test-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  animation: fadeIn 0.25s ease;
  animation-fill-mode: both;
}

.test-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.test-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.test-card-number {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.test-card-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-xl);
  color: var(--success);
  font-weight: 600;
}

.test-card-badge.saved {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.25);
  color: var(--warning);
}

.test-card-meta {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.test-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.test-card-actions {
  display: flex;
  gap: 0.5rem;
}

.test-card-actions .btn {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.5rem 0.6rem;
}

.saved-quiz-card {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.04);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-success {
  background: var(--success);
  color: white;
  border: none;
}

.btn-success:hover {
  background: #16a34a;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-danger {
  background: var(--error);
  color: white;
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-warning {
  background: var(--warning);
  color: #1a1a24;
  border: none;
  font-weight: 600;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ============================================
   Quiz Screen
   ============================================ */
.quiz-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Quiz Header */
.quiz-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 19, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  animation: slideInDown 0.25s ease;
}

.quiz-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: var(--container-narrow);
  margin: 0 auto;
}

.quiz-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-xl);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quiz-mode-badge.practice {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: var(--success);
}

.quiz-mode-badge.exam {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--error);
}

.quiz-counter {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.quiz-counter span {
  color: var(--text-muted);
}

.quiz-timer {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.quiz-timer.warning {
  color: var(--warning);
}

.quiz-timer.danger {
  color: var(--error);
  animation: pulse 1s ease-in-out infinite;
}

.quiz-header-actions {
  display: flex;
  gap: 0.4rem;
}

.quiz-progress {
  max-width: var(--container-narrow);
  margin: 0.35rem auto 0;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Quiz Content */
.quiz-content {
  flex: 1;
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

/* Question */
.question-section {
  margin-bottom: 1.25rem;
}

.question-number {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.7;
}

/* Question Images */
.question-images {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.question-image-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
  max-width: 300px;
}

.question-image-wrapper:hover {
  border-color: var(--accent);
}

.question-image-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.image-zoom-hint {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.6rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.question-image-wrapper:hover .image-zoom-hint {
  opacity: 1;
}

/* Answer Options */
.answers-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.answer-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.answer-option:hover:not(.disabled) {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.answer-option.selected {
  background: var(--accent-glow);
  border-color: var(--selected-border);
}

.answer-option.correct {
  background: var(--correct-bg);
  border-color: var(--correct-border);
}

.answer-option.incorrect {
  background: var(--incorrect-bg);
  border-color: var(--incorrect-border);
}

.answer-option.disabled {
  cursor: default;
}

.answer-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition);
}

.answer-option.selected .answer-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.answer-option.correct .answer-letter {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.answer-option.incorrect .answer-letter {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

.answer-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
  padding-top: 0.15rem;
  font-weight: 400;
}

/* Explanation */
.explanation-inline {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  animation: fadeIn 0.25s ease;
}

.explanation-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.explanation-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Quiz Navigation */
.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.quiz-nav-left,
.quiz-nav-right {
  display: flex;
  gap: 0.5rem;
}

.quiz-nav-center {
  display: flex;
  gap: 0.5rem;
}

/* ============================================
   Results Screen
   ============================================ */
.results-page {
  padding: 2rem 1rem 3rem;
  animation: fadeIn 0.4s ease;
}

.results-hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.results-score-ring {
  width: 150px;
  height: 150px;
  margin: 0 auto 1.25rem;
  position: relative;
}

.results-score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.results-score-ring .ring-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.results-score-ring .ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.results-score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.results-score-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.results-score-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.results-status {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.results-status.pass {
  color: var(--success);
}

.results-status.fail {
  color: var(--error);
}

.results-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  max-width: 550px;
  margin: 0 auto 1.5rem;
}

.result-stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.5rem;
  text-align: center;
}

.result-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.result-stat-value.correct { color: var(--success); }
.result-stat-value.incorrect { color: var(--error); }
.result-stat-value.unanswered { color: var(--text-muted); }
.result-stat-value.total { color: var(--accent); }

.result-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
  font-weight: 500;
}

.results-pass-threshold {
  text-align: center;
  padding: 0.65rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 550px;
  margin: 0 auto 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.results-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

/* Review Section */
.review-section {
  max-width: var(--container-narrow);
  margin: 0 auto;
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.review-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.review-question {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  margin-bottom: 0.6rem;
}

.review-question-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.review-status-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.review-status-icon.correct {
  background: var(--correct-bg);
  border: 1px solid var(--correct-border);
}

.review-status-icon.incorrect {
  background: var(--incorrect-bg);
  border: 1px solid var(--incorrect-border);
}

.review-status-icon.unanswered {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.review-question-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.5;
}

.review-answers {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.review-answer {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.review-answer.correct-answer {
  background: var(--correct-bg);
  border: 1px solid var(--correct-border);
  color: var(--text-primary);
}

.review-answer.user-incorrect {
  background: var(--incorrect-bg);
  border: 1px solid var(--incorrect-border);
  color: var(--text-primary);
}

.review-answer-letter {
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.review-explanation {
  margin-top: 0.6rem;
  padding: 0.65rem;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.review-explanation strong {
  color: var(--accent);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideInUp 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.1rem 0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0 1.1rem 1.1rem;
}

/* Image Modal */
.modal-image-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.modal-image-container img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.modal-image-container .modal-close {
  position: absolute;
  top: -40px;
  right: 0;
}

/* Nav Modal */
.nav-modal {
  max-width: 600px;
}

.nav-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nav-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.nav-dot-answered { background: var(--success); }
.nav-dot-flagged { background: var(--warning); }
.nav-dot-current { background: var(--accent); }
.nav-dot-unanswered { background: var(--bg-tertiary); border: 1px solid var(--border); }

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 0.35rem;
}

.nav-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.nav-cell:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.nav-cell.answered {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--success);
}

.nav-cell.flagged {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

.nav-cell.current {
  background: var(--accent-glow);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ============================================
   Authentication Modal
   ============================================ */
#authModal {
  background: rgba(15, 15, 19, 0.98);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

#authModal .modal-content {
  max-width: 400px;
  width: 90%;
  text-align: center;
  padding: 2.5rem 2rem;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.auth-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.auth-title {
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

.auth-description {
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  font-weight: 400;
}

#authError {
  background: rgba(239, 68, 68, 0.08);
  color: var(--error);
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(239, 68, 68, 0.15);
  text-align: center;
}

#authCodeInput {
  width: 100%;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
  font-family: var(--font);
}

#authCodeInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#authSubmitBtn {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

/* ============================================
   Error State
   ============================================ */
.error-state {
  text-align: center;
  padding: 3rem 1rem;
}

.error-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.85rem;
  opacity: 0.8;
}

.error-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.9rem;
  font-weight: 400;
}

/* ============================================
   Inline Spinner
   ============================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.85rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ============================================
   Keyboard Shortcut Hints
   ============================================ */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 0.35rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.62rem;
  font-family: var(--font);
  font-weight: 600;
  color: var(--text-muted);
}

/* ============================================
   Show Explanation Button Pulse
   ============================================ */
#showExplanation {
  animation: pulse-subtle 2s infinite;
  color: var(--warning);
  font-size: 1.05rem;
}

@keyframes pulse-subtle {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3); }
  70% { transform: scale(1.04); box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-weight: 400;
}

/* ============================================
   Security - Disable Selection
   ============================================ */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ============================================
   Responsive Design
   ============================================ */

/* --- Tablet (768px - 1024px) --- */
@media (max-width: 1024px) {
  .group-categories {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .test-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .results-stats {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  .hero {
    padding: 1.5rem 1rem 0.5rem;
  }

  .hero h1 {
    font-size: 1.7rem;
  }

  .hero-subtitle {
    font-size: 0.88rem;
  }

  .hero-stats {
    gap: 1.25rem;
  }

  .hero-stat-value {
    font-size: 1.15rem;
  }

  /* Category groups - single column */
  .group-categories {
    grid-template-columns: 1fr;
  }

  .group-header {
    padding: 0.6rem 0.75rem;
  }

  .group-name {
    font-size: 0.9rem;
  }

  /* Category cards */
  .category-card {
    padding: 0.8rem;
  }

  .category-card-name {
    font-size: 0.88rem;
    white-space: normal;
    word-wrap: break-word;
  }

  /* Test grid - single column */
  .test-grid {
    grid-template-columns: 1fr;
  }

  /* Search */
  .search-container {
    max-width: 100%;
    margin: 0.75rem auto 1.25rem;
  }

  .search-input {
    font-size: 1rem;
    padding: 0.7rem 1rem 0.7rem 2.5rem;
  }

  /* Page header */
  .page-header {
    padding: 0.85rem 0;
    gap: 0.6rem;
  }

  .page-header-info h2 {
    font-size: 1.05rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .page-header-info p {
    font-size: 0.78rem;
  }

  /* Results */
  .results-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .results-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .results-hero {
    padding: 1rem 0 1.5rem;
  }

  .results-score-ring {
    width: 130px;
    height: 130px;
  }

  .results-score-value {
    font-size: 1.9rem;
  }

  .results-status {
    font-size: 1.2rem;
  }

  /* Quiz header */
  .quiz-header {
    padding: 0.4rem 0.5rem;
  }

  .quiz-header-top {
    gap: 0.3rem;
    flex-wrap: wrap;
  }

  .quiz-mode-badge {
    font-size: 0.58rem;
    padding: 0.15rem 0.4rem;
  }

  .quiz-counter {
    font-size: 0.78rem;
  }

  .quiz-timer {
    font-size: 0.78rem;
  }

  .quiz-header-actions {
    gap: 0.4rem;
  }

  .quiz-header-actions .btn {
    padding: 0.45rem 0.65rem;
    font-size: 1rem;
    min-width: 44px;
    min-height: 44px;
  }

  /* Quiz content */
  .quiz-content {
    padding: 1rem 0.75rem;
  }

  .question-text {
    font-size: 1rem;
    line-height: 1.5;
  }

  .question-images {
    flex-direction: column;
    align-items: center;
  }

  .question-image-wrapper {
    max-width: 100%;
    width: 100%;
  }

  /* Answer options - touch-friendly */
  .answer-option {
    padding: 0.9rem;
    min-height: 52px;
  }

  .answer-text {
    font-size: 0.95rem;
    line-height: 1.4;
  }

  .answer-letter {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }

  /* Quiz navigation - thumb friendly */
  .quiz-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "center center"
      "left right";
    gap: 0.6rem;
    padding: 1rem 0.75rem;
  }

  .quiz-nav-center {
    grid-area: center;
    width: 100%;
    display: flex;
    justify-content: stretch;
    gap: 0.6rem;
  }

  .quiz-nav-center .btn {
    flex: 1;
  }

  .quiz-nav-left { grid-area: left; }
  .quiz-nav-right { grid-area: right; }

  .quiz-nav-left .btn,
  .quiz-nav-right .btn {
    width: 100%;
  }

  .quiz-nav .btn {
    min-height: 48px;
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
  }

  /* Review section */
  .review-question {
    padding: 0.9rem;
  }

  .review-question-header {
    flex-wrap: wrap;
  }

  .review-question-text {
    font-size: 0.82rem;
  }

  .review-answer {
    font-size: 0.78rem;
    padding: 0.35rem 0.55rem;
  }

  .review-explanation {
    font-size: 0.72rem;
  }

  /* Modals - bottom sheet on mobile */
  .modal-content {
    max-width: 100%;
    margin: 0;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: absolute;
    bottom: 0;
    animation: slideInUp 0.25s ease;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-header {
    padding: 1.25rem 1.25rem 0.5rem;
  }

  .modal-body {
    padding: 0 1.25rem 1.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .modal-actions {
    padding: 0 1rem 1rem;
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .desktop-only-hints {
    display: none !important;
  }

  .modal-image-container img {
    max-width: calc(100vw - 2rem);
    max-height: 80vh;
  }

  /* Nav grid */
  .nav-grid {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  }

  .nav-legend {
    gap: 0.5rem;
    font-size: 0.68rem;
  }

  /* Test cards */
  .test-card {
    padding: 0.9rem;
  }

  .test-card-actions {
    flex-direction: column;
  }

  .test-card-actions .btn {
    min-height: 44px;
    justify-content: center;
  }

  /* Buttons - touch-friendly */
  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }

  .back-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Explanation */
  .explanation-inline {
    padding: 0.75rem;
  }

  .explanation-text {
    font-size: 0.82rem;
  }

  /* Footer */
  .footer {
    font-size: 0.68rem;
    padding: 1.25rem 1rem;
  }

  /* Error state */
  .error-state {
    padding: 2rem 1rem;
  }

  .error-state-icon {
    font-size: 2.2rem;
  }

  .error-state h3 {
    font-size: 1rem;
  }

  .error-state p {
    font-size: 0.82rem;
  }

  /* Auth modal - override bottom-sheet for auth */
  #authModal .modal-content {
    position: relative;
    border-radius: var(--radius-lg);
    max-width: 400px;
    bottom: auto;
  }

  #authModal {
    align-items: center;
    padding: 1rem;
  }
}

/* --- Small Mobile (< 480px) --- */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .hero {
    padding: 1rem 0.5rem 0.5rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero-subtitle {
    font-size: 0.82rem;
  }

  .hero-badge {
    font-size: 0.68rem;
    padding: 0.25rem 0.65rem;
  }

  .hero-stat-value {
    font-size: 1rem;
  }

  .hero-stat-label {
    font-size: 0.62rem;
  }

  .hero-stats {
    gap: 0.85rem;
  }

  .category-card {
    padding: 0.7rem;
  }

  .category-card-icon {
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }

  .category-card-name {
    font-size: 0.82rem;
  }

  .category-card-meta span {
    font-size: 0.62rem;
  }

  .category-card-badge {
    font-size: 0.58rem;
  }

  .group-icon {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  .container {
    padding: 0 16px;
  }

  .container-narrow {
    padding: 0 16px;
  }

  .quiz-content {
    padding: 0.75rem 0.5rem;
  }

  .quiz-header {
    padding: 0.3rem 0.5rem;
  }

  .question-number {
    font-size: 0.68rem;
  }

  .question-text {
    font-size: 0.92rem;
  }

  .answer-option {
    padding: 0.65rem;
    gap: 0.5rem;
  }

  .answer-letter {
    width: 24px;
    height: 24px;
    font-size: 0.68rem;
  }

  .answer-text {
    font-size: 0.82rem;
  }

  .results-stats {
    gap: 0.35rem;
  }

  .result-stat-card {
    padding: 0.65rem 0.4rem;
  }

  .result-stat-value {
    font-size: 1.15rem;
  }

  .result-stat-label {
    font-size: 0.58rem;
  }

  .review-question {
    padding: 0.7rem;
  }

  .test-card {
    padding: 0.8rem;
  }

  .test-card-number {
    font-size: 0.9rem;
  }

  .test-card-meta {
    font-size: 0.68rem;
    gap: 0.45rem;
    flex-wrap: wrap;
  }
}

/* --- Extra Small (< 360px) --- */
@media (max-width: 360px) {
  .hero h1 {
    font-size: 1.35rem;
  }

  .hero-stats {
    flex-direction: column;
    gap: 0.4rem;
  }

  .quiz-header-top {
    flex-wrap: nowrap;
  }

  .quiz-mode-badge {
    display: none;
  }

  .quiz-nav .btn {
    font-size: 0.68rem;
    padding: 0.35rem 0.45rem;
  }

  .results-score-ring {
    width: 110px;
    height: 110px;
  }

  .results-score-value {
    font-size: 1.6rem;
  }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================
   RTL Support (Arabic)
   ============================================ */
.rtl-content {
  direction: rtl;
  text-align: right;
}

.rtl-content .question-text,
.rtl-content .answer-text,
.rtl-content .explanation-text,
.rtl-content .review-question-text,
.rtl-content .review-explanation {
  direction: rtl;
  text-align: right;
  unicode-bidi: embed;
}

.rtl-content .answer-option {
  flex-direction: row-reverse;
}

.rtl-content .answer-letter {
  margin-left: 0.75rem;
  margin-right: 0;
}

.rtl-content .question-number {
  text-align: right;
}

.rtl-content .quiz-nav {
  direction: ltr;
}

.rtl-content .review-question-header {
  flex-direction: row-reverse;
}

.rtl-content .review-answer {
  direction: rtl;
  text-align: right;
}

/* Ensure HTML content within questions renders properly */
.question-text p,
.answer-text p,
.explanation-text p,
.review-explanation p {
  margin: 0.25em 0;
}

.question-text p:first-child,
.answer-text p:first-child,
.explanation-text p:first-child {
  margin-top: 0;
}

.question-text p:last-child,
.answer-text p:last-child,
.explanation-text p:last-child {
  margin-bottom: 0;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  body {
    background: white;
    color: black;
  }
  .quiz-header {
    position: relative;
  }
  .modal-overlay {
    display: none !important;
  }
  .quiz-nav {
    display: none;
  }
}
