/* base.css — Students Hub
 * Shared design tokens + reset + components.
 * Brand: mor #6c5ce7 (primary), cyan #0891b2 (accent).
 * Type: DM Sans (body), Lora (titles).
 *
 * Students Hub is intentionally simpler than CH/AH/TH:
 *   - no dropdown navbars
 *   - no admin tooling chrome
 *   - mobile-first (most students will use phones/tablets)
 */

:root {
  --mor:        #6c5ce7;
  --mor-dk:     #5a4ed1;
  --mor-2:      #efedfb;
  --cyan:       #0891b2;
  --cyan-dk:    #0e7490;
  --cyan-2:     #ecfeff;

  --ink:        #1a1d29;
  --ink-2:      #475066;
  --ink-3:      #7d869c;
  --paper:      #f7f7fb;
  --white:      #ffffff;
  --border:     #e3e5ed;
  --border-2:   #d3d7e1;

  --ok:         #166534;
  --ok-bg:      #dcfce7;
  --warn:       #92400e;
  --warn-bg:    #fef3c7;
  --danger:     #b91c1c;
  --danger-bg:  #fee2e2;

  --gold:       #f59e0b;
  --gold-2:     #fef3c7;
  --silver:     #94a3b8;
  --silver-2:   #f1f5f9;
  --bronze:     #b45309;
  --bronze-2:   #fef3c7;

  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --shadow-sm:  0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow:     0 4px 12px rgba(16,24,40,.08);
  --shadow-lg:  0 12px 32px rgba(16,24,40,.12);

  /* Default stage theme = IGCSE (matches brand) — overridden per body[data-stage] below. */
  --stage:        'igcse';
  --stage-name:   'IGCSE';
  --stage-primary:    #6c5ce7;
  --stage-primary-dk: #5a4ed1;
  --stage-primary-2:  #efedfb;
  --stage-accent:     #0891b2;
  --stage-accent-dk:  #0e7490;
  --stage-accent-2:   #ecfeff;
  --stage-gradient:   linear-gradient(135deg, #6c5ce7 0%, #0891b2 100%);
  --stage-glow:       0 18px 40px -16px rgba(108,92,231,.55);
}

/* ─── Stage themes (per-grade-band) ───────────────────────────────
 * Auth-guard sets body[data-stage] from students/{uid}.gradeLevel:
 *   7-8   → checkpoint   (emerald + amber, friendly)
 *   9-10  → igcse        (mor + cyan, focused — matches brand)
 *   11-12 → alevel       (navy + crimson, prestigious)
 */
body[data-stage="checkpoint"] {
  --stage:        'checkpoint';
  --stage-name:   'Checkpoint';
  --stage-primary:    #10b981;
  --stage-primary-dk: #047857;
  --stage-primary-2:  #d1fae5;
  --stage-accent:     #fbbf24;
  --stage-accent-dk:  #d97706;
  --stage-accent-2:   #fef3c7;
  --stage-gradient:   linear-gradient(135deg, #10b981 0%, #fbbf24 100%);
  --stage-glow:       0 18px 40px -16px rgba(16,185,129,.55);
}
body[data-stage="igcse"] {
  --stage:        'igcse';
  --stage-name:   'IGCSE';
  --stage-primary:    #6c5ce7;
  --stage-primary-dk: #5a4ed1;
  --stage-primary-2:  #efedfb;
  --stage-accent:     #0891b2;
  --stage-accent-dk:  #0e7490;
  --stage-accent-2:   #ecfeff;
  --stage-gradient:   linear-gradient(135deg, #6c5ce7 0%, #0891b2 100%);
  --stage-glow:       0 18px 40px -16px rgba(108,92,231,.55);
}
body[data-stage="alevel"] {
  --stage:        'alevel';
  --stage-name:   'A-Level';
  --stage-primary:    #1e293b;
  --stage-primary-dk: #0f172a;
  --stage-primary-2:  #e2e8f0;
  --stage-accent:     #dc2626;
  --stage-accent-dk:  #991b1b;
  --stage-accent-2:   #fee2e2;
  --stage-gradient:   linear-gradient(135deg, #1e293b 0%, #dc2626 100%);
  --stage-glow:       0 18px 40px -16px rgba(30,41,59,.55);
}

/* Stage-tinted page backgrounds — applied to the IGCSE + A-Level
   bodies same way as Checkpoint (defined later in this file).
   Each stage gets its own dual-radial wash so the negative space
   subtly echoes the hero gradient instead of sitting on neutral
   grey. Fixed attachment for the scroll-stage feel. */
body[data-stage="igcse"] {
  background:
    radial-gradient(ellipse 800px 600px at 0% 0%,    rgba(108,92,231,.20) 0%, transparent 65%),
    radial-gradient(ellipse 800px 600px at 100% 100%, rgba(8,145,178,.20)  0%, transparent 65%),
    #f4f1ff;   /* soft lavender cream base — mor-tinted */
  background-attachment: fixed;
}
body[data-stage="alevel"] {
  background:
    radial-gradient(ellipse 800px 600px at 0% 0%,    rgba(30,41,59,.18) 0%, transparent 65%),
    radial-gradient(ellipse 800px 600px at 100% 100%, rgba(220,38,38,.16) 0%, transparent 65%),
    #f1f3f9;   /* soft slate cream base — navy-tinted */
  background-attachment: fixed;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: 'Lora', Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem;  }

a { color: var(--mor); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ──────────────────────────────────────────────────── */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.page-narrow {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ─── Top bar (minimal, not a dropdown nav) ───────────────────── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Lora', serif; font-size: 1.05rem; font-weight: 600;
  color: var(--ink);
}
.topbar-brand .brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--mor) 0%, var(--cyan) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.85rem; font-weight: 700;
}
.topbar-nav {
  display: flex; align-items: center; gap: 4px;
}
.topbar-nav a {
  padding: 7px 12px; border-radius: 8px;
  font-size: 0.88rem; font-weight: 500;
  color: var(--ink-2);
}
.topbar-nav a:hover     { background: var(--mor-2); color: var(--mor); text-decoration: none; }
.topbar-nav a.active    { background: var(--mor); color: #fff; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
}
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--mor-2); color: var(--mor);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem;
  overflow: hidden;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.topbar-avatar:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--stage-primary);
  text-decoration: none;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title { font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.card-sub   { font-size: 0.84rem; color: var(--ink-3); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: filter .15s, transform .05s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--mor);  color: #fff; }
.btn-primary:hover  { filter: brightness(.93); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--paper); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--mor-2); color: var(--mor); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block  { display: flex; width: 100%; justify-content: center; }
.btn-lg { padding: 14px 22px; font-size: 1rem; border-radius: 12px; }

/* ─── Form fields ────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field-label {
  display: block; font-size: 0.84rem; font-weight: 500;
  color: var(--ink-2); margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit; font-size: 0.95rem;
  border: 1px solid var(--border-2); border-radius: 10px;
  background: var(--white); color: var(--ink);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--mor);
  box-shadow: 0 0 0 3px rgba(108,92,231,.18);
}

/* ─── Keyboard focus ring (only for keyboard users, not mouse clicks) ── */
a:focus-visible, button:focus-visible, .btn:focus-visible,
[role="button"]:focus-visible, [role="radio"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--mor);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ─── Badges + chips ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; line-height: 1.4;
  background: var(--paper); color: var(--ink-2); border: 1px solid var(--border);
}
.badge-mor    { background: var(--mor-2);   color: var(--mor);   border-color: #d6d1f5; }
.badge-cyan   { background: var(--cyan-2);  color: var(--cyan);  border-color: #b8e8f0; }
.badge-ok     { background: var(--ok-bg);   color: var(--ok);    border-color: #a7f3c4; }
.badge-warn   { background: var(--warn-bg); color: var(--warn);  border-color: #fcd34d; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,24,40,.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-overlay.is-open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  width: min(520px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

/* ─── Empty + status states ──────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px; color: var(--ink-3);
}
.empty-title { font-size: 1.05rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

/* ─── Test-taking surface (test.html only) ───────────────────── */
/* Stripped-down body — no topbar, no distractions.
 * Wrap all test content in <body class="test-mode">.
 */
body.test-mode { background: #fafbff; }
body.test-mode .topbar { display: none; }

.test-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px 80px;
}
.test-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.test-progress {
  height: 4px; background: var(--border); border-radius: 2px;
  margin: 12px 0 24px; overflow: hidden;
}
.test-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--mor) 0%, var(--cyan) 100%);
  transition: width .25s;
}
.qstem {
  font-size: 1.08rem; line-height: 1.55;
  color: var(--ink); margin-bottom: 20px;
}
.qopt {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border: 1.5px solid var(--border);
  border-radius: 12px; margin-bottom: 10px;
  cursor: pointer; background: var(--white);
  transition: all .15s;
}
.qopt:hover     { border-color: var(--mor); background: var(--mor-2); }
.qopt.selected  { border-color: var(--mor); background: var(--mor-2); }
.qopt:focus-visible {
  outline: 3px solid var(--mor);
  outline-offset: 2px;
}
.qopt-letter {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--paper); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.84rem; flex-shrink: 0;
}
.qopt.selected .qopt-letter {
  background: var(--mor); color: #fff;
}
.qopt-text { flex: 1; font-size: 0.96rem; line-height: 1.5; min-width: 0; }

