/* ============================================================
   ExamForge  - Design System
   Font: Inter (system stack fallback)
   Palette: Teal/medical green, dark forest navy, clean mint surfaces
   Philosophy: utility-first tokens, no framework dependency
   ============================================================ */

/* ── 1. Tokens ────────────────────────────────────────────── */
:root {
  /* Color  - Teal / Medical Green Theme */
  --c-navy:       #143d3b;   /* Primary brand  - headers, nav */
  --c-blue:       #087b79;   /* Accent  - CTAs, links, active states */
  --c-blue-light: #d9f2eb;   /* Accent tint  - badges, hover backgrounds */
  --c-blue-dark:  #05665f;   /* Accent pressed state */
  --c-ink:        #233e3c;   /* Body text */
  --c-muted:      #526b68;   /* Secondary text, placeholders */
  --c-border:     #dce7e3;   /* Default borders */
  --c-surface:    #f4f8f5;   /* Page background */
  --c-white:      #FFFFFF;
  --c-success:    #065F46;
  --c-success-bg: #D1FAE5;
  --c-warn:       #92400E;
  --c-warn-bg:    #FEF3C7;
  --c-danger:     #991B1B;
  --c-danger-bg:  #FEE2E2;
  --c-info:       #0e6e6c;
  --c-info-bg:    #d9f2eb;

  /* Typography */
  --font-sans:    "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  /* Type scale (Major Third  - 1.25) */
  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.25rem;    /* 20px */
  --text-2xl:  1.5rem;     /* 24px */
  --text-3xl:  1.875rem;   /* 30px */
  --text-4xl:  2.25rem;    /* 36px */
  --text-5xl:  3rem;       /* 48px */

  /* Spacing (4px base grid) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Shape */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.12);

  /* Layout */
  --container-max: 1100px;
  --nav-height: 60px;       /* main nav */
  --sub-nav-height: 36px;   /* lower header */
  --total-nav-height: 96px; /* main + sub */

  /* Transition */
  --ease: cubic-bezier(.4,0,.2,1);
  --duration: 150ms;
}

/* Optional professional palettes. Teal remains the default. */
[data-theme="ocean"] { --c-navy:#102a43; --c-blue:#1976a8; --c-blue-light:#d9f0fa; --c-blue-dark:#125a80; --c-ink:#243b53; --c-muted:#627d98; --c-border:#d9e2ec; --c-surface:#f5f9fc; --c-info:#1976a8; --c-info-bg:#d9f0fa; }
[data-theme="indigo"] { --c-navy:#20244a; --c-blue:#5b5bd6; --c-blue-light:#ecebff; --c-blue-dark:#4444ad; --c-ink:#282b45; --c-muted:#686b86; --c-border:#dedff0; --c-surface:#f7f7fc; --c-info:#5b5bd6; --c-info-bg:#ecebff; }
[data-theme="slate"] { --c-navy:#1f2937; --c-blue:#475569; --c-blue-light:#e8edf2; --c-blue-dark:#334155; --c-ink:#273444; --c-muted:#64748b; --c-border:#d8dee7; --c-surface:#f6f8fa; --c-info:#475569; --c-info-bg:#e8edf2; }
[data-theme="rose"] { --c-navy:#4a1d36; --c-blue:#b5476f; --c-blue-light:#fbe8ef; --c-blue-dark:#8e3155; --c-ink:#422333; --c-muted:#806274; --c-border:#ead5df; --c-surface:#fdf8fa; --c-info:#b5476f; --c-info-bg:#fbe8ef; }

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--c-ink);
  background: var(--c-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, video { max-width: 100%; display: block; }
a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── 3. Layout ────────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--sp-6);
}

.main-content {
  flex: 1;
  padding-top: var(--nav-height);
}
/* when sub-nav is present (public home, unauthenticated) */
.has-sub-nav .main-content {
  padding-top: var(--total-nav-height);
}

/* ── 4. Navigation ────────────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--c-navy);
  border-bottom: 1px solid rgba(255,255,255,.08);
  z-index: 100;
  box-shadow: 0 2px 8px rgba(20,61,59,.2);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  height: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-white);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: #b2dfdb; }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-left: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: rgba(255,255,255,.7);
  transition: color var(--duration) var(--ease),
              background var(--duration) var(--ease);
  text-decoration: none;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }
.nav-link--active { color: #fff; background: rgba(255,255,255,.15); }
.nav-link--admin { color: #fbbf24; }
.nav-link--admin:hover { background: rgba(251,191,36,.12); }

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: auto;
}

.nav-user__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: rgba(255,255,255,.9);
}
.site-nav .btn--ghost { color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.25); }
.site-nav .btn--ghost:hover { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.4); }
.site-nav .btn--primary { background: #0ea5a3; border-color: #0ea5a3; }
.site-nav .btn--primary:hover { background: #087b79; border-color: #087b79; }

/* ── 4b. Sub-Navigation (Lower Header) ───────────────────────────── */
.sub-nav {
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0;
  height: var(--sub-nav-height);
  background: linear-gradient(90deg, #0d3533 0%, #0b4a47 60%, #087b79 100%);
  border-bottom: 1px solid rgba(78,210,203,.2);
  z-index: 99;
  box-shadow: 0 2px 10px rgba(8,61,59,.3);
}

.sub-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: var(--sp-4);
}

/* Category pills */
.sub-nav__cats {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sub-nav__cats::-webkit-scrollbar { display: none; }

.sub-nav__cat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.85rem;
  height: var(--sub-nav-height);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
  position: relative;
}
.sub-nav__cat:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
  border-bottom-color: #4dd0c9;
  text-decoration: none;
}
.sub-nav__cat--active {
  color: #fff;
  border-bottom-color: #4dd0c9;
}
.sub-nav__cat-icon {
  font-size: 0.78rem;
  line-height: 1;
  opacity: .85;
}
.sub-nav__cat--all {
  color: #80cbc4;
  font-weight: 700;
}
.sub-nav__cat--all:hover { color: #b2dfdb; }

.sub-nav__divider {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,.18);
  margin: 0 0.3rem;
  flex-shrink: 0;
}

/* Animated ticker (right side) */
.sub-nav__ticker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  margin-left: auto;
  overflow: hidden;
  max-width: 320px;
}
.sub-nav__ticker-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4dd0c9;
  flex-shrink: 0;
  animation: tickerPulse 2s ease infinite;
}
@keyframes tickerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.7); }
}
.sub-nav__ticker-text {
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .3s ease, transform .3s ease;
}

