/* ============================================================
   Soft UI overrides — re-skins the v2 shell components onto the
   neumorphic token set. Loaded last, so it wins.
   ============================================================ */

/* ---------- Shell ---------- */

.shell { background: var(--bg); }

.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 20px 14px 16px;
}

.sidebar .brand { color: var(--text); padding: 4px 8px 20px; }
.brand-accent { color: var(--accent); }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.sidebar .nav-link {
  border-radius: var(--radius-pill);
  padding: 11px 15px;
  color: var(--text-muted);
  font-weight: 600;
  border: 1px solid transparent;
  transition: background var(--press) var(--ease), color var(--press) var(--ease);
}
.sidebar .nav-link:hover {
  background: var(--surface-raised);
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--text);
}
.sidebar .nav-link.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-on);
  box-shadow: var(--shadow-soft);
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }

.sidebar .user-chip {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  padding: 8px 10px;
}
.user-avatar {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.sidebar .user-name { color: var(--text); }
.sidebar .user-role { color: var(--text-dim); }
.sidebar .logout {
  border-radius: var(--radius-pill);
  color: var(--text-dim);
}
.sidebar .logout:hover { background: var(--wrong-bg); color: var(--wrong); }

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-title { color: var(--text); }
.nav-toggle {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  color: var(--text);
}

/* Theme toggle sits beside the user chip */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--text-muted);
  transition: color var(--press) var(--ease), transform var(--press) var(--ease);
}
.theme-toggle:hover { color: var(--accent); transform: translateY(-1px); }

/* ---------- Stat tiles ---------- */

.stat-tile {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 17px 18px;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent-tile, var(--accent));
}
.stat-value { color: var(--text); font-size: 1.55rem; font-weight: 800; }
.stat-label { color: var(--text-dim); font-size: 0.78rem; }

/* ---------- Rows ---------- */

.row-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 13px 15px;
}
.row-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
}
.row-title { color: var(--text); font-weight: 700; }
.row-sub { color: var(--text-dim); }

/* ---------- Section headings ---------- */

.section-label {
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.section-action { color: var(--text-muted); }
.section-action:hover { color: var(--accent); }

/* ---------- Quiz cards ---------- */

.quiz-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  transition: transform var(--press) var(--ease), box-shadow var(--press) var(--ease);
}
.quiz-card:hover { transform: translateY(-3px); text-decoration: none; }
.quiz-card h3 { color: var(--text); }

/* ---------- Player ---------- */

.question-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: 30px 32px;
}
.question-text {
  color: var(--text);
  font-size: 1.32rem;
  font-weight: 700;
  line-height: 1.4;
}

.progress-track {
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  border-radius: var(--radius-pill);
  height: 10px;
  overflow: hidden;
}
.progress-fill {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-pill);
}
.progress-count { color: var(--text-muted); font-weight: 600; }