/* Diagram / option images often arrive on a flat white canvas (ExamView,
 * latihan.id). When the surrounding container is paper / mor-2 / hover
 * tint the image's white edge becomes a hard rectangular seam. Wrap
 * every <img> inside a stem or option in a small white "tile" — soft
 * border, gentle shadow, breathing-room padding — so it reads as a
 * deliberate inline figure regardless of the container's bg colour.
 * `background:#fff` is intentional even though most images already are
 * — it covers transparent PNGs that would otherwise pick up the option
 * tint. */
.qstem img,
.qopt-text img {
  background: #fff;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  box-sizing: border-box;
}
/* Slightly tighter padding inside options — options are denser than
 * the stem area. */
.qopt-text img { padding: 4px; border-radius: 8px; }

.test-nav {
  display: flex; gap: 12px; margin-top: 24px;
}

/* ─── Stage-themed components ────────────────────────────────────
 * These hook into --stage-* vars so they auto-recolour per grade band.
 */

/* Stage hero — big gradient panel used on dashboard / report */
.stage-hero {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  color: #fff;
  background: var(--stage-gradient);
  box-shadow: var(--stage-glow);
  overflow: hidden;
}
.stage-hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(255,255,255,.18) 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,.12) 0%, transparent 50%);
  pointer-events: none;
}
.stage-hero > * { position: relative; z-index: 1; }
.stage-hero h1 { color: #fff; font-family: 'Lora', serif; letter-spacing: -.3px; }
.stage-hero p  { color: rgba(255,255,255,.92); margin: 6px 0 0; line-height: 1.55; }

/* Stage chip — small label showing current band */
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: .72rem; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  backdrop-filter: blur(8px);
}
.stage-chip-light {
  background: var(--stage-primary-2);
  border: 1px solid var(--stage-primary);
  color: var(--stage-primary-dk);
}
.stage-chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff; opacity: .9;
}
.stage-chip-light .dot { background: var(--stage-primary); opacity: 1; }

