/* ===== SC-500 Flashcards ============================================
   Design concept: a security-operations console, not a SaaS dashboard.
   One accent (signal blue), used for interactive state and progress only.
   Prose sets in the system sans; every number/counter sets in monospace,
   like a telemetry readout. No decorative gradients, no uppercase labels.
   ===================================================================== */
:root {
  --bg-0: #0a0d11;
  --bg-1: #10151b;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --ink: #e7ebee;
  --ink-dim: #7c8a95;
  --explain-ink: #c3ccd3;
  --accent: #2f6fed;
  --accent-ink: #f5f9ff;
  --good: #4ade80;
  --bad: #f36b6b;
  --warn: #f5b84e;
  --shadow-lg: 0 20px 50px -22px rgba(0, 0, 0, 0.65);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-0: #f3f5f7;
  --bg-1: #ffffff;
  --surface: rgba(10, 20, 25, 0.035);
  --surface-strong: rgba(10, 20, 25, 0.06);
  --border: rgba(10, 20, 25, 0.1);
  --border-strong: rgba(10, 20, 25, 0.18);
  --ink: #141a1f;
  --ink-dim: #5c6a73;
  --explain-ink: #3a4650;
  --accent: #1e40af;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc3b3b;
  --warn: #b5760f;
  --shadow-lg: 0 20px 50px -24px rgba(20, 26, 31, 0.18);
  color-scheme: light;
}
[data-theme="light"] .bg-glow { opacity: 0.5; }
[data-theme="light"] .bg-grid { opacity: 0.4; }
[data-theme="light"] .choice-letter { background: rgba(10, 20, 25, 0.06); }
[data-theme="light"] .hero-exam { color: #1e40af; }

* { box-sizing: border-box; }

.hidden { display: none !important; }

.stats-row.cols-3 { grid-template-columns: repeat(3, 1fr); }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

body { position: relative; overflow-x: hidden; }

/* A quiet, static vignette — not a drifting gradient blob field. */
.bg-glow {
  position: fixed;
  inset: 0;
  background: radial-gradient(60% 50% at 50% -10%, rgba(47, 111, 237, 0.08), transparent 70%);
  z-index: 0;
  pointer-events: none;
}

/* Faint console scanlines, the one deliberate texture cue tied to the subject. */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.015) 0px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 1px,
    transparent 3px
  );
  mask-image: radial-gradient(ellipse 85% 65% at 50% 15%, black 30%, transparent 85%);
  z-index: 0;
  pointer-events: none;
}

.screen {
  position: relative;
  z-index: 1;
  display: none;
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  animation: fadeUp 0.4s ease both;
}
.screen.active { display: block; }

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

/* ---- Home ---- */
.hero { padding: 12px 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 28px; text-align: center; }
.hero h1 {
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero-exam {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}
.hero-sub {
  color: var(--ink-dim);
  font-size: 15px;
  line-height: 1.55;
  max-width: 58ch;
  margin: 0 auto 20px;
}
.hero-sub strong { color: var(--ink); font-weight: 600; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 0 28px;
}
.stat-card {
  background: var(--bg-1);
  padding: 16px 10px;
  text-align: center;
}
.stat-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
}
.stat-label { font-size: 12.5px; color: var(--ink-dim); margin-top: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  margin-bottom: 16px;
}
.panel-title { margin: 0 0 14px; font-size: 14px; color: var(--ink-dim); font-weight: 600; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-dim);
  padding: 9px 15px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--border-strong); }
.chip.active {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}


.topic-bars { display: flex; flex-direction: column; gap: 9px; }
.topic-bar-row { display: grid; grid-template-columns: 190px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.topic-bar-name { color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-bar-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.06); overflow: hidden; }
.topic-bar-fill { height: 100%; background: var(--accent); }
.topic-bar-count { text-align: right; color: var(--ink-dim); font-family: var(--mono); font-size: 12px; }

