/* =========================================================================
   AETHERA — design tokens
   ========================================================================= */
:root {
  /* Layered navy surfaces — Midnight/Navy per brand kit */
  --bg: #050b14;
  --surface-1: #0d1a30;   /* cards */
  --surface-2: #142640;   /* nested surfaces, inputs, hover */
  --surface-3: #101d38;   /* subtle/inactive chip fill */
  --border: #1f3050;
  --border-strong: #2c4568;

  /* Text — White / Silver per brand kit */
  --text: #f7fafc;
  --text-dim: #9fb0c9;
  --text-faint: #6b7f9c;

  /* Brand accents: Surgical Blue = buttons/CTAs/links/interactive state.
     Medical Teal = progress/success/highlights. Two jobs, two colors —
     never blended into one "primary" the way the old palette did. */
  --primary: #1e88e5;
  --primary-strong: #4da3ec;
  --primary-dim: #14588f;
  --accent: #19c4d6;
  --accent-strong: #3fd6e6;
  --accent-dim: #0f7f8a;

  /* Semantic (unchanged — red/amber carry meaning elsewhere, never touch) */
  --alarm: #ff5d6c;
  --resp: #ffcf4d;

  /* legacy variable names kept as aliases so untouched rules still resolve */
  --panel: var(--surface-1);
  --panel-2: var(--surface-2);
  --line: var(--border);
  --line-soft: var(--border);
  --cyan: var(--accent);
  --cyan-strong: var(--accent-strong);
  --cyan-dim: var(--accent-dim);
  --violet: var(--primary);
  --violet-dim: var(--primary-dim);
  --ecg: var(--accent);
  --ecg-dim: var(--accent-dim);
  --spo2: var(--primary);

  --font-display: 'Sora', 'IBM Plex Sans', system-ui, sans-serif;
  --font-body: 'Inter', 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;

  /* 8pt spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 40px;
  --sp-8: 48px;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(2, 4, 16, 0.28);
  --shadow-md: 0 8px 24px rgba(2, 4, 16, 0.38);
  --shadow-lg: 0 16px 48px rgba(2, 4, 16, 0.45);

  --content-width: 1360px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100%;
  scroll-behavior: smooth;
}
body {
  background-image:
    radial-gradient(900px circle at 20% -10%, rgba(30, 136, 229, 0.07), transparent 60%),
    radial-gradient(700px circle at 85% 10%, rgba(25, 196, 214, 0.05), transparent 55%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.metric-value, .performance-domain-pct, .nce-domain-pct, .nce-subdomain-pct,
.score-pct, .quiz-timer {
  font-variant-numeric: tabular-nums;
}

::selection { background: rgba(30, 136, 229, 0.25); }

a { color: inherit; text-decoration: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.app { max-width: var(--content-width); margin: 0 auto; }
.page { max-width: var(--content-width); margin: 0 auto; padding: 0 24px 40px; }
@media (min-width: 1440px) {
  .page { padding-left: 32px; padding-right: 32px; }
}

.view { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

/* =========================================================================
   Top navigation
   ========================================================================= */
.topnav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(5, 11, 20, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}
.topnav-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topnav-logo-wrap { display: block; position: relative; }
.topnav-logo { height: 30px; width: auto; display: block; }
.topnav-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.topnav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
}
.topnav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.topnav-link:hover { color: var(--text); background: var(--surface-2); }
.topnav-link.is-active { color: var(--primary); background: rgba(30, 136, 229, 0.12); }
.topnav-right { display: flex; align-items: center; gap: var(--sp-2); position: relative; flex-shrink: 0; }

.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  padding: 6px;
  z-index: 40;
}
.settings-menu[hidden] { display: none; }
.settings-menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--alarm);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.settings-menu-item:hover { background: rgba(255, 93, 108, 0.1); }

@media (max-width: 720px) {
  .topnav-links { display: none; }
  .topnav-inner { gap: var(--sp-3); }
}

/* =========================================================================
   Typography scale
   ========================================================================= */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin: 0 0 6px;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--text); margin: 0; }

.section-block { margin-top: var(--sp-6); }
.section-block:first-of-type { margin-top: var(--sp-6); }
.section-head { margin-bottom: var(--sp-4); }
.section-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.section-sub { color: var(--text-dim); font-size: 14px; margin: 8px 0 0; }