.q-difficulty {
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  padding: 4px 13px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.q-difficulty.easy   { color: var(--correct); }
.q-difficulty.medium { color: var(--gold); }
.q-difficulty.hard   { color: var(--wrong); }

.explain {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.explain-head { color: var(--accent); font-weight: 700; }

/* ---------- Results ---------- */

.results { background: none; border: none; box-shadow: none; }
.score-ring-label .score-pct { color: var(--text); }
.ring-bg { stroke: var(--surface-sunk); }
.ring-fill { stroke: var(--accent); }

/* ---------- Answer review ----------

   The old version gave every row an identical card: coloured stripe, icon
   circle, three stacked lines. Six of those in a column read as machine
   output, and the 3px left border against a 14px radius left a tapered
   sliver at the corner that looked like a detached floating stripe.

   Now: correct answers collapse to one quiet line, wrong answers get the
   detail. Status is carried by a filled number chip, so no mismatched
   border widths are involved.                                            */

.review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px;
  transition: border-color var(--press) var(--ease);
}

/* Correct answers recede: they need acknowledgement, not attention. */
.review-item.ok {
  background: var(--surface);
  box-shadow: none;
}
.review-item.bad {
  border-color: color-mix(in srgb, var(--wrong) 32%, var(--border));
}

.review-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* The number chip carries the status. A filled shape reads at a glance and
   avoids the border-width mismatch that caused the corner artifact. */
.review-num {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.review-item.ok .review-num {
  background: var(--correct-bg);
  color: var(--correct);
}
.review-item.bad .review-num {
  background: var(--wrong);
  /* Light theme's --wrong is dark enough for white text; dark theme's is a
     light coral where white drops to 2.7:1. --accent-on flips with the theme
     and clears AA in both (6.3:1 light, 6.9:1 dark). */
  color: var(--accent-on);
}

.review-body { flex: 1; min-width: 0; }

.review-q {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 3px 0 0;
  line-height: 1.45;
}

/* A correct answer is a single quiet line under the question. */
.review-a-ok {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.review-detail {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.answer-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 0.9rem;
}

/* Small caps tag instead of a sentence, so the answer text leads. */
.answer-tag {
  flex: 0 0 auto;
  min-width: 52px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-top: 1px;
}

.answer-val { font-weight: 600; }
.answer-row.is-wrong   .answer-val { color: var(--wrong); text-decoration: line-through;
                                     text-decoration-thickness: 1px;
                                     text-decoration-color: color-mix(in srgb, var(--wrong) 45%, transparent); }
.answer-row.is-correct .answer-val { color: var(--correct); }

.review-why {
  margin: 9px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.ans-correct { color: var(--correct); }
.ans-wrong { color: var(--wrong); }

/* ---------- Tables ---------- */

.table-wrap {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  /* dashboard.css sets overflow-x:auto so table.data (min-width:620px) can
     scroll horizontally on narrow screens; keep that and only clip the
     vertical edges here so the table's square corners still respect the
     wrapper's border-radius. A flat overflow:hidden previously loaded last
     and silently cancelled the horizontal scroll, clipping the Score/XP/When
     columns off-screen on phones with no way to reach them.
     max-width:100% is required too -- without it this block-level wrap has
     no width limit of its own, so it just grows to the table's 620px
     min-width instead of clamping to the viewport and letting the table
     scroll inside it. */
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
table.data th {
  background: var(--surface-sunk);
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
table.data td { border-bottom: 1px solid var(--border); color: var(--text-2); }
table.data tr:last-child td { border-bottom: none; }

/* ---------- Bars & rings ---------- */

.bar {
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  border-radius: var(--radius-pill);
  height: 9px;
  overflow: hidden;
}
.bar-fill { border-radius: var(--radius-pill); }
.bar-fill.good { background: var(--correct); }
.bar-fill.mid  { background: var(--gold); }
.bar-fill.low  { background: var(--wrong); }
.mini-ring-label { color: var(--text); font-weight: 700; }

/* ---------- States ---------- */

.state {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 40px 30px;
}
.state h3 { color: var(--text); }
.state-icon, .state-glyph {
  background: var(--surface-sunk);
  border: none;
  box-shadow: var(--shadow-press);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
}
.big-glyph {
  background: var(--gold-bg);
  color: var(--gold);
  box-shadow: none;
}

.alert {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}
.alert-ok    { background: var(--correct-bg); border-color: transparent; color: var(--correct); }
.alert-error { background: var(--wrong-bg);   border-color: transparent; color: var(--wrong); }
.alert-info  { background: var(--accent-soft);border-color: transparent; color: var(--accent); }

/* ---------- Badges ---------- */

.badge-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.badge-item.locked { opacity: 0.45; filter: grayscale(1); box-shadow: var(--shadow-press); }
.badge-icon { color: var(--gold); }
.badge-name { color: var(--text-2); }

/* ---------- Study modes ---------- */

/* A 3px left border against a 1px top border and a 14px radius makes the
   browser taper one into the other around the curve, leaving a wedge that
   reads as a detached floating stripe. Use an inset shadow for the accent
   edge instead: uniform border widths, no taper. */
.study-head {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-soft);
}
.study-head-icon {
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  border-radius: var(--radius-pill);
  color: var(--accent);
}
.study-title { color: var(--text); }

.exam-timer {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-press);
  color: var(--text);
}
.exam-timer.urgent {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
}

.mode-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 0  var(--accent), var(--shadow-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
  padding: 18px;
}
.mode-card:hover { transform: translateY(-3px); background: var(--surface-raised); }
.mode-card-icon {
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  border-radius: var(--radius-pill);
  color: var(--accent);
}
.mode-card-title { color: var(--text); }
.mode-card-sub { color: var(--text-dim); }

.due-badge { background: var(--gold-bg); color: var(--gold); }

/* ---------- Auth ---------- */

.auth-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.demo-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  transition: transform var(--press) var(--ease);
}
.demo-btn:hover { transform: translateY(-1px); }
.demo-icon {
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  border-radius: var(--radius-pill);
  color: var(--accent);
}
.d-role { color: var(--text); }
.d-mail { color: var(--text-dim); }
.auth-divider { color: var(--text-dim); }

/* ---------- Weekly bars ---------- */

.week-bar { background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.week-bar-label { color: var(--text-dim); }

/* ---------- Public header ---------- */

.app-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
}
.hero h1 { color: var(--text); }
.accent { color: var(--accent); }

/* ============================================================
   Curriculum browser (v3)
   ============================================================ */

.crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.crumbs a { color: var(--text-muted); display: inline-flex; align-items: center; gap: 5px; }
.crumbs a:hover { color: var(--accent); text-decoration: none; }

.subject-head {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px 22px;
  margin-bottom: 24px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  flex-wrap: wrap;
}
.subject-head-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent-tile, var(--accent));
}
.subject-title { font-size: 1.45rem; margin-bottom: 3px; }

/* ---- Subject grid ---- */

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.subject-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  color: var(--text);
  transition: transform var(--press) var(--ease);
}
.subject-card:hover { transform: translateY(-3px); text-decoration: none; }
.subject-card-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent-tile, var(--accent));
}
.subject-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.subject-card-title { font-weight: 700; font-size: 1rem; }
.subject-card-end { flex: none; }