.cta-row { display: flex; justify-content: flex-start; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.complete-box .cta-row { justify-content: center; }

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  padding: 12px 22px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) { background: #4fe3c7; }
[data-theme="light"] .btn-primary:hover:not(:disabled) { background: #1a3696; }
.btn-lg { padding: 15px 28px; font-size: 16px; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-dim);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--border-strong); }
.btn-secondary {
  background: var(--surface-strong);
  border-color: var(--border);
  color: var(--ink);
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-correct { background: rgba(74,222,128,0.12); border-color: rgba(74,222,128,0.5); color: var(--good); }
.btn-correct:hover { background: rgba(74,222,128,0.2); }
.btn-wrong { background: rgba(243,107,107,0.12); border-color: rgba(243,107,107,0.5); color: var(--bad); }
.btn-wrong:hover { background: rgba(243,107,107,0.2); }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }

/* ---- Lab picker screen ---- */
.picker-title { font-size: 20px; font-weight: 700; margin: 0; }
.lab-sections { display: flex; flex-direction: column; gap: 14px; margin: 20px 0; }
.lab-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.lab-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.lab-section-header:hover { background: rgba(255,255,255,0.03); }
.lab-section-title { font-weight: 600; flex: 1; }
.lab-section-count { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); }
.lab-section-chevron { color: var(--ink-dim); transition: transform 0.15s ease; }
.lab-section.open .lab-section-chevron { transform: rotate(90deg); }
.lab-section-body { display: none; padding: 4px 16px 14px; max-height: 420px; overflow-y: auto; }
.lab-section.open .lab-section-body { display: block; }
.lab-section-actions { display: flex; gap: 14px; padding: 0 0 10px; font-size: 12.5px; }
.lab-section-actions a { color: var(--accent); cursor: pointer; text-decoration: none; }
.lab-section-actions a:hover { text-decoration: underline; }
.lab-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 8px;
  margin: 0 -8px;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 6px;
  border-left: 3px solid transparent;
}
.lab-item input { margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
.lab-item-number { font-family: var(--mono); color: var(--ink-dim); flex-shrink: 0; }
.lab-item-text { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-item.answered-correct { border-left-color: var(--good); background: rgba(74,222,128,0.08); }
.lab-item.answered-correct input { accent-color: var(--good); }
.lab-item.answered-incorrect { border-left-color: var(--bad); background: rgba(243,107,107,0.08); }
.lab-item.answered-incorrect input { accent-color: var(--bad); }
.picker-count { font-family: var(--mono); color: var(--ink-dim); font-size: 13px; align-self: center; }

/* ---- Study screen ---- */
.study-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.progress-wrap { flex: 1; }
.progress-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
}
.progress-text { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); }
.score-pill {
  font-family: var(--mono);
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.3);
  color: var(--good);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.3s ease both;
  overflow: hidden;
}
.card-confetti { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 5; }

.streak-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(245, 184, 78, 0.14);
  border: 1px solid rgba(245, 184, 78, 0.4);
  color: var(--warn);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  z-index: 6;
  animation: streakPop 0.3s ease both;
}
.streak-badge.hidden { display: none; }
@keyframes streakPop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid;
}
.badge.hidden { display: none; }
.badge-number { background: transparent; color: var(--ink-dim); border-color: var(--border); font-family: var(--mono); }
.badge-topic { background: rgba(47, 111, 237,0.1); color: #9db8ff; border-color: rgba(47, 111, 237,0.3); }
[data-theme="light"] .badge-topic { color: #1e40af; }
.badge-type { background: transparent; color: var(--ink-dim); border-color: var(--border); }
.badge-validation { background: rgba(245,184,78,0.1); color: var(--warn); border-color: rgba(245,184,78,0.35); }

.case-study-box {
  margin-bottom: 16px;
  border: 1px solid rgba(47, 111, 237,0.3);
  border-radius: 10px;
  background: rgba(47, 111, 237,0.04);
  overflow: hidden;
}
.case-study-box.hidden { display: none; }
.case-study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(47, 111, 237,0.2);
}
.case-study-label { font-size: 13px; font-weight: 700; color: var(--accent); }
.case-study-toggle {
  background: none; border: none; color: var(--accent);
  font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 8px;
  border-radius: 5px; font-family: inherit;
}
.case-study-toggle:hover { background: rgba(47, 111, 237,0.12); }
.case-study-text {
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--ink-dim);
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
}
.case-study-text.hidden { display: none; }

.q-stem {
  font-size: 18px;
  line-height: 1.55;
  font-weight: 600;
  margin: 0 0 22px;
  white-space: pre-wrap;
  max-width: 62ch;
}

.choice-list { display: flex; flex-direction: column; gap: 9px; }
.multi-select-hint {
  margin: -2px 0 2px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}
