/* ============================================================
   VHN Assessment Portal - Design System & Modern Stylesheet
   Theme: Clinical Teal & Deep Slate Healthcare Glassmorphism
   ============================================================ */

:root {
  /* Color Palette - Light Theme */
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --primary-glow: rgba(13, 148, 136, 0.25);

  --accent: #0284c7;
  --accent-light: #e0f2fe;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --bg-page: #f4f7fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-subtle: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.85);

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

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #14b8a6;

  --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-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --primary: #14b8a6;
  --primary-hover: #2dd4bf;
  --primary-light: rgba(20, 184, 166, 0.15);
  --primary-glow: rgba(20, 184, 166, 0.3);

  --accent: #38bdf8;
  --accent-light: rgba(56, 189, 248, 0.15);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.3);

  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.3);

  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.3);

  --bg-page: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1f2937;
  --bg-surface-subtle: #162032;
  --bg-glass: rgba(17, 24, 39, 0.85);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b0f19;

  --border-subtle: #1f2937;
  --border-strong: #374151;
  --border-focus: #2dd4bf;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}

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

html {
  font-family: var(--font-family);
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ================= Layout & Containers ================= */
.app-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ================= Header 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);
  transition: all var(--transition-normal);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.25rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo-icon {
  width: 2.75rem;
  height: 2.75rem;
  background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 10px var(--primary-glow);
  transition: transform var(--transition-fast);
}

.brand-wrapper:hover .brand-logo-icon {
  transform: scale(1.05);
}

.brand-title-group h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-title-group p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ================= Buttons & Form Controls ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.6rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #0f766e 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #115e59 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--border-strong);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.btn-icon {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-surface-subtle);
}

/* ================= View Sections ================= */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= Hero / Welcome Banner ================= */
.hero-section {
  margin: 2rem 0;
  padding: 2.5rem 2rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(2, 132, 199, 0.06) 100%);
  border: 1px solid rgba(13, 148, 136, 0.15);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
}

.hero-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.6rem;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 720px;
  line-height: 1.6;
}

/* ================= Exam Cards Grid ================= */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.exam-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.exam-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.exam-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-xl);
}

.exam-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.exam-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.badge-easy {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-hard {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.exam-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.6rem;
}

.exam-card-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.2rem;
  flex-grow: 1;
}

.exam-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.exam-card-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

/* ================= Mode Selector Modal / Dialog ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-overlay.active {
  display: flex;
  animation: modalFade 0.2s ease;
}

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.mode-option-card {
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

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

.mode-option-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.mode-icon {
  font-size: 1.75rem;
  line-height: 1;
}

/* ================= Quiz Taking View ================= */
.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.quiz-info-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timer-box {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--bg-surface-subtle);
  color: var(--primary);
  border: 1px solid var(--border-subtle);
  letter-spacing: 0.05em;
}

.timer-box.timer-warning {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
  animation: pulseWarning 1.5s infinite;
}

@keyframes pulseWarning {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.quiz-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.quiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #0284c7 100%);
  width: 0%;
  transition: width 0.3s ease;
}

.quiz-layout-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .quiz-layout-grid {
    grid-template-columns: 1fr;
  }
}

/* Question Area */
.question-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.q-header-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.q-section-tag {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
}

.q-flag-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.q-flag-btn:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--warning);
  color: var(--warning);
}

.q-flag-btn.flagged {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning);
  font-weight: 600;
}

.q-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* Choice Cards */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.choice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  background: var(--bg-surface-subtle);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.choice-card:hover {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  transform: translateX(3px);
}

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

.choice-letter {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.choice-card.selected .choice-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.choice-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  flex-grow: 1;
}

/* Practice Mode Instant Feedback Box */
.instant-feedback-box {
  display: none;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  margin-bottom: 1.25rem;
  animation: fadeIn 0.25s ease;
}

.instant-feedback-box.correct {
  display: block;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #065f46;
}

[data-theme="dark"] .instant-feedback-box.correct {
  color: #34d399;
}

.instant-feedback-box.incorrect {
  display: block;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #991b1b;
}

[data-theme="dark"] .instant-feedback-box.incorrect {
  color: #f87171;
}

.feedback-explanation {
  font-size: 0.9rem;
  margin-top: 0.4rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Question Action Nav Buttons */
.q-footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Palette / Question Grid Sidebar */
.quiz-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: sticky;
  top: 5.5rem;
  box-shadow: var(--shadow-sm);
}

.palette-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding: 0.2rem;
}