/* Hide ticker on small screens */
@media (max-width: 640px) {
  .sub-nav__ticker { display: none; }
  .sub-nav__cat { padding: 0 0.55rem; font-size: 0.65rem; }
}

/* ── 4c. Footer ────────────────────────────────────────────────────── */
.site-footer {
  /* mirrors the sub-nav gradient — adapts to every theme via CSS vars */
  background: linear-gradient(90deg, var(--c-navy) 0%, var(--c-blue-dark) 60%, var(--c-blue) 100%);
  border-top: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.45);
  font-size: 0.78rem;
  box-shadow: 0 -2px 12px rgba(0,0,0,.18);
}
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  gap: var(--sp-4);
}
.site-footer a {
  color: rgba(255,255,255,.5);
  text-decoration: none;
  transition: color 150ms ease;
}
/* hover adapts to current theme accent */
.site-footer a:hover { color: var(--c-blue-light); text-decoration: none; }
.footer-links {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ── 5. Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border: 1.5px solid transparent;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--c-blue);
  color: var(--c-white);
  border-color: var(--c-blue);
}
.btn--primary:hover {
  background: var(--c-blue-dark);
  border-color: var(--c-blue-dark);
  box-shadow: 0 2px 8px rgba(8,123,121,.35);
}

.btn--ghost {
  background: transparent;
  color: var(--c-ink);
  border-color: var(--c-border);
}
.btn--ghost:hover {
  background: var(--c-surface);
  border-color: var(--c-muted);
}

.btn--danger {
  background: var(--c-danger);
  color: var(--c-white);
  border-color: var(--c-danger);
}

.btn--sm { padding: var(--sp-2) var(--sp-3); font-size: var(--text-xs); }
.btn--lg { padding: var(--sp-4) var(--sp-8); font-size: var(--text-base); }
.btn--full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── 6. Forms ─────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-4); }

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-ink);
}

.form-input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--c-ink);
  background: var(--c-white);
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  outline: none;
}
.form-input:focus {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 3px rgba(8,123,121,.15);
}
.form-input::placeholder { color: var(--c-muted); }

.form-group--error .form-input { border-color: var(--c-danger); }
.form-group--error .form-input:focus { box-shadow: 0 0 0 3px rgba(153,27,27,.15); }

.form-error { font-size: var(--text-xs); color: var(--c-danger); margin-top: var(--sp-1); }

.form-row { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.form-row--between { justify-content: space-between; }

.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--c-muted);
  cursor: pointer;
}
.form-link { font-size: var(--text-sm); color: var(--c-blue); }

/* ── 7. Flash Messages ────────────────────────────────────── */
.flash-stack {
  position: fixed;
  top: calc(var(--nav-height) + var(--sp-4));
  right: var(--sp-6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 400px;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  animation: slideIn var(--duration) var(--ease);
}

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

.flash--success { background: var(--c-success-bg); color: var(--c-success); border: 1px solid #A7F3D0; }
.flash--danger  { background: var(--c-danger-bg);  color: var(--c-danger);  border: 1px solid #FECACA; }
.flash--warning { background: var(--c-warn-bg);    color: var(--c-warn);    border: 1px solid #FDE68A; }
.flash--info    { background: var(--c-info-bg);    color: var(--c-info);    border: 1px solid #80cbc4; }

.flash__msg { flex: 1; }
.flash__close {
  background: none;
  border: none;
  font-size: var(--text-lg);
  line-height: 1;
  opacity: .6;
  padding: 0;
  color: inherit;
  flex-shrink: 0;
}
.flash__close:hover { opacity: 1; }

/* ── 8. Auth Pages ────────────────────────────────────────── */
.page--auth .main-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
  padding: var(--sp-8) var(--sp-6);
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-10) var(--sp-8);
  box-shadow: var(--shadow-md);
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--c-navy);
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-1);
}

.auth-card__sub {
  font-size: var(--text-sm);
  color: var(--c-muted);
  margin-bottom: var(--sp-8);
}

.auth-card__switch {
  margin-top: var(--sp-6);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--c-muted);
}

/* ── 8b. Social Login Buttons ─────────────────────────────── */
.social-login {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1.5px solid var(--c-border);
}

.btn-social__icon {
  flex-shrink: 0;
}