/* ---- Chapters ---- */

.chapter { margin-bottom: 26px; }
.chapter-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.chapter-num {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--text-muted);
  font-weight: 800;
  font-size: 0.9rem;
}
.chapter-title { font-size: 1.05rem; }

.quiz-list { display: flex; flex-direction: column; gap: 10px; padding-left: 52px; }

.quiz-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 17px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  transition: transform var(--press) var(--ease);
}
a.quiz-row:hover { transform: translateX(3px); text-decoration: none; }
.quiz-row.is-locked { opacity: 0.72; box-shadow: var(--shadow-press); cursor: default; }
.quiz-row-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent);
}
.quiz-row.is-locked .quiz-row-icon { color: var(--text-dim); }
.quiz-row-title { display: block; font-weight: 700; font-size: 0.93rem; }
.quiz-row-end { flex: none; }

@media (max-width: 640px) {
  .quiz-list { padding-left: 0; }
  .chapter-head { gap: 10px; }
  .subject-grid { grid-template-columns: 1fr; }
  .subject-head { flex-direction: column; align-items: stretch; }
  .subject-head .btn { width: 100%; }
}

/* ============================================================
   Onboarding wizard
   ============================================================ */

.onboard { max-width: 780px; margin: 0 auto; }

.onboard-head { text-align: center; margin-bottom: 26px; }
.onboard-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-raised);
  color: var(--accent);
}
.onboard-title { font-size: 1.55rem; margin-bottom: 6px; }

.onboard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 26px;
}
.step-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--text-dim);
}
.step-chip.is-done { color: var(--correct); }
.step-chip.is-current {
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-soft);
}

.onboard-q {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 0 0 13px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 13px;
}
.choice-form { display: contents; }

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 17px 19px;
  text-align: left;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: transform var(--press) var(--ease), border-color var(--press) var(--ease);
}
.choice:hover { transform: translateY(-2px); }
.choice:active { box-shadow: var(--shadow-press); transform: translateY(0); }

