/* ==========================================================================
   IIT JAM Mathematics Mock Test Series - Master Stylesheet
   Modern, Responsive, Mobile-Friendly, High-Contrast Design System
   ========================================================================== */

:root {
  /* Color Palette - Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  /* Brand Accents */
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-accent: #6366f1;
  --brand-accent-hover: #4f46e5;
  
  /* IIT JAM Official Palette Status Colors */
  --status-answered: #16a34a;          /* Green */
  --status-answered-bg: #dcfce7;
  --status-not-answered: #dc2626;      /* Red */
  --status-not-answered-bg: #fee2e2;
  --status-not-visited: #94a3b8;       /* Slate/Grey */
  --status-not-visited-bg: #f1f5f9;
  --status-review: #9333ea;            /* Purple */
  --status-review-bg: #f3e8ff;
  --status-ans-review: #7e22ce;        /* Purple with green indicator */
  
  /* UI Helpers */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --header-height: 64px;
  --footer-height: 64px;
}

[data-theme="dark"] {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: #172033;
  --border-color: #374151;
  --border-focus: #60a5fa;
  
  --text-primary: #f9fafb;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --brand-primary: #3b82f6;
  --brand-primary-hover: #60a5fa;
  --brand-accent: #818cf8;
  
  --status-answered: #16a34a;
  --status-answered-bg: #064e3b;
  --status-not-answered: #dc2626;
  --status-not-answered-bg: #7f1d1d;
  --status-not-visited: #334155;
  --status-not-visited-bg: #1e293b;
  --status-review: #9333ea;
  --status-review-bg: #581c87;
  --status-ans-review: #7e22ce;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}

/* ==========================================================================
   PORTAL / HUB LAYOUT (index.html)
   ========================================================================== */

.portal-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  width: 100%;
}

.portal-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #4338ca 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-xl);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.portal-hero::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 700px;
  margin: 0 auto 24px;
}

.hero-stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.hero-stat-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
}

.hero-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
}

.hero-stat-lbl {
  font-size: 0.8rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Category Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  scrollbar-width: thin;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.filter-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Topic Cards Grid */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-primary);
}

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

.topic-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.topic-category-tag {
  background: #eff6ff;
  color: #2563eb;
}
[data-theme="dark"] .topic-category-tag {
  background: #1e3a8a;
  color: #93c5fd;
}

.topic-id-badge {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--brand-primary);
}

.topic-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.3;
  color: var(--text-primary);
}

.topic-meta-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
  background: var(--bg-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.topic-meta-item {
  display: flex;
  flex-direction: column;
}

.meta-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.meta-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topic-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-start-test {
  background: var(--brand-primary);
  color: #ffffff;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease, transform 0.1s ease;
  width: 100%;
}

.btn-start-test:hover {
  background: var(--brand-primary-hover);
  transform: translateY(-1px);
}

.btn-practice-test {
  background: transparent;
  color: var(--brand-primary);
  border: 1px solid var(--border-color);
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-practice-test:hover {
  background: var(--bg-tertiary);
  border-color: var(--brand-primary);
}

/* ==========================================================================
   EXAM ENGINE LAYOUT (test.html)
   ========================================================================== */

.exam-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-primary);
}