/* Stage-themed button override */
.btn-stage {
  background: var(--stage-gradient);
  color: #fff;
  box-shadow: var(--stage-glow);
  border: none;
  transition: transform .15s ease, box-shadow .2s ease, filter .15s ease;
}
.btn-stage:hover {
  filter: brightness(1.05); text-decoration: none;
  transform: translateY(-1px);
}

/* Stage-themed card border accent */
.card-stage {
  border: 1px solid var(--stage-primary-2);
  position: relative;
  overflow: hidden;
}
.card-stage::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--stage-gradient);
}

/* Override .topbar-brand .brand-mark to use stage gradient */
.topbar-brand .brand-mark { background: var(--stage-gradient); }
.topbar-nav a.active { background: var(--stage-primary); }
.topbar-nav a:hover  { background: var(--stage-primary-2); color: var(--stage-primary-dk); }
.topbar-avatar { background: var(--stage-primary-2); color: var(--stage-primary-dk); }

.test-progress-bar { background: var(--stage-gradient); }
.qopt:hover, .qopt.selected { border-color: var(--stage-primary); background: var(--stage-primary-2); }
.qopt.selected .qopt-letter { background: var(--stage-primary); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--stage-primary);
  box-shadow: 0 0 0 3px var(--stage-primary-2);
}

/* ─── Gamification — Points / Level / Streak / Badges ────────── */

.points-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-2) 0%, #fef9c3 100%);
  border: 1px solid var(--gold);
  color: var(--bronze);
  font-weight: 700; font-size: .85rem;
  box-shadow: 0 4px 10px -4px rgba(245,158,11,.45);
}
.points-chip .icon {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}

.streak-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
  border: 1px solid #fb923c;
  color: #9a3412;
  font-weight: 700; font-size: .85rem;
}