/* =========================================================================
   Buttons — shared states: hover, active/pressed, focus, disabled
   ========================================================================= */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  min-height: 40px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease, opacity 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled, .btn.is-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--primary); color: #04161d; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-secondary { background: var(--surface-2); color: var(--violet); border-color: var(--violet-dim); }
.btn-secondary:hover { background: rgba(30, 136, 229, 0.14); border-color: var(--violet); }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }

.btn-danger { background: var(--surface-2); color: var(--alarm); border-color: rgba(255,93,108,0.5); }
.btn-danger:hover { background: rgba(255,93,108,0.12); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon-btn[aria-pressed="true"], .icon-btn.is-flagged { color: var(--resp); border-color: var(--resp); }

/* =========================================================================
   Continue studying card
   ========================================================================= */
.continue-card {
  margin-top: var(--sp-5);
  background: linear-gradient(135deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.continue-card[hidden] { display: none; }
.continue-info { flex: 1; min-width: 0; }
.continue-topic { font-size: 19px; font-weight: 700; margin: 2px 0 6px; }
.continue-meta { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }
.continue-progress-track { max-width: 360px; }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--cyan);
  transition: width 0.3s ease;
}

@media (max-width: 640px) {
  .continue-card { flex-direction: column; align-items: stretch; }
  .continue-progress-track { max-width: none; }
}

/* =========================================================================
   Metric cards
   ========================================================================= */
.metrics-grid {
  margin-top: var(--sp-5);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
}
.metric-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--cyan);
  margin-bottom: 4px;
}
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.metric-label { color: var(--text-faint); font-size: 12.5px; }

@media (max-width: 860px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .metric-card { padding: var(--sp-3); }
}

/* =========================================================================
   Start-a-quiz mode cards
   ========================================================================= */
.quiz-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: stretch;
}
.mode-card {
  text-align: left;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  font-family: var(--font-body);
}
.mode-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.mode-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.mode-card:active { transform: translateY(0); }
.mode-card-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--primary);
  margin-bottom: 6px;
}
.mode-card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.mode-card-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--text); }
.mode-card-desc { font-size: 14px; color: var(--text-dim); line-height: 1.65; flex: 1; }
.mode-card-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.mode-card-cta { font-size: 13px; font-weight: 600; color: var(--violet); margin-top: 6px; }

.mode-card-primary {
  background: linear-gradient(160deg, rgba(30,136,229,0.14), var(--surface-1) 60%);
  border-color: var(--primary-dim);
}
.mode-card-primary .mode-card-icon { background: rgba(30,136,229,0.16); color: var(--primary); }
.mode-card-primary .mode-card-label { color: var(--primary); }
.mode-card-primary .mode-card-meta { border-top-color: var(--primary-dim); }
.mode-card-primary .mode-card-cta { color: var(--primary); }
.mode-card-primary:hover { border-color: var(--primary); }

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

/* =========================================================================
   Question bank two-column layout + study sidebar
   ========================================================================= */
.question-bank-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 300px);
  gap: 24px;
  align-items: start;
  margin-top: var(--sp-7);
}
.qb-main { min-width: 0; }
.section-block.qb-first-block { margin-top: 0; }

.qb-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar-primary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-right: 2px; /* room for scrollbar without clipping card borders */
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar-primary::-webkit-scrollbar { width: 6px; }
.sidebar-primary::-webkit-scrollbar-track { background: transparent; }
.sidebar-primary::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.sidebar-primary::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.sidebar-secondary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.is-page-hidden { display: none !important; }

.sidebar-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.sidebar-card-prominent {
  padding: 20px 18px;
  border-color: var(--border-strong);
}
.sidebar-card-compact { padding: 16px; }
.sidebar-card-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.sidebar-cta { width: 100%; text-align: center; margin-top: 14px; min-height: 38px; }
.sidebar-empty-note { color: var(--text-faint); font-size: 13px; margin: 0; }
.sidebar-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}
.sidebar-link:hover { color: var(--primary-strong); }

/* Today's goal */
.sidebar-goal-count { font-size: 15px; color: var(--text); margin: 0 0 8px; }
.sidebar-goal-status { font-size: 12.5px; color: var(--text-dim); margin: 8px 0 0; }

/* Recommended session */
.sidebar-rec-topic { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.sidebar-rec-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); margin: 0 0 8px; }
.sidebar-rec-sub { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.55; }

