/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg:            #f5f6fa;
  --surface:       #ffffff;
  --surface-2:     #f8f9fc;
  --border:        #e2e6ed;
  --text:          #1a1d23;
  --text-muted:    #6b7280;
  --primary:       #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --warning:       #d97706;
  --warning-light: #fffbeb;
  --danger:        #dc2626;
  --danger-light:  #fff1f2;
  --radius:        8px;
  --radius-sm:     5px;
  --shadow:        0 1px 3px rgba(0,0,0,.09), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,.1);
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
}
h1, h2, h3 { line-height: 1.3; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { padding-left: 1.25rem; }
li { margin-bottom: 0.25rem; }

/* ── Navigation ──────────────────────────────────────────────────────────── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin-right: auto;
  text-decoration: none;
}
.nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s, opacity 0.13s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary  { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 0.28rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
input[type=text], input[type=number], textarea, select {
  width: 100%;
  padding: 0.48rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.13s, box-shadow 0.13s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; }
label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 0.3rem; }
.form-group { margin-bottom: 1rem; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-orange { background: #ffedd5; color: #9a3412; }

/* ── Divider ─────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Quiz Layout ─────────────────────────────────────────────────────────── */
.quiz-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 52px - 55px - 55px); /* nav + header + footer */
  overflow: hidden;
}
.quiz-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 55px;
}
.quiz-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.quiz-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.quiz-main {
  overflow-y: auto;
  padding: 2rem 2.5rem;
  background: var(--bg);
}
.quiz-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 55px;
  gap: 1rem;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s ease; }