.q-palette-btn {
  height: 2.2rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.q-palette-btn:hover {
  border-color: var(--border-focus);
  color: var(--primary);
}

.q-palette-btn.current {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.q-palette-btn.answered {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(13, 148, 136, 0.4);
}

.q-palette-btn.flagged::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background: var(--warning);
  border-radius: var(--radius-full);
}

.palette-legend {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
}

/* ================= Results View ================= */
.result-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.score-circular-gauge {
  width: 140px;
  height: 140px;
  margin: 0 auto 1.5rem auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.gauge-circle-bg {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 8;
}

.gauge-circle-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 377;
  transition: stroke-dashoffset 1s ease-out;
}

.gauge-text-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-score-number {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.gauge-score-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.result-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.result-status-badge.pass {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.result-status-badge.fail {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.result-stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  max-width: 600px;
  margin: 1.5rem auto 0 auto;
}

.stat-tile {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

.stat-tile-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-tile-lbl {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Competency Breakdown Section */
.competency-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.competency-item {
  margin-bottom: 1.25rem;
}

.competency-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.competency-track {
  height: 8px;
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.competency-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* Review Filter & Question Review List */
.review-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.filter-btn-group {
  display: flex;
  background: var(--bg-surface-subtle);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 0.25rem;
}

.filter-pill {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-pill.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.review-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.review-item-card.is-correct {
  border-left: 4px solid var(--success);
}

.review-item-card.is-wrong {
  border-left: 4px solid var(--danger);
}

.review-choice-row {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.review-choice-row.user-pick-correct {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: #065f46;
}

.review-choice-row.user-pick-wrong {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

.review-choice-row.correct-target {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: #065f46;
}

.review-explanation-box {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ================= Footer ================= */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 1.75rem 0;
  background: var(--bg-surface);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ================= Mobile Bottom Bar & Palette Drawer ================= */
.mobile-palette-btn {
  display: none;
}

.palette-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.palette-backdrop.active {
  display: block;
  opacity: 1;
}

.mobile-sticky-bottom-bar {
  display: none;
}

.palette-close-mobile-btn {
  display: none;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
}

/* ================= Mobile Media Queries (iPhone / Android / Tablet) ================= */
@media (max-width: 899px) {
  html {
    font-size: 15px;
  }

  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-container {
    padding: 0 0.85rem;
  }

  /* Header */
  .header-content {
    height: 3.6rem;
  }

  .brand-logo-icon {
    width: 2.3rem;
    height: 2.3rem;
  }

  .brand-title-group h1 {
    font-size: 0.98rem;
    white-space: nowrap;
  }

  .brand-title-group p {
    display: none;
  }

  /* Hero Banner */
  .hero-section {
    margin: 1rem 0;
    padding: 1.4rem 1.1rem;
  }

  .hero-title {
    font-size: 1.35rem;
  }

  .hero-desc {
    font-size: 0.88rem;
  }

  /* Exam Grid */
  .exam-cards-grid {
    grid-template-columns: 1fr;
    gap: 1.15rem;
    margin-bottom: 2rem;
  }

  .exam-card {
    padding: 1.25rem 1.1rem;
  }

  .exam-card-title {
    font-size: 1.15rem;
  }

  .exam-card-actions {
    flex-direction: column;
  }

  /* Quiz View Top Bar */
  .quiz-top-bar {
    padding: 0.75rem 0.85rem;
    margin-top: 0.75rem;
    margin-bottom: 0.85rem;
  }

  .quiz-info-left {
    gap: 0.5rem;
  }

  #quizCurrentExamTitle {
    font-size: 0.9rem !important;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .timer-box {
    font-size: 0.95rem;
    padding: 0.35rem 0.6rem;
  }

  .mobile-palette-btn {
    display: inline-flex;
  }

  /* Question Area */
  .question-panel {
    padding: 1.2rem 1rem;
    margin-bottom: 5.5rem; /* space for fixed sticky bottom bar */
  }

  .q-title {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 1.2rem;
  }

  .choice-card {
    padding: 0.85rem 0.95rem;
    gap: 0.75rem;
    touch-action: manipulation;
  }

  .choice-letter {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.8rem;
  }

  .choice-text {
    font-size: 0.9rem;
  }

  /* Hide desktop bottom buttons in quiz panel on mobile */
  .q-footer-nav {
    display: none;
  }

  /* Mobile Sticky Bottom Navigation */
  .mobile-sticky-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 120;
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--border-subtle);
    padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom)) 0.85rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
  }

  .mobile-q-indicator-btn {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
  }

  /* Palette Sidebar transforms into a Bottom Sheet Drawer on Mobile */
  .quiz-sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 160;
    background: var(--bg-surface);
    border-top: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom)) 1rem;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(105%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 75vh;
    display: flex;
    flex-direction: column;
  }

  .quiz-sidebar.drawer-open {
    transform: translateY(0%);
  }

  .palette-close-mobile-btn {
    display: inline-flex;
  }

  .palette-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.45rem;
    max-height: 48vh;
  }

  .q-palette-btn {
    height: 2.4rem;
    font-size: 0.85rem;
  }

  /* Results View Mobile */
  .result-hero-card {
    padding: 1.75rem 1rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }

  .score-circular-gauge {
    width: 120px;
    height: 120px;
    margin-bottom: 1.25rem;
  }

  .gauge-score-number {
    font-size: 1.85rem;
  }

  .result-stat-tiles {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .competency-card {
    padding: 1.25rem 1rem;
  }

  .review-filter-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .filter-btn-group {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 0.2rem;
  }

  .filter-pill {
    flex: 1;
    text-align: center;
    padding: 0.4rem 0.55rem;
    font-size: 0.78rem;
  }

  .review-item-card {
    padding: 1.15rem 1rem;
  }

  /* Modal on Mobile */
  .modal-card {
    max-height: 85vh;
    overflow-y: auto;
  }

  .modal-body {
    padding: 1.15rem 1rem;
  }
}

/* ================= Print Styles ================= */
@media print {
  .app-header,
  .quiz-sidebar,
  .q-footer-nav,
  .review-filter-bar,
  .btn,
  .app-footer {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .app-container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .result-hero-card,
  .competency-card,
  .review-item-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}

/* ================= A-Level Practice additions ================= */
.credit-line { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.exam-card-credit { font-size: 0.78rem; color: var(--text-secondary); margin: -0.3rem 0 0.6rem; }
.exam-card-desc { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.exam-card-link { color: inherit; text-decoration: none; }
.exam-card-link:hover { color: var(--primary); }
.meta-pill-video { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.sheet-link, .video-link { margin-top: 0.75rem; text-decoration: none; }
.sheet-link { align-self: flex-start; }
.catalog-filters { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem; }
.catalog-filter-row { display: flex; align-items: baseline; gap: 0.75rem; }
.catalog-filter-label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); min-width: 3.2rem; }
.catalog-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filter-chip { padding: 0.3rem 0.8rem; border-radius: var(--radius-full); border: 1px solid var(--border-subtle); background: var(--bg-surface); font-family: inherit; font-size: 0.82rem; color: var(--text-secondary); cursor: pointer; }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.catalog-year-title { display: flex; align-items: baseline; gap: 0.75rem; font-size: 1.3rem; font-weight: 700; margin: 1.5rem 0 1rem; }
.catalog-year-count { font-size: 0.85rem; font-weight: 400; color: var(--text-secondary); }
.catalog-empty { text-align: center; color: var(--text-secondary); padding: 2rem 0; }
.modal-exam-info { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.9rem; color: var(--text-primary); }

.q-context { margin-bottom: 1rem; }
.q-directions { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 0.6rem; }
.q-passage { white-space: pre-wrap; font-size: 1rem; line-height: 1.75; padding: 1rem 1.15rem; background: var(--bg-surface-subtle); border: 1px solid var(--border-subtle); border-left: 4px solid var(--accent); border-radius: var(--radius-md); max-height: 28rem; overflow: auto; }
.q-figures { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.75rem; }
.q-figure { max-width: 100%; height: auto; background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 0.4rem; }
.q-title { display: flex; gap: 0.75rem; align-items: flex-start; }
.q-no { flex-shrink: 0; font-weight: 700; color: var(--primary); }
.q-body { min-width: 0; flex: 1; }
.q-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.q-line + .q-line { margin-top: 0.3rem; }
u { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.q-table-wrap { overflow-x: auto; margin: 0.5rem 0; }
.q-table { border-collapse: collapse; font-size: 0.9rem; font-weight: 400; }
.q-table th, .q-table td { border: 1px solid var(--border-strong); padding: 0.35rem 0.65rem; text-align: left; }
.q-table th { background: var(--bg-surface-subtle); font-weight: 600; }
.choice-header { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); padding: 0 0.25rem; }
.choice-card.is-key { border-color: var(--success); background: var(--success-bg); }
.choice-card.is-miss { border-color: var(--danger); background: var(--danger-bg); }

.yesno-list { gap: 0.75rem; }
.yesno-row { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border: 1.5px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface-subtle); flex-wrap: wrap; }
.yesno-row.is-key { border-color: var(--success); background: var(--success-bg); }
.yesno-row.is-miss { border-color: var(--danger); background: var(--danger-bg); }
.yesno-text { flex: 1 1 18rem; display: flex; gap: 0.6rem; line-height: 1.5; font-size: 0.95rem; }
.yesno-label { font-weight: 700; color: var(--primary); flex-shrink: 0; }
.yesno-buttons { display: flex; gap: 0.5rem; }
.yesno-btn { padding: 0.4rem 1.1rem; border-radius: var(--radius-full); border: 1.5px solid var(--border-strong); background: var(--bg-surface); font-family: inherit; font-size: 0.9rem; cursor: pointer; color: var(--text-primary); }
.yesno-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.numeric-answer { margin-bottom: 0.5rem; }
.numeric-label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.numeric-label span { font-weight: 400; font-size: 0.82rem; color: var(--text-secondary); }
.numeric-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.numeric-input { flex: 1 1 10rem; max-width: 16rem; padding: 0.7rem 0.9rem; font-family: inherit; font-size: 1.1rem; border: 1.5px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary); }
.numeric-input:focus { outline: none; border-color: var(--border-focus); }

.feedback-key { margin-top: 0.35rem; font-size: 0.9rem; font-weight: 600; }
.feedback-explanation, .review-explanation-text { white-space: pre-line; }
.feedback-video, .review-video { margin-top: 0.5rem; }
.review-key-note { font-size: 0.84rem; color: var(--text-secondary); margin-bottom: 0.75rem; }
.review-context { margin-bottom: 0.75rem; }
.review-q-title { font-size: 1.05rem; margin-bottom: 1rem; }
.review-row-label { font-weight: 700; width: 2.2rem; flex-shrink: 0; }
.review-row-text { flex-grow: 1; min-width: 0; overflow-wrap: anywhere; }
.review-row-tag, .review-row-answer { font-size: 0.8rem; font-weight: 600; margin-left: 0.5rem; }
.review-yesno .review-choice-row { flex-wrap: wrap; }
@media (max-width: 640px) {
  .catalog-filter-row { flex-direction: column; gap: 0.35rem; }
  .q-passage { max-height: 20rem; }
}

/* Physics constants page ("กำหนดให้"), shown as text in a dialog */
.const-open { margin: 0.25rem 0 0.75rem; }
#quizConstantsBtn { margin-top: 4px; }
.const-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.const-modal.open { display: flex; }
.const-card { background: var(--card-bg, #fff); color: var(--text-main, #0f172a); border-radius: 16px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; padding: 1.25rem 1.5rem; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.const-close { position: sticky; top: 0; float: right; }
.const-body h4 { margin: 0.75rem 0 0.35rem; font-size: 1.05rem; }
.const-body ul { margin: 0 0 0.5rem 1.1rem; padding: 0; line-height: 1.9; }
.const-body sup { font-size: 0.7em; }
.const-table { border-collapse: collapse; margin: 0.75rem 0; width: 100%; text-align: center; }
.const-table th, .const-table td { border: 1px solid var(--border-color, #cbd5e1); padding: 0.45rem 0.4rem; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.1; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 2px; }

/* vector letter: an arrow drawn above (the font has no combining arrow U+20D7) */
.vec { position: relative; display: inline-block; padding-top: 0.15em; }
.vec::after { content: "→"; position: absolute; left: 50%; top: -0.45em; transform: translateX(-50%); font-size: 0.62em; line-height: 1; }

/* chemistry: periodic table in the constants dialog */
.const-card.wide { max-width: 1000px; }
.ptable-wrap { overflow-x: auto; margin: 0.5rem 0 0.75rem; }
.ptable { display: grid; grid-template-columns: repeat(18, minmax(42px, 1fr)); gap: 2px; min-width: 760px; font-family: Inter, system-ui, sans-serif; }
.ptable .el { border: 1px solid var(--border-color, #cbd5e1); border-radius: 3px; text-align: center; padding: 2px 1px; line-height: 1.15; background: var(--card-bg, #fff); }
.ptable .el b { display: block; font-size: 0.95rem; }
.ptable .el small { display: block; font-size: 0.62rem; opacity: 0.85; }
.ptable .grp { text-align: center; font-size: 0.7rem; color: #0284c7; align-self: end; }
.ptable .gap { visibility: hidden; }
.ptable .star { text-align: center; align-self: center; font-weight: 700; font-size: 0.72rem; }