/* Exam readiness */
.sidebar-readiness-pct { font-size: 26px; font-weight: 700; color: var(--accent); margin: 0 0 8px; }
.sidebar-readiness-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.readiness-row { display: flex; flex-direction: column; gap: 5px; }
.readiness-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; }
.readiness-row-name { color: var(--text-dim); flex: 1; min-width: 0; overflow-wrap: break-word; line-height: 1.4; }
.readiness-row-pct { font-family: var(--font-mono); color: var(--text); font-weight: 600; flex-shrink: 0; text-align: right; }
.readiness-row .progress-track { height: 5px; }

/* Weak areas */
.sidebar-weak-list { display: flex; flex-direction: column; gap: 2px; }
.weak-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-dim);
  transition: background 0.12s ease;
}
.weak-item:hover { background: var(--surface-2); color: var(--text); }
.weak-item span:first-child { flex: 1; min-width: 0; overflow-wrap: break-word; line-height: 1.4; }
.weak-item-pct { font-family: var(--font-mono); color: var(--alarm); font-weight: 600; font-size: 12.5px; flex-shrink: 0; }

/* Recent activity */
.recent-activity-topic { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.recent-activity-score { font-size: 13px; color: var(--text-dim); margin: 0 0 2px; }
.recent-activity-when { font-size: 12px; color: var(--text-faint); margin: 0; }

/* Filter groups */
.filter-group { margin-bottom: var(--sp-4); }
.filter-group-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

@media (max-width: 1199px) and (min-width: 901px) {
  .question-bank-layout { grid-template-columns: 1fr; }
  .qb-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
  }
  .sidebar-primary, .sidebar-secondary { display: contents; }
}
@media (max-width: 900px) {
  .question-bank-layout { grid-template-columns: 1fr; }
  .qb-sidebar { position: static; }
  .sidebar-primary, .sidebar-secondary { display: contents; }
}
@media (max-width: 767px) {
  .page { padding-left: 16px; padding-right: 16px; }
}

/* =========================================================================
   Search
   ========================================================================= */
.search-row { display: flex; gap: 8px; margin: 0 0 var(--sp-3); }
.input, .select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 42px;
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.12s ease;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary-dim); }
.input::placeholder { color: var(--text-faint); }
.search-input { flex: 1; }
.search-results {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
}
.search-result-item {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--text-dim);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item .sr-topic { color: var(--text-faint); font-family: var(--font-mono); font-size: 11.5px; }
.search-results-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 12px; flex-wrap: wrap; }

/* =========================================================================
   Chips — quick access + shortcuts + filters
   ========================================================================= */
.quick-access-row, .shortcut-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 var(--sp-4);
}
.chip, .shortcut-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  min-height: 32px;
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip:hover, .shortcut-chip:not(.is-empty):hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.chip:focus-visible, .shortcut-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip:disabled, .chip.is-disabled, .shortcut-chip.is-empty {
  opacity: 0.4;
  cursor: not-allowed;
}
.chip-count, .shortcut-count {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   NCE domain / subdomain / topic browser
   ========================================================================= */
.nce-domains { display: flex; flex-direction: column; gap: var(--sp-3); }

.nce-domain {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.nce-domain.is-expanded { border-color: var(--primary-dim); }

.nce-domain-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  background: none;
  border: none;
  color: var(--text);
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: background 0.12s ease;
}
.nce-domain-header:hover { background: var(--surface-2); }
.nce-domain-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--cyan);
}
.nce-domain-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.nce-domain-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.nce-domain-meta { color: var(--text-faint); font-size: 12.5px; }
.nce-domain-progress { max-width: 260px; }
.nce-domain-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nce-domain-pct { color: var(--cyan); font-size: 15px; font-weight: 600; min-width: 3em; text-align: right; }
.nce-domain-chevron { color: var(--text-faint); transition: transform 0.15s ease; }
.nce-domain.is-expanded .nce-domain-chevron { transform: rotate(90deg); color: var(--primary); }