.btn-social--google {
  background: var(--c-white);
  color: var(--c-ink);
}
.btn-social--google:hover {
  background: #f8f9fa;
  border-color: #dadce0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.btn-social--facebook {
  background: #1877F2;
  color: #fff;
  border-color: #1877F2;
}
.btn-social--facebook:hover {
  background: #166fe5;
  border-color: #166fe5;
  box-shadow: 0 1px 3px rgba(24,119,242,0.3);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  color: var(--c-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ── 9. Home / Hero ───────────────────────────────────────── */
.page--home .main-content { padding-top: 0; }

.hero {
  padding: calc(var(--nav-height) + var(--sp-16)) var(--sp-6) var(--sp-16);
  background: linear-gradient(160deg, var(--c-navy) 0%, #0e5250 60%, #087b79 100%);
  color: var(--c-white);
}

.hero__inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-16);
  align-items: center;
}

.hero__eyebrow {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #80cbc4;
  margin-bottom: var(--sp-4);
}

.hero__heading {
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: var(--sp-5);
}

.hero__sub {
  font-size: var(--text-lg);
  color: #b2dfdb;
  max-width: 44ch;
  margin-bottom: var(--sp-8);
  line-height: 1.65;
}

.hero__cta { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.hero .btn--ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.hero .btn--ghost:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.5); }

.hero__stats {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.stat-card {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  text-align: center;
  backdrop-filter: blur(8px);
  min-width: 140px;
}

.stat-card__num {
  display: block;
  font-size: var(--text-4xl);
  font-weight: 900;
  color: var(--c-white);
  letter-spacing: -0.03em;
}

.stat-card__label {
  display: block;
  font-size: var(--text-xs);
  color: #80cbc4;
  font-weight: 600;
  margin-top: var(--sp-1);
}

/* ── 10. Feature Grid ─────────────────────────────────────── */
.features {
  padding: var(--sp-20) var(--sp-6);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-6);
}

.feature-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8) var(--sp-6);
  transition: box-shadow var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.feature-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c-blue);
}

.feature-card__icon {
  font-size: 2rem;
  margin-bottom: var(--sp-4);
}

.feature-card h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-navy);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.02em;
}

.feature-card p {
  font-size: var(--text-sm);
  color: var(--c-muted);
  line-height: 1.65;
}

/* ── 11. Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  text-decoration: none;
}
.badge--warn { background: var(--c-warn-bg); color: var(--c-warn); }
.badge--success { background: var(--c-success-bg); color: var(--c-success); }

/* ── 12. Error Pages ──────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100vh - var(--nav-height) - 80px);
  padding: var(--sp-16) var(--sp-6);
}

.error-page__code {
  font-size: clamp(5rem, 15vw, 9rem);
  font-weight: 900;
  color: var(--c-blue-light);
  letter-spacing: -0.05em;
  line-height: 1;
  display: block;
}

.error-page__heading {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--c-navy);
  margin: var(--sp-4) 0 var(--sp-3);
  letter-spacing: -0.03em;
}

.error-page__sub {
  font-size: var(--text-base);
  color: var(--c-muted);
  max-width: 44ch;
  margin-bottom: var(--sp-8);
}

/* ── 13. Stub Pages ───────────────────────────────────────── */
.page-stub {
  padding: var(--sp-20) var(--sp-6);
}
.page-stub h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--c-navy);
  margin-bottom: var(--sp-3);
}
.stub-note {
  color: var(--c-muted);
  font-size: var(--text-base);
  background: var(--c-blue-light);
  border: 1px solid #80cbc4;
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  display: inline-block;
}

/* ── 14. Footer ───────────────────────────────────────────── */
.site-footer {
  background: var(--c-white);
  border-top: 1px solid var(--c-border);
  padding: var(--sp-6) var(--sp-4);
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.site-footer span { font-size: var(--text-sm); color: var(--c-muted); }

.footer-links {
  display: flex;
  gap: var(--sp-5);
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--c-muted);
  transition: color var(--duration) var(--ease);
}
.footer-links a:hover { color: var(--c-ink); text-decoration: none; }

/* ── 15. Focus & Accessibility ────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ── 16. Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__stats { flex-direction: row; flex-wrap: wrap; }
  .stat-card { flex: 1; min-width: 100px; }
  .nav-user__name { display: none; }
  .auth-card { padding: var(--sp-8) var(--sp-6); }
}

@media (max-width: 480px) {
  .hero { padding-top: calc(var(--nav-height) + var(--sp-10)); }
  .hero__cta { flex-direction: column; }
  .btn--lg { width: 100%; }
}

/* ============================================================
   Session 2  - Admin & Question Bank Extensions
   ============================================================ */