/* Level badge — circular with progress ring */
.level-badge {
  position: relative;
  width: 56px; height: 56px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.level-badge svg.ring {
  position: absolute; inset: 0;
  transform: rotate(-90deg);
  width: 100%; height: 100%;
}
.level-badge .ring-track { stroke: var(--stage-primary-2); fill: none; stroke-width: 5; }
.level-badge .ring-fill  { stroke: var(--stage-primary); fill: none; stroke-width: 5; stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.level-badge .level-num {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--stage-gradient);
  color: #fff; font-weight: 800; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--stage-glow);
}
.level-badge-lg { width: 80px; height: 80px; }
.level-badge-lg .level-num { width: 60px; height: 60px; font-size: 1.35rem; }

/* ── Tier system ──────────────────────────────────────────────────
 * Cosmetic-only rank derived from student_points.level:
 *   1–4   apprentice (grey)
 *   5–9   scholar    (cyan)
 *   10–19 mentor     (mor brand)
 *   20–34 master     (mor→cyan gradient + shimmer)
 *   35+   fellow     (gold halo + pulse)
 * Applied via data-tier on .level-badge. Background gradient of the
 * inner pill also swaps so apprentice doesn't look "advanced" by
 * inheriting the stage gradient.
 */
.level-badge[data-tier="apprentice"] .ring-track { stroke: #e3e5ed; }
.level-badge[data-tier="apprentice"] .ring-fill  { stroke: #94a3b8; }
.level-badge[data-tier="apprentice"] .level-num  {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  box-shadow: 0 6px 16px -8px rgba(100,116,139,.5);
}
.level-badge[data-tier="scholar"] .ring-track { stroke: var(--cyan-2); }
.level-badge[data-tier="scholar"] .ring-fill  { stroke: var(--cyan); }
.level-badge[data-tier="scholar"] .level-num  {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-dk) 100%);
  box-shadow: 0 10px 24px -10px rgba(8,145,178,.55);
}
.level-badge[data-tier="mentor"] .ring-track { stroke: var(--mor-2); }
.level-badge[data-tier="mentor"] .ring-fill  { stroke: var(--mor); }
.level-badge[data-tier="mentor"] .level-num  {
  background: linear-gradient(135deg, var(--mor) 0%, var(--mor-dk) 100%);
  box-shadow: 0 12px 28px -10px rgba(108,92,231,.6);
}
.level-badge[data-tier="master"] .ring-track { stroke: var(--mor-2); }
.level-badge[data-tier="master"] .ring-fill  {
  stroke: url(#tierMasterGrad);
}
.level-badge[data-tier="master"] .level-num  {
  background: linear-gradient(135deg, var(--mor) 0%, var(--cyan) 100%);
  background-size: 200% 200%;
  animation: tierMasterShimmer 4s ease-in-out infinite;
  box-shadow: 0 14px 32px -10px rgba(108,92,231,.65);
}
@keyframes tierMasterShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.level-badge[data-tier="fellow"] { filter: drop-shadow(0 0 12px rgba(245,158,11,.55)); }
.level-badge[data-tier="fellow"] .ring-track { stroke: var(--gold-2); }
.level-badge[data-tier="fellow"] .ring-fill  { stroke: var(--gold); }
.level-badge[data-tier="fellow"] .level-num  {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--gold), 0 14px 32px -10px rgba(245,158,11,.7);
  animation: tierFellowPulse 2.4s ease-in-out infinite;
}
@keyframes tierFellowPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* Tier chip — small badge shown next to greeting */
.tier-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  vertical-align: middle;
}
.tier-chip .tier-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.tier-chip[data-tier="apprentice"] { background: #f1f5f9;          color: #475569;          border-color: #cbd5e1; }
.tier-chip[data-tier="scholar"]    { background: var(--cyan-2);    color: var(--cyan-dk);   border-color: #a5f3fc; }
.tier-chip[data-tier="mentor"]     { background: var(--mor-2);     color: var(--mor-dk);    border-color: #c4b5fd; }
.tier-chip[data-tier="master"]     {
  background: linear-gradient(135deg, var(--mor-2) 0%, var(--cyan-2) 100%);
  color: var(--mor-dk); border-color: #c4b5fd;
}
.tier-chip[data-tier="fellow"]     {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e; border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245,158,11,.2);
}

/* Reusable SVG <defs> sprite — drop once per page to enable master gradient */
.tier-svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Stat tile — gamification dashboard cell */
.stat-tile {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  transition: transform .15s ease, box-shadow .2s ease, border-color .15s ease;
}
.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--stage-primary-2);
}
.stat-tile-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-tile-icon.icon-mor    { background: var(--stage-primary-2); color: var(--stage-primary-dk); }
.stat-tile-icon.icon-gold   { background: var(--gold-2); color: var(--bronze); }
.stat-tile-icon.icon-flame  { background: #ffedd5; color: #c2410c; }
.stat-tile-icon.icon-cyan   { background: var(--cyan-2); color: var(--cyan-dk); }
.stat-tile-icon svg { width: 22px; height: 22px; }
.stat-tile-meta { flex: 1; min-width: 0; }
.stat-tile-val  { font-size: 1.35rem; font-weight: 800; color: var(--ink); line-height: 1.1; font-family: 'Lora', serif; }
.stat-tile-lbl  { font-size: .78rem; color: var(--ink-3); margin-top: 2px; font-weight: 500; }

/* Medal (podium ranks) */
.medal {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .82rem;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  flex-shrink: 0;
}
.medal-gold   { background: linear-gradient(135deg, #fde047 0%, #f59e0b 100%); color: #78350f; }
.medal-silver { background: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%); color: #1e293b; }
.medal-bronze { background: linear-gradient(135deg, #fdba74 0%, #b45309 100%); color: #fff; }
.medal-num    { background: var(--paper); color: var(--ink-2); border-color: var(--border); box-shadow: none; font-size: .75rem; }

/* Achievement badge tile */
.badge-tile {
  position: relative;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  transition: transform .15s ease;
}
.badge-tile.earned {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-2) 0%, #fff 100%);
}
.badge-tile.locked { opacity: .55; filter: grayscale(.6); }
.badge-tile:hover { transform: translateY(-2px); }
.badge-tile .glyph {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--stage-gradient);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; margin-bottom: 8px;
}
.badge-tile.earned .glyph {
  background: linear-gradient(135deg, var(--gold) 0%, #ea580c 100%);
}
.badge-tile .name { font-size: .82rem; font-weight: 600; color: var(--ink); line-height: 1.25; }
.badge-tile .when { font-size: .7rem; color: var(--ink-3); margin-top: 2px; }

/* Points-earned pop animation (after submitting attempt) */
@keyframes pointsPop {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  20%  { transform: translateY(-6px) scale(1.2); opacity: 1; }
  60%  { transform: translateY(-30px) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(.95); opacity: 0; }
}
.points-pop {
  position: absolute;
  font-weight: 800; font-size: 1.2rem;
  color: var(--gold); text-shadow: 0 2px 6px rgba(245,158,11,.4);
  pointer-events: none;
  animation: pointsPop 1.6s ease-out forwards;
}

/* ─── Skeleton loaders ───────────────────────────────────────────
 * Use <div class="skel skel-line"></div>, <div class="skel skel-card"></div> etc.
 * Replace "Loading..." text with concrete skeleton shapes.
 */
@keyframes skelShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skel {
  background:
    linear-gradient(90deg,
      rgba(227,229,237,.6) 0%,
      rgba(243,244,250,.95) 50%,
      rgba(227,229,237,.6) 100%);
  background-size: 200% 100%;
  animation: skelShimmer 1.8s linear infinite;
  border-radius: 8px;
  display: block;
}
.skel-line     { height: 14px; margin: 6px 0; }
.skel-line-sm  { height: 10px; margin: 4px 0; width: 60%; }
.skel-title    { height: 22px; width: 50%; margin-bottom: 12px; }
.skel-card     { height: 120px; border-radius: var(--radius); }
.skel-tile     { height: 78px; border-radius: var(--radius); }
.skel-chip     { display: inline-block; height: 24px; width: 80px; border-radius: 999px; vertical-align: middle; }
.skel-avatar   { width: 44px; height: 44px; border-radius: 50%; }

/* ─── Leaderboard primitives ─────────────────────────────────── */
.lb-tabs {
  display: flex; gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 20px;
  width: 100%; overflow-x: auto;
}
.lb-tab {
  flex: 1; min-width: max-content;
  padding: 10px 16px; border-radius: 10px;
  font-size: .88rem; font-weight: 600;
  color: var(--ink-2); cursor: pointer;
  background: transparent; border: none;
  transition: all .15s;
  white-space: nowrap;
}
.lb-tab:hover  { background: var(--stage-primary-2); color: var(--stage-primary-dk); }
.lb-tab.active {
  background: var(--stage-gradient); color: #fff;
  box-shadow: var(--stage-glow);
}

/* Podium for top 3 */
.podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
}
.podium-step {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px 18px;
  text-align: center;
  position: relative;
  transition: transform .15s ease;
}
.podium-step:hover { transform: translateY(-2px); }
.podium-step.rank-1 {
  order: 2;
  background: linear-gradient(180deg, var(--gold-2) 0%, #fff 100%);
  border: 2px solid var(--gold);
  padding-top: 22px; padding-bottom: 26px;
  box-shadow: 0 12px 28px -8px rgba(245,158,11,.5);
}
.podium-step.rank-2 {
  order: 1;
  background: linear-gradient(180deg, var(--silver-2) 0%, #fff 100%);
  border: 1.5px solid var(--silver);
}
.podium-step.rank-3 {
  order: 3;
  background: linear-gradient(180deg, var(--bronze-2) 0%, #fff 100%);
  border: 1.5px solid var(--bronze);
}
.podium-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--stage-primary-2); color: var(--stage-primary-dk);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem;
  margin: 0 auto 8px;
  border: 3px solid #fff; box-shadow: var(--shadow);
  overflow: hidden;
}
.podium-step.rank-1 .podium-avatar { width: 72px; height: 72px; font-size: 1.5rem; }
.podium-avatar img { width: 100%; height: 100%; object-fit: cover; }
.podium-name { font-weight: 700; font-size: .9rem; color: var(--ink); line-height: 1.25; }
.podium-meta { font-size: .76rem; color: var(--ink-3); margin-top: 2px; }
.podium-pts  { font-family: 'Lora', serif; font-weight: 700; font-size: 1.15rem; margin-top: 6px; color: var(--stage-primary-dk); }
.podium-step.rank-1 .podium-pts { color: var(--bronze); font-size: 1.35rem; }

/* Leaderboard row (rank 4+) */
.lb-row {
  display: grid;
  grid-template-columns: 36px 44px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--white);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: all .15s;
}
.lb-row:hover { border-color: var(--stage-primary-2); box-shadow: var(--shadow-sm); }
.lb-row.is-me {
  border: 2px solid var(--stage-primary);
  background: var(--stage-primary-2);
}
.lb-row .rank {
  text-align: center; font-weight: 700; color: var(--ink-3); font-size: .9rem;
}
.lb-row .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--stage-primary-2); color: var(--stage-primary-dk);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  overflow: hidden;
}
.lb-row .avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-row .name   { font-weight: 600; color: var(--ink); font-size: .94rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .meta   { font-size: .76rem; color: var(--ink-3); }
.lb-row .pts    { font-family: 'Lora', serif; font-weight: 700; color: var(--ink); font-size: 1rem; }
.lb-row .delta  { font-size: .76rem; font-weight: 600; }
.lb-row .delta.up    { color: var(--ok); }
.lb-row .delta.down  { color: var(--danger); }

/* ─── Phone topbar (2026-10-02) ────────────────────────────────
   Brand + points/avatar stay on the first row; the nav drops to its
   own full-width row and scrolls sideways instead of overflowing the
   viewport (it used to push the page wider than a 375 px phone). */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; padding: 10px 14px; }
  .topbar-nav {
    order: 3; width: 100%;
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav a { flex: 0 0 auto; white-space: nowrap; padding: 9px 12px; }
}

/* ─── Mobile tweaks ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar-nav a { padding: 6px 10px; font-size: 0.84rem; }
  .topbar-brand { font-size: 0.95rem; }
  .page, .page-narrow { padding: 20px 16px 60px; }
  h1 { font-size: 1.5rem; }
  .card { padding: 16px; }
  .stage-hero { padding: 20px 18px; }
  .podium { gap: 8px; }
  .podium-step { padding: 12px 8px 14px; }
  .podium-step.rank-1 .podium-avatar { width: 56px; height: 56px; }
  .podium-avatar { width: 44px; height: 44px; font-size: 1rem; }
  .lb-row { grid-template-columns: 28px 36px 1fr auto; gap: 8px; padding: 10px; }
  .lb-row .delta { display: none; }
}

/* Reduced-motion safety */
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: rgba(227,229,237,.6); }
  .points-pop { animation: none; }
}