.progress-text { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Question dot grid ────────────────────────────────────────────────────── */
.q-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.q-dot {
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.1s;
}
.q-dot:hover { border-color: var(--primary); color: var(--primary); }
.q-dot.current { border-color: var(--primary); background: var(--primary); color: #fff; }
.q-dot.answered { background: var(--success-light); border-color: #86efac; color: var(--success); }
.q-dot.flagged  { background: var(--warning-light); border-color: #fcd34d; color: var(--warning); }
.q-dot.answered.flagged { background: var(--warning-light); border-color: #fcd34d; color: var(--warning); }
.q-dot.graded-correct { background: var(--success-light); border-color: #4ade80; }
.q-dot.graded-wrong   { background: var(--danger-light);  border-color: #fca5a5; }
.q-dot.current.answered { background: var(--primary); color: #fff; border-color: var(--primary); }

.sidebar-legend { font-size: 0.75rem; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* ── Topic filter ─────────────────────────────────────────────────────────── */
.topic-filter { font-size: 0.8rem; }
.topic-filter-title { font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.topic-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  margin: 0 3px 4px 0;
  font-size: 0.75rem;
  transition: all 0.1s;
}
.topic-chip:hover { border-color: var(--primary); }
.topic-chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* ── Question card ────────────────────────────────────────────────────────── */
.question-card { max-width: 740px; }
.question-number { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.question-meta { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.question-text { font-size: 1.05rem; margin-bottom: 1.5rem; line-height: 1.65; }
.ms-auto { margin-left: auto; }

/* ── MCQ options ──────────────────────────────────────────────────────────── */
.options-list { display: flex; flex-direction: column; gap: 0.55rem; }
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  line-height: 1.5;
}
.option-item:hover  { 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.wrong    { border-color: var(--danger);  background: var(--danger-light);  }
.option-letter {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.76rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: all 0.1s;
}
.option-item.selected .option-letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-item.correct  .option-letter { background: var(--success); border-color: var(--success); color: #fff; }

/* ── True / False ─────────────────────────────────────────────────────────── */
.tf-buttons { display: flex; gap: 0.75rem; }
.tf-btn {
  flex: 1;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.13s;
}
.tf-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.tf-btn.selected.true-btn  { border-color: var(--success); background: var(--success-light); color: var(--success); }
.tf-btn.selected.false-btn { border-color: var(--danger);  background: var(--danger-light);  color: var(--danger); }
.tf-btn:disabled { cursor: default; }

/* ── Short answer ─────────────────────────────────────────────────────────── */
.short-answer-area { min-height: 120px; }

/* ── Fill in the blank ────────────────────────────────────────────────────── */
.fill-blank-text { font-size: 1.05rem; line-height: 2.2; }
.blank-input {
  display: inline-block;
  border: none;
  border-bottom: 2px solid var(--primary);
  padding: 0 4px 1px;
  min-width: 80px;
  font-size: 1em;
  font-family: inherit;
  background: transparent;
  text-align: center;
  color: var(--text);
  transition: background 0.1s;
}
.blank-input:focus {
  outline: none;
  background: var(--primary-light);
  border-radius: 3px 3px 0 0;
}
.blank-input:disabled { border-bottom-color: var(--border); color: var(--text-muted); }

/* ── Answer reveal (review mode) ─────────────────────────────────────────── */
.answer-reveal {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border-left: 3px solid;
}
.answer-reveal-correct { background: var(--success-light); border-color: var(--success); }
.answer-reveal-wrong   { background: var(--danger-light);  border-color: var(--danger);  }
.answer-reveal-ungraded { background: var(--warning-light); border-color: var(--warning); }
.grade-badge {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.mt-1 { margin-top: 0.5rem; }

/* ── Review page ──────────────────────────────────────────────────────────── */
.review-layout { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }
.score-header { text-align: center; padding: 2.5rem 1rem; }
.score-ring { font-size: 3.5rem; font-weight: 800; color: var(--primary); }
.score-denom { font-size: 1.2rem; color: var(--text-muted); }
.score-label { margin-top: 0.25rem; font-size: 0.9rem; color: var(--text-muted); }
.stats-row { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1.25rem; text-align: center; }
.stat-box .stat-n { font-size: 1.6rem; font-weight: 700; }
.stat-box .stat-l { font-size: 0.75rem; color: var(--text-muted); }

.review-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.75rem; }
.review-item-header {
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.review-item-header:hover { background: var(--bg); }
.review-item-title { font-weight: 500; font-size: 0.9rem; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.review-item-score { font-weight: 700; font-size: 0.85rem; }
.review-item-body { padding: 1rem; border-top: 1px solid var(--border); background: var(--surface); }
.review-item-body.hidden { display: none; }
.answer-block { padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); margin-bottom: 0.5rem; font-size: 0.875rem; }
.answer-block strong { display: block; margin-bottom: 0.15rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }

/* ── Grade form (inline in review) ───────────────────────────────────────── */
.grade-form { display: flex; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.grade-form input[type=number] { width: 70px; }
.grade-form textarea { min-height: 60px; flex: 1; min-width: 180px; }

/* ── Export modal selection ───────────────────────────────────────────────── */
.export-options { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.export-option { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0.85rem; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.export-option:hover, .export-option.selected { border-color: var(--primary); background: var(--primary-light); }
.export-option input[type=radio] { accent-color: var(--primary); }

/* ── Load screen ─────────────────────────────────────────────────────────── */
.load-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 52px);
  padding: 2rem;
}
.load-card { max-width: 420px; width: 100%; text-align: center; }
.load-card h2 { margin-bottom: 0.4rem; }
.load-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ── File drop ────────────────────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.file-drop .drop-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.file-drop p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.35rem; }

/* ── Setup / Docs page layout ─────────────────────────────────────────────── */
.page-layout { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; }
.section { margin-bottom: 2rem; }
.section-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; gap: 0.25rem; }
.tab { padding: 0.55rem 0.9rem; cursor: pointer; font-size: 0.875rem; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.13s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Code blocks ──────────────────────────────────────────────────────────── */
.code-block {
  position: relative;
  background: #1e293b;
  color: #cbd5e1;
  padding: 1.1rem 1.1rem 1.1rem 1.1rem;
  border-radius: var(--radius);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.78rem;
  line-height: 1.65;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}
.code-block pre { white-space: pre-wrap; word-break: break-word; }
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255,255,255,.1);
  border: none;
  color: #94a3b8;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: inherit;
  transition: background 0.1s;
}
.copy-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; z-index: 999; }
.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-size: 0.84rem;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  transition: opacity 0.3s;
  max-width: 300px;
}
.toast-success { background: #14532d; }
.toast-error   { background: #7f1d1d; }
@keyframes toastIn { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal h2 { margin-bottom: 0.75rem; font-size: 1.1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── Topic summary table ──────────────────────────────────────────────────── */
.topic-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.topic-table th, .topic-table td { padding: 0.55rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.topic-table th { font-weight: 600; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.topic-table tbody tr:hover { background: var(--surface-2); }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .quiz-layout { grid-template-columns: 1fr; }
  .quiz-sidebar { display: none; }
  .quiz-main { padding: 1.25rem; }
  .quiz-title { max-width: 120px; }
}

/* ── Scroll mode ──────────────────────────────────────────────────────────── */
.scroll-mode-list { display: flex; flex-direction: column; max-width: 740px; }

.scroll-question-block {
  padding: 0.5rem 0 1.5rem;
  scroll-margin-top: 1rem;
}

.scroll-q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.scroll-q-num {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}
.scroll-flag-btn { font-size: 0.78rem; }
.scroll-flag-btn.flagged { color: var(--warning); }

.scroll-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0 0;
}

/* ── Theme toggle button ──────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.13s, color 0.13s;
  margin-left: auto;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg); color: var(--text); }

/* ── Dark mode ────────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg:            #0e1a2b;
  --surface:       #152236;
  --surface-2:     #1b2d46;
  --border:        #263d5c;
  --text:          #dce8f5;
  --text-muted:    #7096b8;
  --primary:       #4da6ff;
  --primary-hover: #3d96f0;
  --primary-light: #18304f;
  --success:       #3ecf8e;
  --success-light: #0b2e1c;
  --warning:       #f5c842;
  --warning-light: #2c2000;
  --danger:        #f47a7a;
  --danger-light:  #2e0f0f;
  --shadow:        0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-md:     0 4px 16px rgba(0,0,0,.5);
}

/* Badges in dark mode */
html[data-theme="dark"] .badge-blue   { background: #18304f; color: #60b8ff; }
html[data-theme="dark"] .badge-green  { background: #0b2e1c; color: #3ecf8e; }
html[data-theme="dark"] .badge-yellow { background: #2c2000; color: #f5c842; }
html[data-theme="dark"] .badge-red    { background: #2e0f0f; color: #f47a7a; }
html[data-theme="dark"] .badge-gray   { background: #1b2d46; color: #7096b8; }
html[data-theme="dark"] .badge-orange { background: #2c1500; color: #fb9d4b; }

/* Inputs — dark bg with visible border */
html[data-theme="dark"] input[type=text],
html[data-theme="dark"] input[type=number],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #0e1a2b;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(77,166,255,.18);
}

/* Option items */
html[data-theme="dark"] .option-item { background: var(--surface); }
html[data-theme="dark"] .option-item:hover,
html[data-theme="dark"] .option-item.selected { background: var(--primary-light); }
html[data-theme="dark"] .option-item.correct  { background: var(--success-light); }
html[data-theme="dark"] .option-item.wrong    { background: var(--danger-light); }

/* True/False buttons */
html[data-theme="dark"] .tf-btn { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .tf-btn:hover { background: var(--primary-light); }

/* Answer reveal */
html[data-theme="dark"] .answer-reveal-correct { background: var(--success-light); }
html[data-theme="dark"] .answer-reveal-wrong   { background: var(--danger-light); }
html[data-theme="dark"] .answer-reveal-ungraded { background: var(--warning-light); }

/* Review item answer blocks */
html[data-theme="dark"] .answer-block.answer-correct  { background: var(--success-light); }
html[data-theme="dark"] .answer-block.answer-wrong    { background: var(--danger-light); }
html[data-theme="dark"] .answer-block.answer-ungraded { background: var(--warning-light); }

/* Grade form rubric block */
html[data-theme="dark"] .answer-block[style*="surface-2"] { background: var(--surface-2); }

/* Code blocks — already dark, just tweak slightly for dark mode harmony */
html[data-theme="dark"] .code-block { background: #0a1624; border: 1px solid var(--border); }
html[data-theme="dark"] .code-block pre { color: #a8c8e8; }

/* Modal overlay — slightly deeper in dark mode */
html[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.6); }

/* Blank inputs */
html[data-theme="dark"] .blank-input {
  border-bottom-color: var(--primary);
  color: var(--text);
}
html[data-theme="dark"] .blank-input:focus { background: var(--primary-light); }

/* Sidebar legend dots */
html[data-theme="dark"] .q-dot { background: var(--surface-2); }

/* Score header */
html[data-theme="dark"] .score-header { background: var(--surface); }

/* Export option hover */
html[data-theme="dark"] .export-option:hover,
html[data-theme="dark"] .export-option.selected { background: var(--primary-light); border-color: var(--primary); }

/* File drop */
html[data-theme="dark"] .file-drop { background: var(--surface-2); }
html[data-theme="dark"] .file-drop:hover,
html[data-theme="dark"] .file-drop.dragover { background: var(--primary-light); }

/* Toast — slightly more visible in dark */
html[data-theme="dark"] .toast         { background: #1b2d46; color: #dce8f5; border: 1px solid var(--border); }
html[data-theme="dark"] .toast-success { background: #0b2e1c; border-color: var(--success); color: var(--success); }
html[data-theme="dark"] .toast-error   { background: #2e0f0f; border-color: var(--danger);  color: var(--danger); }

/* Scrollbars (webkit) */
html[data-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