/* ── Admin Page Shell ─────────────────────────────────────── */
.admin-page { padding: var(--sp-8) var(--sp-6); }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--c-navy);
  letter-spacing: -0.03em;
}
.page-sub { font-size: var(--text-sm); color: var(--c-muted); margin-top: var(--sp-1); }
.page-header__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.breadcrumb { font-size: var(--text-sm); color: var(--c-muted); margin-bottom: var(--sp-1); }
.breadcrumb a { color: var(--c-blue); }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
}
.card--success { border-color: #A7F3D0; background: var(--c-success-bg); }
.card--warn    { border-color: #FDE68A; background: var(--c-warn-bg); }
.card--danger  { border-color: #FECACA; background: var(--c-danger-bg); }
.section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: var(--sp-4);
}

/* ── Stat Row (dashboard) ─────────────────────────────────── */
.stat-row {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-8);
}
.stat-tile {
  flex: 1;
  min-width: 130px;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  position: relative;
}
.stat-tile--success { border-color: #A7F3D0; }
.stat-tile--warn    { border-color: #FDE68A; }
.stat-tile--danger  { border-color: #FECACA; }
.stat-tile__num {
  font-size: var(--text-3xl);
  font-weight: 900;
  color: var(--c-navy);
  letter-spacing: -0.04em;
}
.stat-tile__label { font-size: var(--text-xs); color: var(--c-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile__cta {
  font-size: var(--text-xs);
  color: var(--c-blue);
  font-weight: 700;
  margin-top: var(--sp-1);
}

/* ── Quick Links ──────────────────────────────────────────── */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-4);
}
.quick-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: box-shadow var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.quick-link-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c-blue);
  text-decoration: none;
}
.quick-link-card__icon { font-size: 2rem; }
.quick-link-card__count { font-size: 1.35rem; font-weight: 900; color: var(--c-navy); letter-spacing: -0.03em; line-height: 1; margin-top: 0.15rem; }
.quick-link-card__label { font-size: var(--text-sm); font-weight: 600; color: var(--c-ink); }

/* Public policy page */
.policy-page{max-width:1120px;padding:2rem 0 4rem}.policy-hero{padding:2rem 0 1.25rem}.policy-eyebrow{font-size:.7rem;font-weight:800;letter-spacing:.14em;color:var(--c-blue)}.policy-hero h1{max-width:760px;font-size:clamp(2rem,4vw,3rem);line-height:1.1;letter-spacing:-.04em;margin:.6rem 0 1rem}.policy-hero p{max-width:760px;color:var(--c-muted);font-size:1rem}.policy-meta{display:flex;flex-wrap:wrap;gap:.6rem 1.5rem;color:var(--c-muted);font-size:.78rem;margin-top:1rem}.policy-notice{border-left:5px solid var(--c-blue);background:var(--c-blue-light);border-radius:10px;padding:1rem 1.2rem;margin:1rem 0 1.5rem;line-height:1.6}.policy-layout{display:grid;grid-template-columns:220px minmax(0,1fr);gap:1.4rem;align-items:start}.policy-toc{position:sticky;top:80px;display:grid;gap:.2rem;background:var(--c-white);border:1px solid var(--c-border);border-radius:12px;padding:.7rem}.policy-toc a{padding:.55rem .65rem;border-radius:7px;font-size:.8rem;text-decoration:none}.policy-toc a:hover{background:var(--c-blue-light)}.policy-card{background:var(--c-white);border:1px solid var(--c-border);border-radius:14px;padding:1.35rem 1.5rem;margin-bottom:1rem}.policy-card h2{font-size:1.25rem;margin:0 0 .65rem}.policy-card p,.policy-card li{line-height:1.65;color:var(--c-ink)}.policy-card--warning{border-left:5px solid var(--c-warn);background:var(--c-warn-bg)}.auth-card__legal{font-size:.72rem;color:var(--c-muted);line-height:1.5;margin-top:1rem}@media(max-width:760px){.policy-layout{grid-template-columns:1fr}.policy-toc{position:static;grid-template-columns:repeat(2,1fr)}.policy-page{padding-inline:1rem}.policy-card{padding:1.1rem}}

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
  align-items: center;
}
.filter-bar__search { flex: 2; min-width: 180px; }
.filter-bar__select { flex: 1; min-width: 130px; }

/* ── Data Table ───────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-5);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead { background: var(--c-navy); }
.data-table thead th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,.8);
  white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--c-border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--c-surface); }
.data-table tbody td { padding: var(--sp-3) var(--sp-4); vertical-align: middle; }
.td--mono  { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--c-muted); }
.td--date  { font-size: var(--text-xs); color: var(--c-muted); white-space: nowrap; }
.td--subject { display: block; font-weight: 600; color: var(--c-ink); }
.td--topic   { display: block; font-size: var(--text-xs); color: var(--c-muted); }
.td--actions { display: flex; gap: var(--sp-1); white-space: nowrap; }

/* ── Badges ───────────────────────────────────────────────── */
.badge-tag {
  display: inline-flex;
  padding: 2px var(--sp-2);
  background: var(--c-blue-light);
  color: var(--c-blue);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.status-badge {
  display: inline-flex;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
}
.status-badge--approved { background: var(--c-success-bg); color: var(--c-success); }
.status-badge--pending  { background: var(--c-warn-bg);    color: var(--c-warn);    }
.status-badge--draft    { background: var(--c-surface);    color: var(--c-muted);   border: 1px solid var(--c-border); }
.status-badge--rejected { background: var(--c-danger-bg);  color: var(--c-danger);  }
.status-badge--archived { background: var(--c-surface);    color: var(--c-muted);   }

.diff-badge {
  display: inline-flex;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}
.diff-badge--very_easy  { background: #D1FAE5; color: #065F46; }
.diff-badge--easy       { background: #D1FAE5; color: #065F46; }
.diff-badge--medium     { background: #FEF3C7; color: #92400E; }
.diff-badge--hard       { background: #FEE2E2; color: #991B1B; }
.diff-badge--very_hard  { background: #991B1B; color: #fff; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
}
.pagination__btn {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--c-blue);
  background: var(--c-white);
  transition: background var(--duration) var(--ease);
}
.pagination__btn:hover { background: var(--c-blue-light); text-decoration: none; }
.pagination__info { font-size: var(--text-sm); color: var(--c-muted); }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
  color: var(--c-muted);
}
.empty-state p { margin-bottom: var(--sp-5); }

/* ── Detail Grid (question_detail) ───────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--sp-6);
  align-items: flex-start;
}
.detail-sidebar { position: sticky; top: calc(var(--nav-height) + var(--sp-4)); }

.meta-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.meta-source { font-size: var(--text-xs); color: var(--c-muted); font-style: italic; }

/* KaTeX rendered content */
.katex-content { line-height: 1.8; }
.katex-content p { margin-bottom: var(--sp-3); }
.katex-content img { max-width: 100%; height: auto; border-radius: 4px; margin: 0.5rem 0; }
.question-body img { max-width: 100%; height: auto; border-radius: 4px; margin: 0.5rem 0; }

/* Question options */
.options-list { margin-top: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.option {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-white);
}
.option--correct {
  border-color: #A7F3D0;
  background: var(--c-success-bg);
}
.option__label { font-weight: 700; color: var(--c-muted); min-width: 1.5rem; }
.option__text  { flex: 1; }
.option__tick  { color: var(--c-success); font-weight: 700; }
.answer-display {
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.answer-display code {
  font-family: var(--font-mono);
  background: var(--c-border);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-sm);
}

/* Question images */
.question-images { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-4); }
.question-image { max-height: 200px; border-radius: var(--radius-md); border: 1px solid var(--c-border); }

/* Detail dl */
.detail-dl { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--text-sm); }
.detail-dl dt { font-weight: 600; color: var(--c-muted); white-space: nowrap; }
.detail-dl dd { color: var(--c-ink); }

/* Tags */
.tag-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tag {
  background: var(--c-blue-light);
  color: var(--c-blue);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Feedback items */
.feedback-item {
  padding: var(--sp-3);
  border-left: 3px solid var(--c-warn);
  margin-bottom: var(--sp-3);
  font-size: var(--text-sm);
}
.feedback-type { font-weight: 700; color: var(--c-warn); display: block; margin-bottom: var(--sp-1); }
.feedback-date { font-size: var(--text-xs); color: var(--c-muted); }

/* ── Form Grid (question_form) ────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--sp-6);
  align-items: flex-start;
}
.form-main  {}
.form-sidebar { position: sticky; top: calc(var(--nav-height) + var(--sp-4)); }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.field-hint { font-size: var(--text-xs); color: var(--c-muted); margin-bottom: var(--sp-2); }

/* Live preview box */
.preview-box {
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  min-height: 80px;
  position: relative;
  margin-top: var(--sp-2);
  background: var(--c-surface);
}
.preview-box__label {
  position: absolute;
  top: -10px;
  left: var(--sp-3);
  background: var(--c-surface);
  font-size: var(--text-xs);
  color: var(--c-muted);
  padding: 0 var(--sp-1);
  font-weight: 600;
}

/* Options builder */
.option-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.option-row__id { font-weight: 700; color: var(--c-muted); min-width: 1.2rem; }
.option-row__text { flex: 1; }
.option-row__correct { font-size: var(--text-sm); cursor: pointer; display: flex; align-items: center; gap: 4px; color: var(--c-success); }
.option-row__del { flex-shrink: 0; }

/* form-check large */
.form-check--lg {
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--c-ink);
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* Image items */
.image-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-2);
}
.image-item__preview { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); }

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
}
.modal__box {
  background: var(--c-white);
  border-radius: var(--radius-xl);
  padding: var(--sp-8);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}
