/* ===========================================================================
   AGORA Mastery Engine - premium "Data Driven" UI
   Warm off-white canvas, emerald accent, violet highlight, layered depth
   =========================================================================== */
:root {
  --green: #2fa14a;
  --green-2: #3fc463;
  --green-dark: #1f7d38;
  --green-soft: #e9f7ed;
  --green-ring: rgba(47, 161, 74, 0.18);
  --violet: #7c6ff0;
  --violet-soft: #f0eefb;
  --ink: #0e1512;
  --ink-2: #2b3531;
  --muted: #6c7671;
  --faint: #9aa39e;
  --bg: #f7f8f5;
  --bg-2: #eef1ec;
  --card: #ffffff;
  --border: #e9ece7;
  --border-strong: #dfe3dc;
  --success: #1f7d38;
  --error: #d6453f;
  --error-soft: #fdecec;
  --warning: #c98a16;

  --r-sm: 12px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --pill: 999px;

  --shadow-xs: 0 1px 2px rgba(14, 21, 18, 0.05);
  --shadow-sm: 0 2px 8px rgba(14, 21, 18, 0.06);
  --shadow: 0 12px 32px -8px rgba(14, 21, 18, 0.12), 0 2px 8px rgba(14, 21, 18, 0.05);
  --shadow-lg: 0 30px 70px -20px rgba(14, 21, 18, 0.22), 0 8px 20px rgba(14, 21, 18, 0.08);
  --glow: 0 10px 30px -6px rgba(47, 161, 74, 0.45);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Sora', var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Ambient brand glow behind everything */
body::before {
  content: '';
  position: fixed;
  top: -260px; left: 50%;
  width: 900px; height: 700px;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side, rgba(63, 196, 99, 0.16), transparent 70%),
    radial-gradient(closest-side, rgba(124, 111, 240, 0.10), transparent 70%);
  background-position: 30% 0, 80% 20%;
  background-repeat: no-repeat;
  background-size: 600px 600px, 500px 500px;
  filter: blur(8px);
  z-index: 0;
  pointer-events: none;
}

main, .site-header { position: relative; z-index: 1; }

