/* ===========================================================
   ElGhazawy Question Bank — Design System
   Brand: black base, electric blue primary, acid green for streak
   =========================================================== */

:root {
  /* Brand palette — dark (default) */
  --bg: #060608;
  --bg-elev-1: #0E0E12;
  --bg-elev-2: #16161B;
  --bg-elev-3: #1E1E25;
  --line: #25252E;
  --line-strong: #353541;
  --text: #FAFAFB;
  --text-dim: #B8B8C2;
  --text-muted: #6E6E7A;
  --text-faint: #45454F;

  --brand: #1500FF;          /* electric royal blue, matches logo */
  --brand-bright: #3D2BFF;
  --brand-soft: rgba(21, 0, 255, 0.12);
  --brand-soft-2: rgba(21, 0, 255, 0.22);
  --brand-ink: #FFFFFF;

  --accent: #C7FF3D;         /* acid green for streak/reward */
  --accent-deep: #9FE600;
  --accent-soft: rgba(199, 255, 61, 0.14);
  --accent-text: var(--accent); /* readable accent for text (overridden in light) */

  --easy: #5FE39A;
  --mod: #5BA7FF;
  --hard: #FF5470;
  --warn: #FFB547;
  --danger: #FF4D6D;

  --tag-points: #c9c2ff;
  --nav-bg: rgba(6, 6, 8, 0.78);
  --overlay-bg: rgba(6, 6, 8, 0.9);
  --overlay-bg-2: rgba(6, 6, 8, 0.92);
  --backdrop: rgba(2, 2, 5, 0.7);
  --body-glow-1: rgba(21, 0, 255, 0.18);
  --body-glow-2: rgba(199, 255, 61, 0.06);
  --theme-color: #060608;

  /* Type */
  --font-display: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radius / shadow */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-1: 0 4px 18px rgba(0,0,0,.35);
  --shadow-brand: 0 8px 28px rgba(21, 0, 255, 0.35);
  --shadow-accent: 0 8px 28px rgba(199, 255, 61, 0.18);

  /* Layout */
  --nav-h: 64px;
  --container: 1180px;
}

[data-theme="light"] {
  /* Surfaces: slightly cooler grey page vs pure white cards for clearer elevation */
  --bg: #EBEDF4;
  --bg-elev-1: #FFFFFF;
  --bg-elev-2: #E4E7F0;
  --bg-elev-3: #D6DBE8;
  --line: #B8BFCF;
  --line-strong: #8E97AB;

  /* Text: darkened for WCAG AA on light surfaces (~7:1 muted, ~4.8:1 faint) */
  --text: #0A0B10;
  --text-dim: #2C2E3A;
  --text-muted: #4A4E5F;
  --text-faint: #656B7C;

  --brand-soft: rgba(21, 0, 255, 0.10);
  --brand-soft-2: rgba(21, 0, 255, 0.18);
  --brand-ink: #FFFFFF;
  --brand-bright: #2A1AD9; /* slightly deeper for link/text on white */

  --accent-soft: rgba(63, 98, 0, 0.14);
  --accent-text: #3F6200; /* deep green — legible on light backgrounds */

  /* Status colors — dark-mode neons fail on white; use readable ink */
  --easy: #0F7A42;
  --mod: #1860C0;
  --hard: #C0183A;
  --warn: #9A5A00;
  --danger: #C0183A;

  --tag-points: #1500FF;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --overlay-bg: rgba(255, 255, 255, 0.94);
  --overlay-bg-2: rgba(255, 255, 255, 0.97);
  --backdrop: rgba(15, 16, 24, 0.5);
  --body-glow-1: rgba(21, 0, 255, 0.07);
  --body-glow-2: rgba(63, 98, 0, 0.06);
  --theme-color: #EBEDF4;

  --shadow-1: 0 4px 18px rgba(15, 16, 24, 0.10);
  --shadow-brand: 0 8px 28px rgba(21, 0, 255, 0.20);
  --shadow-accent: 0 8px 28px rgba(63, 98, 0, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

/* Light theme: soft fills that still hardcode dark-mode neon rgba() */
[data-theme="light"] .tag.easy,
[data-theme="light"] .tag-success { background: rgba(15, 122, 66, 0.12); }
[data-theme="light"] .tag.moderate { background: rgba(24, 96, 192, 0.12); }
[data-theme="light"] .tag.hard { background: rgba(192, 24, 58, 0.12); }
[data-theme="light"] .tag-warn,
[data-theme="light"] .fc-chip.learn { background: rgba(154, 90, 0, 0.12); }
[data-theme="light"] .fc-chip.due { background: rgba(24, 96, 192, 0.12); }
[data-theme="light"] .opt.correct { background: rgba(15, 122, 66, 0.10); }
[data-theme="light"] .opt.wrong { background: rgba(192, 24, 58, 0.08); }
[data-theme="light"] .streak-pill,
[data-theme="light"] .streak-day.met {
  border-color: rgba(63, 98, 0, 0.28);
}
[data-theme="light"] .stat.accent {
  border-color: rgba(63, 98, 0, 0.28);
  background: linear-gradient(180deg, rgba(63, 98, 0, 0.08), transparent), var(--bg-elev-1);
}
[data-theme="light"] .btn-danger { border-color: rgba(192, 24, 58, 0.4); }
[data-theme="light"] .qflag-btn:hover,
[data-theme="light"] .qflag-btn.on {
  border-color: rgba(154, 90, 0, 0.5);
  background: rgba(154, 90, 0, 0.12);
}
[data-theme="light"] .timer.danger { border-color: rgba(192, 24, 58, 0.45); }
[data-theme="light"] .fc-again { border-color: rgba(192, 24, 58, 0.5); }
[data-theme="light"] .fc-hard { border-color: rgba(24, 96, 192, 0.5); }
[data-theme="light"] .fc-easy { border-color: rgba(15, 122, 66, 0.5); }
[data-theme="light"] .stats-revenue__card {
  border-color: rgba(63, 98, 0, 0.28);
  background:
    linear-gradient(145deg, rgba(63, 98, 0, 0.10), transparent 60%),
    var(--bg-elev-2);
}
[data-theme="light"] .badge.unlocked {
  border-color: rgba(63, 98, 0, 0.3);
  background: linear-gradient(180deg, rgba(63, 98, 0, 0.08), transparent), var(--bg-elev-2);
}
[data-theme="light"] .toast.success { border-color: rgba(63, 98, 0, 0.3); }
[data-theme="light"] .toast.error { border-color: rgba(192, 24, 58, 0.4); }

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 8% -10%, var(--body-glow-1), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, var(--body-glow-2), transparent 60%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0; }

/* === Focus ring (accessibility) === */
:focus-visible {
  outline: 2px solid var(--brand-bright);
  outline-offset: 2px;
  border-radius: 6px;
}

/* === Layout === */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; min-width: 0; }
.container#view { padding: 22px 20px 60px; }
.app-root { display: grid; grid-template-rows: var(--nav-h) 1fr; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.spacer { height: 24px; }

/* === Top nav === */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  height: var(--nav-h);
  display: flex; align-items: center;
  min-width: 0;
}
.nav-inner { display: flex; align-items: center; gap: 18px; width: 100%; min-width: 0; max-width: var(--container); margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex-shrink: 0; text-decoration: none; color: inherit; }
.brand-logo { height: 30px; width: auto; display: block; filter: drop-shadow(0 2px 10px rgba(21,0,255,.35)); }
.brand-name { font-family: var(--font-display); font-weight: 800; letter-spacing: -.01em; }
.brand-name small { color: var(--text-muted); font-weight: 600; font-size: .85rem; }
.tabs {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  min-width: 0;
  flex: 1 1 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent; border: none; color: var(--text-dim);
  padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  transition: background .15s, color .15s;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--bg-elev-2); }
