/* ChemQuest design system: tokens first, then layout, then components. */

:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #172033;
  --muted: #586378;
  --border: #dbe1ec;
  --primary: #5b3df5;
  --primary-hover: #4a2ee0;
  --primary-ink: #ffffff;
  --primary-soft: #ece8ff;
  --accent: #0f9d8f;
  --success: #157f3d;
  --success-soft: #e3f6ea;
  --warn: #a35a00;
  --warn-soft: #fff1dc;
  --danger: #c62828;
  --danger-soft: #fde8e8;
  --info: #1d5fc4;
  --info-soft: #e5efff;
  --hero-from: #5b3df5;
  --hero-to: #0f9d8f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 264px;
  --topbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1220;
    --surface: #151c2e;
    --surface-2: #1d2539;
    --text: #e8ecf5;
    --muted: #a0aac0;
    --border: #2a3450;
    --primary: #9b8cff;
    --primary-hover: #b0a4ff;
    --primary-ink: #120d2b;
    --primary-soft: #26204a;
    --accent: #3dd6c4;
    --success: #5fd38d;
    --success-soft: #133222;
    --warn: #f4b55a;
    --warn-soft: #3a2a12;
    --danger: #ff8a80;
    --danger-soft: #3d1a1a;
    --info: #8ab6ff;
    --info-soft: #162a4a;
    --hero-from: #3b2a9e;
    --hero-to: #0b6e65;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1220;
  --surface: #151c2e;
  --surface-2: #1d2539;
  --text: #e8ecf5;
  --muted: #a0aac0;
  --border: #2a3450;
  --primary: #9b8cff;
  --primary-hover: #b0a4ff;
  --primary-ink: #120d2b;
  --primary-soft: #26204a;
  --accent: #3dd6c4;
  --success: #5fd38d;
  --success-soft: #133222;
  --warn: #f4b55a;
  --warn-soft: #3a2a12;
  --danger: #ff8a80;
  --danger-soft: #3d1a1a;
  --info: #8ab6ff;
  --info-soft: #162a4a;
  --hero-from: #3b2a9e;
  --hero-to: #0b6e65;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
}
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.optional { color: var(--muted); font-weight: 400; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 .25rem; font-weight: 600; }
.subhead { font-size: 1rem; margin-top: 1rem; }