#btn-submit-multi { margin-top: 4px; align-self: flex-start; }
.choice-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px 15px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice-item:hover:not(.locked) { border-color: var(--accent); background: rgba(47, 111, 237,0.06); }
.choice-letter {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 5px;
  background: rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12.5px;
}
.choice-item.selected { border-color: var(--accent); background: rgba(47, 111, 237,0.1); }
.choice-item.correct { border-color: var(--good); background: rgba(74,222,128,0.1); }
.choice-item.correct .choice-letter { background: var(--good); color: #052e1c; }
.choice-item.incorrect { border-color: var(--bad); background: rgba(243,107,107,0.1); }
.choice-item.incorrect .choice-letter { background: var(--bad); color: #3a0b0b; }
.choice-item.locked { cursor: default; }
/* De-emphasize unselected/wrong options via the letter badge and option
   text only — never via opacity on the whole item, since that would also
   fade .choice-explain and make its wrong-answer reasoning unreadable. */
.choice-item.dim .choice-letter { opacity: 0.45; }
.choice-item.dim .choice-text { color: var(--ink-dim); }

.choice-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice-explain {
  display: none;
  font-size: 13px;
  line-height: 1.5;
  color: var(--explain-ink);
}
.choice-item.locked .choice-explain:not(:empty) { display: block; }
.choice-item.correct .choice-explain { color: #9ae8b8; }
.choice-item.incorrect .choice-explain { color: #f3a9a9; }
[data-theme="light"] .choice-item.correct .choice-explain { color: #0f7a3c; }
[data-theme="light"] .choice-item.incorrect .choice-explain { color: #a82c2c; }

.reveal-area { padding: 10px 0; }
.reveal-area.hidden { display: none; }

.self-grade { padding: 14px 0 4px; animation: fadeUp 0.3s ease both; }
.self-grade.hidden { display: none; }
.self-grade-prompt { color: var(--ink-dim); margin-bottom: 12px; }
.self-grade-btns { display: flex; gap: 12px; }

.result-panel { margin-top: 22px; animation: fadeUp 0.3s ease both; }
.result-panel.hidden { display: none; }
.result-banner {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 18px;
  font-size: 15px;
  border: 1px solid;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: bannerIn 0.3s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes bannerIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.result-banner.good { background: rgba(74,222,128,0.1); color: var(--good); border-color: rgba(74,222,128,0.35); }
.result-banner.bad { background: rgba(243,107,107,0.1); color: var(--bad); border-color: rgba(243,107,107,0.35); }
.result-banner.neutral { background: rgba(47, 111, 237,0.08); color: var(--accent); border-color: rgba(47, 111, 237,0.3); }
.banner-sparkle { width: 18px; height: 18px; flex-shrink: 0; animation: sparkleSpin 0.5s ease both; }
@keyframes sparkleSpin {
  from { transform: rotate(-45deg) scale(0.5); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}
.banner-subline { font-weight: 400; color: var(--ink-dim); font-size: 13px; margin-left: 4px; }

.result-section { margin-bottom: 18px; }
.result-section h3 { margin: 0 0 8px; font-size: 13px; color: var(--ink-dim); font-weight: 600; }
.result-section-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 8px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.result-section-toggle h3 { margin: 0; }
.result-section-chevron { color: var(--ink-dim); transition: transform 0.15s ease; flex-shrink: 0; }
.result-section-toggle[aria-expanded="true"] .result-section-chevron { transform: rotate(90deg); }
.result-section-body.hidden { display: none; }
.result-section p { margin: 0; line-height: 1.6; font-size: 14.5px; white-space: pre-wrap; max-width: 64ch; }
.result-section p.answer-text { color: var(--good); font-weight: 600; font-family: var(--mono); font-size: 13.5px; }

.hint-analogy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint-box, .analogy-box {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.hint-box h3, .analogy-box h3 { margin: 0 0 6px; font-size: 12.5px; }

#section-validation-note p { color: var(--warn); }

.sources-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.sources-list li a {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12.5px;
  text-decoration: none;
  word-break: break-all;
}
.sources-list li a:hover { text-decoration: underline; }

.exhibits-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.exhibits-list.hidden { display: none; }
.exhibits-list img {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: zoom-in;
}
.exhibits-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.exhibits-list-grid img { width: 100%; height: auto; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  cursor: zoom-out;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; }

.nav-row { display: flex; justify-content: space-between; margin-top: 20px; gap: 12px; }

/* ---- Complete screen ---- */
.complete-box { padding: 40px 0; position: relative; text-align: center; }
.complete-badge { width: 92px; height: 92px; margin-bottom: 10px; animation: badgeDrop 0.5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes badgeDrop {
  from { transform: translateY(-16px) scale(0.6); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.complete-box h1 { font-size: 28px; margin-bottom: 8px; font-weight: 700; }
.complete-score {
  font-family: var(--mono);
  font-size: 64px;
  font-weight: 600;
  color: var(--accent);
  margin: 6px 0;
}
.complete-sub { color: var(--ink-dim); margin: 0 auto 18px; max-width: 48ch; }

.complete-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.confetti {
  position: absolute;
  top: -10px;
  width: 7px; height: 12px;
  border-radius: 1px;
  animation: fall linear forwards;
  opacity: 0.85;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .confetti { animation: none; display: none; }
  .screen, .card { animation: none; }
  .btn, .choice-item, .stat-card, .chip { transition: none; }
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .hint-analogy-grid { grid-template-columns: 1fr; }
  .topic-bar-row { grid-template-columns: 110px 1fr 36px; }
  .cta-row { justify-content: stretch; }
  .cta-row .btn { flex: 1; justify-content: center; }
}

/* ===== Phase two: accounts, study groups ============================= */
.auth-widget {
  position: fixed;
  top: 18px;
  right: 64px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-username { font-size: 13px; color: var(--ink-dim); margin-right: 2px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 110;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-dim);
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

.auth-tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 4px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-dim);
  cursor: pointer;
}
.auth-tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.form-label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 14px;
}
.form-label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.form-label input:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 0 0 10px; }

.groups-list { display: flex; flex-direction: column; gap: 8px; }
.group-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.group-row:hover { border-color: var(--accent); }
.group-code { font-family: var(--mono); font-weight: 600; }
.group-meta { color: var(--ink-dim); font-size: 13px; }

.roster-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.roster-table th, .roster-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.roster-table th { color: var(--ink-dim); font-weight: 600; font-size: 12.5px; }

.form-row { display: flex; gap: 8px; margin-top: 6px; }
.form-row input { margin-top: 0; }

.invite-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.invite-name { font-weight: 600; }
.invite-meta { color: var(--ink-dim); font-size: 13px; }
.invite-actions { display: flex; gap: 8px; align-items: center; }
.invite-actions select {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}

.form-textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  min-height: 72px;
  resize: vertical;
}
.form-textarea:focus { outline: none; border-color: var(--accent); }

/* ===== Support tickets ("Ask Charles") ===== */
.support-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 320px; overflow-y: auto; }
.support-ticket-heading { font-size: 12.5px; color: var(--ink-dim); font-weight: 600; margin-top: 6px; }
.support-msg { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; max-width: 85%; }
.support-msg-student { align-self: flex-end; background: var(--surface-strong); }
.support-msg-admin { align-self: flex-start; background: var(--surface); }
.support-msg-meta { font-size: 11.5px; color: var(--ink-dim); margin-bottom: 3px; }
.support-msg-body { font-size: 13.5px; white-space: pre-wrap; }
.support-ticket-row { flex-direction: column; align-items: stretch; gap: 10px; }
.support-ticket-row .support-thread { max-height: 220px; }

/* ===== Landing page (signed out) ===== */
.landing-hero { text-align: left; padding: 32px 0 8px; }
.landing-kicker {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  margin: 0 0 10px;
}
.landing-hero h1 {
  font-size: clamp(30px, 4.4vw, 42px);
  line-height: 1.18;
  max-width: 22ch;
  margin: 0 0 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.landing-lede { margin: 0 auto 0 0; text-align: left; }

.landing-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 28px 0;
}
.landing-step { background: var(--bg-1); padding: 22px 20px; }
.landing-step-num {
  display: block;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}
.landing-step h3 { margin: 0 0 8px; font-size: 15px; }
.landing-step p { margin: 0; color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; }

@media (max-width: 640px) {
  .auth-widget { position: static; justify-content: flex-end; margin: 0 0 12px; }
  .landing-steps { grid-template-columns: 1fr; }
}