.tab.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }
.tabs--with-menus {
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.tabs--with-menus::-webkit-scrollbar { display: none; }
.nav-dropdown { position: relative; flex-shrink: 0; }
.nav-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.nav-dropdown__chevron {
  width: 14px;
  height: 14px;
  opacity: 0.75;
  transition: transform .18s ease, opacity .15s;
}
.nav-dropdown__trigger:hover .nav-dropdown__chevron,
.nav-dropdown.is-open .nav-dropdown__chevron { opacity: 1; }
.nav-dropdown.is-open .nav-dropdown__chevron { transform: rotate(180deg); }
.nav-dropdown__menu {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 196px;
  max-height: min(70vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(.98);
  transform-origin: top left;
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  z-index: 80;
}
/* While a menu is open, allow it to paint outside the horizontal scroller. */
.tabs--with-menus.has-open-dropdown {
  overflow: visible;
}
.nav-dropdown.is-open .nav-dropdown__menu,
.nav-dropdown__menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.nav-dropdown__item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.2;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-dropdown__item:hover {
  background: var(--bg-elev-3);
  color: var(--text);
}
.nav-dropdown__item.active {
  background: var(--brand-soft);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--brand);
}
.nav-dropdown__section + .nav-dropdown__section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line-strong);
}
.nav-dropdown__heading {
  padding: 6px 12px 4px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nav-dropdown__item--disabled {
  opacity: .45;
  cursor: not-allowed;
}
.nav-dropdown__item--disabled:hover {
  background: transparent;
  color: var(--text-dim);
}
.nav-dropdown__item--disabled small {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.report-filter-card { margin-bottom: 16px; }
.report-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 12px;
  align-items: end;
}
.report-filter-grid .field { margin: 0; min-width: 0; }
.report-filter-grid .input,
.report-filter-grid .select { width: 100%; height: 42px; }
.report-filter-grid__search { grid-column: span 2; min-width: 0; }
.report-filter-grid__search .input-search { min-width: 0; width: 100%; }
.report-filter-grid__actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.report-filter-grid__actions .btn { display: inline-flex; align-items: center; }
@media (max-width: 700px) {
  .report-filter-grid { grid-template-columns: 1fr 1fr; }
  .report-filter-grid__search { grid-column: 1 / -1; }
  .report-filter-grid__actions { flex-wrap: wrap; justify-content: stretch; }
  .report-filter-grid__actions .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 420px) {
  .report-filter-grid { grid-template-columns: 1fr; }
}
.setting-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-muted);
}
.setting-meta b {
  color: var(--text-dim);
  font-weight: 600;
}
.setting-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr);
  gap: 16px;
  align-items: start;
  max-width: 920px;
}
.setting-card { padding: 0; overflow: hidden; }
.setting-card__body { padding: 22px 22px 18px; }
.setting-card__eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.setting-card__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -.01em;
}
.setting-card__copy {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.45;
  max-width: 42ch;
}
.setting-fields {
  display: grid;
  gap: 16px;
}
.setting-card__input {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .04em;
  height: 48px;
}
.setting-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.setting-card__hint {
  font-size: .82rem;
  color: var(--text-muted);
}
.setting-preview { padding: 18px; }
.setting-preview__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.setting-preview__box { margin: 0; }
.setting-preview__note {
  margin: 12px 0 0;
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.4;
}
@media (max-width: 800px) {
  .setting-layout { grid-template-columns: 1fr; max-width: none; }
  .setting-card__footer { flex-wrap: wrap; }
}
.stats-hero { margin-bottom: 8px; }
.stats-hero__eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand-bright);
  margin-bottom: 6px;
}
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stats-kpi {
  position: relative;
  padding: 18px 16px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(165deg, rgba(61,43,255,.14), transparent 55%),
    var(--bg-elev-2);
  overflow: hidden;
}
.stats-kpi::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(61,43,255,.22), transparent 70%);
  pointer-events: none;
}
.stats-kpi--registrations { background: linear-gradient(165deg, rgba(255,176,32,.12), transparent 55%), var(--bg-elev-2); }
.stats-kpi--reservations { background: linear-gradient(165deg, rgba(255,84,112,.12), transparent 55%), var(--bg-elev-2); }
.stats-kpi--attempts { background: linear-gradient(165deg, rgba(91,167,255,.12), transparent 55%), var(--bg-elev-2); }
.stats-kpi--questions { background: linear-gradient(165deg, rgba(95,227,154,.12), transparent 55%), var(--bg-elev-2); }
.stats-kpi__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stats-kpi__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.85rem;
  letter-spacing: -.03em;
  line-height: 1.1;
  color: var(--text);
}
.stats-kpi__hint {
  margin-top: 8px;
  font-size: .8rem;
  color: var(--text-muted);
}
.stats-revenue {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stats-revenue__card {
  padding: 18px 18px 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(199,255,61,.28);
  background:
    linear-gradient(145deg, rgba(199,255,61,.12), transparent 60%),
    var(--bg-elev-2);
}
.stats-revenue__card--soft {
  border-color: var(--line-strong);
  background: var(--bg-elev-2);
}
.stats-revenue__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stats-revenue__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -.02em;
  color: var(--text);
}
.stats-revenue__value small {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}
.stats-panel {
  margin-bottom: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg-elev-1);
  overflow: hidden;
}
.stats-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.stats-panel__head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}
.stats-panel__body { padding: 12px 18px 18px; }
.stats-panel__body--chart { height: 280px; }
.stats-panel__body--donut {
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stats-panel__body--donut canvas {
  max-width: 240px;
  max-height: 240px;
}
.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.stats-grid-2 > .stats-panel { margin-bottom: 0; }
.stats-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stats-insight {
  padding: 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
}
.stats-insight__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stats-insight__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 8px;
}
.stats-insight__meta {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.stats-insight__bar {
  margin-top: 14px;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev-3);
  overflow: hidden;
}
.stats-insight__bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
}
.stats-insight__bar--accent > span {
  background: linear-gradient(90deg, var(--accent-deep, #9fe600), var(--accent));
}
.stats-insight__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.stats-insight__chips span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-elev-3);
  border: 1px solid var(--line);
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-dim);
}
@media (max-width: 1100px) {
  .stats-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .stats-kpi-grid,
  .stats-revenue,
  .stats-grid-2,
  .stats-grid-3 { grid-template-columns: 1fr; }
  .stats-panel__body--chart { height: 240px; }
}
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.report-summary__card {
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
}
.report-summary__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.report-summary__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
  line-height: 1.2;
}
@media (max-width: 700px) {
  .report-range {
    width: 100%;
  }
  .report-range__field {
    flex: 1 1 45%;
  }
  .report-range__field .input {
    min-width: 0;
    width: 100%;
  }
}
.tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  min-height: 48px;
}
.user-chip .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.user-chip .avatar svg { width: 62%; height: 62%; display: block; }
.user-chip__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.25;
}
.user-chip #user-name,
.user-chip .user-chip__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.user-chip .role {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
}
.user-chip .btn {
  padding: 8px 10px;
  font-size: 0.95rem;
  border-radius: 10px;
  flex-shrink: 0;
}
.streak-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid rgba(199,255,61,.3);
  padding: 6px 10px; border-radius: 999px;
  font-weight: 700; font-size: .85rem;
}
.streak-pill .flame { font-size: 1rem; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-elev-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; font-weight: 600; font-size: .92rem;
  transition: transform .08s ease, background .15s, border-color .15s, box-shadow .2s;
}
.btn:hover { background: var(--bg-elev-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-brand); }
.btn-primary:hover { background: var(--brand-bright); }
.btn-accent { background: var(--accent); color: #0a0a0a; border-color: transparent; box-shadow: var(--shadow-accent); }
.btn-accent:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255,77,109,.4); }
.btn-danger:hover { background: rgba(255,77,109,.1); }
.btn-sm { padding: 6px 10px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 14px 22px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* === Cards === */
.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-tight { padding: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-h h3 { font-size: 1.05rem; }
.card-sub { color: var(--text-muted); font-size: .85rem; }

/* === Auth screen === */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 28px;
  box-shadow: var(--shadow-1);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content:""; position:absolute; inset: -2px -40% auto auto;
  height: 120px; background: radial-gradient(closest-side, rgba(21,0,255,.45), transparent);
  filter: blur(20px); pointer-events: none;
}
.auth-logo { display:flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; margin-bottom: 18px; }
.auth-logo-img { height: 64px; width: auto; display: block; margin: 0 auto; filter: drop-shadow(0 6px 22px rgba(21,0,255,.4)); }
.auth-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; }
.auth-sub { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }
.auth-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg-elev-2); border-radius: 12px; padding: 4px; margin: 18px 0;
}
.auth-toggle button {
  background: transparent; border: none; color: var(--text-dim);
  padding: 10px 12px; border-radius: 9px; font-weight: 700;
  transition: background .15s, color .15s;
}
.auth-toggle button.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.input, .select, .textarea {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--text); padding: 11px 13px; border-radius: 10px;
  width: 100%; transition: border-color .15s, background .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-bright); background: var(--bg-elev-1); outline: none; }
.textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* === Form sections & batch editor === */
.form-section { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 14px 2px; margin-bottom: 14px; }
.form-section-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-dim); font-weight: 700; margin-bottom: 12px;
}
.batch-entry { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 14px 2px; margin-bottom: 12px; }
.batch-entry-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.batch-entry-h .badge { font-family: var(--font-mono); font-size: .85rem; color: var(--brand-bright); font-weight: 700; letter-spacing: .04em; }
.batch-opt { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.batch-opt input[type="radio"] { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; cursor: pointer; }

.auth-error, .form-error { color: var(--danger); font-size: .85rem; margin-top: 6px; min-height: 1.2em; }
.auth-hint { margin-top: 18px; padding: 12px; border-radius: 10px; background: var(--bg-elev-2); border: 1px dashed var(--line-strong); font-size: .82rem; color: var(--text-muted); }
.auth-hint b { color: var(--text-dim); }

/* === Stat grid === */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--bg-elev-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px; position: relative; overflow: hidden;
}
.stat .lbl { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat .val { font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; margin-top: 4px; letter-spacing: -.02em; }
.stat .delta { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.stat.accent { border-color: rgba(199,255,61,.3); background: linear-gradient(180deg, rgba(199,255,61,.08), transparent), var(--bg-elev-1); }
.stat.accent .val { color: var(--accent-text); }
.stat.brand { border-color: rgba(21,0,255,.4); background: linear-gradient(180deg, rgba(21,0,255,.12), transparent), var(--bg-elev-1); }

/* === Filters === */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.pill {
  background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text-dim);
  padding: 8px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--brand); color: #fff; border-color: transparent; }
.pill.active.accent { background: var(--accent); color: #0a0a0a; }

/* Compact filter dropdowns — admin question bank (year / module / subject / week) */
.filter-selects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-selects .select {
  flex: 1 1 calc(50% - 8px);
  min-width: 140px;
}
@media (max-width: 560px) {
  .filter-selects { gap: 7px; }
  .filter-selects .select { flex: 1 1 100%; min-width: 0; padding: 9px 9px; font-size: .82rem; }
}

/* === Question card === */
.q-card {
  background: var(--bg-elev-1); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 24px; margin-bottom: 16px;
}
.q-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

/* Practice stage — question is the hero; chrome stays quiet */
.practice-stage .section-h--quiet {
  margin: 10px 0 14px;
  align-items: flex-end;
}
.practice-stage .section-h--quiet h2 {
  font-size: 1.15rem;
  letter-spacing: -.01em;
}
.practice-stage .section-h--quiet .lbl {
  font-size: .84rem;
  max-width: 42ch;
}

.practice-filters {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
}
.practice-filters .filter-selects { margin-bottom: 8px; }
.practice-filters .select {
  background: var(--bg-elev-1);
  border-color: var(--line);
  font-size: .86rem;
  padding: 9px 10px;
}
.practice-filters__meta {
  font-size: .8rem;
  gap: 8px;
  min-height: 28px;
  align-items: center;
}

.practice-host { min-width: 0; }

.q-card--focus {
  position: relative;
  padding: clamp(22px, 3.5vw, 32px);
  margin-bottom: 28px;
  border-color: rgba(21, 0, 255, 0.35);
  background:
    linear-gradient(165deg, rgba(21, 0, 255, 0.10), transparent 42%),
    var(--bg-elev-1);
  box-shadow:
    var(--shadow-brand),
    0 0 0 1px rgba(21, 0, 255, 0.08);
}
.q-card--focus::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(61, 43, 255, 0.55), transparent 42%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.q-progress {
  margin: 0 0 18px;
}
.q-progress__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dim);
}
.q-progress__label b { color: var(--text); font-variant-numeric: tabular-nums; }
.q-progress__pct {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.q-progress__track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev-3);
  overflow: hidden;
}
.q-progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
  transition: width .35s ease;
}

.q-card--focus .q-meta { margin-bottom: 16px; }
.q-card--focus .q-prompt {
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 2.4vw, 1.35rem);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -.015em;
  margin: 4px 0 22px;
  max-width: 48ch;
}
.q-card--focus .options { gap: 12px; }
.q-card--focus .opt {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg-elev-2);
}
.q-card--focus .opt:hover {
  border-color: rgba(21, 0, 255, 0.35);
  background: var(--bg-elev-3);
}
.q-card--focus .opt.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px rgba(21, 0, 255, 0.18);
}
.q-card--focus .opt .letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.q-card--focus .q-actions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.q-card--focus .q-actions .btn-primary,
.q-card--focus .q-actions .btn-accent {
  min-width: 148px;
  padding: 12px 18px;
  font-size: .95rem;
}
.q-card--focus .explain {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
}

[data-theme="light"] .q-card--focus {
  border-color: rgba(21, 0, 255, 0.28);
  background:
    linear-gradient(165deg, rgba(21, 0, 255, 0.06), transparent 42%),
    var(--bg-elev-1);
  box-shadow:
    0 10px 32px rgba(21, 0, 255, 0.12),
    0 0 0 1px rgba(21, 0, 255, 0.06);
}
[data-theme="light"] .practice-filters {
  background: var(--bg-elev-1);
  border-color: var(--line);
}

@media (max-width: 560px) {
  .practice-filters { padding: 10px 12px; }
  .q-card--focus { padding: 18px 16px; }
  .q-card--focus .q-prompt { font-size: 1.08rem; margin-bottom: 18px; }
  .q-card--focus .q-actions .btn-primary,
  .q-card--focus .q-actions .btn-accent { min-width: 0; flex: 1 1 auto; }
}