.modal__box h2 { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--sp-5); }

/* ── Import Result ────────────────────────────────────────── */
.import-result ul { margin: var(--sp-3) 0; padding-left: var(--sp-5); font-size: var(--text-sm); }
.import-result li { margin-bottom: var(--sp-1); }
.error-list { margin-top: var(--sp-4); }
.error-row {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-danger-bg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-1);
  color: var(--c-danger);
}

/* ── Utility text colours ─────────────────────────────────── */
.text--success { color: var(--c-success); }
.text--danger  { color: var(--c-danger); }
.text--warn    { color: var(--c-warn); }
.error-text    { color: var(--c-danger); font-size: var(--text-sm); }

/* ── Responsive admin ─────────────────────────────────────── */
@media (max-width: 900px) {
  .detail-grid,
  .form-grid { grid-template-columns: 1fr; }
  .detail-sidebar,
  .form-sidebar { position: static; }
  .form-row-4,
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .form-row-4,
  .form-row-3 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar__search,
  .filter-bar__select { width: 100%; }
}

/* ============================================================
   Session 3  - Exam Engine & Results
   ============================================================ */

/* ── Exam Page ────────────────────────────────────────────── */
.exam-page { padding: var(--sp-8) var(--sp-6); }

.paper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}
.paper-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: box-shadow var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.paper-card:hover { box-shadow: var(--shadow-md); border-color: var(--c-blue); }
.paper-card__meta { display: flex; align-items: center; gap: var(--sp-2); justify-content: space-between; }
.paper-card__title { font-size: var(--text-lg); font-weight: 700; color: var(--c-navy); letter-spacing: -0.02em; }
.paper-card__stats { display: flex; gap: var(--sp-4); font-size: var(--text-sm); color: var(--c-muted); }
.paper-card__closes { font-size: var(--text-xs); color: var(--c-danger); font-weight: 600; }