.choice-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent-tile, var(--accent));
}
.choice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-weight: 700; font-size: 0.98rem; }
.choice-go { flex: none; color: var(--text-dim); }

/* Multi-select subjects */
.choice-check { position: relative; cursor: pointer; }
.choice-check input { position: absolute; opacity: 0; pointer-events: none; }
.choice-tick {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-sunk);
  color: transparent;
  transition: background var(--press) var(--ease), color var(--press) var(--ease);
}
.choice-check input:checked ~ .choice-tick {
  background: var(--correct);
  border-color: transparent;
  color: #fff;
}
.choice-check:has(input:checked) { border-color: var(--correct); }
.choice-check input:focus-visible ~ .choice-tick { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 640px) {
  .choice-grid { grid-template-columns: 1fr; }
  .onboard-title { font-size: 1.3rem; }
}

/* ============================================================
   Checkout & payments
   ============================================================ */

.checkout { max-width: 940px; margin: 0 auto; }

.checkout-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 22px;
  margin-bottom: 22px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.checkout-price { text-align: right; flex: none; }
.checkout-amount {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.checkout-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.9;
}

.order-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 13px;
  margin: 0 0 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent);
}

.pay-method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.pay-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent);
}
.pay-qr {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 12px auto 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.pay-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-sunk);
  color: var(--text-2);
}

@media (max-width: 640px) {
  .checkout-summary { flex-direction: column; align-items: flex-start; }
  .checkout-price { text-align: left; }
}

/* Pricing fieldset in the curriculum manager */
.pricing-box {
  margin: 18px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
}
.pricing-box legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}
.check-row { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* Answer label inside an option pill — must be able to shrink and wrap
   without pushing the A/B/C/D badge out of the row. */
.option-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Wordmark next to the brand mark. */
.brand-text {
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* ============================================================
   v4 — cascade corrections

   These selectors were still being won by style.css / dashboard.css after
   the v3 rebuild, so they kept painting the v1 magenta/violet palette.
   Redefined here on v3 tokens. Loaded last, so these win.
   ============================================================ */

/* ---- Buttons: the pink "Manage content" button ---- */
.btn-primary {
  background: var(--accent);
  border: 1px solid transparent;
  color: var(--accent-on);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: var(--shadow-raised);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-press);
}

.btn-ghost {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  box-shadow: var(--shadow-soft);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hi);
  border-color: var(--border-hi);
  color: var(--text);
}

/* ---- Focus rings: were magenta on every control ---- */
.btn:focus-visible,
.option:focus-visible,
.quiz-card:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- Form fields: focus was magenta with a pink glow ---- */
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-press), 0 0 0 3px var(--accent-soft);
  outline: none;
}
.select option { background: var(--surface-raised); color: var(--text); }

/* ---- Selected answer: the core interaction, was magenta ---- */
.option.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: var(--shadow-press);
}
.option.selected .option-key {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-on);
}
.option:hover:not(:disabled) { border-color: var(--border-hi); }

/* ---- Misc v1 palette bleed ---- */
.bar-fill      { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.explain       { border-left: 0; box-shadow: inset 3px 0 0 var(--accent); }
.pill-info     { color: var(--accent); }
.stat-tile::before { background: var(--accent-tile, var(--accent)); }
.streak-chip   { background: var(--surface-raised); border: 1px solid var(--border); color: var(--text-2); }
.demo-btn:hover{ border-color: var(--accent); }
.hero h1 .accent {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-link:hover { background: var(--surface-raised); }
.nav-link.active {
  background: var(--accent);
  color: var(--accent-on);
}

/* ============================================================
   v4 — layout density

   Sidebar was 236px for six nav items; content was capped at 1360px with
   its own 26px gutter, leaving dead space in the corner on wide screens.
   ============================================================ */

:root { --sidebar-w: 208px; }

.shell main { padding: 22px 0 56px; }
.shell main .wrap {
  max-width: 1600px;
  padding: 0 22px;
}

.sidebar { padding: 16px 11px 14px; }
.sidebar .brand { padding: 2px 6px 16px; }
.sidebar .nav-link { padding: 10px 13px; }

@media (min-width: 1500px) {
  .shell main .wrap { padding: 0 30px; }
}

/* ---------- Resume prompt ----------

   Shown when a student returns to unfinished work. Their answers were always
   saved; this only asks which attempt the rest of the session writes into.  */

.resume-prompt {
  text-align: center;
  padding: 34px 26px;
  max-width: 400px;
  margin: 0 auto;
}

.resume-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--accent);
}