/* Flag-for-review pill (Practice / Flagged) */
.qflag-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elev-3);
  color: var(--text-dim);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.qflag-btn .qflag-icon {
  color: var(--danger);
  font-size: 1.15rem;
  line-height: 1;
  background: rgba(255,77,109,.18);
  border-radius: 6px;
  padding: 2px 4px;
}
.qflag-btn:hover { color: var(--warn); border-color: rgba(255,181,71,.5); }
.qflag-btn.on {
  background: rgba(255,181,71,.14);
  color: var(--warn);
  border-color: rgba(255,181,71,.5);
}
.qflag-btn:disabled { opacity: .6; cursor: wait; }

.flag-item { padding: 14px 18px; }
.flag-head { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.flag-head:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: 8px; }
.flag-head-main { flex: 1; min-width: 0; }
.flag-item .q-meta { margin-bottom: 10px; }
.flag-item .q-prompt { margin: 0; font-size: 1rem; }
.flag-chevron {
  flex: none;
  color: var(--text-muted);
  transition: transform .18s ease;
  margin-top: 4px;
}
.flag-item.open .flag-chevron { transform: rotate(180deg); }
.flag-body { display: none; margin-top: 16px; }
.flag-item.open .flag-body { display: block; }
.tag {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
  background: var(--bg-elev-3); color: var(--text-dim);
}
.tag.easy { color: var(--easy); background: rgba(95,227,154,.12); }
.tag.moderate { color: var(--mod); background: rgba(91,167,255,.12); }
.tag.hard { color: var(--hard); background: rgba(255,84,112,.14); }
.tag.points { background: var(--brand-soft); color: var(--tag-points); }
.tag.year { background: var(--accent-soft); color: var(--accent-text); }
.q-prompt { font-size: 1.08rem; font-weight: 600; line-height: 1.55; margin: 8px 0 18px; }
.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.opt:hover { border-color: var(--line-strong); background: var(--bg-elev-3); }
.opt .letter {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  background: var(--bg-elev-3); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 700; font-size: .82rem;
}
.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt.selected .letter { background: var(--brand); color: #fff; border-color: transparent; }
.opt.correct { border-color: var(--easy); background: rgba(95,227,154,.1); }
.opt.correct .letter { background: var(--easy); color: #06140d; border-color: transparent; }
.opt.wrong { border-color: var(--hard); background: rgba(255,84,112,.08); }
.opt.wrong .letter { background: var(--hard); color: #200; border-color: transparent; }
.opt.disabled { pointer-events: none; }
.explain {
  margin-top: 16px; padding: 14px; border-radius: 12px;
  background: var(--bg-elev-2); border-left: 3px solid var(--brand);
}
.explain b { color: var(--accent-text); }
.q-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* === Practice screen === */
.section-h { display:flex; align-items:center; justify-content: space-between; margin: 18px 0 12px; flex-wrap: wrap; gap: 12px; }
.section-h h2 { font-size: 1.3rem; }
.section-h .lbl { color: var(--text-muted); }

/* === Admin list (manage tables) === */
.admin-list-card { padding: 0; overflow: hidden; }
.admin-list-card > .tbl-wrap { border: none; border-radius: 0; }

.admin-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; margin: 18px 0 14px;
}
.admin-toolbar__title h2 { font-size: 1.3rem; margin-bottom: 4px; }
.admin-toolbar__title .lbl { color: var(--text-muted); font-size: .88rem; }
.admin-toolbar__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.search-field { position: relative; display: flex; align-items: center; }
.search-field .search-icon {
  position: absolute; left: 12px; width: 16px; height: 16px;
  color: var(--text-muted); pointer-events: none;
}
.input-search { padding-left: 36px; min-width: 220px; }

.tag-success { color: var(--easy); background: rgba(95,227,154,.12); }
.tag-warn { color: var(--warn); background: rgba(255,181,71,.12); }

.action-group {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 10px;
  background: var(--bg-elev-3); border: 1px solid var(--line);
}
.action-group .btn-sm {
  padding: 5px 10px; border: none; background: transparent; border-radius: 7px;
  color: var(--text-dim); font-size: .8rem;
}
.action-group .btn-sm:hover { background: var(--bg-elev-2); color: var(--text); }
.action-group .btn-sm.btn-danger { color: var(--danger); }
.action-group .btn-sm.btn-danger:hover { background: rgba(255,77,109,.12); color: var(--danger); }
.action-group form { display: contents; }

.admin-table-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 16px; padding: 12px 18px;
  background: var(--bg-elev-2); border-top: 1px solid var(--line);
}
.admin-table-meta {
  margin: 0; font-size: .84rem; color: var(--text-muted);
}
.admin-table-meta strong { color: var(--text-dim); font-weight: 600; }

.pagination { display: inline-flex; align-items: center; gap: 6px; }
.pagination-pages { display: inline-flex; align-items: center; gap: 4px; }
.pagination-btn {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px;
  padding: 0 10px; border-radius: 9px;
  background: var(--bg-elev-1); border: 1px solid var(--line);
  color: var(--text-dim); font-size: .84rem; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.pagination-btn:hover { background: var(--bg-elev-3); border-color: var(--line-strong); color: var(--text); }
.pagination-btn.is-active {
  background: var(--brand); border-color: transparent; color: #fff;
  box-shadow: var(--shadow-brand); pointer-events: none;
}
.pagination-btn.is-disabled { opacity: .4; pointer-events: none; }
.pagination-btn--nav { min-width: 34px; padding: 0; }
.pagination-ellipsis {
  display: inline-grid; place-items: center; min-width: 28px; height: 34px;
  color: var(--text-faint); font-size: .9rem; user-select: none;
}

.year-checkbox-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 200px; overflow-y: auto;
  padding: 10px; border-radius: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
}
.year-checkbox {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  font-size: .9rem; color: var(--text-dim);
}
.year-checkbox:hover { background: var(--bg-elev-3); color: var(--text); }
.year-checkbox input { accent-color: var(--brand); width: 16px; height: 16px; flex-shrink: 0; }
.tbl td .tag-year { white-space: normal; max-width: 220px; display: inline-block; line-height: 1.4; }

.modal-modules { max-width: 560px; }
.modal-section-divider { height: 1px; background: var(--line); margin: 18px 0; }
.modal-modules-empty { margin: 0 0 4px; font-size: .9rem; }
.modal-modules-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 260px; overflow-y: auto; margin-bottom: 4px;
}
.module-list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
}
.module-list-row__main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.module-list-row__main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.module-edit-row {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--brand-soft-2);
}
.modules-link { font-weight: 600; }

.repeatable-fields { display: flex; flex-direction: column; gap: 8px; }
.repeatable-row { display: flex; align-items: center; gap: 8px; }
.repeatable-row .input { flex: 1; }
.repeatable-remove { min-width: 34px; padding-inline: 0; font-size: 1.1rem; line-height: 1; }

.module-entry-list { display: flex; flex-direction: column; gap: 12px; }
.module-entry-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
}
.module-entry-year,
.module-entry-name { width: auto; min-width: 0; }
.module-entry-year { min-width: 0; }
.module-entry-remove { min-width: 34px; padding-inline: 0; font-size: 1.1rem; line-height: 1; }
.module-entry-hint { margin-bottom: 4px; }

@media (max-width: 520px) {
  .module-entry-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "year remove"
      "name name";
    gap: 10px;
  }
  .module-entry-year { grid-area: year; width: 100%; }
  .module-entry-name { grid-area: name; width: 100%; }
  .module-entry-remove { grid-area: remove; align-self: start; }
}