.dashboard-section { margin-bottom: var(--sp-10); }
.section-heading { font-size: var(--text-xl); font-weight: 700; color: var(--c-navy); margin-bottom: var(--sp-5); letter-spacing: -0.02em; }

/* Info grid (paper_info) */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.info-item { display: flex; flex-direction: column; gap: var(--sp-1); }
.info-label { font-size: var(--text-xs); font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.info-val { font-size: var(--text-base); font-weight: 600; color: var(--c-ink); }

/* ── Live Session ─────────────────────────────────────────── */
.session-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--c-surface);
}
.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--sp-5);
  background: var(--c-navy);
  color: var(--c-white);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.session-brand { font-weight: 800; font-size: var(--text-base); letter-spacing: -0.02em; opacity: .9; }
.session-title { font-size: var(--text-sm); color: rgba(255,255,255,.7); margin-left: var(--sp-4); }
.session-header__left { display: flex; align-items: center; gap: var(--sp-2); }
.session-header__center { display: flex; align-items: center; gap: var(--sp-4); }
.session-candidate { font-size: var(--text-xs); color: rgba(255,255,255,.6); }
.session-candidate__name { font-weight: 600; color: rgba(255,255,255,.85); }

/* Timer */
.timer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-4);
}
.timer__icon { font-size: var(--text-base); }
.timer__display { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 700; letter-spacing: 0.05em; color: var(--c-white); min-width: 5.5ch; }
.timer--warn .timer__display { color: #FDE68A; }
.timer--expired .timer__display { color: #FCA5A5; }

/* Session layout */
.session-layout { display: flex; flex: 1; overflow: hidden; }
.session-main { flex: 1; overflow-y: auto; padding: var(--sp-6); }
.session-sidebar { width: 280px; background: var(--c-white); border-left: 1px solid var(--c-border); overflow-y: auto; flex-shrink: 0; }

.session-welcome { text-align: center; padding: var(--sp-16) var(--sp-8); color: var(--c-muted); }
.session-welcome h2 { font-size: var(--text-2xl); color: var(--c-navy); margin-bottom: var(--sp-3); }

/* Question rendering */
.question-meta { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.question-num { font-size: var(--text-sm); color: var(--c-muted); font-weight: 600; }
.question-body { font-size: var(--text-lg); line-height: 1.75; margin-bottom: var(--sp-6); color: var(--c-ink); }

/* Options in session */
.option-label {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.option-label:hover { border-color: var(--c-blue); background: var(--c-blue-light); }
.option-label--selected { border-color: var(--c-blue); background: var(--c-blue-light); }
.option-label input { flex-shrink: 0; margin-top: 3px; accent-color: var(--c-blue); }

.question-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-5); }
.btn--warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: #FDE68A; }
.btn--warn:hover { background: #FDE68A; }

.numerical-input { max-width: 320px; }

/* Palette */
.palette-wrap { padding: var(--sp-4); }
.palette-legend { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--text-xs); color: var(--c-muted); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.pal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pal-dot--answered { background: var(--c-success); }
.pal-dot--not-answered { background: #EF4444; }
.pal-dot--review   { background: #8B5CF6; }
.pal-dot--answered-review { background: var(--c-success); border: 2px solid #8B5CF6; }
.pal-dot--unattempted { background: var(--c-border); border: 1px solid var(--c-muted); }

.palette-section { margin-bottom: var(--sp-4); }
.palette-section__name { font-size: var(--text-xs); font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-2); }
.palette-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-1); }

.pal-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-white);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
  position: relative;
}
.pal-btn:hover          { border-color: var(--c-blue); background: var(--c-blue-light); }
.pal-btn:focus-visible  { outline: 2px solid var(--c-blue); outline-offset: 2px; }
/* 5-state palette */
.pal-btn--not-visited   { background: var(--c-white); border-color: var(--c-border); color: var(--c-muted); }
.pal-btn--not-answered  { background: #FEE2E2; border-color: #FCA5A5; color: #DC2626; }
.pal-btn--answered      { background: var(--c-success-bg); border-color: #A7F3D0; color: var(--c-success); }
.pal-btn--review        { background: #EDE9FE; border-color: #C4B5FD; color: #7C3AED; }
.pal-btn--answered-review { background: var(--c-success-bg); border-color: #A7F3D0; color: var(--c-success); box-shadow: inset 0 0 0 2px #8B5CF6; }
.pal-btn--active        { box-shadow: 0 0 0 2px var(--c-blue); border-color: var(--c-blue); }
.pal-btn--answered-review.pal-btn--active { box-shadow: 0 0 0 2px var(--c-blue), inset 0 0 0 2px #8B5CF6; }

.palette-summary { font-size: var(--text-xs); color: var(--c-muted); text-align: center; padding: var(--sp-3) 0; border-top: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); margin: var(--sp-3) 0; }

/* Question navigation buttons */
.question-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
}

/* Subject navigation bar */
.session-subject-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-5);
  background: var(--c-navy);
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.subject-nav-btn {
  padding: var(--sp-1) var(--sp-4);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-md);
  background: transparent;
  color: rgba(255,255,255,.7);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.subject-nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.subject-nav-btn--active { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }

/* Option focus indicators for accessibility */
.option-label:focus-within { outline: 2px solid var(--c-blue); outline-offset: 2px; }

/* Network status banner */
.network-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; background: #DC2626; color: #fff; text-align: center; padding: 8px 16px; font-size: 13px; font-weight: 600; display: none; }

/* ── Tablet Responsive for Session ────────────────────────── */
@media (max-width: 1024px) {
  .session-sidebar { width: 220px; }
  .palette-grid { grid-template-columns: repeat(5, 1fr); }
  .session-main { padding: var(--sp-4); }
  .session-header { padding: 0 var(--sp-3); height: 48px; }
  .session-brand { font-size: var(--text-sm); }
  .session-title { font-size: var(--text-xs); }
  .timer__display { font-size: var(--text-lg); }
}
@media (max-width: 768px) {
  .session-layout { flex-direction: column; }
  .session-sidebar { width: 100%; max-height: 200px; border-left: none; border-top: 1px solid var(--c-border); }
  .session-main { overflow-y: auto; }
  .palette-grid { grid-template-columns: repeat(10, 1fr); }
  .session-subject-bar { flex-wrap: wrap; }
  .session-header__left { min-width: 0; }
  .session-title { display: none; }
}

/* ── Results Page ─────────────────────────────────────────── */
.score-hero {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  background: var(--c-navy);
  color: var(--c-white);
  border-radius: var(--radius-xl);
  padding: var(--sp-8) var(--sp-10);
  margin-bottom: var(--sp-8);
}
.score-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-xl);
  padding: var(--sp-6) var(--sp-8);
  min-width: 140px;
  text-align: center;
}
.score-circle__num  { font-size: 3rem; font-weight: 900; letter-spacing: -0.04em; line-height: 1; }
.score-circle__denom { font-size: var(--text-sm); color: rgba(255,255,255,.6); margin-top: var(--sp-1); }
.score-meta { display: flex; gap: var(--sp-6); flex-wrap: wrap; }
.score-stat { display: flex; flex-direction: column; gap: var(--sp-1); }
.score-stat__num   { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.03em; }
.score-stat__label { font-size: var(--text-xs); color: rgba(255,255,255,.6); font-weight: 600; }

.results-grid { display: grid; grid-template-columns: 1fr 280px; gap: var(--sp-6); margin-bottom: var(--sp-6); }

/* Subject accuracy bars */
.subject-bars { display: flex; flex-direction: column; gap: var(--sp-4); }
.subject-bar { display: flex; align-items: center; gap: var(--sp-3); }
.subject-bar__label { width: 100px; font-size: var(--text-sm); font-weight: 600; color: var(--c-ink); flex-shrink: 0; }
.subject-bar__track { flex: 1; height: 8px; background: var(--c-border); border-radius: var(--radius-full); overflow: hidden; }
.subject-bar__fill  { height: 100%; background: var(--c-blue); border-radius: var(--radius-full); transition: width .5s var(--ease); }
.subject-bar__pct   { width: 36px; text-align: right; font-size: var(--text-sm); font-weight: 600; color: var(--c-ink); }

/* Leaderboard */
.leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); }
.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--c-surface);
}
.leaderboard-item--you { background: var(--c-blue-light); font-weight: 700; }
.leaderboard-item__name { color: var(--c-ink); }
.leaderboard-item__score { font-weight: 700; color: var(--c-navy); }