/* ─── Feedback FX — micro-animations (partials/feedback-fx.js) ──── */

/* One-shot pulse — fx.pulse(el, variant) adds these classes for ~700ms */
@keyframes fx-pulse-success-kf {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.55); }
  60%  { box-shadow: 0 0 0 14px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes fx-pulse-warn-kf {
  0%   { box-shadow: 0 0 0 0 rgba(185,28,28,.5); }
  60%  { box-shadow: 0 0 0 14px rgba(185,28,28,0); }
  100% { box-shadow: 0 0 0 0 rgba(185,28,28,0); }
}
@keyframes fx-pulse-gold-kf {
  0%   { box-shadow: 0 0 0 0 rgba(245,158,11,.6); transform: scale(1); }
  40%  { transform: scale(1.08); }
  60%  { box-shadow: 0 0 0 18px rgba(245,158,11,0); }
  100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); transform: scale(1); }
}
.fx-pulse-success { animation: fx-pulse-success-kf .65s cubic-bezier(.2,.8,.2,1) both; }
.fx-pulse-warn    { animation: fx-pulse-warn-kf    .65s cubic-bezier(.2,.8,.2,1) both; }
.fx-pulse-gold    { animation: fx-pulse-gold-kf    .75s cubic-bezier(.2,.8,.2,1) both; }