/* === Insights === */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.progress-bar { width: 100%; height: 10px; border-radius: 999px; background: var(--bg-elev-3); overflow: hidden; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-bright)); transition: width .4s ease; }
.progress-bar.accent > div { background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }
.kv { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-muted); font-size: .9rem; }
.kv .v { font-weight: 700; }
.topic-row { display: grid; grid-template-columns: 1fr auto 120px; gap: 12px; align-items: center; padding: 8px 0; }
.topic-row .name { color: var(--text); font-size: .92rem; }
.topic-row .pct { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-dim); }

/* === Streak strip === */
.streak-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.streak-day {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border-radius: 10px; background: var(--bg-elev-2); border: 1px solid var(--line);
  font-size: .75rem; color: var(--text-muted);
}
.streak-day .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-elev-3); border: 1px solid var(--line-strong); }
.streak-day.met { border-color: rgba(199,255,61,.4); background: linear-gradient(180deg, rgba(199,255,61,.15), transparent), var(--bg-elev-2); color: var(--accent-text); }
.streak-day.met .dot { background: var(--accent); border-color: transparent; box-shadow: 0 0 12px rgba(199,255,61,.5); }
.streak-day.today { outline: 1px solid var(--brand); }

/* === Reward badges === */
.rewards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.badge {
  position: relative;
  border-radius: 14px; padding: 14px 10px; text-align: center;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  transition: transform .2s ease;
}
.badge .icon {
  width: 54px; height: 54px; border-radius: 14px; margin: 0 auto 8px;
  display: grid; place-items: center;
  background: var(--bg-elev-3);
  color: var(--text-muted);
  font-size: 1.5rem;
  border: 1px solid var(--line);
}
.badge .title { font-weight: 700; font-size: .85rem; }
.badge .desc { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.badge.unlocked { border-color: rgba(199,255,61,.35); background: linear-gradient(180deg, rgba(199,255,61,.1), transparent), var(--bg-elev-2); }
.badge.unlocked .icon { background: var(--accent); color: #0a0a0a; border-color: transparent; box-shadow: 0 0 24px rgba(199,255,61,.35); }
.badge.unlocked .title { color: var(--accent-text); }
@keyframes badgePop {
  0% { transform: scale(.7); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.badge.just-unlocked { animation: badgePop .6s ease both; }
@media (prefers-reduced-motion: reduce) {
  .badge.just-unlocked { animation: none; }
}

/* === Exam mode === */
.exam-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); background: var(--bg); }
.exam-bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--overlay-bg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.exam-bar .progress { flex: 1; height: 8px; border-radius: 999px; background: var(--bg-elev-3); overflow: hidden; }
.exam-bar .progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .3s ease; }
.timer {
  font-family: var(--font-mono); font-weight: 700;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 10px; font-variant-numeric: tabular-nums;
  min-width: 76px; text-align: center;
}
.timer.danger { color: var(--danger); border-color: rgba(255,77,109,.45); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { background: rgba(255,77,109,.15); } }
@media (prefers-reduced-motion: reduce) { .timer.danger { animation: none; } }

.exam-body { padding: 28px 20px 80px; max-width: 820px; margin: 0 auto; width: 100%; }
.exam-footer {
  position: sticky; bottom: 0;
  background: var(--overlay-bg-2); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 12px 20px; display: flex; gap: 10px; justify-content: space-between; align-items: center;
}
.qjump { display: flex; flex-wrap: wrap; gap: 6px; }
.qjump button {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text-dim);
  font-size: .78rem; font-weight: 700;
}
.qjump button.answered { background: var(--brand); color: #fff; border-color: transparent; }
.qjump button.flagged { border-color: var(--warn); color: var(--warn); }
.qjump button.current { outline: 2px solid var(--accent); }

/* === Tables (admin) === */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r-md); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; background: var(--bg-elev-2); position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-elev-2); }
.row-actions { vertical-align: middle; }
.row-actions > * + * { margin-left: 8px; }
.row-actions .action-group { vertical-align: middle; }
.tbl th:last-child, .tbl td:last-child { text-align: right; }
.tbl td.years-cell { white-space: normal; }

/* === Charts === */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-svg { display: block; width: 100%; height: auto; }

/* === Avatar picker === */
.avatar-lg {
  width: 56px; height: 56px; border-radius: 14px; font-size: 1.2rem;
  font-family: var(--font-display); font-weight: 800;
  display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.avatar-lg svg { width: 60%; height: 60%; display: block; }
.avatar-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
.avatar-pick {
  background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: background .15s, border-color .15s, transform .08s;
}
.avatar-pick:hover { background: var(--bg-elev-3); border-color: var(--line-strong); }
.avatar-pick:active { transform: translateY(1px); }
.avatar-pick.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--shadow-brand); }
.avatar-pick.selected::after {
  content: "✓"; position: absolute; /* fallback if positioned */
}
.avatar-pick-label {
  font-size: .72rem; color: var(--text-muted); letter-spacing: .06em;
  text-transform: uppercase; font-weight: 700;
}
.avatar-pick.selected .avatar-pick-label { color: var(--text-dim); }

/* === Modal === */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--backdrop); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto;
  background: var(--bg-elev-1); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-1);
}
.modal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* === Toast === */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 12px; min-width: 220px; max-width: 360px;
  box-shadow: var(--shadow-1);
  animation: slideIn .25s ease both;
  font-size: .9rem;
}
.toast.success { border-color: rgba(199,255,61,.35); }
.toast.error { border-color: rgba(255,77,109,.4); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* === Heatmap === */
.heatmap { display: grid; gap: 4px; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); }
.heatmap .cell { width: 14px; height: 14px; border-radius: 3px; background: var(--bg-elev-2); border: 1px solid var(--line); }
.heatmap .cell.l1 { background: rgba(21,0,255,.25); }
.heatmap .cell.l2 { background: rgba(21,0,255,.5); }
.heatmap .cell.l3 { background: rgba(21,0,255,.8); }
.heatmap .cell.l4 { background: var(--brand); }

/* === Empty state === */
.empty {
  padding: 40px 20px; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* === Misc === */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent-text); }
.text-brand { color: var(--brand-bright); }