/* --------------------------------- Header --------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 30px;
  background: rgba(247, 248, 245, 0.72);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(233, 236, 231, 0.9);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { height: 36px; width: auto; display: block; }
.header-spacer { flex: 1; }
.header-clock {
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.mode-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600;
  padding: 8px 15px; border-radius: var(--pill);
  border: 1px solid transparent;
}
.streak-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700;
  padding: 8px 14px; border-radius: var(--pill);
  background: #fff4e6; color: #c05621; border: 1px solid #f6d8b8;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mode-chip.guest { background: var(--violet-soft); color: var(--violet); border-color: #e4e0fa; }
.mode-chip.mastery { background: var(--green-soft); color: var(--green-dark); border-color: #d6efdc; }
.mode-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px currentColor; opacity: 1; }
.mode-chip .dot { position: relative; }

/* --------------------------------- Buttons -------------------------------- */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: var(--pill);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(.4,0,.2,1), box-shadow 0.25s ease, background 0.2s ease, border-color 0.2s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  letter-spacing: 0.005em;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--green-2), var(--green));
  color: #fff;
  box-shadow: var(--glow);
}
.btn-primary:hover { box-shadow: 0 16px 38px -8px rgba(47, 161, 74, 0.55); }
.btn-ghost { background: #fff; color: var(--green-dark); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { border-color: var(--green); background: var(--green-soft); }
.btn-neutral { background: var(--bg-2); color: var(--ink-2); }
.btn-neutral:hover { background: #e4e7e1; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 30px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------------------------------- Layout -------------------------------- */
.container { max-width: 720px; margin: 0 auto; padding: 56px 24px 90px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--green-dark);
  background: var(--green-soft); border: 1px solid #d6efdc;
  padding: 7px 14px; border-radius: var(--pill);
  margin-bottom: 22px;
}
.hero { text-align: center; margin-bottom: 44px; }
.hero h1 {
  font-family: var(--display);
  font-size: clamp(34px, 5.5vw, 54px);
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.hero h1 .accent {
  background: linear-gradient(120deg, var(--green), var(--green-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); font-size: 17.5px; max-width: 500px; margin: 0 auto; line-height: 1.6; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: 36px;
}
.card + .card { margin-top: 22px; }

/* Landing mode cards */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.mode-card {
  position: relative; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: 32px 30px;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), box-shadow 0.3s ease, border-color 0.3s ease;
}
.mode-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  padding: 1px; background: linear-gradient(135deg, rgba(63,196,99,0.5), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.mode-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: transparent; }
.mode-card:hover::after { opacity: 1; }
.mode-card .icon {
  width: 52px; height: 52px; border-radius: 15px;
  display: grid; place-items: center; font-size: 26px;
  background: var(--green-soft);
}
.mode-card.violet .icon { background: var(--violet-soft); }
.mode-card h3 { font-family: var(--display); font-size: 21px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.mode-card p { color: var(--muted); font-size: 14.5px; margin: 0; flex: 1; line-height: 1.6; }
.mode-card .lock { position: absolute; top: 26px; right: 28px; font-size: 15px; opacity: 0.4; }

/* AI engine selector on the landing page */
.ai-engine {
  max-width: 460px; margin: 26px auto 0; text-align: left;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 18px 20px;
}
.ai-engine .label { margin-bottom: 8px; }
.ai-engine-hint { font-size: 12px; color: var(--faint); margin: 10px 0 0; line-height: 1.5; }

/* ---------------------------------- Forms --------------------------------- */
.field { margin-bottom: 18px; }
.label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted);
  display: block; margin-bottom: 8px;
}
.select-wrap { position: relative; }
.select-wrap::after {
  content: ''; position: absolute; right: 16px; top: 50%;
  width: 9px; height: 9px; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
}
select, textarea, input[type='number'], input[type='password'], input[type='text'] {
  width: 100%; padding: 14px 16px;
  border: 1.5px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 15px; font-family: var(--font); color: var(--ink); font-weight: 500;
  background: #fff; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
}
select { padding-right: 42px; cursor: pointer; }
select::-ms-expand { display: none; }
select:hover, input:hover, textarea:hover { border-color: var(--faint); }
select:focus, input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-ring); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-title {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  margin: 0 0 6px; display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em;
}
.section-sub { color: var(--muted); font-size: 14.5px; margin: 0 0 24px; line-height: 1.55; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }

/* Segmented control */
.segment { display: inline-flex; background: var(--bg-2); border-radius: var(--pill); padding: 5px; gap: 4px; width: 100%; }
.segment button {
  flex: 1; border: 0; background: transparent; padding: 10px 18px; border-radius: var(--pill);
  font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer;
  transition: 0.18s; font-family: var(--font);
}
.segment button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* Priority CTA - special emphasis */
.priority-cta {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #12381f, #1f7d38);
  color: #fff; border: 0;
}
.priority-cta::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 80% -20%, rgba(63,196,99,0.5), transparent 60%);
}
.priority-cta span { position: relative; }
.priority-cta:hover { box-shadow: 0 18px 40px -10px rgba(31, 125, 56, 0.6); }