.resume-prompt h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  color: var(--text);
}

.resume-sub {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.resume-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.resume-actions .btn { min-width: 132px; }

.resume-note {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

@media (max-width: 420px) {
  .resume-actions { flex-direction: column; }
  .resume-actions .btn { width: 100%; }
}

/* ---------- Quiz option states ----------

   These three were still resolving to v1's hardcoded colours: a dark purple
   hover fill (#32266d) that put text at 1.27:1 on a light card, and near-black
   badge text (#06281c / #3d0713) sitting at ~2.7:1 on the light-theme fills.
   All three now use theme-aware tokens.                                     */

.option:hover:not(:disabled) {
  background: var(--surface-hi);
  border-color: var(--border-hi);
}

.option.is-correct .option-key,
.option.is-wrong .option-key {
  /* Flips with the theme: white on light-theme fills, near-black on the
     lighter dark-theme fills. Clears AA in both directions. */
  color: var(--accent-on);
}

/* ============================================================ list tools
   Search + filters + pager for lists that grow with the content: the quiz
   list, users, orders. Everything is built from existing tokens so both
   themes follow automatically.

   The controls wrap onto their own rows on a phone rather than shrinking to
   unusable widths - an editor filtering 2,000 quizzes on a tablet is a real
   case, not a hypothetical one. */
.list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

/* Search is the primary control, so it takes the slack. */
.list-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  min-width: 0;
}
.list-search svg {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
.list-search input {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px 10px 36px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-press);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.list-search input::placeholder { color: var(--text-dim); }
.list-search input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-press), 0 0 0 3px var(--accent-soft);
}
/* The browser's own clear affordance, tinted to match. */
.list-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  background: var(--text-dim);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 6L6 18M6 6l12 12' stroke='black' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  cursor: pointer;
}

.list-tools select {
  min-height: 42px;
  max-width: 260px;
  padding: 10px 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-press);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.list-tools select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-press), 0 0 0 3px var(--accent-soft);
}
.list-tools .btn { min-height: 42px; }

/* ---------------------------------------------------------------- pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}
.pager-status {
  font-size: 0.86rem;
  color: var(--text);
  text-align: center;
  flex: 1 1 auto;
}
.pager .btn { min-height: 40px; white-space: nowrap; }

/* Ends of the range keep their button shape so the row does not reflow as
   you page - it just stops responding. */
.pager .is-disabled {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}

@media (max-width: 560px) {
  .list-tools select { max-width: none; flex: 1 1 100%; }
  .pager-status { order: 3; flex-basis: 100%; }
}


/* ============================================================ page header
   One skeleton for every admin screen. The five pages had drifted to two h1
   sizes (1.8rem / 1.6rem) and six copies of style="flex-wrap:wrap". */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-header-text { min-width: 0; }   /* lets a long title ellipse instead of overflowing */