/* ---------- App shell ---------- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 1.2rem; }
.brand b { color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}
.nav-burger { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; font-weight: 700;
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip-name { font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-role { font-size: .78rem; color: var(--muted); }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 16px 12px 24px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 20;
}
.nav-group { margin-bottom: 4px; }
.nav-group summary {
  list-style: none; cursor: pointer;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: "▸"; float: right; transition: transform .15s; }
.nav-group[open] summary::after { transform: rotate(90deg); }
.nav-group ul { list-style: none; margin: 0 0 8px; padding: 0; }
.nav-group a, .nav-soon {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .93rem;
}
.nav-group a:hover { background: var(--surface-2); }
.nav-group a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-soon { color: var(--muted); cursor: default; }
.nav-soon small { font-size: .68rem; border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.nav-logout { margin-top: 12px; padding: 0 4px; }
.nav-scrim { display: none; }

.main { margin-left: var(--sidebar-w); padding: 28px 32px 48px; max-width: calc(1200px + var(--sidebar-w)); }

@media (max-width: 900px) {
  .nav-burger { display: inline-grid; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 15; }
  .main { margin-left: 0; padding: 20px 16px 40px; }
  .user-chip-text { display: none; }
  .topbar { padding: 0 12px; }
}

/* ---------- Page structure ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-block; margin-bottom: 6px; font-size: .88rem; text-decoration: none; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.grid-tight { gap: 12px; margin-bottom: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
  min-width: 0;
}
.grid > .card { margin-bottom: 0; }
.card-title { font-size: 1.05rem; margin-bottom: 14px; }
.card-narrow { max-width: 560px; }
.card-flush { padding: 0; overflow: hidden; }
.card-feature { border-top: 4px solid var(--primary); }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }

.hero-banner {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px;
  padding: 28px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .18), transparent 40%),
    linear-gradient(120deg, var(--hero-from), var(--hero-to));
  box-shadow: var(--shadow);
}
.hero-banner h1 { font-size: 1.7rem; margin: 0 0 6px; }
.hero-kicker { margin: 0 0 4px; opacity: .85; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.hero-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-meta span { background: rgba(255, 255, 255, .18); padding: 2px 10px; border-radius: 999px; font-size: .88rem; }
.hero-level { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.hero-level-label { font-size: .8rem; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.hero-level-value { font-size: 2rem; font-weight: 700; }
.hint-on-dark { font-size: .8rem; opacity: .85; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
}
.stat-link:hover { border-color: var(--primary); color: var(--text); }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.progress { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 14px 0 6px; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s ease; }
.progress-sm { height: 6px; margin: 8px 0 2px; }

.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.class-tile {
  display: flex; flex-direction: column; padding: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text); background: var(--surface);
}
.class-tile:hover { border-color: var(--primary); color: var(--text); }
.class-tile-code { font-size: 1.15rem; font-weight: 700; }

/* ---------- Lists & details ---------- */
.list { list-style: none; padding: 0; margin: 0 0 14px; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list-bullets { list-style: disc; padding-left: 20px; }
.list-bullets li { border: 0; padding: 3px 0; }
.details { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 8px 16px; margin: 0 0 14px; }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.chip-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip form { margin: 0; }
.chip-remove { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; width: 24px; height: 24px; border-radius: 50%; }
.chip-remove:hover { background: rgba(0, 0, 0, .08); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table-compact th, .table-compact td { padding: 8px 10px; }
.card:not(.card-flush) .table th:first-child, .card:not(.card-flush) .table td:first-child { padding-left: 0; }
.card:not(.card-flush) .table th { background: transparent; }
.details-cell { max-width: 320px; overflow-wrap: anywhere; font-family: var(--mono); font-size: .8rem; color: var(--muted); }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-role-admin { background: var(--danger-soft); color: var(--danger); }
.badge-role-lecturer { background: var(--info-soft); color: var(--info); }
.badge-role-student { background: var(--primary-soft); color: var(--primary); }

.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: .93rem; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-credential { background: var(--warn-soft); color: var(--text); border: 2px dashed var(--warn); font-family: var(--mono); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
fieldset.field { border: 0; padding: 0; }
legend, label { font-weight: 600; font-size: .9rem; }
.radio { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin-right: 16px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="number"], input[type="datetime-local"], input[type="file"], select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
input[readonly] { background: var(--surface-2); color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 72px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: var(--surface-2); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font: inherit; font-size: .8rem; cursor: pointer;
}
.input-code { font-family: var(--mono); font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; }
.form-row-between { display: flex; justify-content: flex-end; font-size: .9rem; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filters .field { width: 160px; }
.filters .field-grow { flex: 1 1 260px; width: auto; }
.filters .field-sm { width: 110px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 160px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.action-row form { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px;
  font: inherit; font-weight: 600; font-size: .92rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.btn-secondary { background: var(--primary-soft); color: var(--primary); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { min-height: 50px; font-size: 1rem; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; }

.segmented { display: inline-flex; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.segmented a { padding: 6px 14px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; }

/* ---------- Auth pages ---------- */
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; padding: 48px;
  color: #fff;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 255, 255, .16), transparent 35%),
    linear-gradient(140deg, var(--hero-from), var(--hero-to));
}
.auth-hero-inner { position: relative; z-index: 1; max-width: 460px; }
.auth-hero-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; opacity: .85; margin: 24px 0 8px; }
.auth-hero-title { font-size: clamp(2rem, 3.5vw, 2.8rem); font-weight: 800; line-height: 1.1; margin: 0 0 12px; letter-spacing: -.01em; }
.auth-hero-sub { font-size: 1.15rem; opacity: .92; margin: 0 0 28px; }
.auth-hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.auth-hero-points li::before { content: "⚗"; margin-right: 10px; }
.auth-molecule { position: absolute; right: -60px; bottom: -60px; width: 420px; color: #fff; }
.auth-main { position: relative; display: grid; place-items: center; padding: 32px 16px; }
.auth-theme { position: absolute; top: 16px; right: 16px; }
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 32px; box-shadow: var(--shadow);
}
.auth-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
.auth-sub { color: var(--muted); margin: 0 0 22px; }
.auth-alt { margin-top: 18px; text-align: center; font-size: .9rem; color: var(--muted); }
.auth-help { margin-top: 20px; font-size: .9rem; color: var(--muted); }
.auth-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.secret-box { display: grid; gap: 6px; padding: 16px; margin-bottom: 18px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; }
.secret { font-family: var(--mono); font-size: 1.15rem; letter-spacing: .06em; word-break: break-all; color: var(--text); }
.secret-sm { font-size: .78rem; letter-spacing: 0; display: block; }
.error-code { font-size: 3rem; font-weight: 800; margin: 0; color: var(--primary); }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 20px; min-height: 0; }
  .auth-hero-points, .auth-molecule, .auth-hero-inner > img { display: none; }
  .auth-hero-kicker { margin-top: 0; }
  .auth-hero-sub { margin-bottom: 0; font-size: 1rem; }
  .auth-card { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Phase 2: support / demo banner ---------- */
.support-banner {
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px;
  padding: 8px 16px; font-size: .9rem; color: #fff; text-align: center;
}
.support-banner form { margin: 0; }
.support-banner .btn { min-height: 32px; background: #fff; color: #1a1a1a; }
.support-banner-support { background: #b45309; }
.support-banner-demo { background: #6d28d9; }
.support-banner-act { background: #b91c1c; }
.has-support-banner .topbar { top: 48px; }
.has-support-banner .sidebar { top: calc(var(--topbar-h) + 48px); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: .85rem; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.demo-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-bottom: 20px; }
.demo-card { margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.demo-soon { opacity: .7; box-shadow: none; }
textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); resize: vertical;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.badge-info { background: var(--info-soft); color: var(--info); }
.group-row td { background: var(--surface-2); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.details-compact { grid-template-columns: minmax(100px, 30%) 1fr; font-size: .92rem; }

/* ---------- Phase 3: Alchemy SK015 ---------- */
.chapter { padding: 0; overflow: hidden; }
.chapter > :not(summary) { margin-left: 22px; margin-right: 22px; }
.chapter > .level-grid:last-child { margin-bottom: 22px; }
.chapter-head {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 14px;
  padding: 18px 22px;
}
.chapter-head::-webkit-details-marker { display: none; }
.chapter-code {
  grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.2rem; color: #fff; background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
}
.chapter-title { font-weight: 700; font-size: 1.05rem; }
.chapter-meta { color: var(--muted); font-size: .85rem; text-align: right; }
.chapter-bar { grid-column: 2 / 4; margin: 0; }
/* Stage (subtopic) header and game-style level cards (one per LO) */
.stage-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px;
  margin-top: 18px; margin-bottom: 12px;
}
.stage-code { font-family: var(--mono); font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 2px 10px; border-radius: 999px; }
.stage-title { font-weight: 700; }
.stage-count { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage-bar { grid-column: 1 / -1; margin: 0; }

.level-grid {
  list-style: none; padding: 0; margin: 0 0 8px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: 14px;
}
.level-card { --lv: var(--primary); --lv-soft: var(--primary-soft); }
.level-in_progress { --lv: #d97706; --lv-soft: var(--warn-soft); }
.level-completed { --lv: var(--info); --lv-soft: var(--info-soft); }
.level-mastered { --lv: #c08a00; --lv-soft: #fff4cc; }
.level-locked { --lv: var(--muted); --lv-soft: var(--surface-2); }
:root[data-theme="dark"] .level-mastered { --lv: #f5c542; --lv-soft: #3a2f0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .level-mastered { --lv: #f5c542; --lv-soft: #3a2f0b; } }

.level-card-inner {
  position: relative; height: 100%; min-height: 188px;
  display: flex; flex-direction: column; gap: 8px; padding: 14px;
  border: 2px solid var(--lv); border-bottom-width: 6px; border-radius: 18px;
  background: linear-gradient(180deg, var(--lv-soft), var(--surface) 70%);
  color: var(--text); text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
a.level-card-inner:hover { transform: translateY(-4px); box-shadow: 0 10px 22px rgba(0, 0, 0, .15); color: var(--text); }
a.level-card-inner:active { transform: translateY(1px); }
.level-top { display: flex; align-items: center; justify-content: space-between; }
.level-code { font-family: var(--mono); font-size: 1.35rem; font-weight: 800; color: var(--lv); }
.level-icon { font-size: 1.4rem; line-height: 1; }
.level-title {
  flex: 1; font-size: .82rem; line-height: 1.35; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.level-stars { display: flex; gap: 2px; font-size: 1.35rem; line-height: 1; }
.star { color: var(--border); }
.star.is-on { color: #f5b301; text-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
.level-cta {
  align-self: stretch; text-align: center; font-weight: 800; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 7px 10px; border-radius: 999px; background: var(--lv); color: #fff;
}
.level-locked .level-card-inner { opacity: .55; border-style: dashed; }
.level-locked .level-cta { background: var(--surface-2); color: var(--muted); }
.level-mastered .level-card-inner { box-shadow: 0 0 0 3px rgba(245, 179, 1, .25); }
.is-next .level-card-inner { animation: level-glow 1.6s ease-in-out infinite; }
@keyframes level-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91, 61, 245, .45); }
  50% { box-shadow: 0 0 0 8px rgba(91, 61, 245, 0); }
}
.lo-description { max-width: 760px; margin: 4px 0 0; }

.question-row { padding: 16px 20px; margin-bottom: 12px; }
.question-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.question-row-head .btn { margin-left: auto; }
.question-row .question-stem { font-size: 1rem; margin: 10px 0; }
.option-edit { display: flex; align-items: center; gap: 10px; }
.option-edit input[type="text"] { flex: 1; }
.option-edit input[type="radio"] { width: 18px; height: 18px; }

.confetti { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; pointer-events: none; animation: confetti-fall 1.8s ease-in forwards; }
@keyframes confetti-fall { to { transform: translateY(420px) rotate(540deg); opacity: 0; } }
@media (max-width: 600px) {
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .level-card-inner { min-height: 170px; padding: 12px; }
  .chapter-meta { grid-column: 2; text-align: left; }
}

/* ---------- Admin question bank previews ---------- */
.question-stem { font-size: 1.08rem; font-weight: 600; margin: 8px 0 18px; white-space: pre-line; }
.option-letter {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center;
  background: var(--surface-2); font-weight: 700; font-size: .85rem;
}
.option-review { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.option-review li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.option-review li.is-correct { border-color: var(--success); background: var(--success-soft); }
.option-review-compact li { padding: 6px 10px; font-size: .92rem; }

/* ---------- Alchemy play screen (question, feedback, result) ---------- */
.quest-head { max-width: 820px; margin-bottom: 16px; }
.quest-title { display: flex; align-items: center; gap: 14px; }
.quest-lo {
  flex: none; padding: 10px 14px; border-radius: 16px; color: #fff; box-shadow: var(--shadow);
  font-family: var(--mono); font-weight: 800; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
}
.quest-desc { margin: 2px 0 0; font-weight: 600; }

.play-card {
  position: relative; overflow: hidden; max-width: 820px; margin-bottom: 20px; padding: 24px 22px 22px;
  border: 1px solid var(--border); border-radius: 24px; background: var(--surface);
  box-shadow: 0 3px 0 var(--border), var(--shadow);
}
.play-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg, #6a45f5, #0b8585, #cf3f35, #e59e00);
}
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.q-dots { list-style: none; display: flex; gap: 8px; margin: 0; padding: 0; }
.q-dots li {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; color: var(--muted); background: var(--surface-2); border: 2px solid var(--border);
}
.q-dots li.is-done { color: #fff; background: var(--success); border-color: var(--success); }
.q-dots li.is-now { color: var(--primary-ink); background: var(--primary); border-color: var(--primary); transform: scale(1.12); }
.timer-ring { position: relative; flex: none; width: 64px; height: 64px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke .3s; }
.timer-ring.is-low .ring-fg { stroke: #f97316; }
.timer-ring.is-late .ring-fg { stroke: var(--border); }
.timer-text { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-weight: 800; font-size: .8rem; }
.play-stem { margin: 10px 0 20px; font-size: clamp(1.1rem, 2.4vw, 1.35rem); font-weight: 700; line-height: 1.45; white-space: pre-line; }

.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  --opt: #6a45f5; --opt-ink: #fff;
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 78px; padding: 14px 16px;
  border: 2px solid var(--opt); border-bottom-width: 6px; border-radius: 18px;
  background: color-mix(in srgb, var(--opt) 12%, var(--surface)); color: var(--text);
  font-weight: 600; line-height: 1.35;
}
.tile-a { --opt: #6a45f5; }
.tile-b { --opt: #0b8585; }
.tile-c { --opt: #cf3f35; }
.tile-d { --opt: #e59e00; --opt-ink: #1f1500; }
.tile-true { --opt: #128a45; }
.tile-false { --opt: #cc2f35; }
.tile-badge {
  flex: none; width: 40px; height: 44px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.05rem; color: var(--opt-ink); background: var(--opt);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.tile-text { flex: 1; overflow-wrap: anywhere; }
.tile-pick { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.tile-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tile-pick:hover { transform: translateY(-3px); box-shadow: 0 8px 18px color-mix(in srgb, var(--opt) 30%, transparent); }
.tile-pick:active { transform: translateY(2px); border-bottom-width: 3px; }
.tile-pick:has(input:checked) {
  background: var(--opt); color: var(--opt-ink); transform: translateY(-3px);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--opt) 35%, transparent);
}
.tile-pick:has(input:checked) .tile-badge { background: var(--surface); color: var(--opt); }
.tile-pick:has(input:checked)::after {
  content: "\2714"; position: absolute; top: -10px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: .9rem; color: var(--opt); background: var(--surface); box-shadow: var(--shadow);
}
.tile-pick:has(input:focus-visible) { outline: 3px solid var(--text); outline-offset: 3px; }
.plain-fieldset[disabled] .tile-pick { cursor: not-allowed; opacity: .7; }
.tile-grid-tf .tile { justify-content: center; min-height: 96px; font-size: 1.2rem; font-weight: 800; }
.tile-grid-tf .tile-text { flex: none; }
.lock-in { min-height: 56px; border-radius: 16px; font-size: 1.1rem; letter-spacing: .04em; }
.lock-in:disabled { opacity: .45; cursor: not-allowed; }
.center { text-align: center; }

.tile-right { --opt: #128a45; background: color-mix(in srgb, #128a45 18%, var(--surface)); }
.tile-miss { --opt: #cc2f35; background: color-mix(in srgb, #cc2f35 15%, var(--surface)); }
.tile-dim { opacity: .5; }
.tile-flag {
  position: absolute; top: -11px; right: 12px; padding: 2px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--opt);
}
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 4px 0 6px; }
.verdict-emoji { font-size: 2.4rem; line-height: 1; }
.verdict-title { margin: 0; font-size: 1.7rem; font-weight: 800; }
.verdict-sub { margin: 0; font-size: .85rem; color: var(--muted); }
.is-correct .verdict-title { color: var(--success); }
.is-wrong .verdict-title { color: var(--danger); }
.verdict .xp-chip { margin-left: auto; }
.xp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-weight: 800; color: var(--primary-ink); background: var(--primary); }
.xp-chip small { font-weight: 700; opacity: .9; }
.xp-chip-gold { color: #2a1c00; background: #f5b301; }
.pop { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.explain-box { margin-bottom: 16px; padding: 14px 16px; border-left: 5px solid var(--accent); border-radius: 16px; background: var(--surface-2); }
.explain-label { font-weight: 800; color: var(--accent); }
.play-next { border-radius: 16px; }

.result-card, .start-card { text-align: center; }
.result-kicker { margin: 6px 0; font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.result-stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0; }
.big-star { font-size: 3rem; line-height: 1; color: var(--border); }
.big-star.is-on { color: #f5b301; text-shadow: 0 3px 0 #c98a00; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.big-star.is-on:nth-child(2) { animation-delay: .15s; }
.big-star.is-on:nth-child(3) { animation-delay: .3s; }
.result-score { margin: 4px 0; font-size: 2.2rem; font-weight: 800; }
.result-score span { font-size: 1rem; font-weight: 600; color: var(--muted); }
.ribbon {
  display: inline-block; margin: 6px 0 12px; padding: 8px 22px; border-radius: 999px;
  font-weight: 800; letter-spacing: .06em; color: #2a1c00; background: linear-gradient(90deg, #ffd75e, #f5b301); box-shadow: 0 4px 0 #c98a00;
}
.xp-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
.result-total { margin: 6px 0 12px; font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.level-up-banner { display: inline-block; padding: 8px 18px; border-radius: 14px; font-weight: 800; color: #fff; background: linear-gradient(90deg, var(--hero-from), var(--hero-to)); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
.result-actions form { margin: 0; }
.start-emblem {
  width: 96px; height: 104px; margin: 8px auto 4px; display: grid; place-items: center; font-size: 2.6rem;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.start-btn { min-width: 220px; border-radius: 16px; font-size: 1.15rem; letter-spacing: .06em; box-shadow: 0 5px 0 color-mix(in srgb, var(--primary) 60%, #000); }
.history-card { max-width: 820px; }
.attempt-list { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.attempt-list li { display: flex; align-items: center; gap: 12px; }
.attempt-stars { font-size: 1.1rem; }

@media (max-width: 600px) {
  .tile-grid { grid-template-columns: 1fr; }
  .tile-grid-tf { grid-template-columns: 1fr 1fr; }
  .play-card { padding: 20px 14px 16px; border-radius: 20px; }
  .big-star { font-size: 2.4rem; }
}

/* "Learning set complete" popup */
.result-modal {
  width: min(560px, calc(100% - 32px)); max-height: calc(100vh - 32px);
  padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible;
}
.result-modal:modal { animation: modal-in .35s cubic-bezier(.2, 1.4, .4, 1); }
.result-modal:not(:modal) { position: static; margin: 0 0 20px; }
.result-modal::backdrop { background: rgba(14, 10, 40, .62); backdrop-filter: blur(3px); }
.result-modal .play-card { margin: 0; max-height: calc(100vh - 32px); overflow-y: auto; }
@keyframes modal-in { from { transform: translateY(24px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close-form { position: absolute; top: 14px; right: 14px; z-index: 2; margin: 0; }
.modal-close {
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 50%;
  font-size: 1.3rem; line-height: 1; color: var(--text); background: var(--surface); cursor: pointer;
}
.modal-close:hover { background: var(--surface-2); }
.review-link { margin-top: 14px; font-size: .9rem; }

/* =====================================================================
   Vibrant theme: colourful sidebar, pastel page, gradient stat cards.
   Placed last so it refines the base components above.
   ===================================================================== */
:root {
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --bg: #f4f1ff;
  --primary: #6a3df0;
  --primary-hover: #5a2ee0;
  --primary-soft: #ede7ff;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(60, 30, 140, .06), 0 10px 30px rgba(76, 29, 149, .09);
  --side-from: #2a1673;
  --side-mid: #4a23c9;
  --side-to: #7c3aed;
  --blob-1: rgba(255, 170, 210, .45);
  --blob-2: rgba(120, 230, 205, .40);
  --blob-3: rgba(150, 170, 255, .40);
}
:root[data-theme="dark"] {
  --bg: #0f0c1f;
  --surface: #191530;
  --surface-2: #231d40;
  --border: #322a58;
  --primary: #a48bff;
  --primary-hover: #b8a5ff;
  --primary-soft: #2b2252;
  --side-from: #120a33;
  --side-mid: #22135e;
  --side-to: #3b1d8f;
  --blob-1: rgba(219, 39, 119, .16);
  --blob-2: rgba(13, 148, 136, .16);
  --blob-3: rgba(99, 102, 241, .18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0c1f;
    --surface: #191530;
    --surface-2: #231d40;
    --border: #322a58;
    --primary: #a48bff;
    --primary-hover: #b8a5ff;
    --primary-soft: #2b2252;
    --side-from: #120a33;
    --side-mid: #22135e;
    --side-to: #3b1d8f;
    --blob-1: rgba(219, 39, 119, .16);
    --blob-2: rgba(13, 148, 136, .16);
    --blob-3: rgba(99, 102, 241, .18);
  }
}

body.app-shell, body.auth-shell {
  background:
    radial-gradient(circle at 15% 6%, var(--blob-1) 0, transparent 30%),
    radial-gradient(circle at 92% 14%, var(--blob-2) 0, transparent 32%),
    radial-gradient(circle at 60% 96%, var(--blob-3) 0, transparent 38%),
    var(--bg);
  background-attachment: fixed;
}
h1 { font-weight: 800; }

/* ---------- Top bar ---------- */
.topbar { background: color-mix(in srgb, var(--surface) 80%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.brand span { font-weight: 700; }
.brand b {
  background: linear-gradient(90deg, #7c3aed, #db2777 60%, #f59e0b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.avatar { background: linear-gradient(135deg, #7c3aed, #db2777); }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--side-from) 0%, var(--side-mid) 55%, var(--side-to) 100%);
  border-right: 0; color: #fff; padding: 18px 12px 24px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent;
}
.nav-group { margin-bottom: 6px; }
.nav-group summary {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  color: rgba(255, 255, 255, .92); font-size: .74rem; letter-spacing: .09em;
}
.nav-group summary:hover { background: rgba(255, 255, 255, .08); }
.nav-group summary::after { margin-left: auto; color: rgba(255, 255, 255, .6); }
.nav-group-label { flex: 1; }
.nav-chip {
  flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
}
.nav-chip .icon { width: 17px; height: 17px; }
.nav-violet { --c1: #c4b5fd; --c2: #7c3aed; }
.nav-teal { --c1: #5eead4; --c2: #0d9488; }
.nav-coral { --c1: #fda4af; --c2: #e11d48; }
.nav-amber { --c1: #fde68a; --c2: #d97706; }
.nav-blue { --c1: #93c5fd; --c2: #2563eb; }
.nav-pink { --c1: #f9a8d4; --c2: #db2777; }
.nav-green { --c1: #86efac; --c2: #16a34a; }
.nav-slate { --c1: #cbd5e1; --c2: #475569; }
.nav-group ul { margin: 2px 0 10px; padding-left: 6px; }
.nav-group a, .nav-soon {
  justify-content: flex-start; gap: 10px; padding: 8px 12px; border-radius: 12px;
  color: rgba(255, 255, 255, .86); font-size: .9rem; font-weight: 500;
}
.nav-group a .icon, .nav-soon .icon { flex: none; width: 18px; height: 18px; opacity: .9; }
.nav-group a > span, .nav-soon > span { flex: 1; }
.nav-group a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-group a[aria-current="page"] {
  background: #fff; color: var(--side-mid); font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .22);
}
.nav-group a[aria-current="page"] .icon { color: var(--c2); opacity: 1; }
.nav-soon { color: rgba(255, 255, 255, .45); }
.nav-soon small { border-color: rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .6); }
.nav-logout { margin-top: 16px; }
.nav-logout-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px;
  font: inherit; font-weight: 700; color: #fff; cursor: pointer;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25); border-radius: 14px;
}
.nav-logout-btn:hover { background: rgba(255, 255, 255, .2); }
.nav-logout-btn .icon { width: 18px; height: 18px; }
.icon { width: 20px; height: 20px; }

/* ---------- Cards & headings ---------- */
.card { border: 0; box-shadow: var(--shadow); }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.card-title::before {
  content: ""; flex: none; width: 6px; height: 20px; border-radius: 4px;
  background: linear-gradient(180deg, #7c3aed, #db2777);
}
.card-feature { border-top: 0; background: linear-gradient(180deg, var(--primary-soft), var(--surface) 55%); }
.table th { background: var(--primary-soft); color: var(--primary); }
.card-flush { border-radius: var(--radius); }

/* ---------- Gradient stat cards ---------- */
.stat {
  position: relative; overflow: hidden; border: 0; color: #fff; padding: 18px 20px;
  box-shadow: 0 10px 24px rgba(76, 29, 149, .16);
}
.stat::after {
  content: ""; position: absolute; right: -26px; top: -26px; width: 96px; height: 96px; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
}
.stat-row > .stat:nth-child(4n+1) { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.stat-row > .stat:nth-child(4n+2) { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.stat-row > .stat:nth-child(4n+3) { background: linear-gradient(135deg, #be123c, #f43f5e); }
.stat-row > .stat:nth-child(4n+4) { background: linear-gradient(135deg, #b45309, #ea8a0c); }
.stat-label { color: rgba(255, 255, 255, .9); font-weight: 600; }
.stat-value { color: #fff; }
.stat .hint { color: rgba(255, 255, 255, .88); }
.stat .progress { background: rgba(255, 255, 255, .3); }
.stat .progress > span { background: #fff; }
.stat-link:hover { color: #fff; transform: translateY(-3px); }
.stat-link { transition: transform .15s ease; }

/* ---------- Hero banner ---------- */
.hero-banner {
  position: relative; overflow: hidden; border-radius: 26px;
  background: linear-gradient(120deg, #5b21b6 0%, #9333ea 40%, #db2777 75%, #f59e0b 100%);
  box-shadow: 0 14px 34px rgba(124, 58, 237, .28);
}
.hero-banner::before, .hero-banner::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); pointer-events: none; }
.hero-banner::before { width: 260px; height: 260px; right: -60px; top: -120px; }
.hero-banner::after { width: 140px; height: 140px; right: 180px; bottom: -80px; }
.hero-banner > * { position: relative; z-index: 1; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #a21caf); color: #fff;
  box-shadow: 0 4px 0 #4c1d95; border: 0;
}
.btn-primary:hover { background: linear-gradient(135deg, #6d28d9, #86198f); color: #fff; }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #4c1d95; }
.btn-secondary { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.btn { border-radius: 14px; }

/* ---------- Auth pages ---------- */
.auth-hero { background: radial-gradient(circle at 15% 15%, rgba(255, 255, 255, .18), transparent 35%), linear-gradient(140deg, #4c1d95, #9333ea 45%, #db2777 80%, #f59e0b); }
.auth-card { border: 0; border-radius: 26px; box-shadow: 0 20px 50px rgba(76, 29, 149, .18); }
.auth-title {
  background: linear-gradient(90deg, #6d28d9, #db2777); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Chapter cards on the level map ---------- */
.chapter { border-radius: 24px; }
.chapter-code { background: linear-gradient(135deg, #7c3aed, #db2777); box-shadow: 0 4px 10px rgba(124, 58, 237, .35); }

/* ---------- Student dashboard ---------- */
.top-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: .85rem; white-space: nowrap; }
.top-chip-xp { background: var(--primary-soft); color: var(--primary); }
.top-chip-token { background: #fff4cc; color: #8a5a00; }
:root[data-theme="dark"] .top-chip-token { background: #3a2f0b; color: #f5c542; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .top-chip-token { background: #3a2f0b; color: #f5c542; } }

.dash-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 24px; align-items: center;
  margin-bottom: 20px; padding: 30px; border-radius: 28px; color: #fff;
  background: radial-gradient(circle at 85% 110%, rgba(56, 189, 248, .55), transparent 45%), linear-gradient(115deg, #6d28d9 0%, #8b5cf6 45%, #6366f1 75%, #0ea5e9 100%);
  box-shadow: 0 16px 40px rgba(109, 40, 217, .3);
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.hero-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700; background: rgba(255, 255, 255, .2); }
.hero-chip .icon { width: 15px; height: 15px; }
.dash-hero-title { margin: 0 0 8px; font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 800; line-height: 1.15; }
.dash-hero-text { margin: 0 0 20px; font-size: 1.02rem; opacity: .95; }
.dash-hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.dash-hero-actions form { margin: 0; }
.hero-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 20px; border: 0; border-radius: 14px;
  font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .12s ease;
}
.hero-btn .icon { width: 18px; height: 18px; }
.hero-btn:hover { transform: translateY(-2px); }
.hero-btn-light { background: #fff; color: #4c1d95; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.hero-btn-light:hover { color: #4c1d95; }
.hero-btn-gold { background: #fbbf24; color: #3b2600; box-shadow: 0 4px 0 #b7791f; }
.hero-btn-done { background: rgba(255, 255, 255, .18); color: #fff; cursor: default; font-weight: 700; }
.hero-btn-done:hover { transform: none; }

.rank-panel {
  position: relative; overflow: hidden; padding: 20px; border-radius: 20px;
  background: rgba(30, 20, 80, .35); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(6px);
}
.rank-top { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rank-label, .rank-xp-label { font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.rank-tier { font-size: 1.5rem; font-weight: 800; }
.rank-tier small { font-size: .85rem; font-weight: 700; color: #fde68a; }
.rank-xp { font-size: .9rem; opacity: .9; }
.rank-xp strong { font-size: 1.5rem; opacity: 1; }
.rank-bar { position: relative; z-index: 1; display: block; height: 12px; margin: 14px 0 10px; border-radius: 999px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.rank-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #fbbf24, #fde047); transition: width .6s ease; }
.rank-foot { font-size: .82rem; opacity: .9; }
.rank-atom { position: absolute; right: -30px; bottom: -40px; width: 150px; height: 150px; fill: none; stroke: rgba(255, 255, 255, .18); stroke-width: .8; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
  border-bottom: 4px solid var(--k); transition: transform .15s ease;
}
a.kpi:hover { transform: translateY(-3px); color: var(--text); }
.kpi-head { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-head .icon { width: 20px; height: 20px; color: var(--k); }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--k); line-height: 1.15; }
.kpi-value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.kpi-sub { font-size: .85rem; color: var(--muted); }
.kpi-violet { --k: #7c3aed; } .kpi-teal { --k: #0d9488; } .kpi-amber { --k: #d97706; } .kpi-pink { --k: #db2777; } .kpi-blue { --k: #2563eb; }
:root[data-theme="dark"] .kpi-violet { --k: #a78bfa; } :root[data-theme="dark"] .kpi-teal { --k: #2dd4bf; } :root[data-theme="dark"] .kpi-amber { --k: #fbbf24; } :root[data-theme="dark"] .kpi-pink { --k: #f472b6; } :root[data-theme="dark"] .kpi-blue { --k: #60a5fa; }
.coin { font-size: 1.4rem; }

.activity-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 16px; margin-bottom: 20px; }
.activity-card {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: 20px; text-decoration: none; color: var(--text);
  background: var(--surface); box-shadow: var(--shadow); border-top: 5px solid var(--a); transition: transform .15s ease;
}
a.activity-card:hover { transform: translateY(-4px); color: var(--text); }
.activity-emoji { font-size: 2rem; line-height: 1.2; }
.activity-title { font-weight: 800; font-size: 1.05rem; }
.activity-sub { font-size: .85rem; color: var(--muted); }
.activity-card.is-soon { opacity: .6; }
.act-teal { --a: #14b8a6; } .act-violet { --a: #8b5cf6; } .act-amber { --a: #f59e0b; } .act-pink { --a: #ec4899; } .act-coral { --a: #f43f5e; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.dash-grid .card { margin-bottom: 20px; }
.dash-side { display: grid; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head .card-title { margin-bottom: 2px; }
.card-head p { margin: 0; }
.chapter-progress-list { display: grid; gap: 12px; }
.chapter-progress { padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; }
.cp-top, .cp-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; align-items: baseline; }
.cp-bar { display: block; height: 10px; margin: 10px 0 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cp-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--cp); transition: width .6s ease; }
.cp-link { font-weight: 700; font-size: .88rem; text-decoration: none; color: var(--cp); }
.cp-0 { --cp: #0ea5e9; } .cp-1 { --cp: #8b5cf6; } .cp-2 { --cp: #10b981; } .cp-3 { --cp: #f59e0b; } .cp-4 { --cp: #ec4899; } .cp-5 { --cp: #6366f1; } .cp-6 { --cp: #ef4444; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 16px; }
.mini-stats div { display: flex; flex-direction: column; align-items: center; padding: 14px 8px; border-radius: 14px; background: var(--surface-2); text-align: center; }
.mini-stats strong { font-size: 1.4rem; font-weight: 800; }
.mini-stats span { font-size: .8rem; color: var(--muted); }
.text-green { color: var(--success); }

.weak-list, .feed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.weak-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.weak-code { display: block; font-weight: 800; color: var(--danger); font-size: .9rem; }
.weak-desc { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; font-size: .88rem; font-weight: 600; }
.btn-boost { background: #16a34a; color: #fff; flex: none; }
.btn-boost:hover { background: #15803d; color: #fff; }
.feed-list li { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; }
.feed-dot { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--info-soft); }
.feed-dot.is-gold { background: #fff4cc; }
.empty-note { margin: 0; padding: 14px; border-radius: 14px; background: var(--surface-2); color: var(--muted); font-size: .9rem; }
.token-gain { color: #b7791f; }

@media (max-width: 1000px) {
  .dash-hero, .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .top-chip { display: none; }
}

/* ---------- Celebration (all activities) ---------- */
.confetti-boom {
  position: absolute; left: 50%; top: 32%; z-index: 5; width: 10px; height: 14px; border-radius: 2px; pointer-events: none;
  animation: boom 2.4s cubic-bezier(.12, .7, .3, 1) forwards;
}
.confetti-boom.is-round { width: 9px; height: 9px; border-radius: 50%; }
@keyframes boom {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  55% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 320px)) rotate(calc(var(--rot) * 1.6)); opacity: 0; }
}
[data-levelup] .level-up-banner { animation: levelup-pulse 1.2s ease-in-out .9s 3; }
@keyframes levelup-pulse { 50% { transform: scale(1.12); box-shadow: 0 0 0 10px rgba(251, 191, 36, .35); } }
.result-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.rt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 6px; border-radius: 16px; color: #fff; }
.rt strong { font-size: 1.5rem; font-weight: 800; }
.rt span { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .9; }
.rt-violet { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.rt-amber { background: linear-gradient(135deg, #b45309, #f59e0b); }
.rt-teal { background: linear-gradient(135deg, #0f766e, #14b8a6); }

/* ---------- Training Centre ---------- */
.mode-hero {
  margin-bottom: 20px; padding: 24px 26px; border-radius: 24px; background: var(--surface);
  border-left: 6px solid #10b981; box-shadow: var(--shadow);
}
.mode-hero h1 { margin: 10px 0 6px; font-size: clamp(1.4rem, 3vw, 2rem); }
.mode-hero p { margin: 0; color: var(--muted); }
.mode-pill { display: inline-block; padding: 5px 14px; border-radius: 999px; font-size: .82rem; font-weight: 800; background: #d1fae5; color: #065f46; }
.builder-card .card-title .icon { color: #10b981; }
.builder-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.builder-grid label { font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }
.builder-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.builder-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-go { background: linear-gradient(135deg, #059669, #10b981); color: #fff; box-shadow: 0 4px 0 #047857; }
.btn-go:hover { color: #fff; background: linear-gradient(135deg, #047857, #059669); }
.btn-go:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.btn-go .icon { width: 18px; height: 18px; }
.btn-weak { background: #fef3c7; color: #92400e; font-weight: 800; }
.btn-weak:hover { background: #fde68a; color: #78350f; }
.drill-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.drill-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.drill-list a { font-weight: 700; }
.section-title { margin: 26px 0 12px; font-size: 1.25rem; font-weight: 800; }

.topic-block { margin-bottom: 18px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.topic-head {
  list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  padding: 18px 22px; color: #fff; background: linear-gradient(120deg, var(--tb1), var(--tb2));
}
.topic-head::-webkit-details-marker { display: none; }
.topic-title { font-weight: 800; font-size: 1.1rem; }
.topic-count { padding: 4px 12px; border-radius: 999px; font-size: .8rem; font-weight: 800; background: rgba(255, 255, 255, .22); }
.tb-0 { --tb1: #1e1b4b; --tb2: #4338ca; } .tb-1 { --tb1: #4c1d95; --tb2: #9333ea; } .tb-2 { --tb1: #064e3b; --tb2: #0d9488; }
.tb-3 { --tb1: #7c2d12; --tb2: #ea580c; } .tb-4 { --tb1: #831843; --tb2: #db2777; } .tb-5 { --tb1: #1e3a8a; --tb2: #2563eb; } .tb-6 { --tb1: #7f1d1d; --tb2: #dc2626; }
.topic-sub { margin: 18px 22px 10px; font-size: 1rem; }
.lo-quest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; padding: 0 22px 22px; }
.lo-quest {
  display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 16px; border-radius: 18px;
  background: color-mix(in srgb, var(--tb2) 6%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tb2) 25%, var(--border));
}
.lo-quest.is-empty { opacity: .6; }
.lo-quest-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lo-quest-code { padding: 3px 10px; border-radius: 8px; font-family: var(--mono); font-weight: 800; font-size: .85rem; color: var(--tb2); background: color-mix(in srgb, var(--tb2) 14%, var(--surface)); }
.mastery-pill { padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 800; }
.m-good { background: #d1fae5; color: #065f46; } .m-mid { background: #fef3c7; color: #92400e; }
.m-low { background: #fee2e2; color: #991b1b; } .m-none { background: var(--surface-2); color: var(--muted); }
.lo-quest-eyebrow { margin: 0; font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--tb2); }
.lo-quest-text { flex: 1; margin: 0; font-size: .92rem; font-weight: 600; }
.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.diff-btn { padding: 7px 4px; border-radius: 10px; font: inherit; font-size: .78rem; font-weight: 800; cursor: pointer; border: 1px solid; }
.diff-btn:disabled { opacity: .4; cursor: not-allowed; }
.diff-easy { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.diff-medium { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.diff-hard { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }

/* ---------- Training drill player ---------- */
.drill-head {
  margin-bottom: 18px; padding: 22px 24px; border-radius: 24px; color: #fff;
  background: linear-gradient(120deg, #1d4ed8, #2563eb 45%, #0ea5e9); box-shadow: 0 12px 30px rgba(37, 99, 235, .3);
}
.drill-head-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drill-kicker { margin: 0 0 4px; font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.drill-pill { padding: 3px 10px; border-radius: 8px; background: rgba(255, 255, 255, .22); }
.drill-title { margin: 0; font-size: clamp(1.2rem, 2.6vw, 1.6rem); color: #fff; }
.drill-head-actions { display: flex; gap: 10px; }
.drill-timer, .drill-exit {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 12px;
  font-weight: 800; color: #fff; text-decoration: none; background: rgba(255, 255, 255, .2);
}
.drill-timer .icon { width: 18px; height: 18px; }
.drill-timer .timer-text { position: static; display: inline; font-size: .95rem; font-variant-numeric: tabular-nums; }
.drill-timer.is-late { opacity: .6; }
.drill-exit:hover { color: #fff; background: rgba(255, 255, 255, .3); }
.drill-progress-label { display: flex; justify-content: space-between; margin: 16px 0 6px; font-size: .85rem; font-weight: 700; }
.drill-bar { display: block; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.drill-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: #fff; transition: width .5s ease; }
.drill-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.drill-card { max-width: none; }
.q-badges { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.q-badge { padding: 4px 12px; border-radius: 999px; font-size: .8rem; font-weight: 800; }
.q-badge-dark { background: #1e1b4b; color: #fff; }
.q-badge-lo { background: var(--primary-soft); color: var(--primary); }
.q-badge-easy { background: #d1fae5; color: #065f46; } .q-badge-medium { background: #fef3c7; color: #92400e; } .q-badge-hard { background: #fee2e2; color: #991b1b; }
.drill-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.drill-nav-right { display: flex; flex-wrap: wrap; gap: 10px; }
.drill-nav-right form { margin: 0; }
.btn-next { background: linear-gradient(135deg, #0284c7, #0ea5e9); color: #fff; box-shadow: 0 4px 0 #0369a1; }
.btn-next:hover { color: #fff; }
.btn-finish { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; box-shadow: 0 4px 0 #5b21b6; }
.btn-finish:hover { color: #fff; }
.drill-side { display: grid; gap: 16px; }
.drill-side .card { margin: 0; }
.nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.nav-cell {
  display: grid; place-items: center; height: 44px; border-radius: 12px; font-weight: 800; text-decoration: none;
  color: var(--text); background: var(--surface-2); border: 2px solid transparent;
}
.nav-cell.is-right { background: #d1fae5; color: #065f46; }
.nav-cell.is-wrong { background: #fee2e2; color: #991b1b; }
.nav-cell.is-current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.magic-panel .card-title .icon { color: #a855f7; }
.token-count { font-weight: 800; color: #b45309; }
.magic-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); opacity: .75; }
.magic-item div { display: flex; flex-direction: column; }
.magic-item span:not(.badge) { font-size: .78rem; color: var(--muted); }

@media (max-width: 1000px) { .drill-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .result-tiles { grid-template-columns: 1fr; } }

/* ---------- Alchemy LO page with side panel ---------- */
.quest-layout { display: grid; grid-template-columns: minmax(0, 820px) minmax(260px, 340px); gap: 20px; align-items: start; }
.quest-main > .play-card, .quest-main > .card { max-width: none; }
.quest-side { display: grid; gap: 16px; }
.quest-side .card { margin: 0; }
.side-card { padding: 18px; }
.side-card .card-title { font-size: 1rem; margin-bottom: 10px; }
.side-kicker { margin: 0 0 4px; font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.side-journey { color: #fff; background: linear-gradient(135deg, #6d28d9, #9333ea 55%, #db2777); }
.side-level { margin: 0; font-size: 1.25rem; font-weight: 800; }
.side-bar { display: block; height: 10px; margin: 10px 0 6px; border-radius: 999px; background: rgba(255, 255, 255, .28); overflow: hidden; }
.side-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #fbbf24, #fde047); transition: width .6s ease; }
.side-small { margin: 0 0 12px; font-size: .82rem; opacity: .9; }
.side-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.side-stats div { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.side-journey .side-stats div { background: rgba(255, 255, 255, .16); }
.side-stats strong { font-size: 1.15rem; font-weight: 800; }
.side-stats span { font-size: .72rem; color: var(--muted); }
.side-journey .side-stats span { color: rgba(255, 255, 255, .85); }
.quick-links { display: grid; gap: 8px; }
.quick-links form { margin: 0; }
.quick-link {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; text-align: left;
  font: inherit; color: var(--text); text-decoration: none; cursor: pointer;
  background: color-mix(in srgb, var(--ql) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ql) 30%, transparent);
  transition: transform .12s ease;
}
.quick-link:hover { transform: translateX(3px); color: var(--text); }
.quick-link > span:first-child { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; font-size: 1.2rem; background: color-mix(in srgb, var(--ql) 18%, var(--surface)); }
.quick-link strong { display: block; font-size: .92rem; }
.quick-link small { color: var(--muted); font-size: .78rem; }
.quick-link.is-soon { opacity: .55; cursor: default; }
.quick-link.is-soon:hover { transform: none; }
.ql-green { --ql: #10b981; } .ql-violet { --ql: #8b5cf6; } .ql-blue { --ql: #3b82f6; } .ql-pink { --ql: #ec4899; }
@media (max-width: 1100px) { .quest-layout { grid-template-columns: 1fr; } }

/* ---------- Pop Quiz & Mission ---------- */
.mode-quiz { border-left-color: #f43f5e; } .mode-quiz .mode-pill { background: #ffe4e6; color: #9f1239; }
.mode-mission { border-left-color: #f59e0b; } .mode-mission .mode-pill { background: #fef3c7; color: #92400e; }
.rule-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rule-chip { padding: 6px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-2); }
.set-grid-pad { padding-top: 18px; }
.set-card form { margin: 0; }
.set-note, .set-deadline { margin: 0; }
.set-deadline { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #b45309; }
.set-deadline .icon { width: 15px; height: 15px; }
.set-stars .star { font-size: 1.15rem; }
.head-quiz { background: linear-gradient(120deg, #be123c, #e11d48 45%, #fb7185); box-shadow: 0 12px 30px rgba(225, 29, 72, .3); }
.head-mission { background: linear-gradient(120deg, #b45309, #d97706 45%, #f59e0b); box-shadow: 0 12px 30px rgba(217, 119, 6, .3); }
.drill-due { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 0; font-weight: 700; font-size: .9rem; }
.drill-due .icon { width: 16px; height: 16px; }
.saved-note { margin: 16px 0 4px; padding: 12px 16px; border-radius: 14px; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.tile-chosen { --opt: var(--primary); background: color-mix(in srgb, var(--primary) 16%, var(--surface)); }
.nav-cell.is-done { background: var(--primary-soft); color: var(--primary); }
.reward-rules { margin: 0 0 10px; padding-left: 18px; display: grid; gap: 6px; font-size: .9rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 8px; }
.check-grid[hidden] { display: none; }
.check-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: .88rem; cursor: pointer; }
.check-item input { margin-top: 3px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.stat-small { font-size: 1rem; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.task-list .task-meta { display: flex; flex-direction: column; min-width: 0; }
.task-list .task-meta span { font-size: .8rem; color: var(--muted); }

/* ---------- Marketplace ---------- */
.market-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.market-tabs a {
  padding: 9px 16px; border-radius: 999px; font-weight: 800; font-size: .9rem; text-decoration: none;
  color: var(--text); background: var(--surface); box-shadow: var(--shadow); border: 2px solid transparent;
}
.market-tabs a[aria-current="page"] { color: #fff; background: linear-gradient(135deg, #db2777, #f59e0b); }
.market-hero {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 20px; padding: 24px 26px; border-radius: 24px; color: #fff; box-shadow: var(--shadow);
}
.market-hero h1 { margin: 4px 0 6px; color: #fff; font-size: clamp(1.4rem, 3vw, 2rem); }
.market-hero p { margin: 0; max-width: 720px; opacity: .95; }
.market-kicker { margin: 0; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.mh-tokens { background: linear-gradient(120deg, #0f766e, #0d9488 50%, #14b8a6); }
.mh-powerups { background: linear-gradient(120deg, #5b21b6, #7c3aed 50%, #c026d3); }
.mh-draws { background: linear-gradient(120deg, #15803d, #16a34a 50%, #84cc16); }
.mh-box { background: linear-gradient(120deg, #be185d, #db2777 50%, #f59e0b); }
.hero-stack { display: flex; flex-direction: column; gap: 8px; }
.market-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 20px; align-items: start; }
.market-grid .card { margin: 0 0 20px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 16px; margin-bottom: 20px; }
.shop-card {
  display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: 22px; background: var(--surface);
  box-shadow: var(--shadow); border-top: 6px solid #a855f7;
}
.shop-card.is-locked { opacity: .65; }
.shop-icon { font-size: 2.4rem; line-height: 1; }
.shop-name { margin: 0; font-size: 1.15rem; }
.shop-desc { flex: 1; margin: 0; font-size: .9rem; color: var(--muted); }
.shop-meta { display: flex; justify-content: space-between; align-items: center; }
.shop-price { padding: 4px 12px; border-radius: 999px; font-weight: 800; background: #fef3c7; color: #92400e; }
.shop-buy { display: flex; gap: 8px; width: 100%; }
.shop-buy select { flex: 1; }
.inventory-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.inventory-chip { padding: 8px 14px; border-radius: 999px; font-weight: 700; background: #ede9fe; color: #5b21b6; }
.draw-card { border-top-color: #16a34a; }
.draw-facts { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 4px; font-size: .88rem; }
.draw-result { margin: 0; padding: 10px 12px; border-radius: 12px; font-weight: 700; background: var(--surface-2); }
.draw-result.is-win { background: #dcfce7; color: #166534; }
.box-stage { text-align: center; }
.box-stage form { margin: 0 0 8px; }
.mystery-box { font-size: 5.5rem; line-height: 1.1; margin: 6px 0 14px; animation: box-wobble 2.4s ease-in-out infinite; }
@keyframes box-wobble { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-8deg) scale(1.05); } 82% { transform: rotate(8deg) scale(1.05); } 88% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .mystery-box { animation: none; } }
.box-reward { margin: 8px 0; font-size: 2rem; font-weight: 800; }
.odds-table td:last-child, .num { text-align: right; }
.analysis-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.analysis-list li { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.text-red { color: var(--danger); }
.power-note { margin: 12px 0 0; padding: 8px 12px; border-radius: 12px; font-weight: 700; font-size: .88rem; background: #ede9fe; color: #5b21b6; }
.tile-gone { opacity: .35; text-decoration: line-through; pointer-events: none; }
.magic-live { opacity: 1; margin: 8px 0 0; }
.magic-live.is-off { opacity: .55; }
.magic-live .owned { font-size: .8rem; color: #7c3aed; }
.btn-magic { background: linear-gradient(135deg, #7c3aed, #c026d3); color: #fff; }
.btn-magic:hover { color: #fff; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.input-sm { max-width: 110px; }
.card-pad { padding: 20px 22px 0; }
.magic-item .magic-why { margin-top: 4px; font-size: .76rem; font-weight: 700; color: #b45309; }

/* ---------- Magic Powers v2, stacked play layout, footer ---------- */
.drill-stack { display: grid; gap: 18px; }
.drill-stack .drill-side { display: grid; gap: 18px; }
.drill-stack .drill-side .card { margin: 0; }
.magic-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.magic-cat { margin: 4px 0 0; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: #7c3aed; }
.power-info { display: grid; gap: 10px; margin: 14px 0 4px; }
.power-info-box { padding: 12px 16px; border-radius: 14px; background: #f5f3ff; border-left: 5px solid #8b5cf6; }
.power-info-title { margin: 0 0 4px; font-weight: 800; color: #5b21b6; }
.power-info-text { margin: 0; }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: .85rem; }
:root[data-theme="dark"] .power-info-box { background: #2e1065; }
:root[data-theme="dark"] .power-info-title { color: #ddd6fe; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .power-info-box { background: #2e1065; } :root:not([data-theme="light"]) .power-info-title { color: #ddd6fe; } }
.check-wide { margin: 8px 0; }
.site-footer { margin-top: 32px; padding: 18px 8px 6px; border-top: 1px solid var(--border); text-align: center; font-size: .8rem; color: var(--muted); }
.auth-main .site-footer { border-top: 0; max-width: 520px; margin-inline: auto; }
.mh-mine { background: linear-gradient(120deg, #1e3a8a, #4f46e5 50%, #a855f7); }
.hero-link { color: #fff; font-weight: 800; text-decoration: underline; }
.owned-card { border-top-color: #4f46e5; }
.owned-top { display: flex; justify-content: space-between; align-items: center; }
.owned-qty { padding: 4px 14px; border-radius: 999px; font-size: 1.1rem; font-weight: 800; background: #e0e7ff; color: #3730a3; }

/* ---------- Tournament ---------- */
.mode-tournament { border-left-color: #db2777; } .mode-tournament .mode-pill { background: #fce7f3; color: #9d174d; }
.head-tournament { background: linear-gradient(120deg, #831843, #db2777 45%, #f59e0b); box-shadow: 0 12px 30px rgba(219, 39, 119, .3); }
.result-rank { margin: 4px 0 10px; font-size: 1.1rem; font-weight: 700; color: #9d174d; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 12px; max-width: 640px; margin: 10px auto 24px; }
.podium-step { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.podium-medal { font-size: 2.4rem; line-height: 1; }
.podium-name { font-size: .95rem; overflow-wrap: anywhere; }
.podium-score { font-size: .8rem; color: var(--muted); font-weight: 700; }
.podium-block { width: 100%; display: grid; place-items: center; border-radius: 16px 16px 6px 6px; color: #fff; font-size: 1.6rem; font-weight: 800; }
.podium-1 .podium-block { height: 130px; background: linear-gradient(180deg, #f59e0b, #b45309); }
.podium-2 .podium-block { height: 95px; background: linear-gradient(180deg, #94a3b8, #475569); }
.podium-3 .podium-block { height: 70px; background: linear-gradient(180deg, #fb923c, #9a3412); }
.podium-step.is-me .podium-name { color: #db2777; }
.leaderboard-table tr.is-me td { background: #fdf2f8; font-weight: 800; }
:root[data-theme="dark"] .leaderboard-table tr.is-me td { background: #500724; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaderboard-table tr.is-me td { background: #500724; } }

/* ---------- KHERmistry Live ---------- */
.live-hero {
  margin-bottom: 20px; padding: 26px; border-radius: 24px; color: #fff; text-align: center;
  background: radial-gradient(circle at 20% 20%, #f472b6 0, transparent 40%), linear-gradient(120deg, #312e81, #7c3aed 50%, #db2777);
  box-shadow: var(--shadow);
}
.live-hero h1 { margin: 6px 0; color: #fff; font-size: clamp(1.5rem, 3.4vw, 2.2rem); }
.live-hero p { margin: 0 auto; max-width: 640px; }
.pin-form { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.pin-form input { width: 220px; max-width: 100%; text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: .3em; border-radius: 14px; }
.live-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px;
  padding: 18px 22px; border-radius: 22px; color: #fff; background: linear-gradient(120deg, #312e81, #7c3aed 55%, #db2777);
}
.live-title { margin: 2px 0 0; color: #fff; font-size: clamp(1.1rem, 2.4vw, 1.5rem); }
.live-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.live-chip { padding: 8px 14px; border-radius: 12px; font-weight: 700; background: rgba(255, 255, 255, .2); }
.card .live-chip { background: #ede9fe; color: #5b21b6; }
.live-connection { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; background: #fef3c7; color: #92400e; font-weight: 700; text-align: center; }
.live-panel { padding: 24px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.live-big { margin: 6px 0 10px; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; }
.live-pulse { margin-top: 18px; font-size: 3.5rem; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .live-pulse { animation: none; } }
.live-qcount { margin: 0 0 8px; font-weight: 800; color: #7c3aed; }
.live-timebar { background: var(--surface-2); margin-bottom: 14px; }
.live-timebar > span { background: linear-gradient(90deg, #db2777, #f59e0b); transition: width .25s linear; }
.live-stem { text-align: left; }
.live-options { text-align: left; }
.live-option { width: 100%; font: inherit; cursor: pointer; }
.live-feedback { margin: 14px 0 0; padding: 12px 16px; border-radius: 14px; background: var(--surface-2); font-weight: 600; text-align: left; }
.live-panel .btn-next { margin-top: 14px; }
.live-correct { font-size: 1.05rem; }
.live-sub { margin-top: 16px; }
.live-summary { font-size: 1.05rem; font-weight: 700; }
.live-board { list-style: none; margin: 10px auto; padding: 0; display: grid; gap: 6px; max-width: 560px; text-align: left; }
.live-board li { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.live-board li.is-me { background: #fce7f3; font-weight: 800; }
.live-rank { font-weight: 800; text-align: center; }
.live-name { min-width: 0; overflow-wrap: anywhere; }
.live-pts { color: #7c3aed; }
.live-pin-card {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; align-items: center; margin-bottom: 16px;
  padding: 20px 24px; border-radius: 22px; color: #fff; background: linear-gradient(120deg, #312e81, #7c3aed 55%, #db2777);
}
.live-pin { margin: 0; font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 800; letter-spacing: .08em; }
.live-join-url { margin: 0; font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.live-status { margin: 0 0 12px; font-weight: 700; }
.live-bars { display: grid; gap: 8px; margin-top: 10px; }
.live-bar-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 40px; align-items: center; gap: 10px; }
.live-bar-label { overflow-wrap: anywhere; font-weight: 600; }
.live-bar-track { height: 18px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.live-bar-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: #8b5cf6; transition: width .4s ease; }
.live-bar-row.is-correct .live-bar-fill { background: #10b981; }
.live-bar-row.is-correct .live-bar-label { color: #047857; }
.live-bar-count { text-align: right; }
.live-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 360px; overflow: auto; }
.live-players li { display: flex; align-items: center; gap: 8px; }
.live-players .live-name { flex: 1; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; flex: none; }
.live-dot.is-on { background: #10b981; }
:root[data-theme="dark"] .live-board li.is-me { background: #500724; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .live-board li.is-me { background: #500724; } }
@media (max-width: 700px) { .live-pin-card { grid-template-columns: 1fr; text-align: center; } }
/* The hidden attribute must win over component display rules (e.g. .btn is inline-flex). */
[hidden] { display: none !important; }

/* ---------- Lecturer: dashboard action, class cards, filterable/sortable result tables ---------- */
.hero-with-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.hero-action-card {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-radius: 18px; text-decoration: none;
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .45); color: #fff;
  backdrop-filter: blur(4px); transition: transform .15s ease, background .15s ease;
}
.hero-action-card:hover { color: #fff; background: rgba(255, 255, 255, .28); transform: translateY(-3px); }
.hero-action-card strong { display: block; font-size: 1.1rem; }
.hero-action-card small { display: block; opacity: .9; }
.hero-action-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; font-size: 1.6rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 4px 0 #b7791f;
}
a.stat { display: block; text-decoration: none; cursor: pointer; }

.class-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.class-card {
  display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 20px; color: #fff; text-decoration: none;
  box-shadow: 0 10px 24px rgba(76, 29, 149, .16); transition: transform .15s ease, box-shadow .15s ease;
}
.class-card:hover { color: #fff; transform: translateY(-4px); box-shadow: 0 16px 30px rgba(76, 29, 149, .24); }
.class-card.cc-0 { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.class-card.cc-1 { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.class-card.cc-2 { background: linear-gradient(135deg, #be123c, #f43f5e); }
.class-card.cc-3 { background: linear-gradient(135deg, #b45309, #ea8a0c); }
.class-card.cc-4 { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.class-card.cc-5 { background: linear-gradient(135deg, #047857, #22c55e); }
.class-card-head { display: block; }
.class-card-code { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: .02em; }
.class-card-sub { display: block; opacity: .9; font-size: .92rem; }
.class-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.class-card-stats > span { display: block; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .16); font-size: .78rem; line-height: 1.25; }
.class-card-stats strong { display: block; font-size: 1.15rem; }
.class-card .progress { background: rgba(255, 255, 255, .3); }
.class-card .progress > span { background: #fff; }
.class-card-foot { font-size: .85rem; opacity: .92; }

.filters .field-wide { flex: 1 1 320px; width: auto; }
.filter-count { align-self: center; margin-left: auto; }
.table-sortable th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table-sortable th.sortable::after { content: " ↕"; opacity: .35; font-size: .8em; }
.table-sortable th[aria-sort="ascending"]::after { content: " ▲"; opacity: .9; }
.table-sortable th[aria-sort="descending"]::after { content: " ▼"; opacity: .9; }
.table-sortable th.sortable:hover, .table-sortable th.sortable:focus-visible { color: var(--primary); }

.race-options { margin: 8px 0 0; padding-left: 24px; }
.race-options li { padding: 4px 0; }
.race-option-correct { color: var(--success); font-weight: 700; }
.cell-name { min-width: 180px; }

/* ---------- Student: twice-daily Token claim ---------- */
.daily-claim { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 0; }
.daily-note { font-size: .82rem; color: rgba(255, 255, 255, .92); font-weight: 600; }
.daily-box { flex-shrink: 0; }

/* ---------- Student: My Learning cards ---------- */
.learning-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.learning-card {
  --lc: #7c3aed;
  display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 18px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-top: 5px solid var(--lc); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.learning-card:hover { color: var(--text); transform: translateY(-3px); box-shadow: 0 14px 28px rgba(76, 29, 149, .16); }
.lc-alchemy { --lc: #7c3aed; }
.lc-training { --lc: #0d9488; }
.lc-quiz { --lc: #db2777; }
.lc-mission { --lc: #2563eb; }
.lc-tournament { --lc: #d97706; }
.lc-race { --lc: #e11d48; }
.learning-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.learning-type { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--lc); }
.learning-title { font-size: 1.05rem; line-height: 1.3; }
.learning-sub { font-size: .85rem; color: var(--muted); }
.learning-score { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: auto; }
.learning-pct { font-size: 1.5rem; font-weight: 800; color: var(--lc); }
.learning-card .progress > span { background: var(--lc); }
.learning-foot { font-size: .8rem; color: var(--muted); }

/* ---- Student Performance pages ---------------------------------------------------------- */
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.toolbar-row .segmented { flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 2px 0 8px; vertical-align: -1px; }
.ld-alchemy, .xp-seg-alchemy { background: #7c3aed; }
.ld-activity, .xp-seg-activity { background: #14b8a6; }
.xp-chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; align-items: end; height: 200px; padding-top: 6px; }
.xp-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.xp-day-value { font-size: .7rem; font-weight: 700; color: var(--muted); min-height: 1em; }
.xp-stack { display: flex; flex-direction: column; width: 100%; max-width: 30px; height: 0; min-height: 3px; border-radius: 6px 6px 2px 2px; overflow: hidden; background: var(--surface-2); transition: height .6s ease; }
.xp-seg { display: block; width: 100%; flex: none; }
.xp-day-label { font-size: .65rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
@media (max-width: 560px) { .xp-day-label { font-size: .55rem; } .xp-day-value { font-size: .6rem; } }
.type-score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.type-score-list li { display: grid; gap: 5px; }
.type-score-head { display: flex; justify-content: space-between; gap: 8px; }
.type-score-list .progress > span { background: var(--lc); }
.type-score-pct { font-size: .8rem; font-weight: 700; color: var(--lc); }
.level-hero { display: flex; align-items: center; gap: 20px; padding: 22px 24px; margin-bottom: 20px; border-radius: 22px; color: #fff; background: linear-gradient(135deg, #4c1d95, #7c3aed 55%, #db2777); box-shadow: var(--shadow); }
.level-hero-badge { flex: none; display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%; background: rgba(255, 255, 255, .18); border: 3px solid #fde047; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; line-height: 1.1; text-align: center; }
.level-hero-num { display: block; font-size: 2.2rem; font-weight: 800; }
.level-hero-main { flex: 1; min-width: 0; }
.level-hero-main h2 { margin: 0; color: #fff; font-size: 1.6rem; }
.level-hero-main p { margin: 4px 0 0; opacity: .9; }
@media (max-width: 560px) { .level-hero { flex-direction: column; text-align: center; } .level-hero-main { width: 100%; } }
.level-ladder { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.level-ladder li { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface); }
.level-ladder .ladder-num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.level-ladder li.is-reached { border-color: #c4b5fd; }
.level-ladder li.is-reached .ladder-num { background: #ede9fe; color: #6d28d9; }
.level-ladder li.is-current { border-color: #7c3aed; box-shadow: 0 6px 18px rgba(124, 58, 237, .22); }
.level-ladder li.is-current .ladder-num { background: linear-gradient(135deg, #7c3aed, #db2777); color: #fff; }
.level-ladder li.is-locked { opacity: .65; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline-item { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--tl); }
.timeline-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; background: var(--surface-2); }
.timeline-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.timeline-reward { flex: none; font-weight: 800; color: var(--tl); white-space: nowrap; }
.tl-milestone { --tl: #7c3aed; } .tl-level { --tl: #d97706; } .tl-podium { --tl: #0d9488; } .tl-race { --tl: #e11d48; }
:root[data-theme="dark"] .level-ladder li.is-reached .ladder-num { background: #2e1065; color: #c4b5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .level-ladder li.is-reached .ladder-num { background: #2e1065; color: #c4b5fd; } }
.card-head .btn { white-space: nowrap; flex: none; }

/* ---- Lecturer Performance & Analytics --------------------------------------------------- */
.stat-sub { display: block; font-size: .78rem; opacity: .9; margin-top: 2px; }
.heat-table td:not(.cell-name) { text-align: center; font-weight: 700; }
.heat-0 { background: var(--surface-2); color: var(--muted); }
.heat-1 { background: #ede9fe; color: #5b21b6; }
.heat-2 { background: #c4b5fd; color: #3b0764; }
.heat-3 { background: #8b5cf6; color: #fff; }
.heat-4 { background: #6d28d9; color: #fff; }
:root[data-theme="dark"] .heat-1 { background: #2e1065; color: #ddd6fe; }
:root[data-theme="dark"] .heat-2 { background: #4c1d95; color: #ede9fe; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .heat-1 { background: #2e1065; color: #ddd6fe; } :root:not([data-theme="light"]) .heat-2 { background: #4c1d95; color: #ede9fe; } }
.hard-list { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 12px; }
.hard-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hard-stem { display: block; margin-top: 4px; font-size: .9rem; overflow-wrap: anywhere; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; margin-bottom: 16px; }
.report-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.report-card .btn { margin-top: auto; }
.analytics-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 20px; align-items: start; margin-bottom: 20px; }
.analytics-pair .card { margin-bottom: 0; }

/* ---- Exit Ticket -------------------------------------------------------------------------- */
.mode-exit { border-left-color: #0891b2; } .mode-exit .mode-pill { background: #cffafe; color: #155e75; }
.head-exit { background: linear-gradient(120deg, #164e63, #0891b2 50%, #22c55e); box-shadow: 0 12px 30px rgba(8, 145, 178, .3); }
.lc-exit { --lc: #0891b2; }
.reflect-card { border: 2px solid #67e8f9; margin-bottom: 20px; }
.confidence-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: 10px; }
.confidence-option { position: relative; cursor: pointer; }
.confidence-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.confidence-option > span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border: 2px solid var(--border); border-radius: 16px; font-weight: 700; background: var(--surface); transition: border-color .15s ease, transform .15s ease; }
.confidence-option input:checked + span { border-color: #0891b2; background: #ecfeff; transform: translateY(-2px); }
.confidence-option input:focus-visible + span { outline: 3px solid #0891b2; outline-offset: 2px; }
:root[data-theme="dark"] .confidence-option input:checked + span { background: #164e63; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .confidence-option input:checked + span { background: #164e63; } }
.reflect-emoji { font-size: 1.8rem; line-height: 1; }
.reflect-sent { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 4px; }
.confidence-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 14px; margin-bottom: 18px; }
.confidence-bar { display: grid; gap: 6px; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.confidence-head { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.confidence-head strong { margin-left: auto; font-size: 1.3rem; }
.cb-1 .progress > span { background: #e11d48; } .cb-2 .progress > span { background: #f59e0b; } .cb-3 .progress > span { background: #0891b2; } .cb-4 .progress > span { background: #16a34a; }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.note-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.note-emoji { font-size: 1.5rem; line-height: 1; }
.note-text { margin: 0 0 2px; overflow-wrap: anywhere; }

/* ---- Announcements, alerts, recent activity ----------------------------------------------- */
.announce-list { display: grid; gap: 14px; }
.announce-card { padding: 18px 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid #7c3aed; box-shadow: var(--shadow); }
.announce-card.is-off { opacity: .6; border-left-color: var(--border); }
.announce-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.announce-body { margin: 0 0 8px; overflow-wrap: anywhere; }
.announce-foot { display: grid; grid-template-columns: auto minmax(80px, 1fr) auto; align-items: center; gap: 12px; }
.announce-foot form { margin: 0; }
.announce-reads { font-size: .85rem; font-weight: 600; }
@media (max-width: 560px) { .announce-foot { grid-template-columns: 1fr; } }
.announce-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.announce-mini li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.announce-mini li .muted { flex-basis: 100%; }
.alert-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.alert-feed li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); border-left: 5px solid var(--af); background: var(--surface); }
.af-danger { --af: #e11d48; } .af-warn { --af: #f59e0b; } .af-info { --af: #0891b2; }
.af-icon { font-size: 1.4rem; flex: none; }
.af-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.alert-feed .btn { flex: none; }
@media (max-width: 560px) { .alert-feed li { flex-wrap: wrap; } }
.tl-activity { --tl: #2563eb; } .tl-lo { --tl: #7c3aed; } .tl-reflection { --tl: #0891b2; }

/* ---- Badges & Showcase ------------------------------------------------------------------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 14px; }
.badge-card { --rc: #64748b; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 16px 12px; border-radius: 18px; background: var(--surface); border: 2px solid var(--border); scroll-margin-top: 90px; }
.rarity-common { --rc: #64748b; } .rarity-rare { --rc: #2563eb; } .rarity-epic { --rc: #9333ea; } .rarity-legendary { --rc: #d97706; }
.badge-card.is-earned { border-color: var(--rc); box-shadow: 0 8px 20px color-mix(in srgb, var(--rc) 22%, transparent); }
.badge-card.is-earned.rarity-legendary { background: linear-gradient(160deg, var(--surface) 55%, color-mix(in srgb, #fbbf24 22%, var(--surface))); }
.badge-card.is-locked { opacity: .72; }
.badge-card.is-locked .badge-emoji { filter: grayscale(1); }
.badge-emoji { font-size: 2.4rem; line-height: 1.1; }
.badge-name { font-size: .98rem; }
.badge-rarity { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--rc); }
.badge-req { font-size: .8rem; color: var(--muted); }
.badge-when { font-size: .76rem; font-weight: 700; color: var(--muted); margin-top: auto; }
.badge-card.is-earned .badge-when { color: var(--rc); }
.badge-card .progress { width: 100%; margin-top: auto; }
.badge-card .progress > span { background: var(--rc); }
.showcase-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; align-items: end; }
.showcase-row { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: middle; }
.showcase-badge { font-size: 1.05rem; line-height: 1; cursor: default; }
.podium-step .showcase-row { margin: 0; }
.badge-guide { margin: 4px 0 10px; }
.badge-guide ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: .88rem; }
.tl-badge { --tl: #d97706; }

/* ---- Admin: reset, sortable directory, bulk select ----------------------------------------- */
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { color: #fff; filter: brightness(.92); }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link span { opacity: .4; font-size: .8em; }
.sort-link.is-active span { opacity: .9; }
.check-col { width: 36px; }
.check-col input { width: 18px; height: 18px; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.reset-scopes, .reset-components { display: grid; gap: 10px; margin-bottom: 14px; }
.reset-scopes { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.reset-head { margin: 16px 0 4px; font-size: 1rem; }
.reset-confirm { max-width: 640px; }
.my-badge-grid { margin-bottom: 20px; }
a.badge-card { color: var(--text); text-decoration: none; }
a.badge-card:hover { transform: translateY(-2px); }

/* ---- Student profile, class analysis, lecturer dashboard extras ---------------------------- */
.section-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.section-nav a { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .88rem; text-decoration: none; }
.section-nav a:hover { border-color: var(--primary); }
.sub-title { margin: 18px 0 8px; font-size: 1rem; }
.sub-head { margin-top: 20px; align-items: center; flex-wrap: wrap; }
.sub-head .sub-title { margin: 0; }
.more-details { margin-top: 12px; }
.more-details > summary { cursor: pointer; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.ledger-wrap { max-height: 420px; overflow-y: auto; }
.ld-me { background: #7c3aed; } .ld-class { background: #14b8a6; } .ld-all { background: #f59e0b; }
.compare-list { display: grid; gap: 14px; }
.compare-row { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr) auto; gap: 14px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.compare-row:last-child { border-bottom: 0; }
.compare-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.compare-bars { display: grid; gap: 5px; }
.cbar { display: grid; grid-template-columns: 1fr 48px; gap: 8px; align-items: center; }
.cbar-track { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cbar-track > span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .6s ease; }
.cbar-me .cbar-track > span { background: #7c3aed; } .cbar-class .cbar-track > span { background: #14b8a6; } .cbar-all .cbar-track > span { background: #f59e0b; }
.cbar-value { font-size: .8rem; font-weight: 700; text-align: right; }
.compare-diff { font-weight: 800; font-size: .85rem; white-space: nowrap; color: var(--muted); }
.compare-diff.is-up { color: var(--success); } .compare-diff.is-down { color: var(--danger); }
@media (max-width: 640px) { .compare-row { grid-template-columns: 1fr; } }
.reward-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.reward-box { padding: 16px; border-radius: 16px; background: var(--surface-2); }
.reward-box h3 { margin: 0 0 10px; font-size: 1rem; }
.analysis-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.analysis-filters .segmented { flex-wrap: wrap; }
.hbar-chart { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hbar-chart li { display: grid; grid-template-columns: minmax(120px, 30%) 1fr 120px; gap: 10px; align-items: center; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; font-weight: 600; }
.hbar-track { display: block; height: 16px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7c3aed, #a855f7); transition: width .6s ease; }
.hbar-fill.is-below { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.hbar-value { font-size: .85rem; font-weight: 800; white-space: nowrap; }
.hbar-value small { font-weight: 500; color: var(--muted); }
.hbar-chart li.is-empty .hbar-label { color: var(--muted); }
.hbar-chart li.is-current .hbar-label { color: var(--primary); }
.hbar-chart li.is-current .hbar-fill { background: linear-gradient(90deg, #db2777, #f472b6); }
@media (max-width: 560px) { .hbar-chart li { grid-template-columns: 1fr 90px; } .hbar-label { grid-column: 1 / -1; } }
.create-row { margin-bottom: 20px; }
.activity-go { margin-top: 6px; font-size: .8rem; font-weight: 800; color: var(--a); }
.top-filters { margin-bottom: 12px; }
.top-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 8px; }
.top-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.top-rank { flex: none; width: 36px; text-align: center; font-weight: 800; }
.top-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.top-xp { flex: none; font-weight: 800; color: var(--primary); font-size: .88rem; }

/* ---- Lecturer tools & admin system pages --------------------------------------------------- */
.qb-list { display: grid; gap: 14px; }
.qb-card { padding: 18px 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); }
.qb-stem { font-weight: 600; margin: 10px 0; overflow-wrap: anywhere; }
.qb-acc { margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--muted); }
.qb-options { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px; }
.qb-options li { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; }
.qb-options li.is-correct { background: var(--success-soft); color: var(--success); font-weight: 700; }
.qb-letter { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--surface); font-weight: 800; margin-right: 6px; }
.row-soon td { background: color-mix(in srgb, var(--danger-soft) 60%, transparent); }
.details-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.details-grid dt { font-weight: 700; }
.details-grid dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Question import ------------------------------------------------------------------------ */
.guide-steps { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 8px; }
.code-box { position: relative; margin-top: 12px; }
.code-box pre { margin: 0; padding: 16px; padding-top: 44px; border-radius: 14px; background: #0f172a; color: #e2e8f0; font-size: .82rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 460px; overflow-y: auto; }
.code-copy { position: absolute; top: 8px; right: 8px; background: #fff; color: #0f172a; border-color: #fff; }
.code-copy:hover { background: #ede9fe; color: #4c1d95; }
.problem-list { margin: 8px 0 14px; padding-left: 20px; display: grid; gap: 4px; color: var(--danger); font-size: .9rem; }
.pre-line { white-space: pre-line; }
.import-confirm { margin-top: 16px; }

/* ---- Groups, collections, manual ----------------------------------------------------------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.group-card .card-head { align-items: center; }
.group-rename input { max-width: 200px; font-weight: 700; }
.member-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 10px; background: var(--surface-2); }
.member-list li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list form { margin: 0; }
.collect-bar { position: sticky; top: 72px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 14px; }
.collect-bar select, .collect-bar input[type="text"] { width: auto; flex: 1 1 180px; }
.qb-pick input { width: 20px; height: 20px; cursor: pointer; }
.collection-card { color: var(--text); text-decoration: none; }
.collection-card:hover { border-color: var(--primary); }
.manual-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.manual-toc a { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: .88rem; text-decoration: none; }
.manual-section { scroll-margin-top: 90px; }
.manual-section h2 { margin-top: 0; font-size: 1.2rem; }
.manual-section li { margin-bottom: 6px; }

/* Past-paper banks: PastYear Fighter, GUP is Real, Eazypezy UPS */
.mode-pspm { border-left-color: #7c3aed; } .mode-pspm .mode-pill { background: #ede9fe; color: #5b21b6; }
.mode-gup { border-left-color: #ea580c; } .mode-gup .mode-pill { background: #ffedd5; color: #9a3412; }
.mode-ups { border-left-color: #16a34a; } .mode-ups .mode-pill { background: #dcfce7; color: #166534; }
.level-pill { padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.level-easy { background: #dcfce7; color: #166534; } .level-medium { background: #fef3c7; color: #92400e; } .level-hard { background: #fee2e2; color: #991b1b; }
.bank-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.bank-tabs a { padding: 6px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: .88rem; text-decoration: none; color: inherit; }
.bank-tabs a[aria-current="page"] { background: var(--primary, #7c3aed); color: #fff; }
.source-pill { padding: 2px 8px; border-radius: 6px; font-size: .72rem; font-weight: 800; background: #ede9fe; color: #5b21b6; }
.source-gup { background: #ffedd5; color: #9a3412; } .source-ups { background: #dcfce7; color: #166534; } .source-core { background: var(--surface-2); color: var(--muted); }
.lc-pspm { --lc: #7c3aed; } .lc-gup { --lc: #ea580c; } .lc-ups { --lc: #16a34a; }

/* Class cards (My Group) */
.class-cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.class-card-link { display: flex; flex-direction: column; gap: 2px; min-width: 110px; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 2px solid var(--border, #e5e7eb); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.class-card-link strong { font-size: 1.05rem; }
.class-card-link:hover { border-color: var(--primary); }
.class-card-link[aria-current="page"] { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.class-card-link[aria-current="page"] .muted { color: inherit; opacity: .85; }
.class-card-combined { border-style: dashed; }

/* ---------- Login intro panel ---------- */
.auth-hero { align-items: flex-start; padding: 44px 48px; background: radial-gradient(circle at 12% 10%, rgba(255, 255, 255, .16), transparent 32%), radial-gradient(circle at 90% 85%, rgba(45, 212, 191, .35), transparent 40%), linear-gradient(150deg, #0f2a5c, #1d4e89 40%, #0e7490 75%, #14b8a6); }
.auth-hero .auth-hero-inner { max-width: 620px; }
.hero-brand { display: flex; align-items: center; gap: 14px; }
.hero-brand img { padding: 8px; border-radius: 16px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); }
.hero-brand-name { margin: 0; font-weight: 800; letter-spacing: .2em; font-size: 1.15rem; }
.hero-brand-sub { margin: 2px 0 0; font-size: .82rem; opacity: .8; }
.hero-headline { margin: 30px 0 14px; font-size: clamp(2rem, 3.6vw, 3rem); font-weight: 800; line-height: 1.08; letter-spacing: -.02em; color: #fff; }
.hero-headline span { background: linear-gradient(90deg, #fde68a, #f9a8d4 55%, #a5f3fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lede { margin: 0 0 22px; font-size: 1.02rem; line-height: 1.6; opacity: .92; }
.hero-lede strong { color: #fde68a; }
.hero-stats { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.hero-stats li { padding: 10px 8px; border-radius: 14px; text-align: center; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); }
.hero-stats strong { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.hero-stats span { font-size: .72rem; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.hero-flow { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; }
.hero-flow li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .16); }
.hero-flow li + li::before { content: "→"; margin: 0 6px 0 -2px; opacity: .7; }
.hero-tiles { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hero-tiles li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(6px); transition: transform .15s ease, background .15s ease; }
.hero-tiles li:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .16); }
.hero-tiles strong { display: block; font-size: .95rem; }
.hero-tiles small { display: block; font-size: .8rem; opacity: .82; }
.hero-ico { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 1.25rem; box-shadow: 0 6px 14px rgba(0, 0, 0, .18); }
.ico-violet { background: linear-gradient(135deg, #8b5cf6, #6d28d9); } .ico-teal { background: linear-gradient(135deg, #2dd4bf, #0f766e); }
.ico-amber { background: linear-gradient(135deg, #fbbf24, #d97706); } .ico-pink { background: linear-gradient(135deg, #f472b6, #be185d); }
.ico-coral { background: linear-gradient(135deg, #fb7185, #e11d48); } .ico-blue { background: linear-gradient(135deg, #60a5fa, #1d4ed8); }
.ico-purple { background: linear-gradient(135deg, #c084fc, #7e22ce); } .ico-gold { background: linear-gradient(135deg, #fde047, #ca8a04); }
.hero-lecturer { margin: 0; padding: 12px 14px; border-radius: 14px; font-size: .9rem; background: rgba(15, 23, 42, .28); border: 1px dashed rgba(255, 255, 255, .28); }
.auth-hero .auth-molecule { opacity: .5; }
@media (max-width: 1100px) {
  .hero-tiles { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .auth-hero { padding: 24px 20px; }
  .hero-headline { margin-top: 18px; font-size: 1.8rem; }
  .hero-lede { font-size: .95rem; margin-bottom: 14px; }
  .hero-tiles, .hero-flow, .hero-lecturer { display: none; }
  .hero-stats { margin: 0; gap: 6px; }
  .hero-stats strong { font-size: 1.1rem; }
  .hero-stats span { font-size: .62rem; }
}
@media (prefers-reduced-motion: reduce) { .hero-tiles li { transition: none; } }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.q-filters { border: 1px dashed var(--border); border-radius: 14px; padding: 12px 14px 4px; }
.q-filters legend { font-weight: 700; padding: 0 6px; }

/* Alchemy Race for guests (/race) */
.guest-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.guest-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.guest-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); text-decoration: none; }
.guest-brand span { font-weight: 600; color: var(--muted); }
.guest-main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 16px; }
.guest-join { max-width: 460px; margin: 24px auto; }
.guest-join .pin-input { font-size: 1.6rem; letter-spacing: .2em; text-align: center; font-weight: 800; }
.check-audience { border-style: dashed; }
/* Student alerts: Join Alchemy Race button, activity card alerts, updates list */
.race-btn {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  min-height: 46px; margin-top: 14px; padding: 10px 16px; border-radius: 14px; font-weight: 800; text-decoration: none;
  background: #fff; color: #9f1239; box-shadow: 0 4px 0 rgba(0, 0, 0, .18); transition: transform .12s ease;
}
.race-btn:hover { transform: translateY(-2px); color: #9f1239; }
.race-btn.is-live { background: linear-gradient(90deg, #f43f5e, #f59e0b); color: #fff; animation: race-glow 1.6s ease-in-out infinite; }
.race-btn.is-live:hover { color: #fff; }
.race-live-dot { padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .25); font-size: .78rem; }
@keyframes race-glow { 50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, .35), 0 4px 0 rgba(0, 0, 0, .18); } }
.activity-card { position: relative; }
.activity-card.has-alert { background: color-mix(in srgb, var(--a) 12%, var(--surface)); box-shadow: 0 0 0 2px var(--a), var(--shadow); }
.activity-card.has-alert .activity-sub { color: var(--text); font-weight: 700; }
.activity-alert {
  position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800;
  background: var(--a); color: #fff; animation: alert-pop 1.8s ease-in-out infinite;
}
@keyframes alert-pop { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .race-btn.is-live, .activity-alert { animation: none; } }
.update-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.update-list li a { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.update-list li a:hover { border-color: var(--primary, #7c3aed); }
.update-list li.is-new a { background: var(--surface-2); border-left: 4px solid #f43f5e; }
.update-ico { font-size: 1.4rem; line-height: 1.2; }
.update-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.audience-grid { margin-bottom: 10px; }
.guest-join .pin-input::placeholder { letter-spacing: .05em; font-weight: 600; font-size: 1rem; }

/* SK015 / SK025 course switch (top bar) */
.course-switch { display: inline-flex; gap: 2px; padding: 3px; margin: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.course-btn { min-height: 32px; padding: 4px 12px; border: 0; border-radius: 999px; font: inherit; font-size: .82rem; font-weight: 800; color: var(--muted); background: transparent; cursor: pointer; }
.course-btn:hover { color: var(--text); }
.course-btn.is-active { background: var(--primary); color: var(--primary-ink); }
@media (max-width: 520px) { .course-btn { padding: 4px 8px; font-size: .75rem; } }@media (max-width: 520px) { .topbar:has(.course-switch) .brand span { display: none; } }

/* Content protection: page text cannot be selected; form fields and [data-allow-copy] areas can. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body[data-protect="none"], body[data-protect="copy"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
input, textarea, select, [contenteditable="true"], [data-allow-copy], .alert, code.secret { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img { -webkit-user-drag: none; }
/* 50-level ladder: a heading row for each rank of ten levels. */
.level-ladder .ladder-rank { grid-column: 1 / -1; margin-top: 10px; border: 0; padding: 6px 10px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; }
.rank-up-banner { background: linear-gradient(90deg, #f59e0b, #ec4899); color: #fff; }

/* Profile Style (level milestone rewards): avatar borders, effects, nameplates, theme. */
.cq-av { position: relative; flex: none; }
.cq-av-sm { width: 32px; height: 32px; font-size: .8rem; }
.cq-av-md { width: 40px; height: 40px; font-size: .95rem; }
.cq-av-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.cq-av-xl { width: 96px; height: 96px; font-size: 2rem; }
.cq-border-bronze { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px #c47a3a; }
.cq-border-emerald { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px #10b981, 0 0 0 7px #a7f3d0; }
.cq-border-silver { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px #c0c6d4, 0 0 0 7px #8b93a7; }
.cq-border-golden { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px #f5b301, 0 0 0 8px #fde68a, 0 0 14px 6px rgba(245, 179, 1, .35); }
.cq-border-hero { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px #8b5cf6, 0 0 0 8px #22d3ee, 0 0 16px 8px rgba(139, 92, 246, .35); }
.cq-border-royal { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px #f5b301, 0 0 0 9px #7c3aed, 0 0 20px 10px rgba(245, 179, 1, .45); }
.cq-crown { position: absolute; top: -.95em; left: 50%; transform: translateX(-50%); font-size: .85em; line-height: 1; }
.cq-av-sm .cq-crown { top: -1.1em; }
.cq-effect-electric { animation: cq-electric 1.6s ease-in-out infinite; }
.cq-effect-electric:not([class*="cq-border-"]) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #38bdf8; }
@keyframes cq-electric { 0%, 100% { filter: drop-shadow(0 0 2px #38bdf8); } 50% { filter: drop-shadow(0 0 9px #38bdf8) drop-shadow(0 0 3px #e0f2fe); } }
.cq-plate { display: inline-block; margin: 2px 0; padding: 2px 10px; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; vertical-align: middle; }
.cq-plate-cadet { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }
.cq-plate-legend { color: #fff; background: linear-gradient(90deg, #f59e0b, #ec4899, #8b5cf6, #06b6d4, #f59e0b); background-size: 300% 100%; animation: cq-plate 6s linear infinite; }
.cq-plate-royalplate { color: #3b2600; background: linear-gradient(90deg, #fde68a, #f5b301, #fde68a); border: 1px solid #b45309; }
@keyframes cq-plate { to { background-position: 300% 0; } }
@media (prefers-reduced-motion: reduce) { .cq-effect-electric, .cq-plate-legend { animation: none; } }
.dash-hero.theme-champion, .style-preview.theme-champion { color: #fff; background: radial-gradient(circle at 85% 110%, rgba(245, 158, 11, .55), transparent 45%), linear-gradient(115deg, #3b0764 0%, #6d28d9 45%, #a21caf 80%, #d97706 100%); }
.board-who { display: inline-flex; align-items: center; gap: 10px; }
.podium-step .cq-av { margin: 6px 0; }
.style-preview { margin-bottom: 20px; }
.style-preview-row { display: flex; align-items: center; gap: 22px; margin-top: 34px; flex-wrap: wrap; }
.user-chip .cq-av { margin: 0 6px; }
.board-who .cq-av { margin: 0 4px; }
.style-preview-name { font-size: 1.2rem; }
.style-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.style-slot { border: 0; margin: 0; }
.style-option { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.style-option.is-locked { opacity: .55; cursor: not-allowed; }
.cert-grid, .hall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cert-card, .hall-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-decoration: none; color: inherit; }
.hall-card { align-items: center; text-align: center; padding-top: 30px; }
.hall-place { align-self: flex-start; font-weight: 800; color: var(--muted); }
.cert-card-level { font-weight: 800; color: var(--primary); text-transform: uppercase; font-size: .8rem; letter-spacing: .05em; }
.cert-card.is-locked { opacity: .7; }
.cert-card.is-earned { border: 2px solid #f5b301; }

/* Certificate page (print layout). */
.print-shell { background: var(--bg); padding: 16px; }
.print-toolbar { display: flex; justify-content: space-between; gap: 10px; max-width: 980px; margin: 0 auto 16px; }
.certificate { max-width: 980px; margin: 0 auto; padding: 14px; background: #fffdf5; color: #1c1917; border: 10px double #b45309; border-radius: 16px; }
.certificate-inner { border: 2px solid #f5d38a; border-radius: 10px; padding: 38px 28px; text-align: center; }
.certificate-kicker { margin: 0; letter-spacing: .2em; text-transform: uppercase; font-size: .8rem; color: #92400e; }
.certificate-title { margin: 10px 0 18px; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1.6rem, 4vw, 2.6rem); color: #7c2d12; }
.certificate-name { margin: 8px 0; font-size: clamp(1.2rem, 3vw, 1.9rem); font-weight: 800; }
.certificate-level { margin: 10px 0 2px; font-size: clamp(1.1rem, 2.6vw, 1.6rem); font-weight: 800; color: #b45309; }
.certificate-rank { margin: 0 0 22px; color: #57534e; }
.certificate-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-top: 1px solid #e7d7b0; padding-top: 14px; font-size: .85rem; color: #57534e; }
.certificate-org { margin: 14px 0 0; font-size: .8rem; color: #78716c; }
.cert-level-50 { border-color: #7c3aed; }
.cert-level-50 .certificate-level { color: #7c3aed; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  .no-print { display: none !important; }
  .print-shell { background: #fff; padding: 0; }
  .certificate { box-shadow: none; max-width: none; }
}
/* Timed sets (0.32.0): untimed label, live speed-bonus label, timed pill in set lists. */
.drill-untimed { opacity: .85; font-size: .85rem; }
.drill-timer .timer-bonus { font-size: .8rem; opacity: .9; }
.set-timed { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.set-untimed { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; background: var(--surface-2); color: var(--muted); }

/* Dashboard card groups and record pages (0.32.0). */
.dash-group-title { margin: 22px 0 10px; font-size: .85rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-row-5 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.live-q { margin-bottom: 14px; }
.live-q-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.live-q-options { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.live-q-options li { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); }
.live-q-options li.is-right { border-color: var(--success); background: var(--success-soft); }
.live-q-options li.is-miss { border-color: var(--danger); background: var(--danger-soft); }
.live-q-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 6px 0 10px; font-size: .9rem; }

/* Admin: open / close official set groups (0.33.0). */
.group-switch { border-top: 1px solid var(--border); padding: 10px 0; }
.group-switch > summary { cursor: pointer; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.group-switch .check-grid { margin-top: 8px; }

/* Mystery Box tiers, Special Lucky Draw and Event draws (0.33.0). */
.badge-warning { background: #fff7ed; color: #c2410c; }
.box-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; margin-bottom: 20px; }
.box-tier { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.box-tier .mystery-box { font-size: 3.2rem; }
.box-price { font-size: 1.4rem; font-weight: 800; margin: 0; }
.box-silver { border: 2px solid #c0c6d4; }
.box-gold { border: 2px solid #f5b301; box-shadow: 0 10px 30px rgba(245, 179, 1, .18); }
.box-odds { text-align: left; }
.box-odds > summary { cursor: pointer; font-weight: 700; }
.special-draw { border: 2px solid #f5b301; }
.special-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.special-head h2 { margin: 4px 0; }
.special-buy { min-width: min(100%, 240px); }
.special-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; margin-top: 14px; }
.special-odds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.special-odds li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.draw-top3 { display: flex; flex-wrap: wrap; gap: 6px 12px; font-weight: 700; margin: 6px 0; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* Feedback (0.34.0): star rating input, feedback card, replies, screenshots. */
.star-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; }
.star-rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-rating label { font-size: 2.1rem; line-height: 1; color: var(--border); cursor: pointer; transition: color .15s, transform .15s; }
.star-rating input:checked ~ label, .star-rating label:hover, .star-rating label:hover ~ label { color: #f5b301; }
.star-rating input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.fb-stars { color: #f5b301; letter-spacing: 1px; white-space: nowrap; }
.feedback-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.feedback-message { margin: 14px 0; white-space: normal; font-size: 1.02rem; }
.feedback-files { display: flex; flex-wrap: wrap; gap: 12px; }
.feedback-files img { max-width: min(100%, 320px); max-height: 240px; border-radius: 12px; border: 1px solid var(--border); object-fit: contain; background: var(--surface-2); }
.feedback-replies { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.feedback-replies li { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.feedback-replies p { margin: 6px 0 0; }

/* Lecturer All Activities cards and Result & analysis (0.35.0). */
.act-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px; margin-bottom: 20px; }
.act-type-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 20px; text-decoration: none; color: var(--text); background: var(--surface); box-shadow: var(--shadow); border-top: 5px solid var(--a); transition: transform .15s ease; }
a.act-type-card:hover { transform: translateY(-4px); color: var(--text); }
.act-type-head { display: flex; align-items: center; gap: 10px; }
.act-type-name { font-weight: 800; font-size: 1.05rem; }
.act-type-count { font-size: 2rem; font-weight: 800; line-height: 1; }
.act-type-count small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.act-type-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); }
.act-type-stats strong { color: var(--text); }
.act-type-go { font-size: .85rem; font-weight: 700; color: var(--primary); margin-top: auto; }
.analysis-filter { align-items: flex-end; }
.analysis-table { margin-top: 14px; }
.analysis-table > summary { cursor: pointer; font-weight: 700; }
tr.is-muted-row td { color: var(--muted); }

/* Activity type colours (same as the student activity pages), used on Create and All Activities (0.36.2). */
.tc-quiz { --tc: #f43f5e; } .tc-mission { --tc: #f59e0b; } .tc-tournament { --tc: #db2777; } .tc-exit { --tc: #0891b2; }
.tc-pspm { --tc: #7c3aed; } .tc-gup { --tc: #ea580c; } .tc-ups { --tc: #16a34a; } .tc-live { --tc: #10b981; }
.act-type-card[class*="tc-"] { border-top-color: var(--tc); }
.create-hero { margin: 8px 0 16px; padding: 22px 24px; border-radius: 22px; border-left: 6px solid var(--tc);
  background: linear-gradient(120deg, color-mix(in srgb, var(--tc) 16%, var(--surface)), var(--surface) 75%); box-shadow: var(--shadow); }
.create-hero h1 { margin: 10px 0 6px; font-size: clamp(1.4rem, 3vw, 2rem); }
.create-hero p { margin: 0 0 6px; max-width: 900px; }
.create-hero .create-note { color: var(--muted); font-size: .9rem; margin: 0; }
.create-pill { display: inline-block; padding: 5px 14px; border-radius: 999px; font-size: .82rem; font-weight: 800; color: #fff; background: var(--tc); }
.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 10px; margin-bottom: 18px; }
.type-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 2px solid color-mix(in srgb, var(--tc) 30%, var(--border)); transition: transform .12s ease, border-color .12s ease, background .12s ease; }
a.type-card:hover { transform: translateY(-2px); border-color: var(--tc); color: var(--text); }
.type-card.is-on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, var(--surface)); box-shadow: 0 6px 18px color-mix(in srgb, var(--tc) 25%, transparent); }
.type-card-emoji { font-size: 1.6rem; line-height: 1; }
.type-card-text { display: flex; flex-direction: column; min-width: 0; }
.type-card-text strong { font-size: .95rem; }
.type-card-text small { color: var(--muted); font-size: .78rem; }
.type-card-check { position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 800; color: #fff; background: var(--tc); }
@media (max-width: 560px) { .type-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); } .type-card { padding: 10px; } .type-card-emoji { font-size: 1.3rem; } }
/* Create forms: question source, preview with Delete / Change, and the Change dialog (0.37.0). */
.q-source { border: 1px dashed var(--border); border-radius: 14px; padding: 12px 14px 6px; }
.q-source legend { font-weight: 700; padding: 0 6px; }
.field-sub { margin: 8px 0 6px; font-weight: 700; font-size: .85rem; color: var(--muted); }
.qp-panel { border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; background: var(--surface-2); margin-bottom: 16px; }
.qp-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; justify-content: space-between; }
.qp-title { margin: 0 0 4px; font-size: 1rem; }
.qp-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.qp-status { margin: 10px 0; font-size: .88rem; font-weight: 600; }
.qp-status:empty { display: none; }
.qp-status.is-warn { color: var(--warn); }
.qp-card .q-badges { flex-wrap: wrap; }
.qp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.qp-delete { color: var(--danger); }
.qp-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: 18px; padding: 18px 20px; background: var(--surface); color: var(--text); }
.qp-dialog::backdrop { background: rgba(10, 14, 30, .55); }
.qp-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qp-dialog-head h3 { margin: 0; }
.qp-results { display: grid; gap: 10px; max-height: 48vh; overflow: auto; padding-right: 4px; }
.qp-option { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.qp-option > input { width: 20px; height: 20px; margin-top: 4px; flex: none; cursor: pointer; }
.qp-option-body { min-width: 0; flex: 1; }
.qp-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
@media (max-width: 560px) { .qp-panel { padding: 12px; } .qp-dialog { padding: 14px; } }

/* Admin class cards, join codes and the group directory (0.38.0). */
.class-card-box { display: flex; flex-direction: column; gap: 4px; min-width: 150px; max-width: 220px; }
.class-card-box .class-card-link { min-width: 0; height: 100%; }
.class-card-lecturers { font-size: .78rem; line-height: 1.3; overflow-wrap: anywhere; }
.class-card-link[aria-current="page"] .class-card-lecturers { opacity: .9; }
.class-card-action { font-size: .8rem; font-weight: 700; text-align: center; padding: 4px 8px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.class-card-action:hover { background: var(--primary); color: var(--primary-ink); }
.join-code { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.join-code form { margin: 0; }
.join-code-label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.join-code-value { font-size: 1.15rem; letter-spacing: .14em; }
.join-code.is-closed .join-code-value { opacity: .55; text-decoration: line-through; }
.group-counts { display: flex; gap: 10px; margin: 8px 0; }
.group-counts > div { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface-2); }
.group-counts strong { font-size: 1.4rem; }
.group-counts span { font-size: .8rem; color: var(--muted); }
.group-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.target-block { margin-top: 8px; }
.target-block > summary { color: var(--text); }
.replace-form { margin-top: 6px; }
.join-group input[name="code"] { width: 9em; text-transform: uppercase; letter-spacing: .12em; }
.create-box > summary { cursor: pointer; margin: 0; }
.create-box[open] > summary { margin-bottom: 12px; }

/* Crowd Poll bars (0.40.0). */
.poll-bars { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.poll-bars li { display: grid; grid-template-columns: 3.2em 1fr 3em; align-items: center; gap: 8px; font-size: .88rem; }
.poll-label { font-weight: 800; }
.poll-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.poll-fill { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--primary); }
.poll-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Themes page (0.42.0) ---------- */
.theme-btn span { font-size: 1.15rem; line-height: 1; }
.theme-btn[aria-current="page"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.mh-themes { background: linear-gradient(120deg, #312e81, #7c3aed 45%, #db2777 75%, #f59e0b); }
.theme-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.theme-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; font-weight: 700; text-decoration: none; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.theme-tabs a[aria-current="page"] { color: #fff; background: var(--primary); }
.theme-count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 999px; font-size: .78rem; background: var(--surface-2); color: var(--muted); }
.theme-tabs a[aria-current="page"] .theme-count { background: rgba(255, 255, 255, .25); color: #fff; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 18px; margin-bottom: 20px; }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 2px solid transparent; scroll-margin-top: 90px; }
.theme-card.is-current { border-color: var(--success); }
.theme-card.is-soon { opacity: .62; }
.theme-card form { margin: 0; }
.theme-thumb { display: grid; grid-template-columns: 22% 1fr; height: 120px; border-radius: 14px; overflow: hidden; background: var(--t-bg); border: 1px solid rgba(0, 0, 0, .08); }
.tt-side { display: grid; align-content: start; gap: 6px; padding: 12px 8px; background: var(--t-side); }
.tt-side i { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--t-acc) 70%, transparent); }
.tt-side i:first-child { background: var(--t-acc); }
.tt-main { display: grid; grid-template-rows: 1fr auto; gap: 8px; padding: 10px; min-width: 0; }
.tt-hero { display: flex; align-items: center; padding: 0 12px; border-radius: 10px; color: #fff; font-weight: 800; font-size: 1.25rem; background: var(--t-hero); white-space: nowrap; overflow: hidden; }
.tt-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tt-cards i { height: 26px; border-radius: 6px; background: var(--t-card); border-bottom: 3px solid var(--t-acc); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.theme-name { margin: 4px 0 0; font-size: 1.05rem; font-weight: 800; }
.theme-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.pill-on { background: var(--success-soft); color: var(--success); }
.pill-free { background: var(--info-soft); color: var(--info); }
.pill-owned { background: var(--primary-soft); color: var(--primary); }
.pill-lock { background: var(--warn-soft); color: var(--warn); }
.pill-default { background: var(--surface-2); color: var(--text); }
.theme-default-form { text-align: center; }

/* ---------- MVP boards (0.42.0) ---------- */
.mvp-boards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.mvp-card { margin-bottom: 20px; scroll-margin-top: 90px; }
.mvp-table th a { color: inherit; text-decoration: none; white-space: nowrap; }
.mvp-table th a:hover { text-decoration: underline; }
.mvp-table th.is-sorted { color: var(--text); }
.mvp-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mvp-table .mvp-rank { font-weight: 800; white-space: nowrap; }
.mvp-table .mvp-name { font-weight: 700; }
.mvp-table .mvp-lecturer { font-size: .85rem; color: var(--muted); min-width: 140px; }
.mvp-table tr.is-me td { background: var(--primary-soft); }
.podium-step.is-open .podium-medal { opacity: .35; filter: grayscale(1); }
.podium-step.is-open .podium-block { opacity: .45; }
.mvp-card .podium { margin-top: 0; }