.exam-app.results-mode {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Top Navbar */
.exam-navbar {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  max-width: 100vw;
}

.exam-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-home-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.exam-topic-info {
  display: flex;
  flex-direction: column;
}

.exam-topic-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.exam-topic-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.exam-nav-center {
  display: flex;
  align-items: center;
}

.timer-box {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="dark"] .timer-box {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.timer-box.timer-normal {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}
[data-theme="dark"] .timer-box.timer-normal {
  background: #172554;
  color: #93c5fd;
  border-color: #1e3a8a;
}

.timer-box.timer-warning {
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

.exam-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.nav-icon-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-submit-exam {
  background: #16a34a;
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
  transition: background 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-submit-exam:hover {
  background: #15803d;
  transform: translateY(-1px);
}

.btn-submit-exam:active {
  transform: translateY(0);
}

/* Main Workspace */
.exam-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Question Area */
.question-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow-y: auto;
  padding: 20px 24px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  flex: 1;
}

.question-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.q-num-badge {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.q-type-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #334155;
  text-transform: uppercase;
  border: 1px solid transparent;
}

[data-theme="dark"] .q-type-badge {
  background: #1e293b;
  color: #94a3b8;
}

.q-type-mcq { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.q-type-msq { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.q-type-nat { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

[data-theme="dark"] .q-type-mcq {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}

[data-theme="dark"] .q-type-msq {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .q-type-nat {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.q-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.q-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.q-year-tag {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  letter-spacing: 0.3px;
}

.btn-official-screenshot {
  background: var(--bg-card);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}

.btn-official-screenshot:hover {
  background: var(--brand-primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.28);
}

[data-theme="dark"] .btn-official-screenshot {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.4);
}

[data-theme="dark"] .btn-official-screenshot:hover {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.q-marks-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.q-body-content {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 24px;
  user-select: text;
}

/* CBT Fill-in-the-Blank for NAT */
.cbt-blank {
  display: inline-block;
  min-width: 80px;
  border-bottom: 2.5px solid var(--brand-primary);
  color: transparent;
  user-select: none;
  margin: 0 4px;
  vertical-align: baseline;
  letter-spacing: 2px;
}

[data-theme="dark"] .cbt-blank {
  border-bottom-color: var(--brand-accent);
}

/* Statement Lists (e.g. P:, Q: or I., II.) */
.statement-list {
  list-style: none;
  margin: 14px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.statement-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: var(--bg-tertiary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-primary);
  font-size: 1.05rem;
}

.statement-tag {
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--brand-primary);
  min-width: 24px;
}

.statement-text {
  flex: 1;
}

/* MathJax Equation Container Styling */
mjx-container {
  outline: none !important;
}

mjx-container[jax="SVG"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  vertical-align: middle;
  padding: 2px 0;
}

mjx-container[jax="SVG"][display="true"] {
  margin: 14px 0 !important;
  text-align: center;
}

/* Options Rendering */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.option-item:hover {
  border-color: #cbd5e1;
  background: var(--bg-card);
}

[data-theme="dark"] .option-item:hover {
  border-color: var(--border-color);
  background: var(--bg-tertiary);
}

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

[data-theme="dark"] .option-item.selected {
  background: #1e293b;
  border-color: var(--brand-primary);
}

.option-label {
  font-weight: 800;
  font-size: 1rem;
  color: var(--brand-primary);
  min-width: 28px;
}

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

/* Review Mode Options */
.option-item.opt-neutral {
  background: var(--bg-tertiary);
  border-color: transparent;
  color: var(--text-primary);
}

.option-item.opt-correct,
.option-item.opt-correct-chosen {
  background: #dcfce7;
  border-color: #22c55e;
}
.option-item.opt-correct .option-label,
.option-item.opt-correct-chosen .option-label {
  color: #15803d;
}
.option-item.opt-correct .opt-tag,
.option-item.opt-correct-chosen .opt-tag {
  color: #15803d;
  font-weight: 700;
  font-size: 0.82rem;
  margin-left: 6px;
}

[data-theme="dark"] .option-item.opt-correct,
[data-theme="dark"] .option-item.opt-correct-chosen {
  background: rgba(34, 197, 94, 0.16);
  border-color: #22c55e;
}
[data-theme="dark"] .option-item.opt-correct .option-label,
[data-theme="dark"] .option-item.opt-correct-chosen .option-label {
  color: #4ade80;
}
[data-theme="dark"] .option-item.opt-correct .opt-tag,
[data-theme="dark"] .option-item.opt-correct-chosen .opt-tag {
  color: #4ade80;
}

.option-item.opt-incorrect {
  background: #fee2e2;
  border-color: #ef4444;
}
.option-item.opt-incorrect .option-label {
  color: #b91c1c;
}
.option-item.opt-incorrect .opt-tag {
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.82rem;
  margin-left: 6px;
}

[data-theme="dark"] .option-item.opt-incorrect {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
}
[data-theme="dark"] .option-item.opt-incorrect .option-label {
  color: #f87171;
}
[data-theme="dark"] .option-item.opt-incorrect .opt-tag {
  color: #f87171;
}

/* NAT Input Area */
.nat-container {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: var(--radius-md);
  max-width: 460px;
  margin: 16px 0;
}

.nat-input-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: block;
}

.nat-input-field {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  margin-bottom: 16px;
  outline: none;
}

.nat-input-field:focus {
  border-color: var(--brand-primary);
}

.nat-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.nat-key {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.1s ease;
}

.nat-key:hover {
  background: var(--border-color);
}

.nat-key:active {
  transform: scale(0.96);
}

.nat-key-action {
  background: #f1f5f9;
  color: #334155;
}
[data-theme="dark"] .nat-key-action {
  background: #334155;
  color: #f1f5f9;
}

/* Action Footer */
.exam-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.footer-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-action-text-short {
  display: none;
}

.btn-action {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-secondary {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-review {
  background: var(--status-review-bg);
  border-color: var(--status-review);
  color: var(--status-review);
}

.btn-review:hover {
  background: var(--status-review);
  color: #ffffff;
}

.btn-clear {
  background: transparent;
  border-color: #cbd5e1;
  color: var(--text-secondary);
}

.btn-clear:hover {
  border-color: var(--status-not-answered);
  color: var(--status-not-answered);
}

.btn-save-next {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-save-next:hover {
  background: var(--brand-primary-hover);
}

/* ==========================================================================
   QUESTION PALETTE SIDEBAR
   ========================================================================== */

.palette-pane {
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  transition: transform 0.3s ease;
}

.palette-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.palette-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.palette-close-btn {
  display: none;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}

.palette-close-btn:hover {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.palette-backdrop {
  display: none;
}

.palette-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.2;
}

.legend-badge {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: #ffffff;
  flex-shrink: 0;
}

.bg-answered { 
  background: #16a34a; 
  color: #ffffff;
}
.bg-not-answered { 
  background: #dc2626; 
  color: #ffffff;
}
.bg-not-visited { 
  background: #64748b; 
  color: #ffffff;
}
[data-theme="dark"] .bg-not-visited {
  background: #334155;
  border: 1px solid #475569;
  color: #f1f5f9;
}
.bg-review { 
  background: #9333ea; 
  color: #ffffff;
}
.bg-ans-review {
  background: #7e22ce;
  color: #ffffff;
  position: relative;
}
.bg-ans-review::after {
  content: "";
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background: #22c55e;
  border: 1px solid #ffffff;
  border-radius: 50%;
}

.palette-filter-row {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow-x: auto;
}

.palette-filter-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.palette-filter-btn:hover {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.palette-filter-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.35);
}

.palette-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.palette-grid::-webkit-scrollbar {
  width: 6px;
}
.palette-grid::-webkit-scrollbar-track {
  background: transparent;
}
.palette-grid::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.palette-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.palette-btn {
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  color: #ffffff;
  user-select: none;
  background: #64748b; /* Fallback */
}

.palette-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.06);
  z-index: 1;
}

/* 1. Not Visited Status */
.palette-btn.status-not_visited,
.palette-btn.status-not-visited,
.palette-btn.st-not-visited {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
}

[data-theme="dark"] .palette-btn.status-not_visited,
[data-theme="dark"] .palette-btn.status-not-visited,
[data-theme="dark"] .palette-btn.st-not-visited {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #3b4d66;
}

[data-theme="dark"] .palette-btn.status-not_visited:hover,
[data-theme="dark"] .palette-btn.status-not-visited:hover,
[data-theme="dark"] .palette-btn.st-not-visited:hover {
  background: #334155;
  color: #ffffff;
  border-color: #60a5fa;
}

/* 2. Not Answered Status (Red) */
.palette-btn.status-not_answered,
.palette-btn.status-not-answered,
.palette-btn.st-not-answered {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #ef4444;
}

[data-theme="dark"] .palette-btn.status-not_answered,
[data-theme="dark"] .palette-btn.status-not-answered,
[data-theme="dark"] .palette-btn.st-not-answered {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #f87171;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.4);
}

/* 3. Answered Status (Green) */
.palette-btn.status-answered,
.palette-btn.st-answered {
  background: #16a34a;
  color: #ffffff;
  border: 1px solid #22c55e;
}

[data-theme="dark"] .palette-btn.status-answered,
[data-theme="dark"] .palette-btn.st-answered {
  background: #16a34a;
  color: #ffffff;
  border: 1px solid #4ade80;
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.4);
}

/* 4. Marked for Review (Purple) */
.palette-btn.status-review,
.palette-btn.st-review {
  background: #9333ea;
  color: #ffffff;
  border: 1px solid #a855f7;
}

[data-theme="dark"] .palette-btn.status-review,
[data-theme="dark"] .palette-btn.st-review {
  background: #9333ea;
  color: #ffffff;
  border: 1px solid #c084fc;
  box-shadow: 0 1px 3px rgba(147, 51, 234, 0.4);
}

/* 5. Answered & Marked for Review (Purple with Green Dot) */
.palette-btn.status-ans_review,
.palette-btn.status-ans-review,
.palette-btn.st-ans-review {
  background: #7e22ce;
  color: #ffffff;
  border: 1px solid #9333ea;
  position: relative;
}

[data-theme="dark"] .palette-btn.status-ans_review,
[data-theme="dark"] .palette-btn.status-ans-review,
[data-theme="dark"] .palette-btn.st-ans-review {
  background: #7e22ce;
  color: #ffffff;
  border: 1px solid #a855f7;
  box-shadow: 0 1px 3px rgba(126, 34, 206, 0.4);
}

.palette-btn.status-ans_review::after,
.palette-btn.status-ans-review::after,
.palette-btn.st-ans-review::after {
  content: "";
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border: 1.5px solid #ffffff;
  border-radius: 50%;
}

/* Current / Active Selected Question Highlight */
.palette-btn.current,
.palette-btn.current-q {
  outline: 3px solid #3b82f6 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.7) !important;
  font-weight: 900 !important;
  z-index: 2;
}

/* Mobile Drawer Overlay */
.palette-drawer-toggle {
  display: none;
  position: fixed;
  bottom: 74px;
  right: 16px;
  background: var(--brand-primary);
  color: #ffffff;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  box-shadow: var(--shadow-lg);
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 30;
  align-items: center;
  justify-content: center;
}

.palette-drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  display: none;
}

.btn-palette-submit {
  width: 100%;
  background: #16a34a;
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s ease;
}

.btn-palette-submit:hover {
  background: #15803d;
}

/* ==========================================================================
   SCIENTIFIC CALCULATOR MODAL
   ========================================================================== */

.calc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.calc-container {
  background: #ffffff;
  color: #1e293b;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

[data-theme="dark"] .calc-container {
  background: #1e293b;
  color: #f8fafc;
  border-color: #475569;
}

.calc-header {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
}

.calc-title {
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.calc-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.1rem;
  cursor: pointer;
}

/* Screenshot Modal Styles */
.screenshot-modal-container {
  max-width: 960px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.screenshot-modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: #ffffff;
}

[data-theme="dark"] .screenshot-modal-body {
  background: #0f172a;
}

.screenshot-modal-body img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background: #ffffff;
}

.screenshot-loading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 30px;
  text-align: center;
}

/* Modal Helper Layout Classes */
.modal-submit-container {
  max-width: 440px;
  padding: 24px;
}

.modal-submit-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-submit-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-submit-meta {
  margin-bottom: 24px;
}

.modal-btn-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-confirm-submit {
  background: var(--status-answered);
  color: #ffffff;
}

.btn-confirm-submit:hover {
  filter: brightness(1.1);
}

.modal-qpaper-container {
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-qpaper-list {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

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

.screenshot-open-btn {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.modal-instructions-container {
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-instructions-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.instructions-section-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--brand-primary);
}

.instructions-list {
  padding-left: 20px;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.instructions-list strong {
  color: var(--text-primary);
}

.instructions-footer-row {
  text-align: right;
  margin-top: 20px;
}

.legend-color-answered {
  color: var(--status-answered);
  font-weight: 700;
}

.legend-color-not-answered {
  color: var(--status-not-answered);
  font-weight: 700;
}

.legend-color-not-visited {
  color: var(--status-not-visited);
  font-weight: 700;
}

.legend-color-review {
  color: var(--status-review);
  font-weight: 700;
}

.legend-color-ans-review {
  color: var(--status-ans-review);
  font-weight: 700;
}

.calc-screen-wrap {
  background: #f8fafc;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  text-align: right;
}

[data-theme="dark"] .calc-screen-wrap {
  background: #0f172a;
  border-color: #334155;
}

.calc-history {
  font-size: 0.8rem;
  color: #64748b;
  min-height: 18px;
  font-family: var(--font-mono);
}

.calc-display {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  overflow-x: auto;
  white-space: nowrap;
}

.calc-mode-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #f1f5f9;
  font-size: 0.8rem;
  font-weight: 600;
}

[data-theme="dark"] .calc-mode-bar {
  background: #111827;
}

.calc-mode-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.calc-mem-indicator {
  margin-left: auto;
  color: var(--brand-primary);
  font-weight: 800;
}

.calc-keypad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  padding: 10px;
  background: #e2e8f0;
}

[data-theme="dark"] .calc-keypad {
  background: #1e293b;
}

.calc-btn {
  padding: 10px 4px;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: #ffffff;
  color: #1e293b;
  transition: all 0.1s ease;
}

[data-theme="dark"] .calc-btn {
  background: #334155;
  color: #f8fafc;
}

.calc-btn:hover {
  filter: brightness(0.9);
}

.calc-btn.btn-fn {
  background: #e0e7ff;
  color: #3730a3;
}
[data-theme="dark"] .calc-btn.btn-fn {
  background: #312e81;
  color: #c7d2fe;
}

.calc-btn.btn-op {
  background: #ffedd5;
  color: #9a3412;
}
[data-theme="dark"] .calc-btn.btn-op {
  background: #7c2d12;
  color: #fed7aa;
}

.calc-btn.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}
[data-theme="dark"] .calc-btn.btn-danger {
  background: #7f1d1d;
  color: #fecaca;
}

.calc-btn.btn-equals {
  grid-column: span 3;
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 1rem;
}

/* ==========================================================================
   RESULTS & SOLUTIONS VIEW (results.js)
   ========================================================================== */

.results-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  width: 100%;
}

.scorecard-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  margin-bottom: 28px;
}

.scorecard-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.scorecard-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 24px;
}