.nce-subdomain-list { border-top: 1px solid var(--border); }
.nce-subdomain-row { border-bottom: 1px solid var(--border); }
.nce-subdomain-row:last-child { border-bottom: none; }
.nce-subdomain-row.is-empty {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  color: var(--text-faint);
  font-size: 13px;
  opacity: 0.6;
}
.nce-subdomain-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text);
  padding: 11px 20px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13.5px;
}
.nce-subdomain-header:hover { background: var(--surface-2); }
.nce-subdomain-right { display: flex; align-items: center; gap: 10px; }
.nce-subdomain-count { font-family: var(--font-mono); color: var(--text-dim); font-size: 12px; }
.nce-subdomain-pct { font-family: var(--font-mono); color: var(--cyan); font-size: 12px; min-width: 2.5em; text-align: right; }
.btn-quiz-subdomain {
  background: var(--surface-2);
  border: 1px solid var(--primary-dim);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.12s ease;
}
.btn-quiz-subdomain:hover { background: rgba(30,136,229,0.14); }
.nce-subdomain-note { color: var(--text-faint); font-size: 12.5px; padding: 4px 20px 12px; }

.nce-topic-list { padding: 0 20px 12px 32px; display: flex; flex-direction: column; gap: 2px; }
.nce-topic-row {
  display: flex;
  justify-content: space-between;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 7px 0;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  border-bottom: 1px dashed var(--border);
}
.nce-topic-row:hover { color: var(--text); }
.nce-topic-row:last-child { border-bottom: none; }
.nce-topic-count { font-family: var(--font-mono); color: var(--text-faint); font-size: 12px; }

/* =========================================================================
   Performance section
   ========================================================================= */
.performance-list { display: flex; flex-direction: column; gap: var(--sp-3); }

.performance-row {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.performance-row-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.performance-domain-name { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.performance-domain-pct { color: var(--cyan); font-weight: 600; font-size: 14px; }
.performance-row-meta { color: var(--text-faint); font-size: 12px; margin-top: 8px; }

/* =========================================================================
   Study plan / saved quizzes / flagged sections
   ========================================================================= */
.card-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
}
.card-section-head h3 { margin: 0 0 10px; font-size: 15px; }
.preset-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: 8px;
}
.preset-item:last-child { margin-bottom: 0; }
.preset-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.preset-meta { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.preset-topics { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.preset-actions { display: flex; gap: 8px; margin-top: 10px; }

.empty-state {
  color: var(--text-faint);
  font-size: 14px;
  padding: 32px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* =========================================================================
   Fields / selects / checkbox lists (modals)
   ========================================================================= */
.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.field-hint { color: var(--text-faint); font-size: 12.5px; margin: 6px 0 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.custom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

.checkbox-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 6px 8px;
}
.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.checkbox-list label:hover { color: var(--text); }
.checkbox-list input[type="checkbox"] { accent-color: var(--primary); }
.checkbox-list .cbl-empty { color: var(--text-faint); font-size: 12.5px; padding: 6px 4px; }

.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.segmented button:hover { border-color: var(--border-strong); }
.segmented button[aria-checked="true"] {
  background: rgba(30,136,229,0.14);
  border-color: var(--primary);
  color: var(--primary);
}

/* =========================================================================
   Modals
   ========================================================================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 6, 18, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin: 0 0 20px; font-size: 19px; }
.modal-wide { max-width: 640px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* =========================================================================
   Quiz view
   ========================================================================= */
.quiz-bar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) 24px;
  border-bottom: 1px solid var(--border);
  max-width: var(--content-width);
  margin: 0 auto;
}
.quiz-bar-mid { flex: 1; min-width: 0; }
.quiz-cat {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--border);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.dot:hover { transform: scale(1.4); }
.dot:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.dot.done-correct { background: var(--cyan); }
.dot.done-incorrect { background: var(--alarm); }
.dot.flagged { background: var(--resp); }
.dot.current { background: var(--violet); }
.dot.is-active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text-faint); }

.quiz-timer { font-size: 14px; color: var(--cyan); flex-shrink: 0; }