/* === Leaderboard === */
.lb-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; overflow: hidden; flex-shrink: 0; }
.lb-avatar svg { width: 62%; height: 62%; display: block; }
.lb-rank { font-family: var(--font-display); font-weight: 800; }
.tbl tr.lb-me { background: var(--brand-soft); }
.lb-podium { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.lb-podium .card { margin: 0; text-align: center; }
.lb-podium .pos { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.lb-podium .avatar-lg { margin: 10px auto; }
.lb-pts { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; }
.right { margin-left: auto; }
.tabular { font-variant-numeric: tabular-nums; }

/* === Brand transition: logo flies to center, blue fills in & out === */
.brand-transition {
  position: fixed; inset: 0; z-index: 250;
  pointer-events: none;
  overflow: hidden;
}
.brand-transition-bg {
  position: absolute; inset: 0;
  background: var(--brand);
  clip-path: circle(0 at 50% 50%);
  will-change: clip-path;
  transition: clip-path 540ms cubic-bezier(.6,.05,.35,1);
}
.brand-transition-bg.peak { clip-path: circle(150vmax at 50% 50%); }
.brand-transition-bg.retract {
  transition: clip-path 640ms cubic-bezier(.7,0,.4,1);
  clip-path: circle(0 at 50% 50%);
}
.brand-transition-logo {
  position: absolute;
  left: 50%; top: 50%;
  width: clamp(220px, 38vw, 380px);
  height: auto;
  transform: translate(-50%, -50%) scale(.9);
  opacity: 0;
  will-change: opacity, transform;
  filter: drop-shadow(0 16px 50px rgba(0,0,0,.45));
}

/* Subtle app-shell entrance after the blue retracts */
@keyframes appNavIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes appViewIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.app-root.is-entering .nav  { animation: appNavIn 360ms cubic-bezier(.2,.8,.2,1) both; }
.app-root.is-entering #view { animation: appViewIn 420ms cubic-bezier(.2,.8,.2,1) 80ms both; }

@media (prefers-reduced-motion: reduce) {
  .brand-transition { display: none !important; }
  .app-root.is-entering .nav,
  .app-root.is-entering #view { animation: none !important; }
}

/* ===========================================================
   Responsive system
   Breakpoints: 1024 (tablet landscape) · 880 (tablet) ·
                768 (tablet portrait) · 560 (phone) · 380 (small phone)
   =========================================================== */

/* --- Tablet landscape & below --- */
@media (max-width: 1024px) {
  :root { --nav-h: 60px; --container: 960px; }
  .container { padding: 0 18px; }
  .grid-2 { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
  .lb-podium { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- Tablet --- */
@media (max-width: 880px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.35rem; }
}

/* --- Tablet portrait --- */
@media (max-width: 768px) {
  .topic-row { grid-template-columns: 1fr auto 90px; }
  .exam-body { padding: 24px 16px 90px; }
  .rewards-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); }
}

/* --- Phones: reflow nav to two rows, stack panels --- */
@media (max-width: 560px) {
  /* Nav: brand + user on row 1, tabs scroll full-width on row 2 */
  .app-root { grid-template-rows: auto 1fr; }
  .nav { height: auto; }
  .nav-inner { flex-wrap: wrap; gap: 8px 10px; padding-top: 8px; padding-bottom: 8px; }
  .tabs { order: 5; flex-basis: 100%; margin-left: 0; padding-bottom: 2px; flex: 1 1 100%; }
  .tabs--with-menus { padding-bottom: 2px; }
  .nav-dropdown__menu { min-width: 180px; }
  .tab { padding: 8px 13px; }
  .brand-name small { display: none; }
  .brand-logo { height: 26px; }
  .user-chip { padding: 6px 10px 6px 6px; min-height: 42px; gap: 10px; }
  .user-chip .avatar { width: 32px; height: 32px; font-size: 12px; }
  .user-chip #user-name,
  .user-chip .user-chip__name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
  .user-chip .role { display: none; }
  .nav-right { gap: 8px; }

  .container { padding: 0 14px; }
  .container#view { padding: 16px 14px 56px; }

  .section-h { margin: 12px 0 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat { padding: 13px; }
  .stat .val { font-size: 1.4rem; }
  .card { padding: 16px; }
  .q-card { padding: 18px 16px; }
  .q-prompt { font-size: 1rem; }
  .topic-row { grid-template-columns: 1fr auto 64px; gap: 8px; }

  /* Auth card uses more of the screen */
  .auth-card { padding: 22px 20px; }

  /* Buttons that sit in a row become easier to tap */
  .q-actions .btn { flex: 1 1 auto; }

  .admin-toolbar { align-items: stretch; }
  .admin-toolbar__actions { width: 100%; }
  .admin-toolbar__actions form { flex: 1 1 auto; }
  .input-search { min-width: 0; width: 100%; }
  .admin-table-footer { justify-content: center; text-align: center; }
  .admin-table-meta { width: 100%; }
  .pagination { width: 100%; justify-content: center; }
  .action-group { flex-wrap: wrap; justify-content: flex-end; }
}

/* --- Small phones --- */
@media (max-width: 380px) {
  html, body { font-size: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .lb-podium { grid-template-columns: 1fr; }
  .btn { padding: 9px 13px; }
  .q-card { padding: 16px 13px; }
}

/* --- Landscape phones (short height): trim vertical padding --- */
@media (max-height: 480px) and (orientation: landscape) {
  .container#view { padding-top: 12px; }
  .auth-wrap { align-items: start; }
}

/* --- Touch devices: larger tap targets, no hover-only affordances --- */
@media (hover: none) and (pointer: coarse) {
  .btn-sm { padding: 8px 12px; }
  .tab { padding: 9px 14px; }
  .pill { padding: 9px 13px; }
  .opt { padding: 13px 14px; }
  .qjump button { width: 34px; height: 34px; }
  .btn:hover, .pill:hover, .tab:hover, .opt:hover { background: inherit; }
  /* Keep sticky hover from wiping the active tab / open trigger styles. */
  .tab.active:hover,
  .nav-dropdown__trigger.active:hover { background: var(--brand); color: #fff; }
  .nav-dropdown__item:hover { background: var(--bg-elev-3); color: var(--text); }
  .nav-dropdown__item.active:hover {
    background: var(--brand-soft);
    color: var(--text);
  }
}

/* === Question images === */
.q-image {
  display: block;
  max-width: 100%;
  max-height: 360px;
  margin: 4px 0 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  object-fit: contain;
}
.q-image-preview { margin-top: 10px; }
.q-image-preview .q-image { max-height: 200px; margin: 0; }

/* === Quality flags === */
.qflag {
  display: inline-block;
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
  line-height: 1.6;
}

/* === Level pill (header) === */
.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-2);
  color: var(--brand-bright);
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
  user-select: none;
}

/* === Level & XP card === */
.xp-card { margin-bottom: 16px; }
.xp-row { display: flex; align-items: center; gap: 18px; }
.xp-badge {
  flex-shrink: 0;
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 800;
  color: #fff;
  background: radial-gradient(circle at 30% 30%, var(--brand-bright), var(--brand));
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.xp-bar-wrap { flex: 1; min-width: 0; }
.progress-bar.brand > div { background: var(--brand-bright); }

@media (max-width: 560px) {
  .level-pill { display: none; }
  .xp-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .xp-badge { width: 52px; height: 52px; font-size: 1.3rem; }
}

/* === Exam mode responsive === */
.exam-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.toast-wrap { bottom: max(18px, env(safe-area-inset-bottom)); }

@media (max-width: 768px) {
  .exam-bar { flex-wrap: wrap; }
  .exam-bar .progress { order: 5; flex-basis: 100%; }
}

@media (max-width: 560px) {
  /* Exam top bar: brand + timer + exit on row 1, progress full-width below */
  .exam-bar { padding: 10px 14px; gap: 10px; }
  .exam-bar .brand-name { display: none; }

  /* Exam footer: question-jump grid on top, controls below, full-width */
  .exam-footer { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
  .exam-footer .row { width: 100%; }
  .exam-footer .row .btn { flex: 1 1 auto; }
  .qjump { justify-content: center; max-height: 96px; overflow-y: auto; }

  /* Modal becomes a bottom sheet */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 90vh; max-height: 90dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  /* Toasts span the width so they're readable on small screens */
  .toast-wrap { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .toast { max-width: none; min-width: 0; }
}

/* === Theme toggle === */
.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  flex-shrink: 0;
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}
.theme-toggle .theme-icon-moon { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-sun { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-moon { display: block; }

.auth-theme-slot {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 40;
}

.question-image-thumb {
  display: inline-flex;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev-2);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.question-image-thumb:hover {
  border-color: var(--brand-bright);
  box-shadow: var(--shadow-brand);
}
.question-image-thumb img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.auth-back-link {
  position: absolute;
  top: 18px;
  left: 18px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color .15s;
  z-index: 2;
}
.auth-back-link:hover { color: var(--text); }

/* === Landing page === */
.landing-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.landing-nav .brand-name small { display: block; margin-top: 1px; }

.landing-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 1;
}
.landing-menu::-webkit-scrollbar { display: none; }
.landing-menu__link {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .92rem;
  color: var(--text-dim);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.landing-menu__link:hover { color: var(--text); background: var(--bg-elev-2); }
.landing-menu__link.active {
  color: #fff;
  background: var(--brand);
  box-shadow: var(--shadow-brand);
}
.landing-menu__link--soon {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}
.landing-nav-cta { white-space: nowrap; }

.landing-hero {
  padding: 56px 0 72px;
  position: relative;
  overflow: hidden;
}
.landing-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 48px;
  align-items: center;
}
.landing-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent-text);
}
.landing-hero__title {
  font-size: clamp(2rem, 4.8vw, 3.35rem);
  line-height: 1.05;
  letter-spacing: -.03em;
  max-width: 12ch;
}
.landing-hero__lead {
  margin-top: 18px;
  max-width: 52ch;
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.65;
}
.landing-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}
.landing-hero__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.landing-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.landing-stat strong {
  font-family: var(--font-display);
  font-size: .95rem;
}
.landing-stat span {
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.4;
}

.landing-hero__visual {
  position: relative;
  min-height: 360px;
}
.landing-preview {
  position: relative;
  z-index: 1;
  padding: 22px;
  border-color: rgba(21, 0, 255, .22);
  box-shadow: var(--shadow-1);
}
.landing-preview__top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.landing-preview__prompt {
  font-weight: 600;
  line-height: 1.55;
  font-size: .98rem;
}
.landing-preview__options {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.landing-preview__option {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  font-size: .88rem;
  color: var(--text-dim);
}
.landing-preview__option--active {
  border-color: rgba(21, 0, 255, .45);
  background: var(--brand-soft);
  color: var(--text);
}
.landing-preview__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.landing-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}
.landing-glow--brand {
  width: 220px;
  height: 220px;
  background: rgba(21, 0, 255, .35);
  top: -20px;
  right: -10px;
}
.landing-glow--accent {
  width: 180px;
  height: 180px;
  background: rgba(199, 255, 61, .18);
  bottom: 10px;
  left: -20px;
}

.landing-section {
  padding: 72px 0;
}
.landing-section--muted {
  background: linear-gradient(180deg, transparent, var(--bg-elev-1) 12%, var(--bg-elev-1) 88%, transparent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.landing-section__head {
  max-width: 640px;
  margin-bottom: 32px;
}
.landing-section__head h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-top: 8px;
}
.landing-section__sub {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.6;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.landing-feature {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: border-color .2s, transform .2s;
}
.landing-feature:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}
.landing-feature h3 { margin-top: 14px; }
.landing-feature p { margin-top: 8px; line-height: 1.55; flex: 1; }
.landing-feature__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-size: 1.2rem;
}
.landing-feature__icon--brand {
  background: var(--brand-soft);
  border-color: rgba(21, 0, 255, .25);
}
.landing-feature__icon--accent {
  background: var(--accent-soft);
  border-color: rgba(199, 255, 61, .28);
}
.landing-soon-tag {
  display: inline-flex;
  margin-top: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  width: fit-content;
}

.landing-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.landing-step {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-elev-1);
}
.landing-step__num {
  display: inline-flex;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brand-bright);
  font-size: .9rem;
  margin-bottom: 12px;
}
.landing-step h3 { margin-bottom: 8px; }
.landing-step p { line-height: 1.55; }

.landing-cta {
  padding: 24px 0 72px;
}
.landing-cta__card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border-color: rgba(21, 0, 255, .28);
  background:
    radial-gradient(600px 180px at 0% 0%, var(--brand-soft), transparent 70%),
    var(--bg-elev-1);
}
.landing-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.landing-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 22px 0 max(22px, env(safe-area-inset-bottom));
  background: var(--bg-elev-1);
}
.landing-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.landing-footer__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: .88rem;
}
.landing-footer__logo { height: 22px; width: auto; opacity: .9; }
.landing-footer__links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.landing-footer__links a {
  color: var(--text-dim);
  font-size: .9rem;
  font-weight: 600;
}
.landing-footer__links a:hover { color: var(--text); }