/* --------------------------------- Quiz ----------------------------------- */
.progress-track { height: 9px; background: var(--bg-2); border-radius: var(--pill); overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--green-2)); width: 0%; border-radius: var(--pill); transition: width 0.5s cubic-bezier(.4,0,.2,1); }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 26px; font-weight: 500; }
.q-crumb { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--green-dark); margin-bottom: 12px; }
.q-text { font-family: var(--display); font-size: 23px; font-weight: 600; line-height: 1.4; margin-bottom: 26px; letter-spacing: -0.01em; }
.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  text-align: left; background: #fff; border: 1.5px solid var(--border-strong);
  border-radius: var(--r); padding: 16px 18px; font-size: 15px; font-family: var(--font); font-weight: 500;
  cursor: pointer; transition: 0.16s cubic-bezier(.4,0,.2,1); color: var(--ink-2);
  display: flex; align-items: center; gap: 14px;
}
.option .key {
  width: 28px; height: 28px; flex: none; border-radius: 9px; background: var(--bg-2);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted);
  transition: 0.16s;
}
.option:hover:not(:disabled) { border-color: var(--green); background: var(--green-soft); transform: translateX(3px); }
.option:hover:not(:disabled) .key { background: #fff; color: var(--green-dark); }
.option:disabled { cursor: default; }
.option.correct { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); font-weight: 600; }
.option.correct .key { background: var(--green); color: #fff; }
.option.wrong { background: var(--error-soft); border-color: var(--error); color: var(--error); }
.option.wrong .key { background: var(--error); color: #fff; }

/* ------------------------------- AI tutor --------------------------------- */
#hintWrap { margin-bottom: 18px; }
.btn-ai-link {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 0; cursor: pointer; padding: 4px 0;
  font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--violet);
  transition: opacity 0.15s ease;
}
.btn-ai-link:hover { opacity: 0.7; }
.btn-ai-link:disabled { opacity: 0.5; cursor: default; }
.btn-ai {
  background: linear-gradient(135deg, #8b7ff5, #6f5fe8);
  color: #fff; box-shadow: 0 10px 26px -8px rgba(124, 111, 240, 0.55);
  margin: 4px 0 14px;
}
.btn-ai:hover { box-shadow: 0 16px 34px -8px rgba(124, 111, 240, 0.7); }

.ai-box {
  border-radius: var(--r); padding: 16px 18px; font-size: 14.5px; line-height: 1.62;
  margin-top: 12px; animation: aiIn 0.3s cubic-bezier(.4,0,.2,1); color: var(--ink-2);
}
@keyframes aiIn { from { opacity: 0; transform: translateY(-4px); } }
.ai-box.hint { background: var(--violet-soft); border: 1px solid #e4e0fa; color: #4b3fb0; }
.ai-box.explain { background: #f7f6fe; border: 1px solid #e9e6fb; }
.ai-box .ai-head {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--violet); margin-bottom: 10px;
}
.ai-box .ai-loading { display: flex; align-items: center; gap: 10px; color: var(--violet); font-weight: 600; }
.ai-box .ai-loading .spinner { border-color: #e4e0fa; border-top-color: var(--violet); }
.ai-box strong { color: var(--ink); font-weight: 700; }
.ai-box p { margin: 0 0 10px; }
.ai-box p:last-child { margin-bottom: 0; }
.ai-box ul { margin: 6px 0 10px; padding-left: 20px; }
.ai-box li { margin-bottom: 6px; }
.ai-box .err { color: var(--error); font-weight: 500; }
#drillWrap .err { display: block; margin-top: 10px; }

/* ----------------------------- Drill deeper ------------------------------- */
/* The mastery "master this question" action: green-tinted to set it apart from
   the violet hint/explain tutor, since drilling writes to the bank. */
.btn-drill {
  background: linear-gradient(135deg, var(--green-2), var(--green-dark));
  color: #fff; box-shadow: var(--glow);
  margin: 4px 0 14px;
}
.btn-drill:hover { box-shadow: 0 16px 38px -8px rgba(47, 161, 74, 0.55); }

.ai-box.drill { background: var(--green-soft); border: 1px solid #d6efdc; }
.ai-box.drill .ai-head { color: var(--green-dark); }
.ai-box.drill .ai-loading { color: var(--green-dark); }
.ai-box.drill .ai-loading .spinner { border-color: #d6efdc; border-top-color: var(--green); }

.confusion-list { display: flex; flex-direction: column; gap: 10px; }
.confusion-opt {
  text-align: left; background: #fff; border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px;
  font-family: var(--font); font-weight: 500; color: var(--ink-2);
  cursor: pointer; transition: 0.16s cubic-bezier(.4,0,.2,1);
  display: flex; align-items: center; gap: 12px; width: 100%;
}
.confusion-opt .key {
  width: 26px; height: 26px; flex: none; border-radius: 8px; background: var(--bg-2);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--muted);
  transition: 0.16s;
}
.confusion-opt .confusion-txt { flex: 1; }
.confusion-opt:hover:not(:disabled) { border-color: var(--green); background: #fff; transform: translateX(3px); }
.confusion-opt:hover:not(:disabled) .key { background: var(--green); color: #fff; }
.confusion-opt.custom { color: var(--green-dark); font-weight: 600; }
.confusion-opt:disabled { opacity: 0.55; cursor: default; }

.confusion-custom { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.confusion-custom textarea { resize: vertical; min-height: 70px; line-height: 1.5; }

.feedback { text-align: center; font-weight: 600; margin: 20px 0; font-size: 16px; }
.feedback.ok { color: var(--success); }
.feedback.no { color: var(--error); }
.flag-box {
  display: flex; align-items: center; gap: 11px; justify-content: center;
  background: #fffaeb; border: 1px solid #f5e6b8; border-radius: var(--r-sm); padding: 13px;
}
.flag-box label { font-size: 14px; color: var(--warning); font-weight: 600; cursor: pointer; }
.flag-box input { width: auto; accent-color: var(--warning); }

/* --------------------------------- Results -------------------------------- */
.score-ring { text-align: center; margin-bottom: 8px; }
.score-num {
  font-family: var(--display); font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -0.03em;
  background: linear-gradient(120deg, var(--green), var(--green-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.score-label { color: var(--muted); font-size: 15px; margin-top: 10px; font-weight: 500; }
.table-wrap { max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); margin-top: 26px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--bg); padding: 12px 14px; text-align: left; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px; position: sticky; top: 0; }
td { padding: 12px 14px; border-top: 1px solid var(--border); }
.tag { padding: 4px 11px; border-radius: var(--pill); font-weight: 700; font-size: 11px; }
.tag.pass { background: var(--green-soft); color: var(--green-dark); }
.tag.fail { background: var(--error-soft); color: var(--error); }
.sync-note { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; font-weight: 500; }

/* --------------------------------- Stats ---------------------------------- */
.stats-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.stats-head .section-sub { margin: 0; }
.stats-head .btn { flex: none; padding: 10px 18px; font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 22px 20px; text-align: center;
}
.stat-value {
  font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--green-dark), var(--green-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-top: 10px; }
.stat-sub { font-size: 11.5px; color: var(--faint); margin-top: 3px; }

.block-title { font-family: var(--display); font-size: 17px; font-weight: 600; margin: 0 0 16px; letter-spacing: -0.01em; }
.block-hint { font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--faint); letter-spacing: 0; }

/* Horizontal mini-bar (priority + course accuracy) */
.mini-bar { display: inline-block; width: 100%; min-width: 54px; height: 8px; background: var(--bg-2); border-radius: var(--pill); overflow: hidden; vertical-align: middle; }
.mini-fill { display: block; height: 100%; border-radius: var(--pill); transition: width 0.5s cubic-bezier(.4,0,.2,1); }

/* By-course rows */
.course-row { display: flex; align-items: center; gap: 18px; padding: 12px 0; border-top: 1px solid var(--border); }
.course-row:first-child { border-top: 0; }
.course-meta { flex: 1.1; min-width: 0; }
.course-name { display: block; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-track { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.course-bar-wrap { flex: 1; display: flex; align-items: center; gap: 12px; }
.course-pct { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }

/* Activity chart */
.activity { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 8px; }
.act-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.act-bar { width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px; min-height: 2px; transition: height 0.4s cubic-bezier(.4,0,.2,1); }
.act-x { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ----------------------------- Progress tree ------------------------------ */
.prog-legend {
  display: flex; flex-wrap: wrap; gap: 16px; margin: -8px 0 18px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.prog-legend span { display: inline-flex; align-items: center; gap: 6px; }
.prog-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.prog-tree { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }

.prog-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px 13px 0; cursor: default;
  border-top: 1px solid var(--border);
  transition: background 0.15s ease;
}
.prog-node:first-child > .prog-row { border-top: 0; }
.prog-node.has-children > .prog-row { cursor: pointer; }
.prog-node.has-children > .prog-row:hover { background: var(--bg); }

/* Nested levels get a subtle tint so depth is readable. */
.prog-children { display: none; background: rgba(238, 241, 236, 0.35); }
.prog-node.open > .prog-children { display: block; }

.prog-caret {
  width: 16px; flex: none; text-align: center; color: var(--faint);
  font-size: 11px; transition: transform 0.18s ease; user-select: none;
  margin-left: 16px;
}
.prog-node.open > .prog-row .prog-caret { transform: rotate(90deg); }

.prog-info { flex: 1.2; min-width: 0; }
.prog-name {
  display: block; font-weight: 600; font-size: 14px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prog-sub { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.prog-bar-wrap { flex: 1; display: flex; align-items: center; gap: 12px; }
.prog-pct {
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
  min-width: 38px; text-align: right;
}

/* Per-node action buttons */
.prog-actions { flex: none; display: flex; gap: 6px; padding-right: 14px; }
.prog-btn {
  font-family: var(--font); font-weight: 600; font-size: 11.5px;
  padding: 6px 10px; border-radius: var(--pill); cursor: pointer; white-space: nowrap;
  border: 1.5px solid var(--border-strong); background: #fff; color: var(--green-dark);
  transition: 0.15s cubic-bezier(.4,0,.2,1);
}
.prog-btn:hover { border-color: var(--green); background: var(--green-soft); transform: translateY(-1px); }
.prog-btn.review { color: var(--violet); }
.prog-btn.review:hover { border-color: var(--violet); background: var(--violet-soft); }

/* --------------------------------- Modal ---------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(14, 21, 18, 0.5);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  padding: 36px; width: 100%; max-width: 410px;
  animation: pop 0.25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(0.94) translateY(8px); opacity: 0; } }
.modal.modal-lg { max-width: 640px; }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.review-head h3 { font-family: var(--display); margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.review-head .btn { flex: none; padding: 9px 16px; font-size: 13px; }
#reviewBody { max-height: 60vh; overflow-y: auto; margin: 0; }
.review-actions { margin-top: 18px; }
.modal h3 { font-family: var(--display); margin: 0 0 8px; font-size: 23px; letter-spacing: -0.01em; }
.modal p { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; line-height: 1.55; }
.modal .error-text { color: var(--error); font-size: 13px; min-height: 18px; margin-top: 10px; font-weight: 500; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

/* --------------------------------- Loader --------------------------------- */
.loader { display: flex; align-items: center; justify-content: center; gap: 11px; color: var(--green-dark); font-weight: 600; padding: 18px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--green-soft); border-top-color: var(--green); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------- KaTeX ---------------------------------- */
/* Keep rendered math at the surrounding text size and let wide/display math
   scroll horizontally instead of overflowing its card. */
.katex { font-size: 1.05em; }
.katex-display { margin: 0.5em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.q-text .katex { font-size: 1em; }
.option .katex, .feedback .katex { font-size: 1em; }
.ai-box .katex-display { margin: 0.4em 0; }

.hidden { display: none !important; }

/* --------------------------------- Mobile --------------------------------- */
@media (max-width: 640px) {
  .container { padding: 36px 18px 70px; }
  .site-header { padding: 13px 18px; gap: 12px; }
  .brand-logo { height: 28px; }
  .header-clock { display: none; }
  .mode-grid { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .card, .mode-card { padding: 24px; }
  .q-text { font-size: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 28px; }
  .course-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .activity { gap: 3px; }
  .act-x { font-size: 8px; }
  /* Progress tree: let the bar + actions wrap below the name on small screens. */
  .prog-row { flex-wrap: wrap; row-gap: 10px; padding-right: 12px; }
  .prog-bar-wrap { order: 3; flex-basis: 100%; }
  .prog-actions { order: 4; padding-right: 0; }
  .modal.modal-lg { padding: 24px; }
}