.results-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; padding-top: var(--sp-4); border-top: 1px solid var(--c-border); }

/* ── Review Answers ───────────────────────────────────────── */
.review-item {
  padding: var(--sp-5);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
  border-left: 4px solid var(--c-border);
}
.review-item--correct { border-left-color: var(--c-success); background: var(--c-success-bg); }
.review-item--wrong   { border-left-color: var(--c-danger);  background: var(--c-danger-bg); }
.review-item--skip    { border-left-color: var(--c-border);  background: var(--c-surface); }
.review-item__header  { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.review-item__num     { font-weight: 700; color: var(--c-muted); }
.review-item__content { font-size: var(--text-base); }
.review-item__marks   { margin-left: auto; font-weight: 700; font-size: var(--text-sm); }
.option--wrong        { border-color: #FECACA !important; background: var(--c-danger-bg) !important; }

.explanation-box {
  margin-top: var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.explanation-box summary {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-blue);
  background: var(--c-blue-light);
  user-select: none;
}
.explanation-box > .katex-content { padding: var(--sp-4); font-size: var(--text-sm); line-height: 1.7; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .results-grid { grid-template-columns: 1fr; }
  .score-hero { flex-direction: column; gap: var(--sp-5); text-align: center; }
  .info-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .session-layout { flex-direction: column-reverse; }
  .session-sidebar { width: 100%; max-height: 220px; border-left: none; border-top: 1px solid var(--c-border); }
  .session-title { display: none; }
}

/* ============================================================
   Session 4  - Paper Management & Bug Fixes
   ============================================================ */

/* Paper section card in paper_detail */
.paper-section-card { margin-bottom: var(--sp-5); }
.paper-section-header { display: flex; justify-content: space-between; align-items: flex-start; }
.paper-section__name { font-size: var(--text-lg); font-weight: 700; color: var(--c-navy); }
.paper-section__meta { font-size: var(--text-sm); color: var(--c-muted); }

/* Add section form row */
.add-section-form .form-row-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-3); }
.add-section-form .form-row-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--sp-3); }