/* Streak flame — appended next to .feedback.ok when streak >= 3 */
@keyframes fx-flame-kf {
  0%   { transform: scale(.6) rotate(-8deg); opacity: 0; }
  30%  { transform: scale(1.25) rotate(6deg); opacity: 1; }
  70%  { transform: scale(1) rotate(-3deg); opacity: 1; }
  100% { transform: scale(.95) rotate(0); opacity: .85; }
}
.fx-flame {
  display: inline-block;
  animation: fx-flame-kf .9s cubic-bezier(.2,.8,.2,1) both;
  filter: drop-shadow(0 0 6px rgba(245,158,11,.55));
  font-size: 1.4rem;
  vertical-align: middle;
  margin-left: 4px;
}

/* Correct option flash — overlay on the chosen option for ~600ms */
@keyframes fx-flash-correct-kf {
  0%   { background-color: rgba(16,185,129,.4); transform: scale(1); }
  40%  { background-color: rgba(16,185,129,.25); transform: scale(1.02); }
  100% { background-color: rgba(16,185,129,0); transform: scale(1); }
}
.fx-flash-correct { animation: fx-flash-correct-kf .6s ease-out both; }

/* Wrong option shake — short horizontal jitter, no scale */
@keyframes fx-shake-kf {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}
.fx-shake { animation: fx-shake-kf .42s cubic-bezier(.3,.8,.3,1) both; }

/* Level-up overlay — full-screen brief celebration */
.fx-levelup-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: radial-gradient(circle at center, rgba(108,92,231,.35) 0%, rgba(15,23,42,.65) 70%);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
.fx-levelup-overlay.is-shown { opacity: 1; }
.fx-levelup-card {
  background: linear-gradient(135deg, #6c5ce7 0%, #0891b2 100%);
  color: #fff;
  padding: 36px 48px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 30px 60px -10px rgba(0,0,0,.6), 0 0 0 4px rgba(255,255,255,.18);
  transform: scale(.7) rotate(-2deg);
  transition: transform .45s cubic-bezier(.34,1.56,.64,1);
  min-width: 220px;
}
.fx-levelup-overlay.is-shown .fx-levelup-card { transform: scale(1) rotate(0); }
.fx-levelup-eyebrow {
  font-size: .72rem; font-weight: 700;
  letter-spacing: .25em; text-transform: uppercase;
  opacity: .85; margin-bottom: 8px;
}
.fx-levelup-num {
  font-family: 'Lora', serif;
  font-size: 4rem; font-weight: 700;
  line-height: 1;
  margin: 4px 0 6px;
  text-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.fx-levelup-tier {
  font-size: 1rem; font-weight: 600;
  opacity: .95;
}

/* Mute toggle button in topbar */
.fx-mute-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-3);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all .12s;
  padding: 0;
}
.fx-mute-btn:hover {
  border-color: var(--stage-primary);
  color: var(--stage-primary);
  background: var(--stage-primary-2);
}
.fx-mute-btn.is-muted {
  color: var(--ink-3);
  background: var(--paper);
}

/* Reduced motion: kill anims, keep overlay (no harm) */
@media (prefers-reduced-motion: reduce) {
  .fx-pulse-success, .fx-pulse-warn, .fx-pulse-gold,
  .fx-flame, .fx-flash-correct, .fx-shake { animation: none; }
  .fx-levelup-overlay { transition: opacity .12s; }
  .fx-levelup-card { transition: none; transform: none; }
}

/* ───────────────────────────────────────────────────────────────
 * CHECKPOINT-STAGE CARTOON OVERHAUL (Year 7-8 pilot, 2026-05-13)
 *
 * Scoped to body[data-stage="checkpoint"] only — IGCSE + A-Level
 * keep their existing professional chrome.
 *
 * Design hooks:
 *   - "Chunky" offset shadows for a 3D-button game feel
 *   - Larger border-radius everywhere (18-24px)
 *   - Thicker borders (2-3px)
 *   - Boosted colour saturation in the Checkpoint palette
 *   - Springier interaction transitions (cubic-bezier overshoot)
 *
 * Nothing is page-specific — pages that respect base.css tokens
 * inherit automatically. Page-level overrides on specific surfaces
 * (dashboard hero, quest panel) live in their own <style> block.
 * ─────────────────────────────────────────────────────────────── */