.question-wrap { max-width: var(--content-width); margin: 0 auto; padding: 28px 24px 12px; }
.q-index { color: var(--text-faint); font-size: 12px; margin: 0 0 10px; }
.q-stem { font-family: var(--font-display); font-size: 21px; line-height: 1.45; margin: 0 0 26px; font-weight: 700; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.option:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.option-letter {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
}
.option.selected { border-color: var(--violet); background: rgba(30,136,229,0.1); }
.option.correct { border-color: var(--cyan); background: rgba(25,196,214,0.1); }
.option.correct .option-letter { background: var(--cyan); color: #04161d; border-color: var(--cyan); }
.option.incorrect { border-color: var(--alarm); background: rgba(255,93,108,0.1); }
.option.incorrect .option-letter { background: var(--alarm); color: #200; border-color: var(--alarm); }
.option:disabled { cursor: default; }

.feedback {
  margin-top: 22px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface-1);
  border: 1px solid var(--border);
}
.feedback[hidden] { display: none; }
.feedback-head { font-weight: 700; font-size: 15px; margin: 0 0 8px; }
.feedback.is-correct .feedback-head { color: var(--cyan); }
.feedback.is-incorrect .feedback-head { color: var(--alarm); }
.feedback-body { margin: 0; color: var(--text-dim); line-height: 1.6; font-size: 14px; }
.feedback-source { margin: 10px 0 0; color: var(--text-faint); font-size: 12px; }
.feedback-source:empty { display: none; }

.quiz-footer {
  display: flex; justify-content: space-between;
  max-width: var(--content-width); margin: 0 auto;
  padding: 24px 24px 48px;
}

/* =========================================================================
   Results view
   ========================================================================= */
.results-hero { text-align: center; padding: 40px 24px 20px; max-width: var(--content-width); margin: 0 auto; }
.score-ring-wrap { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.score-ring { width: 140px; height: 140px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: var(--cyan); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 377; stroke-dashoffset: 377;
  transition: stroke-dashoffset 0.6s ease;
}
.score-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-ring-text .mono { font-size: 14px; color: var(--text-dim); }
.score-pct { font-size: 26px; font-weight: 700; }
.results-cat { color: var(--text-dim); font-size: 14px; margin-top: 10px; }

.review-list { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; max-width: var(--content-width); margin-left: auto; margin-right: auto; padding: 0 24px; }
.review-item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.review-item.wrong { border-left-color: var(--alarm); }
.review-item.right { border-left-color: var(--cyan); }
.review-q { font-weight: 700; margin: 0 0 10px; font-size: 15px; }
.review-answer-row { font-size: 13px; margin: 4px 0; color: var(--text-dim); }
.review-answer-row strong { color: var(--text); }
.review-rationale { margin: 10px 0 0; font-size: 13.5px; color: var(--text-dim); line-height: 1.6; }
.review-source { margin: 8px 0 0; font-size: 12px; color: var(--text-faint); }
.results-footer { justify-content: space-between; max-width: var(--content-width); margin: 0 auto; padding: 24px 24px 48px; }

/* =========================================================================
   Logo (used inside nav; oversized hero/orbit rings removed per redesign)
   ========================================================================= */
.logo-img { height: 26px; width: auto; display: block; }

/* =========================================================================
   Auth pages (login, signup, forgot/reset password, onboarding)
   Reuses all existing tokens/components (.btn, .input, .field, colors,
   fonts) — no new palette or typography introduced.
   ========================================================================= */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-shell { width: 100%; max-width: 400px; }
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-brand img { height: 32px; width: auto; }
.auth-brand span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: var(--text);
}
.auth-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 0 0 6px; }
.auth-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 24px; line-height: 1.5; }
.auth-field { margin-bottom: 16px; }
.auth-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
}
.auth-submit { width: 100%; margin-top: 8px; }
.auth-error {
  background: rgba(255, 93, 108, 0.1);
  border: 1px solid var(--alarm);
  color: var(--alarm);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.auth-error[hidden] { display: none; }
.auth-success {
  background: rgba(25, 196, 214, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.auth-success[hidden] { display: none; }
.auth-links { text-align: center; margin-top: 20px; font-size: 13.5px; color: var(--text-dim); }
.auth-links a { color: var(--primary); font-weight: 600; }
.auth-links a:hover { color: var(--primary-strong); }
.auth-links p { margin: 6px 0; }

/* Full-screen auth-check overlay shown on the dashboard while a session is
   being verified, and while a protected redirect is in flight. */
.auth-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}
.auth-loading-overlay[hidden] { display: none; }
.auth-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: auth-spin 0.7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-loading-overlay p { color: var(--text-dim); font-size: 13.5px; margin: 0; }

/* Profile menu (added to the existing settings dropdown) */
.profile-menu-email {
  padding: 10px 12px 8px;
  font-size: 12.5px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  word-break: break-all;
}