.score-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 4px solid rgba(255, 255, 255, 0.4);
  margin: 0 auto 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-val {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
}

.score-max {
  font-size: 0.85rem;
  opacity: 0.85;
}

.results-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

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

.stat-card-val {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.stat-card-val.val-total { color: var(--brand-primary); }
.stat-card-val.val-correct { color: #16a34a; }
[data-theme="dark"] .stat-card-val.val-correct { color: #4ade80; }
.stat-card-val.val-incorrect { color: #dc2626; }
[data-theme="dark"] .stat-card-val.val-incorrect { color: #f87171; }
.stat-card-val.val-unattempted { color: #94a3b8; }
[data-theme="dark"] .stat-card-val.val-unattempted { color: #94a3b8; }

.stat-card-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

/* Section Breakdown Table */
.results-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.results-breakdown-table th {
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
}
.results-breakdown-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}
.results-breakdown-table tr:hover td {
  background: var(--bg-tertiary);
}
.results-breakdown-table td.col-correct {
  color: #16a34a;
  font-weight: 700;
}
[data-theme="dark"] .results-breakdown-table td.col-correct {
  color: #4ade80;
}

/* Solution Review Items */
.review-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.review-filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.review-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.review-card.status-correct {
  border-left: 6px solid #16a34a;
}
[data-theme="dark"] .review-card.status-correct {
  border-left-color: #22c55e;
}

.review-card.status-incorrect {
  border-left: 6px solid #dc2626;
}
[data-theme="dark"] .review-card.status-incorrect {
  border-left-color: #ef4444;
}

.review-card.status-unattempted {
  border-left: 6px solid #94a3b8;
}
[data-theme="dark"] .review-card.status-unattempted {
  border-left-color: #64748b;
}

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

/* Review Status & Marks Badges */
.review-status-badge {
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.review-status-badge.status-correct {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
[data-theme="dark"] .review-status-badge.status-correct {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.review-status-badge.status-incorrect {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
[data-theme="dark"] .review-status-badge.status-incorrect {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.review-status-badge.status-skipped {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
[data-theme="dark"] .review-status-badge.status-skipped {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.review-marks-badge {
  font-weight: 800;
  font-size: 0.95rem;
}
.review-marks-badge.marks-pos { color: #16a34a; }
[data-theme="dark"] .review-marks-badge.marks-pos { color: #4ade80; }
.review-marks-badge.marks-neg { color: #dc2626; }
[data-theme="dark"] .review-marks-badge.marks-neg { color: #f87171; }
.review-marks-badge.marks-zero { color: #64748b; }
[data-theme="dark"] .review-marks-badge.marks-zero { color: #94a3b8; }

/* Review Response Box */
.review-response-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.review-response-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.review-response-box .resp-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}
.review-response-box .key-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #16a34a;
}
[data-theme="dark"] .review-response-box .key-val {
  color: #4ade80;
}

.solution-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
}

[data-theme="dark"] .solution-box {
  background: #0f172a;
  border-color: #334155;
}

.solution-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
[data-theme="dark"] .solution-title {
  color: #60a5fa;
}

/* Modal Summary Colors */
.meta-val.val-answered { color: #16a34a; }
[data-theme="dark"] .meta-val.val-answered { color: #4ade80; }
.meta-val.val-not-answered { color: #dc2626; }
[data-theme="dark"] .meta-val.val-not-answered { color: #f87171; }
.meta-val.val-review { color: #9333ea; }
[data-theme="dark"] .meta-val.val-review { color: #c084fc; }
.meta-val.val-not-visited { color: var(--text-primary); }

/* ==========================================================================
   UTILITY & RESPONSIVE RULES
   ========================================================================== */

.hidden {
  display: none !important;
}

@media (max-width: 992px) {
  .palette-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .palette-backdrop.drawer-open,
  .palette-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .palette-pane {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    height: calc(100% - var(--header-height));
    z-index: 50;
    box-shadow: -6px 0 25px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s ease;
    visibility: hidden;
    pointer-events: none;
  }

  .palette-pane.drawer-open,
  .palette-pane.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

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

  .palette-drawer-toggle {
    display: flex;
  }

  .palette-drawer-footer {
    display: block;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 54px;
  }

  .exam-navbar {
    padding: 0 12px;
  }

  .nav-home-btn {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .exam-topic-title {
    max-width: 160px;
    font-size: 0.88rem;
  }

  .exam-topic-sub {
    font-size: 0.7rem;
  }

  .timer-box {
    padding: 5px 12px;
    font-size: 1rem;
    gap: 5px;
  }

  .exam-nav-right {
    gap: 6px;
  }

  .nav-icon-btn {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .btn-submit-exam {
    padding: 6px 14px;
    font-size: 0.85rem;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 50px;
  }

  .portal-hero {
    padding: 28px 16px;
  }
  
  .hero-title {
    font-size: 1.6rem;
  }
  
  .topics-grid {
    grid-template-columns: 1fr;
  }
  
  .exam-navbar {
    padding: 0 8px;
  }

  .nav-home-btn {
    padding: 5px 8px;
    font-size: 0.78rem;
  }

  .nav-home-text {
    display: none;
  }

  .exam-nav-left {
    gap: 6px;
  }

  .exam-topic-info {
    max-width: 90px;
  }

  .exam-topic-title {
    max-width: 90px;
    font-size: 0.8rem;
  }

  .exam-topic-sub {
    display: none;
  }

  .timer-box {
    padding: 4px 8px;
    font-size: 0.88rem;
    gap: 4px;
  }

  .exam-nav-right {
    gap: 4px;
  }

  .nav-icon-btn {
    padding: 5px 7px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
  }

  .hide-mobile {
    display: none !important;
  }

  .btn-submit-exam {
    padding: 6px 10px;
    font-size: 0.8rem;
    gap: 3px;
  }

  .question-pane {
    padding: 10px 12px;
  }
  
  .question-card {
    padding: 16px 14px;
    margin-bottom: 12px;
  }

  /* 2x2 Grid for Footer on Mobile Portrait */
  .exam-footer {
    padding: 8px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .footer-btn-group {
    display: contents;
  }

  .footer-left-group .btn-review {
    grid-column: 1;
    grid-row: 1;
  }

  .footer-left-group .btn-clear {
    grid-column: 2;
    grid-row: 1;
  }

  .footer-right-group .btn-secondary {
    grid-column: 1;
    grid-row: 2;
  }

  .footer-right-group .btn-save-next {
    grid-column: 2;
    grid-row: 2;
  }

  .btn-action {
    width: 100%;
    justify-content: center;
    padding: 9px 8px;
    font-size: 0.8rem;
    min-height: 40px;
    border-radius: var(--radius-sm);
  }

  .btn-action-text {
    display: none;
  }

  .btn-action-text-short {
    display: inline;
  }

  .palette-drawer-toggle {
    bottom: 105px;
    right: 14px;
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }
}

@media (max-width: 380px) {
  .exam-navbar {
    padding: 0 4px;
  }

  .exam-topic-info {
    max-width: 70px;
  }

  .exam-topic-title {
    max-width: 70px;
    font-size: 0.75rem;
  }

  .timer-box {
    padding: 3px 6px;
    font-size: 0.82rem;
    gap: 2px;
  }

  .exam-nav-right {
    gap: 3px;
  }

  .nav-icon-btn {
    padding: 4px 6px;
    font-size: 0.75rem;
  }

  .btn-submit-exam {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
}

/* Mobile Landscape Orientation Optimization */
@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --header-height: 44px;
  }

  .exam-navbar {
    height: 44px;
    padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }

  .nav-home-btn {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .exam-topic-info {
    max-width: 160px;
  }

  .exam-topic-title {
    max-width: 160px;
    font-size: 0.82rem;
  }

  .exam-topic-sub {
    display: none;
  }

  .timer-box {
    padding: 3px 10px;
    font-size: 0.9rem;
    gap: 4px;
  }

  .exam-nav-right {
    gap: 5px;
  }

  .nav-icon-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .btn-submit-exam {
    padding: 5px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .question-pane {
    padding: 8px 14px;
  }

  .question-card {
    padding: 14px;
    margin-bottom: 8px;
  }

  .question-header-row {
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .exam-footer {
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  .footer-btn-group {
    display: flex;
    gap: 6px;
  }

  .btn-action {
    padding: 6px 10px;
    font-size: 0.78rem;
    min-height: 34px;
  }

  .btn-action-text {
    display: none;
  }

  .btn-action-text-short {
    display: inline;
  }

  .palette-pane {
    top: 44px;
    height: calc(100% - 44px);
    width: 280px;
  }

  .palette-drawer-toggle {
    bottom: 50px;
    right: 12px;
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
}

/* ==========================================================================
   SCREENSHOT-FIRST QUESTION CARD & CHOICE TILES (2005-2026 PYQs)
   ========================================================================== */

.q-screenshot-wrapper {
  margin-bottom: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.q-screenshot-wrapper:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
}

.q-screenshot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 8px;
}

.q-screenshot-pill {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-screenshot-zoom {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-screenshot-zoom:hover {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.q-screenshot-img-container {
  padding: 18px 20px;
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
}

[data-theme="dark"] .q-screenshot-img-container {
  background: #1e293b;
}

.q-screenshot-img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-in;
  transition: transform 0.2s ease;
}

/* In dark mode, ensure crisp readability for scanned math formulas */
[data-theme="dark"] .q-screenshot-img {
  filter: contrast(1.08) brightness(1.02);
  background: #ffffff;
  padding: 8px;
  border-radius: 6px;
}

/* Options Choice Grid */
.mcq-choices-container,
.msq-choices-container {
  margin-top: 10px;
}

.choices-header-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  flex-wrap: wrap;
  gap: 8px;
}

.shortcut-tip {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.choice-tiles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (max-width: 680px) {
  .choice-tiles-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.choice-tile {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
  font-family: inherit;
  width: 100%;
}

.choice-tile:hover {
  border-color: var(--brand-primary);
  background: var(--bg-tertiary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.choice-tile.selected {
  border-color: var(--brand-primary);
  background: #eff6ff;
  box-shadow: 0 0 0 1px var(--brand-primary), 0 4px 12px rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .choice-tile.selected {
  background: #1e3a8a33;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 1px var(--brand-primary), 0 4px 12px rgba(59, 130, 246, 0.25);
}

.choice-tile-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.choice-tile.selected .choice-tile-badge {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.choice-tile-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.choice-tile-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.choice-tile-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.choice-tile-radio {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.choice-tile.selected .choice-tile-radio {
  border-color: var(--brand-primary);
}

.radio-inner {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: transparent;
  transition: background 0.2s ease;
}

.choice-tile.selected .radio-inner {
  background: var(--brand-primary);
}

.choice-tile-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
  transition: all 0.2s ease;
}

.choice-tile-checkbox.checked {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
}

/* NAT Layout */
.nat-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 10px;
}

.nat-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 6px;
}

.nat-input-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.nat-input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: center;
}

.nat-input-field {
  flex: 1;
  max-width: 360px;
  padding: 12px 16px;
  font-size: 1.25rem;
  font-family: var(--font-mono);
  font-weight: 700;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.nat-input-field:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.nat-clear-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nat-clear-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.nat-keypad-wrapper {
  max-width: 320px;
}

.nat-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.nat-key {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 0;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.nat-key:hover {
  background: var(--border-color);
  transform: translateY(-1px);
}

.nat-key:active {
  transform: translateY(1px);
}

.nat-key-action {
  background: #f1f5f9;
  color: #dc2626;
  font-size: 0.85rem;
}

[data-theme="dark"] .nat-key-action {
  background: #334155;
  color: #f87171;
}

.nat-key-sign {
  font-size: 0.88rem;
  color: var(--brand-primary);
}

/* Question Paper Modal Cards */
.qpaper-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.qpaper-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 8px;
}

.qpaper-item-body {
  padding: 14px 18px;
  background: #ffffff;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

[data-theme="dark"] .qpaper-item-body {
  background: #1e293b;
}

.qpaper-screenshot-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

[data-theme="dark"] .qpaper-screenshot-img {
  background: #ffffff;
  padding: 6px;
  border-radius: 4px;
}

.qpaper-ans-badge {
  font-size: 0.82rem;
  background: #dcfce7;
  color: #15803d;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.qpaper-unans-badge {
  font-size: 0.82rem;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* Solution Review in Results */
.solution-review-section {
  margin-top: 36px;
}

.solution-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.solution-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.solution-filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sol-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sol-filter-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.solution-cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-q-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.review-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 8px;
}

.review-q-num {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.review-status-pill {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.pill-correct { background: #dcfce7; color: #15803d; }
.pill-incorrect { background: #fee2e2; color: #dc2626; }
.pill-unattempted { background: var(--bg-primary); color: var(--text-muted); }
.pill-mta { background: #f3e8ff; color: #7e22ce; }

[data-theme="dark"] .pill-correct { background: #064e3b; color: #86efac; }
[data-theme="dark"] .pill-incorrect { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .pill-unattempted { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] .pill-mta { background: #581c87; color: #d8b4fe; }

.review-q-body {
  padding: 16px 20px;
  background: #ffffff;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

[data-theme="dark"] .review-q-body {
  background: #1e293b;
}

.review-screenshot-box {
  width: 100%;
  display: flex;
  justify-content: center;
}

.review-screenshot-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

[data-theme="dark"] .review-screenshot-img {
  background: #ffffff;
  padding: 6px;
  border-radius: 4px;
}

.review-answers-box {
  display: flex;
  padding: 14px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.review-answer-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ans-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
}

.ans-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ans-val.user-val { color: var(--brand-primary); }
.ans-val.key-val { color: #16a34a; }
.ans-val.pos { color: #16a34a; }
.ans-val.neg { color: #dc2626; }
.ans-val.zero { color: var(--text-muted); }

.results-actions-bar {
  display: flex;
  gap: 12px;
  margin: 24px 0;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Question Difficulty Tags & Interactive Popover Menu --- */
.q-diff-selector-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.q-diff-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.q-diff-badge-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.q-diff-btn-caret {
  font-size: 0.7rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.q-diff-selector-wrap.open .q-diff-btn-caret {
  transform: rotate(180deg);
}

.q-diff-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 175px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: fadeInDown 0.15s ease-out;
}

.q-diff-dropdown.hidden {
  display: none;
}

.q-diff-dropdown-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2px;
}

.q-diff-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.q-diff-dropdown-item:hover {
  background: var(--bg-hover);
}

.q-diff-dropdown-item.active {
  background: var(--bg-tertiary);
  font-weight: 700;
}

/* Color definitions */
.diff-very-easy {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #10b981 !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
}

.diff-easy {
  background: rgba(6, 182, 212, 0.15) !important;
  color: #06b6d4 !important;
  border-color: rgba(6, 182, 212, 0.4) !important;
}

.diff-medium {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #f59e0b !important;
  border-color: rgba(245, 158, 11, 0.4) !important;
}

.diff-hard {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

.diff-hardest {
  background: rgba(168, 85, 247, 0.15) !important;
  color: #a855f7 !important;
  border-color: rgba(168, 85, 247, 0.4) !important;
}

.diff-unrated {
  background: var(--bg-card) !important;
  color: var(--text-muted) !important;
  border-color: var(--border-color) !important;
}

.q-diff-badge-btn.is-suggested {
  border-style: dashed !important;
}

html.hide-suggested-difficulty .q-diff-badge.is-suggested,
body.hide-suggested-difficulty .q-diff-badge.is-suggested {
  display: none !important;
}

.btn-mock-toggle-diff.active {
  background: rgba(56, 189, 248, 0.2) !important;
  border-color: rgba(56, 189, 248, 0.5) !important;
  color: var(--accent) !important;
}

.q-diff-badge-btn.is-user-tagged {
  border-style: solid !important;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

.diff-badge-prefix {
  font-size: 0.74rem;
  opacity: 0.82;
  font-weight: 500;
}

.diff-badge-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 4px;
  letter-spacing: 0.2px;
}

.diff-badge-pill.user {
  background: rgba(16, 185, 129, 0.25);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.diff-badge-pill.unrated {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.diff-tag-pill {
  font-size: 0.68em;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  margin-left: 4px;
}

.diff-tag-pill.user {
  background: rgba(16, 185, 129, 0.25);
  color: #10b981;
}

.diff-tag-pill.unrated {
  background: rgba(148, 163, 184, 0.2);
  color: inherit;
  opacity: 0.85;
}

.q-diff-status-box {
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.74rem;
  border: 1px solid var(--border-color);
}

.q-diff-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.q-diff-status-label {
  color: var(--text-muted);
  font-weight: 600;
}

.q-diff-status-val {
  font-weight: 700;
}

/* Difficulty Badge component */
.q-diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.q-diff-badge.size-sm {
  font-size: 0.7rem;
  padding: 2px 6px;
}

.q-diff-badge.size-lg {
  font-size: 0.85rem;
  padding: 5px 12px;
}

/* Results: Difficulty Performance Section */
.results-diff-section {
  margin: 28px 0;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.results-diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.results-diff-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.diff-stat-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.diff-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.diff-stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.diff-stat-name {
  font-size: 0.88rem;
  font-weight: 700;
}

.diff-stat-score {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.diff-stat-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.diff-stat-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  overflow: hidden;
  margin-top: 4px;
}

.diff-stat-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

/* Toast message for difficulty update */
.diff-toast-notification {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: toastFadeIn 0.2s ease-out;
  pointer-events: none;
}
@keyframes toastFadeIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