body[data-stage="checkpoint"] {
  /* Boost the existing emerald + amber palette */
  --stage-primary:    #059669;
  --stage-primary-dk: #065f46;
  --stage-primary-2:  #d1fae5;
  --stage-accent:     #f59e0b;
  --stage-accent-dk:  #b45309;
  --stage-accent-2:   #fef3c7;
  --stage-gradient:   linear-gradient(135deg, #10b981 0%, #fbbf24 100%);
  --stage-glow:       0 14px 28px -8px rgba(16,185,129,.45),
                      0 0 0 1px rgba(255,255,255,.4) inset;
  /* Cartoon-specific tokens */
  --cp-shadow-chunk:  0 4px 0 rgba(6,95,70,.18);
  --cp-shadow-chunk-lg: 0 6px 0 rgba(6,95,70,.22);
  --cp-radius:        18px;
  --cp-radius-lg:     24px;
  --cp-border:        2px solid rgba(6,95,70,.16);
  --cp-spring:        cubic-bezier(.34,1.56,.64,1);
}

/* Soft tinted page background for Checkpoint — two radial washes
   (emerald top-left, amber bottom-right) layered on a soft mint-
   cream base instead of neutral paper grey. Cards keep their
   white/paper fills, so the wash only shows in negative space.
   Fixed attachment so the tint stays put while content scrolls. */
body[data-stage="checkpoint"] {
  background:
    radial-gradient(ellipse 800px 600px at 0% 0%,    rgba(16,185,129,.22) 0%, transparent 65%),
    radial-gradient(ellipse 800px 600px at 100% 100%, rgba(251,191,36,.22) 0%, transparent 65%),
    #f0fbf6;   /* soft mint cream base — emerald-tinted off-white */
  background-attachment: fixed;
}

/* Cards: thicker borders, chunky offset shadow, more rounded */
body[data-stage="checkpoint"] .card {
  border: var(--cp-border);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow-chunk);
  transition: transform .15s var(--cp-spring),
              box-shadow .15s var(--cp-spring);
}
body[data-stage="checkpoint"] .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--cp-shadow-chunk-lg);
}

/* Hero — extra punch + soft rotated highlight */
body[data-stage="checkpoint"] .stage-hero,
body[data-stage="checkpoint"] .hero-dc,
body[data-stage="checkpoint"] .ease-cta,
body[data-stage="checkpoint"] .start-bar {
  border-radius: var(--cp-radius-lg);
  box-shadow:
    0 18px 32px -8px rgba(16,185,129,.45),
    0 8px 0 rgba(6,95,70,.18),
    0 0 0 2px rgba(255,255,255,.4) inset;
}

/* Primary buttons get a 3D-game button feel */
body[data-stage="checkpoint"] .btn-primary,
body[data-stage="checkpoint"] .dc-cta,
body[data-stage="checkpoint"] .btn-start,
body[data-stage="checkpoint"] .btn-next {
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 4px 0 rgba(6,95,70,.32),
              0 8px 16px -4px rgba(16,185,129,.45);
  transition: transform .12s var(--cp-spring),
              box-shadow .12s var(--cp-spring);
}
body[data-stage="checkpoint"] .btn-primary:hover,
body[data-stage="checkpoint"] .dc-cta:hover,
body[data-stage="checkpoint"] .btn-start:hover:not(:disabled),
body[data-stage="checkpoint"] .btn-next:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 0 rgba(6,95,70,.32),
              0 10px 22px -4px rgba(16,185,129,.55);
}
body[data-stage="checkpoint"] .btn-primary:active,
body[data-stage="checkpoint"] .dc-cta:active,
body[data-stage="checkpoint"] .btn-start:active:not(:disabled),
body[data-stage="checkpoint"] .btn-next:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(6,95,70,.32),
              0 3px 8px -2px rgba(16,185,129,.55);
}

/* Stat tiles get chunky shadows + spring hover */
body[data-stage="checkpoint"] .stat-tile {
  border: var(--cp-border);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow-chunk);
  transition: transform .15s var(--cp-spring),
              box-shadow .15s var(--cp-spring);
}
body[data-stage="checkpoint"] .stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--cp-shadow-chunk-lg);
}

/* CTA tiles → bouncier hover */
body[data-stage="checkpoint"] .cta-tile {
  border: var(--cp-border);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow-chunk);
  transition: transform .18s var(--cp-spring),
              box-shadow .18s var(--cp-spring),
              border-color .12s;
}
body[data-stage="checkpoint"] .cta-tile:hover {
  transform: translateY(-3px) rotate(-.4deg);
  box-shadow: var(--cp-shadow-chunk-lg);
}
body[data-stage="checkpoint"] .cta-tile:nth-child(2n):hover { transform: translateY(-3px) rotate(.4deg); }

/* Level badge — slightly thicker ring + drop shadow */
body[data-stage="checkpoint"] .level-badge .ring-track { stroke-width: 6; }
body[data-stage="checkpoint"] .level-badge .ring-fill  { stroke-width: 6; }
body[data-stage="checkpoint"] .level-badge .level-num {
  box-shadow:
    0 4px 0 rgba(6,95,70,.32),
    var(--stage-glow);
}