@media (max-width: 960px) {
  .landing-hero__inner { grid-template-columns: 1fr; gap: 36px; }
  .landing-hero__title { max-width: none; }
  .landing-hero__visual { min-height: 0; }
  .landing-features,
  .landing-steps,
  .landing-hero__stats { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .landing-hero { padding-top: 32px; }
  .landing-nav-cta { display: none; }
  .landing-cta__card { align-items: flex-start; }
  .landing-menu__link { padding: 8px 10px; font-size: .85rem; }
}

/* === Landing inner pages === */
.landing-main { flex: 1; }
.landing-page-hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(800px 320px at 0% 0%, var(--brand-soft), transparent 65%),
    transparent;
}
.landing-page-hero--compact {
  padding: 40px 0 28px;
}
.landing-page-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -.03em;
  max-width: 18ch;
}
.landing-page-hero__lead {
  margin-top: 14px;
  max-width: 58ch;
  color: var(--text-dim);
  font-size: 1.02rem;
  line-height: 1.65;
}
.landing-page-hero__meta {
  margin-top: 12px;
  font-size: .88rem;
}
.landing-section--tight { padding: 48px 0; }
.landing-cta--compact { padding: 8px 0 56px; }

.landing-prose h2 {
  font-size: 1.35rem;
  margin: 0 0 12px;
}
.landing-prose p {
  color: var(--text-dim);
  line-height: 1.65;
  margin: 0 0 14px;
}
.landing-prose p:last-child { margin-bottom: 0; }

.landing-split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
  gap: 18px;
  align-items: start;
}
.landing-split__main h2 { margin-bottom: 14px; }
.landing-values {
  display: grid;
  gap: 12px;
}
.landing-value h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}
.landing-value p { margin: 0; font-size: .92rem; line-height: 1.55; }

.landing-features--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.landing-contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.landing-contact-card h3 { margin-bottom: 8px; }
.landing-contact-card p { margin: 0; font-size: .92rem; line-height: 1.55; }
.landing-contact-card__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-size: 1.2rem;
  margin-bottom: 12px;
}
.landing-contact-card__link {
  display: inline-block;
  margin-top: 12px;
  font-weight: 700;
  color: var(--brand-bright);
}
.landing-contact-card__link:hover { text-decoration: underline; }
.landing-contact-note h3 { margin-bottom: 12px; }
.landing-prose-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-dim);
  line-height: 1.65;
}
.landing-prose-list li + li { margin-top: 10px; }
.landing-prose-list strong { color: var(--text); }

.landing-legal__card { width: 100%; }
.landing-legal h2 {
  font-size: 1.15rem;
  margin: 28px 0 10px;
}
.landing-legal h2:first-child { margin-top: 0; }
.landing-legal p,
.landing-legal li {
  color: var(--text-dim);
  line-height: 1.65;
}
.landing-legal ul {
  margin: 0 0 14px;
  padding-left: 1.2rem;
}
.landing-legal li + li { margin-top: 8px; }
.landing-legal a {
  color: var(--brand-bright);
  font-weight: 600;
}
.landing-legal a:hover { text-decoration: underline; }

