/* =========================================================
   Foundations of Nursing — Learning Management System
   Vibrant Modern Education Theme
   ========================================================= */

:root {
  --primary:       #4F46E5;
  --primary-dark:  #3730A3;
  --primary-light: #EEF2FF;
  --accent:        #F59E0B;
  --accent-dark:   #D97706;
  --accent-light:  #FEF3C7;
  --warning:       #F97316;
  --danger:        #EF4444;
  --success:       #10B981;
  --success-light: #D1FAE5;
  --wrong-light:   #FEE2E2;
  --neutral:       #94A3B8;
  --text:          #0F172A;
  --text-muted:    #64748B;
  --border:        #E2E8F0;
  --bg:            #F8FAFC;
  --card:          #ffffff;
  --sidebar-w:     300px;
  --header-h:      64px;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 6px 30px rgba(0,0,0,.15);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout Shell ── */
.shell {
  display: flex;
  min-height: 100vh;
}

/* ── Top Header ── */
.top-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(79,70,229,.4);
}

.top-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.2px;
  flex-shrink: 0;
}

.top-header .logo svg {
  width: 28px; height: 28px;
  fill: #fff;
  opacity: .9;
}

.top-header .overall-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 400px;
  margin-left: auto;
}

.top-header .overall-progress label {
  font-size: .8rem;
  white-space: nowrap;
  opacity: .85;
}

.top-header .overall-progress .prog-bar-wrap {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.25);
  border-radius: 4px;
  overflow: hidden;
}

.top-header .overall-progress .prog-bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 4px;
  transition: width .4s ease;
}

.top-header .prog-pct {
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

.menu-toggle svg { width: 24px; height: 24px; stroke: #fff; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 90;
  transition: transform .3s ease;
}

.sidebar-inner { padding: 16px 0; }

.sidebar-section-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

/* Unit group (expandable) */
.sidebar-unit-group {
  border-left: 3px solid transparent;
  transition: border-color .15s;
}

.sidebar-unit-group.active-unit {
  border-left-color: var(--primary);
}

.sidebar-unit-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 20px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  color: var(--text);
  user-select: none;
}

.sidebar-unit-header:hover {
  background: var(--primary-light);
}

.sidebar-unit-group.active-unit .sidebar-unit-header {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.sidebar-unit-group.completed .unit-num { background: var(--success); color: #fff; }
.sidebar-unit-group.completed .unit-status-icon { color: var(--success); }

.unit-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-unit-group.active-unit .unit-num {
  background: var(--primary);
  color: #fff;
}

.unit-label {
  font-size: .8rem;
  line-height: 1.3;
  flex: 1;
  font-weight: 500;
}

.unit-chevron {
  font-size: .9rem;
  color: var(--text-muted);
  transition: transform .2s;
  flex-shrink: 0;
}

.sidebar-unit-group.expanded .unit-chevron {
  transform: rotate(90deg);
}

.unit-status-icon {
  font-size: .85rem;
  flex-shrink: 0;
}

/* Section list (collapsed by default) */
.sidebar-sections {
  display: none;
  background: #FAFBFF;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.sidebar-unit-group.expanded .sidebar-sections {
  display: block;
}

.sidebar-section-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 16px 7px 36px;
  cursor: pointer;
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.35;
  transition: background .12s, color .12s;
  border-left: 2px solid transparent;
}

.sidebar-section-item:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.sidebar-section-item.active-section {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

.sidebar-section-num {
  font-weight: 700;
  flex-shrink: 0;
  color: var(--primary);
  opacity: .7;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  flex: 1;
  padding: 32px;
  max-width: 900px;
  min-height: calc(100vh - var(--header-h));
}

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

/* ── Dashboard ── */
.dashboard-hero {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 60%, #A855F7 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px 40px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
}

.dashboard-hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 8px;
}

.dashboard-hero p {
  opacity: .85;
  font-size: .95rem;
  max-width: 520px;
  margin-bottom: 24px;
}

.progress-overview {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 16px 20px;
  backdrop-filter: blur(4px);
}

.progress-overview .stats {
  display: flex;
  gap: 28px;
}

.stat-item { text-align: center; }
.stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}
.stat-lbl {
  font-size: .72rem;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.dash-prog-bar-wrap {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,.3);
  border-radius: 5px;
  overflow: hidden;
}

.dash-prog-bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 5px;
  transition: width .5s ease;
}

/* Unit Cards Grid */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 4px;
}

.unit-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  position: relative;
  overflow: hidden;
}

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

.unit-card.completed {
  border-color: var(--success);
}

.unit-card.in-progress {
  border-color: var(--primary);
}