/* form-row-2 utility */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* Gen section rows */
.gen-section-row { padding: var(--sp-4); }

@media (max-width: 768px) {
  .add-section-form .form-row-3 { grid-template-columns: 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   Session 5  - Analytics & Dashboard
   ============================================================ */

.analytics-page { padding: var(--sp-8) var(--sp-6); }

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--sp-6);
  align-items: flex-start;
}

/* Heatmap */
.heatmap-subject { margin-bottom: var(--sp-4); }
.heatmap-subject__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-1);
}
.heatmap-subject__name { font-size: var(--text-sm); font-weight: 600; color: var(--c-ink); }
.heatmap-subject__acc  { font-size: var(--text-xs); color: var(--c-muted); }
.heatmap-bar-wrap {
  height: 10px;
  background: var(--c-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--sp-1);
}
.heatmap-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .5s var(--ease);
  min-width: 4px;
}
.heatmap-detail { font-size: var(--text-xs); color: var(--c-muted); }

/* Recent attempts sidebar */
.recent-attempt {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--c-border);
}
.recent-attempt:last-of-type { border-bottom: none; }
.recent-attempt__title { flex: 1; font-size: var(--text-sm); font-weight: 600; color: var(--c-ink); }
.recent-attempt__score { font-size: var(--text-sm); color: var(--c-muted); white-space: nowrap; }

/* Leaderboard highlight */
tr.leaderboard-item--you td { background: var(--c-blue-light); font-weight: 700; }

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

/* ============================================================
   Session 6  - AI Chat Interface
   ============================================================ */

.page--chat .main-content { height: 100vh; padding-top: 0; overflow: hidden; }

.chat-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.chat-sidebar {
  width: 260px;
  background: var(--c-navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-4);
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.chat-sidebar__title { font-weight: 700; color: var(--c-white); font-size: var(--text-sm); }
.chat-session-list { flex: 1; overflow-y: auto; padding: var(--sp-2); }
.chat-session-item {
  display: block;
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  margin-bottom: var(--sp-1);
  transition: background var(--duration) var(--ease);
}
.chat-session-item:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.chat-session-item--active { background: rgba(255,255,255,.15); }
.chat-session-item__preview {
  display: block;
  font-size: var(--text-xs);
  color: rgba(255,255,255,.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-session-item__date { font-size: 10px; color: rgba(255,255,255,.4); }
.chat-sidebar__empty { font-size: var(--text-xs); color: rgba(255,255,255,.4); padding: var(--sp-4); }
.chat-sidebar__footer { padding: var(--sp-3); border-top: 1px solid rgba(255,255,255,.1); }

/* ── Main chat area ────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-surface);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Welcome state */
.chat-welcome {
  text-align: center;
  padding: var(--sp-12) var(--sp-8);
  max-width: 560px;
  margin: auto;
}
.chat-welcome__icon { font-size: 3rem; margin-bottom: var(--sp-4); }
.chat-welcome h2 { font-size: var(--text-xl); font-weight: 700; color: var(--c-navy); margin-bottom: var(--sp-2); }
.chat-welcome p { color: var(--c-muted); margin-bottom: var(--sp-6); }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
.chat-suggestion {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-full);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.chat-suggestion:hover { border-color: var(--c-blue); background: var(--c-blue-light); }

/* Messages */
.chat-msg { display: flex; max-width: 78%; }
.chat-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg--assistant { align-self: flex-start; }
.chat-msg__bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg--user .chat-msg__bubble {
  background: var(--c-blue);
  color: var(--c-white);
  border-bottom-right-radius: var(--radius-sm);
}
.chat-msg--assistant .chat-msg__bubble {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  color: var(--c-ink);
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* Typing indicator */
.typing-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--c-muted);
  margin: 0 2px;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input bar */
.chat-input-bar {
  padding: var(--sp-4) var(--sp-6);
  background: var(--c-white);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.chat-input-wrap {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color var(--duration) var(--ease);
}
.chat-input-wrap:focus-within { border-color: var(--c-blue); }
.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--text-sm);
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 160px;
  font-family: var(--font-sans);
  line-height: 1.5;
}
.chat-input-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}
.chat-sonnet-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  color: var(--c-muted);
  cursor: pointer;
  white-space: nowrap;
}

/* AI feedback box in review */
.ai-feedback-box {
  margin-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
  padding-top: var(--sp-3);
}
.ai-feedback-box__header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.ai-feedback-box__icon { font-size: var(--text-lg); }
.ai-feedback-box__label { font-weight: 600; font-size: var(--text-sm); color: var(--c-blue); }
.ai-feedback-box__content {
  background: var(--c-blue-light);
  border: 1px solid #80cbc4;
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  font-size: var(--text-sm);
  line-height: 1.7;
}
.ai-loading {
  font-size: var(--text-xs);
  color: var(--c-muted);
  font-style: italic;
  margin-left: var(--sp-2);
}
.ai-explain-btn { margin-top: var(--sp-2); }

@media (max-width: 768px) {
  .chat-sidebar { display: none; }
  .chat-msg { max-width: 92%; }
}

/* ── LAN access notice (replaces Google OAuth button on private-IP requests) */
.lan-oauth-note {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--c-ink);
  background: var(--c-blue-light);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  line-height: 1.4;
}