@media (max-width: 960px) {
  .landing-split,
  .landing-features--two,
  .landing-contact-grid { grid-template-columns: 1fr; }
}

/* === Student workspaces (display) === */
.student-workspaces__header { margin-top: 4px; }

.student-workspaces__empty {
  text-align: center;
  padding: 48px 28px;
}
.student-workspaces__empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--brand-soft);
  border: 1px solid rgba(21, 0, 255, .2);
  color: var(--brand-bright);
}
.student-workspaces__empty-icon svg { width: 36px; height: 36px; }
.student-workspaces__empty h3 { margin-bottom: 8px; }
.student-workspaces__empty p { max-width: 42ch; margin: 0 auto; line-height: 1.6; }

.student-workspaces__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.student-workspace-card {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.student-workspace-card:hover {
  border-color: rgba(21, 0, 255, .28);
  box-shadow: var(--shadow-1);
  transform: translateY(-2px);
}

.student-workspace-card__media {
  position: relative;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--line);
}
.student-workspace-card__image-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.student-workspace-card__image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}
.student-workspace-card__image-btn:hover .student-workspace-card__image {
  transform: scale(1.03);
}
.student-workspace-card__zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--overlay-bg-2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  font-size: .75rem;
  font-weight: 700;
  color: var(--text);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s, transform .2s;
}
.student-workspace-card__image-btn:hover .student-workspace-card__zoom,
.student-workspace-card__image-btn:focus-visible .student-workspace-card__zoom {
  opacity: 1;
  transform: translateY(0);
}

.student-workspace-card__placeholder {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  color: var(--brand-bright);
  background:
    radial-gradient(ellipse at 30% 20%, var(--brand-soft), transparent 55%),
    var(--bg-elev-2);
}
.student-workspace-card__placeholder svg {
  width: 52px;
  height: 52px;
  opacity: .75;
}

.student-workspace-card__body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.student-workspace-card__title {
  font-size: 1.15rem;
  margin-bottom: 16px;
  letter-spacing: -.02em;
}

.student-workspace-card__details {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  flex: 1;
}
.student-workspace-card__details li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.student-workspace-card__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.student-workspace-card__icon svg { width: 18px; height: 18px; }

.student-workspace-card__label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.student-workspace-card__value {
  margin: 0;
  font-size: .94rem;
  line-height: 1.5;
  color: var(--text);
}
.student-workspace-card__link {
  font-weight: 700;
  color: var(--brand-bright);
}
.student-workspace-card__link:hover { text-decoration: underline; }

.student-workspace-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
  .student-workspaces__grid { grid-template-columns: 1fr; }
}

/* ============ Flash cards (student study) ============ */
.fc-chip {
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-elev-3); color: var(--text-dim); border: 1px solid var(--line);
}
.fc-chip.due   { color: var(--mod);  background: rgba(91,167,255,.12); border-color: transparent; }
.fc-chip.new   { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
.fc-chip.learn { color: var(--warn); background: rgba(255,181,71,.14); border-color: transparent; }

.flashcard { perspective: 1800px; max-width: 540px; margin: 10px auto 18px; }
.flip-inner {
  display: grid;
  min-height: 360px;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.85,.2,1);
}
.flashcard.is-flipped .flip-inner { transform: rotateY(180deg); }
.flashcard:not(.is-flipped):hover .flip-inner { transform: translateY(-6px); }
.flip-face {
  grid-area: 1 / 1;
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: radial-gradient(130% 90% at 50% -10%, rgba(61,43,255,.22), var(--bg-elev-1) 55%);
  border: 1px solid rgba(99,79,255,.55);
  border-radius: 20px;
  box-shadow: 0 0 28px rgba(21,0,255,.40), inset 0 0 32px rgba(21,0,255,.10), 0 16px 40px rgba(0,0,0,.5);
  padding: 26px 26px 20px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.flip-face::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright), #8A6BFF);
  box-shadow: 0 0 14px rgba(61,43,255,.85);
}
.flip-front { cursor: pointer; }
.flashcard:not(.is-flipped):hover .flip-front {
  box-shadow: 0 0 42px rgba(21,0,255,.58), inset 0 0 34px rgba(21,0,255,.14), 0 22px 48px rgba(0,0,0,.55);
}
.flip-back {
  transform: rotateY(180deg);
  background: radial-gradient(130% 90% at 50% -10%, rgba(159,230,0,.16), var(--bg-elev-1) 55%);
  border-color: rgba(159,230,0,.42);
  box-shadow: 0 0 26px rgba(159,230,0,.25), inset 0 0 30px rgba(159,230,0,.08), 0 16px 40px rgba(0,0,0,.5);
}
.flip-back::before {
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 14px rgba(159,230,0,.55);
}
.flip-front .q-meta { justify-content: center; margin: 6px 0 0; }
.fc-corner {
  position: absolute; top: 14px; right: 16px;
  font-size: .6rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
  color: #9C8BFF; opacity: .9;
}
.flip-back .fc-corner { color: var(--accent-text); opacity: .85; }
.fc-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  gap: 14px; padding: 10px 2px;
}
.fc-text {
  font-size: 1.4rem; font-weight: 700; line-height: 1.4; letter-spacing: -.01em;
  text-shadow: 0 0 20px rgba(61,43,255,.30);
  white-space: pre-wrap; /* preserve Enter / newlines from admin textarea */
}
.flip-back .fc-text { font-size: 1.5rem; text-shadow: 0 0 20px rgba(159,230,0,.22); }
.fc-foot {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.fc-flip-hint { font-size: .76rem; color: var(--text-muted); }
.fc-grade {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 14px; padding-top: 16px; border-top: 1px dashed var(--line);
}
.fc-grade .btn { justify-content: center; font-weight: 700; }
.fc-again { border-color: rgba(255,84,112,.5);  color: var(--hard); }
.fc-hard  { border-color: rgba(91,167,255,.5);  color: var(--mod); }
.fc-easy  { border-color: rgba(95,227,154,.5);  color: var(--easy); }

[data-theme="light"] .flip-face {
  background: radial-gradient(130% 90% at 50% -10%, rgba(21,0,255,.10), var(--bg-elev-1) 60%);
  border-color: rgba(21,0,255,.32);
  box-shadow: 0 0 22px rgba(21,0,255,.16), 0 14px 30px rgba(18,20,40,.14);
}
[data-theme="light"] .flashcard:not(.is-flipped):hover .flip-front {
  box-shadow: 0 0 30px rgba(21,0,255,.24), 0 20px 40px rgba(18,20,40,.18);
}
[data-theme="light"] .flip-back {
  background: radial-gradient(130% 90% at 50% -10%, rgba(63, 98, 0, 0.12), var(--bg-elev-1) 60%);
  border-color: rgba(63, 98, 0, 0.35);
  box-shadow: 0 0 22px rgba(63, 98, 0, 0.12), 0 14px 30px rgba(18, 20, 40, 0.14);
}
[data-theme="light"] .fc-text,
[data-theme="light"] .flip-back .fc-text { text-shadow: none; }
[data-theme="light"] .fc-corner { color: var(--brand); }
[data-theme="light"] .flip-back .fc-corner { color: var(--accent-text); }

@media (max-width: 560px) {
  .flip-inner { min-height: 320px; }
  .flip-face { padding: 22px 18px 16px; border-radius: 18px; }
  .fc-text { font-size: 1.2rem; }
  .flip-back .fc-text { font-size: 1.3rem; }
  .fc-foot { flex-direction: column; gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .flip-inner { transition: none; }
}