.unit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.unit-card-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  font-weight: 800;
}

.unit-card.completed .unit-card-num {
  background: var(--success-light);
  color: var(--success);
}

.unit-card-status {
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-muted);
}

.unit-card.completed .unit-card-status {
  background: var(--success-light);
  color: var(--success);
}

.unit-card.in-progress .unit-card-status {
  background: var(--primary-light);
  color: var(--primary);
}

.unit-card h3 {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.unit-card p {
  font-size: .77rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.unit-card-mini-prog {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.unit-card-mini-prog-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .4s;
}

.unit-card.completed .unit-card-mini-prog-fill {
  background: var(--success);
}

/* ── Review View ── */
.view-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.view-header-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: .83rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.view-header-back:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.view-header-info { flex: 1; }

.breadcrumb {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.view-header-info h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.view-header-info p {
  font-size: .85rem;
  color: var(--text-muted);
}

/* Section Progress Steps */
.section-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.section-step {
  width: 28px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background .3s;
}

.section-step.done { background: var(--success); }
.section-step.active { background: var(--primary); }

/* Content Card */
.content-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.content-card-header {
  background: linear-gradient(135deg, var(--primary-light) 0%, #F5F3FF 100%);
  padding: 16px 24px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-card-header .section-badge {
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

.content-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.content-card-body {
  padding: 24px;
}

/* Markdown Content Styles */
.md-content h3 { display: none; } /* section title already in header */
.md-content h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 20px 0 10px;
}

.md-content p {
  margin-bottom: 12px;
  font-size: .92rem;
  line-height: 1.7;
}

.md-content ul, .md-content ol {
  margin: 0 0 12px 20px;
  font-size: .92rem;
}

.md-content li { margin-bottom: 4px; }

.md-content strong { color: var(--text); font-weight: 700; }
.md-content em { font-style: italic; }
.md-content code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .85rem;
}

.md-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 10px 16px;
  background: var(--primary-light);
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  font-size: .88rem;
  color: var(--primary-dark);
}

/* Tables */
.md-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.md-content th {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: .82rem;
}

.md-content td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.md-content tr:last-child td { border-bottom: none; }
.md-content tr:nth-child(even) td { background: var(--bg); }

/* Navigation buttons */
.nav-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: all .2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), #6D28D9);
  box-shadow: 0 4px 14px rgba(79,70,229,.4);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 14px rgba(16,185,129,.4);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

/* ── Quiz View ── */
.unit-progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}

.unit-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7C3AED, var(--accent));
  border-radius: 4px;
  transition: width .4s;
}

/* Legacy quiz bar kept for compatibility */
.quiz-progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  margin-bottom: 28px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width .4s;
}

.question-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.question-card-header {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  color: #fff;
  padding: 18px 24px;
}

.question-meta {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  color: #fff;
}

.badge-sata { background: rgba(230,126,34,.8); }

.question-num {
  font-size: .78rem;
  opacity: .7;
  margin-bottom: 6px;
}

.question-text {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}

.question-card-body { padding: 20px 24px; }

/* Options */
.options-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  background: var(--card);
}

.option-item:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}

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

.option-item.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.option-item.incorrect {
  border-color: var(--danger);
  background: var(--wrong-light);
}

.option-item.missed {
  border-color: var(--success);
  background: var(--success-light);
  opacity: .7;
}

.option-item.disabled { cursor: default; }

.option-marker {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all .2s;
  background: var(--bg);
}

/* SATA uses checkboxes */
.sata .option-marker { border-radius: 5px; }