/* Topbar: cleaner separation, no glass effect needed */
body[data-stage="checkpoint"] .topbar {
  border-bottom: 2px solid rgba(6,95,70,.12);
  box-shadow: 0 2px 0 rgba(6,95,70,.06);
}
body[data-stage="checkpoint"] .topbar-nav a.active {
  background: var(--stage-primary);
  box-shadow: 0 3px 0 rgba(6,95,70,.32);
}

/* Stage chip — pill with a hand-drawn vibe */
body[data-stage="checkpoint"] .stage-chip {
  border: 2px solid currentColor;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 12px;
}
body[data-stage="checkpoint"] .tier-chip {
  font-weight: 800;
  letter-spacing: .06em;
  box-shadow: 0 2px 0 rgba(6,95,70,.18);
}

/* Reduced motion respects user preference */
@media (prefers-reduced-motion: reduce) {
  body[data-stage="checkpoint"] .card,
  body[data-stage="checkpoint"] .stat-tile,
  body[data-stage="checkpoint"] .cta-tile,
  body[data-stage="checkpoint"] .btn-primary,
  body[data-stage="checkpoint"] .dc-cta,
  body[data-stage="checkpoint"] .btn-start,
  body[data-stage="checkpoint"] .btn-next {
    transition: none;
  }
  body[data-stage="checkpoint"] .card:hover,
  body[data-stage="checkpoint"] .stat-tile:hover,
  body[data-stage="checkpoint"] .cta-tile:hover {
    transform: none;
  }
}

/* ─── HQ Observer Strip ─────────────────────────────────────────────
   Shared by /practice-run, /test and /ease-test. Only rendered when
   students/{uid}.is_hq_observer === true. Plain students never see it.
   Helper: partials/observer-strip.js builds the runtime behaviour.
   Flag target: practice_question_flags collection.
*/
.obs-strip {
  margin-top: 14px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px dashed #f59e0b;
  border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  font-size: .8rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
/* `hidden` HTML attribute is overridden by the explicit `display:flex`
   above, which is why the strip showed for non-observer students. Make
   the attribute win so only window.installObserverStrip → update() can
   reveal it (it sets stripEl.hidden = false after observer mode is
   confirmed). */
.obs-strip[hidden] { display: none; }
.obs-strip .obs-eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: #92400e;
}
.obs-strip .obs-id {
  flex: 1 1 auto; min-width: 200px;
  color: #1f2937; font-weight: 600;
  word-break: break-all;
}
.obs-strip .obs-meta {
  font-family: 'DM Sans', sans-serif;
  color: #92400e; font-size: .76rem;
}
.obs-strip .obs-btn {
  font-family: 'DM Sans', sans-serif;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .76rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  border: 1px solid #f59e0b;
  background: #fff; color: #92400e;
  transition: background .12s;
}
.obs-strip .obs-btn:hover { background: #fef3c7; }
.obs-strip .obs-btn.is-primary { background: #f59e0b; color: #fff; }
.obs-strip .obs-btn.is-primary:hover { background: #d97706; }
.obs-strip .obs-btn.is-flagged { background: #ef4444; color: #fff; border-color: #dc2626; cursor: default; }

.obs-modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.obs-modal-back.is-open { display: flex; }
.obs-modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px -10px rgba(0,0,0,.3);
}
.obs-modal h3 {
  margin: 0 0 6px;
  font-family: 'Lora', serif;
  font-size: 1.15rem;
}
.obs-modal p.sub {
  margin: 0 0 14px;
  color: var(--ink-3);
  font-size: .85rem;
}
.obs-modal .obs-modal-id {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .76rem;
  background: var(--paper);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  word-break: break-all;
}
.obs-modal label.obs-reason {
  display: block;
  font-size: .82rem;
  color: var(--ink-2);
  margin-bottom: 4px;
  font-weight: 600;
}
.obs-modal select, .obs-modal textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.obs-modal textarea { min-height: 70px; resize: vertical; }
.obs-modal .obs-modal-actions {
  display: flex; gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.obs-modal .obs-modal-err {
  color: var(--danger);
  font-size: .8rem;
  margin: 0 0 8px;
  display: none;
}
.obs-modal .obs-modal-err.is-visible { display: block; }

/* Star (endorse) button — same look as flag button but cyan, not amber.
   .is-starred state filled in once the specialist has saved an endorsement. */
.obs-strip .obs-btn.is-starred {
  background: #d1fae5; color: #065f46;
  border-color: #6ee7b7;
}
.obs-strip .obs-btn.is-starred:hover { background: #a7f3d0; }

/* Endorse modal tag-row — checkbox chips */
.obs-modal .obs-tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.obs-modal .obs-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .82rem;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
  user-select: none;
}
.obs-modal .obs-tag:hover { border-color: #f59e0b; }
.obs-modal .obs-tag input[type="checkbox"] {
  margin: 0;
  accent-color: #f59e0b;
}
.obs-modal .obs-tag:has(input:checked) {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 600;
}

/* Students Hub logo mark (2026-10-03) — replaces the gradient "E" tile in the topbar */
.topbar-brand .brand-mark-img { width: 34px; height: 34px; display: block; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(15,95,102,.35)); }