.page-title {
  font-size: 1.7rem;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-sub { margin: 0; color: var(--text-muted); font-size: 0.94rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; flex: none; }

@media (max-width: 640px) {
  .page-title { font-size: 1.35rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}

/* ============================================================ tabs
   Screen-level sub-navigation. Real anchors, so back/forward and bookmarks
   work with no JS -- and the counts in the labels are the fastest read of how
   much content exists once a full syllabus is loaded. */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 20px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: -1px;                /* sits ON the rule, not above it */
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: color var(--press) var(--ease), background var(--press) var(--ease);
}
.tab:hover { background: var(--surface-raised); color: var(--text); text-decoration: none; }
.tab.is-active {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
  /* Inset shadow, NOT border-top: a 2px border against a 1px sibling border
     tapers at the radius. That artifact has bitten this codebase twice
     already -- see the notes at .study-head and .mode-card. */
  box-shadow: inset 0 2px 0 var(--accent);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-count {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab-count { color: var(--accent); }

/* ============================================================ toolbar
   Shared filter bar. users.php had hand-rolled this as a .card with six
   inline styles while content.php used .list-tools; now there is one. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar > .list-search { flex: 1 1 240px; min-width: 0; }
.toolbar select,
.toolbar .input {
  min-height: 42px;
  max-width: 260px;
  padding: 10px 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-press);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
}
.toolbar select { cursor: pointer; }
.toolbar select:focus,
.toolbar .input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-press), 0 0 0 3px var(--accent-soft);
}
.toolbar .btn { min-height: 42px; }
.toolbar-boxed {
  padding: 12px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.toolbar-end { margin-left: auto; }

@media (max-width: 560px) {
  .toolbar select, .toolbar .input { max-width: none; flex: 1 1 100%; }
}

/* ============================================================ empty state */
.empty-state {
  text-align: center;
  padding: 40px 26px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.empty-state .state-glyph { margin: 0 auto 14px; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-size: 1.08rem; }
.empty-state p  { margin: 0 auto; max-width: 46ch; color: var(--text-muted); font-size: 0.92rem; }
.empty-state .btn { margin-top: 18px; }
/* Inline variant for an empty column inside a .split, where 40px is too much air. */
.empty-state.is-inline {
  padding: 24px 18px;
  box-shadow: none;
  background: var(--surface);
}

/* ============================================================ panel
   A card that owns a titled region -- the box things stay inside. Distinct
   from .card, which is a bare surface with no header slot. */
.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
  overflow: hidden;                   /* keeps a table's corners inside the radius */
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.panel-title { margin: 0; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.panel-body { padding: 18px; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-body.is-flush { padding: 0; }  /* for a full-bleed .table-wrap */

/* ============================================================ small buttons
   Replaces twelve copies of min-height:32-46px;padding:...;font-size:...
   spread across four pages, which had drifted into three sizes for one job. */
.btn-sm  { min-height: 34px; padding: 6px 14px;  font-size: 0.82rem; gap: 6px; }
.btn-xs  { min-height: 30px; padding: 4px 11px;  font-size: 0.76rem; gap: 5px; }
.btn-icon { padding: 6px; width: 34px; min-height: 34px; }
/* Destructive: colour only, never a red fill -- a filled red button in a table
   row reads as the primary action, which it never is. */
.btn-danger { color: var(--wrong); }
.btn-danger:hover:not(:disabled) { background: var(--wrong-bg); color: var(--wrong); }

/* ============================================================ modal
   The users.php password dialog was a position:fixed card with a hardcoded
   rgba(8,4,24,.75) backdrop that ignored the theme entirely. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: color-mix(in srgb, var(--bg) 72%, #000);
  backdrop-filter: blur(2px);
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: min(400px, 92vw);
  padding: 22px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.modal[hidden], .modal-backdrop[hidden] { display: none; }

/* ============================================================ nav groups
   Section labels in the sidebar. Roles with a flat nav never emit these. */
.nav-group-label {
  padding: 16px 13px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.main-nav > .nav-group-label:first-child { padding-top: 4px; }
/* The sidebar is a fixed-height flex column; once groups add labels the nav
   has to be able to scroll rather than push the user chip off-screen. */
.main-nav { overflow-y: auto; min-height: 0; }

/* ============================================================ utilities
   The handful of one-line styles that were repeated across admin pages.
   Anything genuinely dynamic (a per-subject --accent, a computed width) stays
   inline, because it carries runtime data. */
.w-full     { width: 100%; }
.inline-form { display: inline; }
.btn-row-tight { display: flex; gap: 10px; }
.icon-lg    { width: 46px; height: 46px; font-size: 1.3rem; }
.icon-sm    { width: 30px; height: 30px; font-size: 0.82rem; flex-shrink: 0; }
/* Checkboxes inherit the accent so they are not browser-blue in a themed UI. */
.check      { width: 17px; height: 17px; accent-color: var(--accent); }
.check-lg   { width: 19px; height: 19px; accent-color: var(--correct); flex-shrink: 0; }

/* ============================================================
   Auth — split layout (brand panel + form)
   Overrides the older single-card .auth-wrap/.auth-card from dashboard.css;
   this file loads last so these rules win without needing to delete those.
   ============================================================ */

/* style.css's main{padding:40px 0 96px} and .wrap{max-width:1100px} are built
   for content pages, not an edge-to-edge split panel -- cancel both only
   when this class is present, rather than touching those shared rules. The
   split panel carries its own brand mark, so the app-header above it (which
   would otherwise show "QuizLab" twice) is hidden the same way. */
body:has(.auth-shell) .app-header { display: none; }
main:has(> .auth-shell) { padding: 0; }
.auth-shell.wrap { max-width: none; padding: 0; margin: 0; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
}

/* Brand panel — decorative, so it drops out entirely on narrow screens
   rather than squeezing; the form is the only thing that matters there.
   Centered as one grouped block (not stretched edge-to-edge with
   space-between) so the content reads as a unit regardless of viewport
   height, instead of the stats row landing below the fold on a tall
   monitor. */
.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background:
    radial-gradient(680px 460px at 15% 15%, var(--accent-soft), transparent 60%),
    radial-gradient(520px 420px at 85% 85%, rgba(124, 77, 219, 0.12), transparent 60%),
    var(--surface-sunk);
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.auth-brand-top {
  position: absolute;
  top: 40px;
  left: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
}
.auth-brand-top .brand-mark { width: 34px; height: 34px; border-radius: 10px; }

.auth-brand-body { max-width: 420px; }
.auth-brand-body h2 {
  font-size: 2rem;
  line-height: 1.15;
  margin: 0 0 14px;
  color: var(--text);
}
.auth-brand-body p {
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
  margin: 0;
}

/* Floating subject glyphs — reuse the app's own icon set and accent tokens
   instead of an external illustration, so the panel costs nothing to ship
   and never goes stale relative to the real product. */
.auth-glyphs { display: flex; gap: 14px; margin-top: 32px; }
.auth-glyph {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
  color: var(--accent);
}
.auth-glyph:nth-child(2) { color: var(--gold); transform: translateY(10px); }
.auth-glyph:nth-child(3) { color: var(--accent-2); }

.auth-brand-stats {
  display: flex;
  gap: 28px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  max-width: 420px;
}
.auth-brand-stat strong { display: block; font-size: 1.3rem; color: var(--text); }
.auth-brand-stat span { font-size: 0.82rem; color: var(--text-dim); }

/* Form side */
.auth-form-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 48px;
  background: var(--surface);
}
.auth-form-inner { width: 100%; max-width: 360px; margin: 0 auto; }

.auth-form-inner h1 { font-size: 1.5rem; margin: 0 0 6px; }
.auth-form-inner .sub { color: var(--text-muted); margin: 0 0 28px; font-size: 0.95rem; }

/* Demo accounts collapse behind <details> so a real customer's first
   impression is the sign-in form, not four staging-account buttons. */
.auth-demo-toggle { margin-top: 22px; }
.auth-demo-toggle summary {
  display: block;
  cursor: pointer;
  list-style: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  user-select: none;
}
.auth-demo-toggle summary::-webkit-details-marker { display: none; }
.auth-demo-toggle summary:hover { color: var(--accent); }
.auth-demo-toggle[open] summary { color: var(--accent); margin-bottom: 12px; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form-side { padding: 32px 20px; }
}