.option-item.selected .option-marker {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.option-item.correct .option-marker {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.option-item.incorrect .option-marker,
.option-item.missed .option-marker {
  border-color: currentColor;
}

.option-text { font-size: .9rem; line-height: 1.5; flex: 1; padding-top: 2px; }

.option-result-icon { font-size: 1.1rem; margin-left: auto; flex-shrink: 0; }

/* Submit / Next area */
.quiz-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Rationale / Explanation */
.explanation-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
  animation: slideIn .3s ease;
}

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

.explanation-card-header {
  padding: 14px 20px;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.explanation-card-header.correct-header {
  background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
  color: #065F46;
  border-bottom: 1px solid #6EE7B7;
}

.explanation-card-header.incorrect-header {
  background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
  color: #991B1B;
  border-bottom: 1px solid #FCA5A5;
}

.explanation-card-header.partial-header {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  color: #92400E;
  border-bottom: 1px solid #FCD34D;
}

.explanation-body {
  padding: 16px 20px;
}

.explanation-body .correct-answer-line {
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

/* Explanation markdown */
.explanation-body p { font-size: .88rem; margin-bottom: 8px; line-height: 1.6; }
.explanation-body ul, .explanation-body ol { margin: 0 0 8px 18px; font-size: .88rem; }
.explanation-body li { margin-bottom: 3px; }
.explanation-body strong { font-weight: 700; }

/* ── Unit Complete View ── */
.complete-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}

.complete-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  line-height: 1;
}

.complete-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.complete-card .score-display {
  font-size: 3rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin: 20px 0 4px;
}

.complete-card .score-display.perfect { color: var(--success); }
.complete-card .score-display.needs-work { color: var(--warning); }

.complete-card .score-label {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.complete-card .score-breakdown {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 28px;
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
}

.score-breakdown-item { text-align: center; }
.sbi-num { font-size: 1.4rem; font-weight: 800; }
.sbi-lbl { font-size: .75rem; color: var(--text-muted); }

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

/* ── Intro screen ── */
.unit-intro-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 560px;
  margin: 0 auto 24px;
}

.unit-intro-card h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.unit-intro-card p { font-size: .9rem; color: var(--text-muted); margin-bottom: 20px; }

.unit-intro-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.intro-stat {
  text-align: center;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px 20px;
  flex: 1;
}

.intro-stat-num { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.intro-stat-lbl { font-size: .75rem; color: var(--text-muted); }

/* ── Toast Notification ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: .88rem;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .menu-toggle { display: flex; }

  .top-header .logo span { display: none; }

  .units-grid { grid-template-columns: 1fr; }

  .dashboard-hero { padding: 24px 20px; }

  .progress-overview { flex-wrap: wrap; }

  .complete-card { padding: 28px 20px; }

  .nav-actions { flex-direction: column; }
}

/* ── Scrollbar ── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Utility ── */
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: .85rem; }

/* ── Distractor Popup ── */
.distractor-popup {
  display: none;
  position: fixed;
  z-index: 9999;
  max-width: 400px;
  width: 90vw;
  background: #1E293B;
  color: #F1F5F9;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: .82rem;
  line-height: 1.55;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  pointer-events: none;
}

.distractor-popup p { margin: 0 0 6px; color: #F1F5F9; font-size: .82rem; }
.distractor-popup strong { color: #FCD34D; }
.distractor-popup em { color: #94A3B8; font-style: italic; }

.distractor-popup-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #EF4444;
  margin-bottom: 6px;
}

/* Has-distractor options show a hint icon */
.option-item.has-distractor { cursor: pointer; }

.option-item.has-distractor::after {
  content: "ℹ";
  font-size: .85rem;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
  opacity: .7;
}

.option-item.has-distractor:hover::after {
  opacity: 1;
}

/* Correct rationale block */
.rationale-correct-block {
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--success-light);
  border-left: 4px solid var(--success);
  border-radius: 0 6px 6px 0;
  font-size: .88rem;
  line-height: 1.6;
}

.rationale-correct-block p { margin: 0; }
.rationale-correct-block strong { color: #065F46; }

/* Takeaway block */
.rationale-takeaway {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
  font-size: .85rem;
  color: #92400E;
  line-height: 1.5;
}

.rationale-takeaway p { margin: 0; }

.distractor-hint-note {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 10px;
  font-style: italic;
}


/* ── Search Toggle Button (header) ── */
.search-toggle {
  margin-left: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.18);
  color: #fff;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.search-toggle:hover {
  background: rgba(255,255,255,.32);
  border-color: rgba(255,255,255,.7);
}

/* ── Search Modal ── */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 32px;
}

.search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(2px);
}

.search-modal-panel {
  position: relative;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: searchSlideDown .22s cubic-bezier(.34,1.56,.64,1);
}

@keyframes searchSlideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  flex-shrink: 0;
}

.search-modal-title {
  font-size: .92rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
}

.search-close-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.search-close-btn:hover { background: rgba(255,255,255,.35); }

.search-input-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

.search-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0 12px;
}

.search-hint {
  padding: 20px 20px;
  color: var(--text-muted);
  font-size: .88rem;
  text-align: center;
  line-height: 1.65;
}

.search-hint code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: .82rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 4px;
}

.search-hint kbd {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: .75rem;
  background: var(--border);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #CBD5E1;
  box-shadow: 0 1px 0 #CBD5E1;
}

.search-no-results { color: var(--danger); }

.search-group {
  padding: 4px 0 8px;
}

.search-group-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 8px 20px 4px;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 9px 20px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.search-result-item:hover { background: var(--primary-light); }

.search-result-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.search-result-sub {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Keyboard shortcut hint */
.search-toggle::after {
  content: ' ⌘K';
  opacity: .65;
  font-size: .7rem;
}
@media (max-width: 600px) {
  .search-toggle::after { display: none; }
  .search-toggle { font-size: .7rem; padding: 5px 10px; }
  .search-modal { padding: 50px 8px 16px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   NOTES BUTTON (header)
   ════════════════════════════════════════════════════════════════════════════ */

.notes-toggle { margin-left: 0; }

/* suppress ⌘K pseudo-element inherited from .search-toggle */
.notes-toggle::after { content: none; }

.notes-header-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(255,255,255,.9);
  color: var(--primary);
  font-size: .65rem;
  font-weight: 700;
  margin-left: 5px;
  vertical-align: middle;
}

/* ════════════════════════════════════════════════════════════════════════════
   NOTE WIDGET (per-step)
   ════════════════════════════════════════════════════════════════════════════ */

.note-widget {
  margin-top: 20px;
  background: #FEFCE8;
  border: 1.5px solid #FDE68A;
  border-radius: var(--radius);
  padding: 16px 20px;
}

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

.note-widget-title {
  font-size: .82rem;
  font-weight: 700;
  color: #92400E;
  display: flex;
  align-items: center;
  gap: 6px;
}

.note-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #F59E0B;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
}

.note-widget-loc {
  font-size: .72rem;
  color: #A16207;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Saved notes list inside the widget */
.note-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.note-item {
  background: #fff;
  border: 1px solid #FDE68A;
  border-radius: 8px;
  padding: 10px 12px;
}

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.note-item-time {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.note-item-loc {
  font-size: .7rem;
  color: #A16207;
  font-style: italic;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .75rem;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.note-delete-btn:hover { color: var(--danger); background: var(--wrong-light); }

.note-item-text {
  font-size: .85rem;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Input area */
.note-input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #FDE68A;
  border-radius: 8px;
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.note-textarea:focus {
  border-color: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}
.note-textarea::placeholder { color: #D97706; opacity: .7; }

.note-save-btn {
  align-self: flex-end;
  padding: 7px 18px;
  background: #F59E0B;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.note-save-btn:hover { background: #D97706; }

/* ════════════════════════════════════════════════════════════════════════════
   NOTES MODAL (aggregated)
   ════════════════════════════════════════════════════════════════════════════ */

.notes-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 32px;
}

.notes-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(2px);
}

.notes-modal-panel {
  position: relative;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: searchSlideDown .22s cubic-bezier(.34,1.56,.64,1);
}

.notes-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  background: linear-gradient(135deg, #D97706, #F59E0B);
  flex-shrink: 0;
  gap: 12px;
}

.notes-modal-title {
  font-size: .92rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
}

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

.notes-copy-btn {
  padding: 5px 12px;
  background: rgba(255,255,255,.22);
  border: 1.5px solid rgba(255,255,255,.5);
  border-radius: 20px;
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.notes-copy-btn:hover { background: rgba(255,255,255,.38); border-color: rgba(255,255,255,.8); }

.notes-modal-content {
  overflow-y: auto;
  flex: 1;
  padding: 20px 24px;
}

.notes-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  padding: 40px 20px;
  line-height: 1.65;
}

.notes-unit {
  margin-bottom: 28px;
}

.notes-unit-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--primary);
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 14px;
}

.notes-step {
  margin-bottom: 16px;
  padding-left: 14px;
  border-left: 3px solid #FDE68A;
}

.notes-step-title {
  font-size: .82rem;
  font-weight: 700;
  color: #92400E;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notes-step-title h4 {
  margin: 0;
  font-size: .82rem;
  font-weight: 700;
  color: #92400E;
}

.notes-step-goto-btn {
  background: none;
  border: 1px solid #D97706;
  color: #D97706;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 12px;
  line-height: 1.4;
  transition: background .15s, color .15s;
  white-space: nowrap;
  margin-left: auto;
}
.notes-step-goto-btn:hover {
  background: #D97706;
  color: #fff;
}

.notes-note-item {
  background: #FEFCE8;
  border: 1px solid #FDE68A;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.notes-note-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.notes-note-time {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.notes-note-loc {
  font-size: .7rem;
  color: #A16207;
  font-style: italic;
  flex: 1;
}

.notes-note-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .85rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity .15s, color .15s;
  margin-left: auto;
}
.notes-note-delete-btn:hover { opacity: 1; color: var(--danger); }

.notes-note-text {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 600px) {
  .notes-modal { padding: 50px 8px 16px; }
  .notes-modal-panel { max-height: calc(100vh - 60px); }
  .notes-toggle { font-size: .7rem; padding: 5px 10px; }
}
