/* Maneframe — base + components. All values via tokens.css / theme.css variables. */

/* ── Base ─────────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; transition: color var(--t-fast), text-shadow var(--t-fast); }
a:hover { color: var(--text-bright); text-shadow: 0 0 10px var(--green-glow); }

h1, h2, h3 { color: var(--text-bright); line-height: var(--lh-tight); font-weight: 700; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }

code, pre {
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
code { padding: 0.1em 0.4em; font-size: 0.9em; color: var(--green); }
pre {
  padding: var(--sp-4);
  overflow-x: auto;
  margin: var(--sp-4) 0;
  line-height: 1.5;
  font-size: var(--fs-sm);
}
pre code { border: 0; padding: 0; background: none; color: var(--text); }

img { max-width: 100%; }

::selection { background: var(--green); color: var(--text-on-green); }

/* ── Brand ────────────────────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: var(--sp-3); }
.brand-mark { height: 42px; width: auto; }
.brand-word {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.22em;
  color: var(--text-bright);
  text-transform: uppercase;
}
.brand-word .accent { color: var(--green); }
.landing-nav .brand:hover .brand-word { color: var(--green); text-shadow: 0 0 10px var(--green-glow); }
.brand-sub { font-size: var(--fs-xs); color: var(--text-muted); letter-spacing: 0.12em; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 700;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: center;
}
.btn-primary { background: var(--green); color: var(--text-on-green); }
.btn-primary:hover { background: var(--green-dim); color: var(--text-on-green); box-shadow: 0 0 18px var(--green-glow); text-shadow: none; }
.btn-ghost { background: transparent; color: var(--green); border-color: var(--border-green); }
.btn-ghost:hover { background: var(--green-soft); color: var(--green); text-shadow: none; }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn-lg { padding: 0.9rem 2rem; font-size: var(--fs-md); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-1); }
.field .req { color: var(--green); }
.input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-faint); }
.field-error { color: var(--red); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.field-hint { color: var(--text-dim); font-size: var(--fs-xs); margin-top: var(--sp-1); }
.input.invalid { border-color: var(--red); }

/* ── Flash / alerts ───────────────────────────────────────────────────── */
.alert { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); margin-bottom: var(--sp-4); font-size: var(--fs-sm); border: 1px solid; }
.alert-success { background: var(--green-soft); border-color: var(--border-green); color: var(--green); }
.alert-error { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.alert-info { background: var(--yellow-soft); border-color: var(--yellow); color: var(--yellow); }

/* ── Auth screens ─────────────────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--sp-5); }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.auth-card .brand { justify-content: center; width: 100%; margin-bottom: var(--sp-2); }
.auth-head { text-align: center; margin-bottom: var(--sp-5); }
.auth-head h1 { font-size: var(--fs-lg); margin-top: var(--sp-3); }
.auth-head p { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.auth-links { text-align: center; margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); }
.auth-links a { display: inline-block; margin: 0 var(--sp-2); }

/* ── App shell (sidebar layout) ───────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand-mark { height: 24px; }
.sidebar .brand-word { font-size: 0.9rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.55rem var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.nav a:hover { background: var(--bg-card-hover); color: var(--text); text-shadow: none; }
.nav a.active { background: var(--green-soft); color: var(--green); }
.nav a .ico { width: 18px; text-align: center; color: inherit; }
.sidebar-foot { margin-top: auto; font-size: var(--fs-xs); color: var(--text-dim); }
.sidebar-user { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.sidebar-user .avatar { flex-shrink: 0; }
.sidebar-user .u-name { font-size: var(--fs-sm); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .u-level { font-size: var(--fs-xs); color: var(--text-muted); }

.main { flex: 1; min-width: 0; padding: var(--sp-6); }
.main-inner { max-width: var(--content-max); margin: 0 auto; }
.main-inner.wide { max-width: var(--content-wide); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head p { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }

.crumbs { font-size: var(--fs-xs); color: var(--text-dim); margin-bottom: var(--sp-3); letter-spacing: 0.04em; }
.crumbs a { color: var(--text-muted); }
.crumbs .sep { margin: 0 var(--sp-2); color: var(--text-dim); }

/* Mobile top bar + drawer. Both are hidden by default and only exist below the
   sidebar breakpoint. Without the default rule the drawer's links render as a
   stray text list above every authenticated page on desktop. */
.topbar { display: none; }
.mobile-nav { display: none; }

/* ── The sticky page bar ──────────────────────────────────────────────────
   One component, one place. Back is always top-left; page actions sit right.
   It sticks to the viewport top on desktop and beneath the mobile topbar below
   the sidebar breakpoint (the topbar is itself sticky and ~53px tall). */
.page-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: calc(-1 * var(--sp-6)) calc(-1 * var(--sp-6)) var(--sp-5);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .page-bar { background: var(--bg); }
}
.page-bar-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.pb-back {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 36px; padding: 0.35rem 0.75rem 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: var(--fs-sm);
}
.pb-back:hover { background: var(--bg-card-hover); color: var(--green); text-shadow: none; }
.pb-back .pb-arrow { color: var(--green); font-size: var(--fs-md); line-height: 1; }
.pb-back-spacer { display: inline-block; }
.pb-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }
.pb-action {
  display: inline-flex; align-items: center; min-height: 36px;
  padding: 0.35rem 0.7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap;
}
.pb-action:hover { color: var(--green); border-color: var(--border-green); text-shadow: none; }

/* Quiz shell centres on a narrower column; keep its bar aligned with it. */
.quiz-shell .page-bar-inner { max-width: 720px; }

@media (max-width: 1023px) {
  .page-bar {
    top: 53px;
    margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-4)) var(--sp-4);
    padding: 0 var(--sp-4);
  }
}
@media (max-width: 600px) {
  .pb-back .pb-label { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── Module steps ─────────────────────────────────────────────────────────
   One renderer, two containers: the module sidebar (vertical) and, below the
   sidebar breakpoint, a band above the content. */
.cn-steps { list-style: none; display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; padding: 0; counter-reset: step; }
.cn-steps li { margin: 0; }
.cn-vertical { flex-direction: column; flex-wrap: nowrap; gap: var(--sp-1); }
.cn-step {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 36px; padding: 0.35rem 0.7rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: var(--fs-xs);
}
.cn-step:hover { background: var(--bg-card-hover); color: var(--text); text-shadow: none; }
.cn-step .cn-mark { font-size: 0.8em; line-height: 1; color: var(--text-dim); width: 1em; text-align: center; }
.cn-step .cn-dot { font-size: 0.5em; }
.cn-step.done { color: var(--green); }
.cn-step.done .cn-mark { color: var(--green); }
.cn-step.here { background: var(--green-soft); border-color: var(--border-green); color: var(--green); font-weight: 700; }
.cn-step.here .cn-mark { color: var(--green); }

/* ── The module sidebar ───────────────────────────────────────────────────
   Deliberately not the app sidebar: no global links, a green rail down its
   inside edge, and a labelled way out. You are somewhere else while you learn. */
.module-sidebar {
  width: 260px;
  border-right: 1px solid var(--border-green);
  box-shadow: inset -3px 0 0 -1px var(--green-faint);
  background: linear-gradient(180deg, var(--green-faint), transparent 220px), var(--bg-card);
  gap: var(--sp-4);
}
.ms-head { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-4); }
.ms-exit {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 32px; font-size: var(--fs-xs); color: var(--text-muted);
}
.ms-exit:hover { color: var(--green); text-shadow: none; }
.ms-code {
  font-family: var(--font-brand); font-size: var(--fs-lg); color: var(--text-bright);
  letter-spacing: 0.08em; margin-top: var(--sp-3);
}
.ms-title { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-1); }
.ms-progress { font-size: var(--fs-xs); color: var(--text-dim); }
.md-kicker {
  font-size: var(--fs-xs); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--green); padding: var(--sp-2) var(--sp-3);
}

@media (max-width: 1023px) {
  /* The module sidebar is content, not a drawer: it sits above the page. The doubled
     class beats the plain `.sidebar { display: none }` further down this stylesheet. */
  .shell { flex-direction: column; }
  .sidebar.module-sidebar {
    display: flex; width: auto; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--border-green); box-shadow: none;
    background: var(--bg-card);
    padding: var(--sp-4);
    gap: var(--sp-3);
    overflow-y: visible;
  }
  .sidebar.module-sidebar .cn-vertical { flex-direction: row; flex-wrap: wrap; }
  .sidebar.module-sidebar .sidebar-foot,
  .sidebar.module-sidebar .ms-progress { display: none; }
}

/* ── Cards / stats ────────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); }
.card + .card { margin-top: var(--sp-4); }
.card h2 { margin-bottom: var(--sp-4); font-size: var(--fs-md); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
}
.stat .stat-label { font-size: var(--fs-xs); color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; }
.stat .stat-value { font-size: var(--fs-xl); font-weight: 700; color: var(--text-bright); margin-top: var(--sp-1); font-variant-numeric: tabular-nums; }
.stat .stat-value .unit { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 400; }
.stat.glow { border-color: var(--border-green); }
.stat.glow .stat-value { color: var(--green); text-shadow: 0 0 12px var(--green-glow); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-full);
  background: var(--green-soft); border: 1px solid var(--border-green);
  color: var(--green); font-size: var(--fs-xs); font-weight: 700;
}

/* ── Path (home) ──────────────────────────────────────────────────────── */
.continue-hero {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  background: linear-gradient(135deg, var(--green-faint), transparent 60%), var(--bg-card);
  border: 1px solid var(--border-green);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.continue-hero .ch-label { font-size: var(--fs-xs); color: var(--green); letter-spacing: 0.12em; text-transform: uppercase; }
.continue-hero .ch-title { font-size: var(--fs-lg); color: var(--text-bright); font-weight: 700; margin-top: var(--sp-1); }

.phase-block { margin-bottom: var(--sp-6); }
.phase-head { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.phase-head .ph-num {
  font-family: var(--font-brand); font-size: var(--fs-sm); color: var(--green);
  border: 1px solid var(--border-green); border-radius: var(--radius-sm);
  padding: 0.2rem 0.6rem; letter-spacing: 0.1em; white-space: nowrap;
}
.phase-head h2 { font-size: var(--fs-md); }
.phase-head .ph-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.phase-head .ph-score { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.phase-block.locked { opacity: 0.55; }

.path { position: relative; margin-left: 19px; border-left: 2px solid var(--border); padding-left: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.node { position: relative; }
.node::before {
  content: '';
  position: absolute; left: calc(-1 * var(--sp-5) - 9px); top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: var(--radius-full);
  background: var(--node-locked); border: 2px solid var(--node-locked-border);
}
.node.done::before { background: var(--green); border-color: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.node.next::before { background: var(--bg); border-color: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.node-card {
  display: flex; align-items: center; gap: var(--sp-4);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color var(--t-fast), background var(--t-fast);
}
a.node-card:hover { background: var(--bg-card-hover); border-color: var(--border-light); text-shadow: none; }
.node.next .node-card { border-color: var(--border-green); }
.node-card .n-code { font-size: var(--fs-xs); color: var(--green); white-space: nowrap; }
.node-card .n-title { color: var(--text); font-size: var(--fs-sm); flex: 1; min-width: 0; }
.node-card .n-meta { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.node-card .n-state { font-size: var(--fs-xs); white-space: nowrap; }
.node.done .n-state { color: var(--green); }
.node.locked .node-card { opacity: 0.55; }
.node.gate .node-card { border-style: dashed; }
.node.gate.done .node-card { border-style: solid; }

.progress-bar { height: 6px; background: var(--bg-raised); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--green); border-radius: var(--radius-full); transition: width var(--t-base); }

/* ── Quiz player ──────────────────────────────────────────────────────── */
.quiz-shell { max-width: 720px; margin: 0 auto; }
/* Count, progress, the two review links and the exit. On a phone the links wrap to their own
   row rather than squeezing the progress bar to nothing. */
.quiz-top { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.quiz-top .progress-bar { flex: 1 1 120px; min-width: 90px; }
.quiz-top .q-count { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.q-prompt { font-size: var(--fs-md); color: var(--text-bright); margin-bottom: var(--sp-5); }
.q-prompt p + p { margin-top: var(--sp-3); }
.q-prompt pre { font-size: var(--fs-sm); }

.q-options { display: flex; flex-direction: column; gap: var(--sp-3); }
.q-option {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: var(--sp-4); cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  font-size: var(--fs-sm);
}
.q-option:hover { border-color: var(--green-dim); background: var(--bg-card-hover); }
.q-option input { accent-color: var(--green); margin-top: 3px; flex-shrink: 0; }
.q-option.selected { border-color: var(--green); background: var(--green-faint); }

.q-fill textarea, .q-fill input[type="text"] { font-size: var(--fs-base); }

.q-order { display: flex; flex-direction: column; gap: var(--sp-2); }
.q-order .o-item {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm);
}
.q-order .o-item .o-pos { color: var(--green); font-variant-numeric: tabular-nums; min-width: 1.4em; }
.q-order .o-item .o-move { margin-left: auto; display: flex; gap: var(--sp-1); }
.q-order .o-item button {
  background: var(--bg-raised); color: var(--text-muted); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); width: 30px; height: 30px; cursor: pointer; font-family: var(--font-mono);
}
.q-order .o-item button:hover { color: var(--green); border-color: var(--green-dim); }

.q-actions { margin-top: var(--sp-5); display: flex; justify-content: flex-end; }

.q-feedback { border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); margin-top: var(--sp-5); border: 1px solid; }
.q-feedback.ok { background: var(--green-soft); border-color: var(--border-green); }
.q-feedback.bad { background: var(--red-soft); border-color: var(--red); }
.q-feedback .f-verdict { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: var(--fs-sm); }
.q-feedback.ok .f-verdict { color: var(--green); }
.q-feedback.bad .f-verdict { color: var(--red); }
.q-feedback .f-expected { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text); }
.q-feedback .f-explain { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }

.quiz-result { text-align: center; padding: var(--sp-7) var(--sp-5); }
.quiz-result .r-score { font-size: var(--fs-3xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.quiz-result.pass .r-score { color: var(--green); text-shadow: 0 0 24px var(--green-glow); }
.quiz-result.fail .r-score { color: var(--red); }
.quiz-result .r-line { color: var(--text-muted); margin-top: var(--sp-2); }
.quiz-result .r-actions { margin-top: var(--sp-6); display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }
.quiz-result .r-xp { margin-top: var(--sp-3); color: var(--green); font-size: var(--fs-sm); }

/* ── Lesson: a chapter, not a summary ─────────────────────────────────── */
.lesson-meta { color: var(--text-dim); font-size: var(--fs-xs); margin-top: var(--sp-2); }

.chapter-toc {
  background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--green);
  border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); margin: var(--sp-5) 0;
}
.chapter-toc .toc-label {
  font-size: var(--fs-xs); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: var(--sp-2);
}
.chapter-toc ol { margin: 0; padding-left: 1.2rem; }
.chapter-toc li { margin: var(--sp-1) 0; font-size: var(--fs-sm); }
.chapter-toc a { color: var(--text-muted); }
.chapter-toc a:hover { color: var(--green); text-shadow: none; }

.lesson-body { font-size: var(--fs-base); }
/* Headings clear the sticky page bar when jumped to from the contents. */
.lesson-body h2, .lesson-body h3 { scroll-margin-top: 72px; }
.lesson-body h2 {
  font-size: var(--fs-lg); color: var(--text-bright); margin: var(--sp-7) 0 var(--sp-3);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border);
}
.lesson-body h2:first-child { margin-top: var(--sp-4); }
.lesson-body h3 { font-size: var(--fs-md); color: var(--green); margin: var(--sp-5) 0 var(--sp-2); }
.lesson-body p { margin: var(--sp-4) 0; }
.lesson-body ul, .lesson-body ol { margin: var(--sp-4) 0 var(--sp-4) var(--sp-5); }
.lesson-body li { margin-bottom: var(--sp-2); }
.lesson-body table { border-collapse: collapse; margin: var(--sp-4) 0; width: 100%; font-size: var(--fs-sm); }
.lesson-body th, .lesson-body td { border: 1px solid var(--border); padding: var(--sp-2) var(--sp-3); text-align: left; }
.lesson-body th { color: var(--green); background: var(--bg-card); }
.lesson-body strong { color: var(--text-bright); }
.lesson-nav { display: flex; justify-content: flex-end; gap: var(--sp-4); margin-top: var(--sp-6); flex-wrap: wrap; }

/* ── Worked examples ──────────────────────────────────────────────────── */
.example-badge {
  display: inline-block; font-size: var(--fs-xs); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--green); border: 1px solid var(--border-green); background: var(--green-faint);
  border-radius: var(--radius-full); padding: 0.2rem 0.7rem; margin-bottom: var(--sp-3);
}
.lesson-body .ex-head {
  font-size: var(--fs-md); color: var(--green); margin: var(--sp-6) 0 var(--sp-3);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border);
}
.ex-gate {
  background: var(--bg-card); border: 1px dashed var(--border-light); border-radius: var(--radius-lg);
  padding: var(--sp-5); margin-top: var(--sp-5); text-align: center;
}
.ex-gate p { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
.ex-takeaway {
  background: var(--green-faint); border: 1px solid var(--border-green); border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5); margin-top: var(--sp-6);
}
.ex-takeaway-label {
  font-size: var(--fs-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--green);
  margin-bottom: var(--sp-2);
}
.ex-takeaway p { margin: 0; }

/* ── Question hint ────────────────────────────────────────────────────── */
.q-hint { margin-top: var(--sp-4); border: 1px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-card); }
.q-hint summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); list-style: none; }
.q-hint summary::-webkit-details-marker { display: none; }
.q-hint summary::before { content: '? '; color: var(--green); font-weight: 700; }
.q-hint summary:hover { color: var(--green); }
.q-hint[open] summary { border-bottom: 1px solid var(--border); color: var(--green); }
.q-hint-body { padding: var(--sp-4); font-size: var(--fs-sm); color: var(--text); }
.q-hint-body p:first-child { margin-top: 0; }
.q-hint-body p:last-child { margin-bottom: 0; }

/* ── Leaderboard ──────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.tabs a {
  padding: 0.4rem 1rem; border-radius: var(--radius-full); font-size: var(--fs-sm);
  border: 1px solid var(--border-light); color: var(--text-muted);
}
.tabs a:hover { color: var(--text); border-color: var(--text-muted); text-shadow: none; }
.tabs a.active { background: var(--green-soft); border-color: var(--border-green); color: var(--green); }

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  text-align: left; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 400;
  letter-spacing: 0.08em; text-transform: uppercase; padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.lb-table td { padding: var(--sp-3); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.lb-table tr:last-child td { border-bottom: 0; }
.lb-table .lb-rank { color: var(--text-muted); font-variant-numeric: tabular-nums; width: 3em; }
.lb-table tr.top1 .lb-rank { color: var(--green); font-weight: 700; }
.lb-table .lb-user { display: flex; align-items: center; gap: var(--sp-3); }
.lb-table .lb-xp { font-variant-numeric: tabular-nums; color: var(--text-bright); text-align: right; }
.lb-table tr.me td { background: var(--green-faint); }
.lb-table .lb-phase { color: var(--text-muted); font-size: var(--fs-xs); }

/* ── Reports / charts ─────────────────────────────────────────────────── */
.chart-svg { width: 100%; height: auto; display: block; }
.heatmap { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.heat-cell { aspect-ratio: 1; border-radius: 2px; }
.legend { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-3); }
.legend .heat-cell { width: 10px; }

.bar-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); font-size: var(--fs-sm); }
.bar-row .b-label { width: 30%; min-width: 110px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .b-track { flex: 1; }
.bar-row .b-val { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* ── Streak flame (terminal glyph, not cartoon) ───────────────────────── */
.streak-badge { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--green); font-weight: 700; }
.streak-badge .glyph { font-size: 1.1em; }
.streak-badge.cold { color: var(--text-dim); }

/* ── Admin tables ─────────────────────────────────────────────────────── */
/* Wide matrix tables scroll inside their own container so the page body never does. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table { min-width: 640px; }
.table-wrap > .lb-table { min-width: 480px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.admin-table .row-actions { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }
/* Dense internal-tool actions, still >= 32px tall for touch. */
.btn-xs { padding: 0.3rem 0.7rem; font-size: var(--fs-xs); min-height: 32px; }
.admin-table th { text-align: left; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); font-weight: 400; }
.admin-table td { padding: var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: var(--radius-full); font-size: var(--fs-xs); border: 1px solid; }
.pill-green { color: var(--green); border-color: var(--border-green); background: var(--green-faint); }
.pill-yellow { color: var(--yellow); border-color: var(--yellow); background: var(--yellow-soft); }
.pill-red { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.pill-dim { color: var(--text-muted); border-color: var(--border-light); }

/* ── Landing page ─────────────────────────────────────────────────────── */
.landing { max-width: 1060px; margin: 0 auto; padding: 0 var(--sp-5); }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) 0; flex-wrap: wrap; gap: var(--sp-4); }
.landing-nav .l-actions { display: flex; gap: var(--sp-3); align-items: center; }

.hero { text-align: center; padding: var(--sp-8) 0 var(--sp-7); }
.hero .hero-kicker { color: var(--green); font-size: var(--fs-sm); letter-spacing: 0.2em; text-transform: uppercase; }
.hero h1 { font-size: clamp(2rem, 5.5vw, var(--fs-3xl)); margin: var(--sp-4) auto; max-width: 18em; }
.hero h1 .accent { color: var(--green); text-shadow: 0 0 24px var(--green-glow); }
.hero .hero-sub { color: var(--text-muted); max-width: 40em; margin: 0 auto var(--sp-6); }
.hero .hero-cta { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }

.term {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  max-width: 640px; margin: var(--sp-7) auto 0; text-align: left; overflow: hidden;
}
.term .term-bar { display: flex; gap: 6px; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.term .term-bar span { width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--border-light); }
.term .term-bar span:first-child { background: var(--green-dark); }
.term pre { border: 0; margin: 0; background: none; padding: var(--sp-5); }
.term .t-green { color: var(--green); }
.term .t-dim { color: var(--text-muted); }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-4); padding: var(--sp-7) 0; }
.feature { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); }
.feature .f-glyph { color: var(--green); font-size: var(--fs-lg); }
.feature h3 { margin: var(--sp-3) 0 var(--sp-2); font-size: var(--fs-base); }
.feature p { color: var(--text-muted); font-size: var(--fs-sm); }

.phase-list { padding: var(--sp-7) 0; }
.phase-list h2, .section-head { text-align: center; margin-bottom: var(--sp-6); }
.section-head .s-sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--sp-2); }
.phase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-4); }
.phase-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); }
.phase-card .pc-num { font-family: var(--font-brand); color: var(--green); font-size: var(--fs-sm); letter-spacing: 0.1em; }
.phase-card h3 { margin: var(--sp-2) 0; font-size: var(--fs-base); }
.phase-card p { color: var(--text-muted); font-size: var(--fs-sm); }

.landing-cta { text-align: center; padding: var(--sp-7) 0 var(--sp-8); }
.landing-foot { border-top: 1px solid var(--border); padding: var(--sp-5) 0; display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); flex-wrap: wrap; color: var(--text-dim); font-size: var(--fs-xs); }

/* ── Program page (client curriculum prospectus) ──────────────────────── */
.prog-glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); padding: var(--sp-5) 0 var(--sp-6); }
.prog-stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5); }
.prog-stat b { display: block; font-family: var(--font-brand); font-weight: 500; font-size: var(--fs-xl); color: var(--text-bright); letter-spacing: 0.02em; margin-bottom: var(--sp-1); }
.prog-stat b i { font-style: normal; color: var(--green); }
.prog-stat small { display: block; color: var(--text-dim); font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; line-height: var(--lh-base); }

.prog-sect { padding: var(--sp-6) 0; }
.prog-sect .sect-label { color: var(--green); font-size: var(--fs-xs); letter-spacing: 0.2em; text-transform: uppercase; margin: 0 0 var(--sp-2); }
.prog-sect h2 { font-family: var(--font-brand); font-weight: 500; font-size: var(--fs-xl); letter-spacing: 0.02em; text-transform: uppercase; margin: 0 0 var(--sp-3); }
.prog-lede { color: var(--text-muted); max-width: 68ch; margin: 0 0 var(--sp-5); }

.prog-halves { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.prog-half { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.prog-half.coached { border-color: var(--border-green); background: linear-gradient(var(--green-faint), var(--green-faint)), var(--bg-card); }
.prog-half .when { color: var(--green); font-size: var(--fs-xs); letter-spacing: 0.14em; text-transform: uppercase; }
.prog-half h3 { font-family: var(--font-brand); font-weight: 500; font-size: var(--fs-md); letter-spacing: 0.03em; text-transform: uppercase; margin: 0; }
.prog-half p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
.prog-half ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); }
.prog-half li { position: relative; padding-left: 20px; font-size: var(--fs-sm); }
.prog-half li::before { content: '>'; position: absolute; left: 0; color: var(--green-dim); }

.prog-chip { font-size: var(--fs-xs); letter-spacing: 0.12em; text-transform: uppercase; padding: 0.25rem 0.75rem; border-radius: var(--radius-full); white-space: nowrap; flex: none; }
.prog-chip.online { color: var(--green); border: 1px solid var(--border-green); background: var(--green-faint); }
.prog-chip.live { background: var(--green); color: var(--text-on-green); font-weight: 500; }

.prog-week { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: var(--sp-4); }
.prog-week-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-4) var(--sp-5); background: var(--bg-raised); border-bottom: 1px solid var(--border); }
.prog-week-head h3 { font-family: var(--font-brand); font-weight: 500; font-size: var(--fs-md); letter-spacing: 0.04em; text-transform: uppercase; margin: 0; }
.prog-week-head h3 small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: var(--fs-xs); letter-spacing: 0.14em; color: var(--text-dim); margin-top: 2px; }
.prog-day { display: grid; grid-template-columns: 56px 1fr; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.prog-day:last-child { border-bottom: none; }
.prog-day:hover { background: var(--green-faint); }
.prog-day .num { color: var(--green); font-weight: 500; font-size: var(--fs-sm); }
.prog-day h4 { margin: 0 0 var(--sp-1); font-size: var(--fs-base); color: var(--text-bright); }
.prog-day p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); max-width: 72ch; }

.prog-outcomes { background: var(--bg-card); border: 1px solid var(--border-green); border-radius: var(--radius-lg); padding: var(--sp-5); }
.prog-outcomes ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3) var(--sp-6); }
.prog-outcomes li { position: relative; padding-left: 26px; font-size: var(--fs-sm); }
.prog-outcomes li::before { content: '[x]'; position: absolute; left: 0; top: 2px; color: var(--green); font-weight: 500; font-size: var(--fs-xs); }

@media (max-width: 720px) {
  .prog-halves { grid-template-columns: 1fr; }
  .prog-outcomes ul { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
  .prog-day { grid-template-columns: 44px 1fr; gap: var(--sp-3); padding: var(--sp-4); }
  .prog-week-head { padding: var(--sp-4); }
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-3) var(--sp-4); background: var(--bg-card);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
  }
  .topbar .ham { background: none; border: 1px solid var(--border-light); color: var(--text); border-radius: var(--radius-sm); padding: 0.3rem 0.7rem; font-size: var(--fs-md); cursor: pointer; font-family: var(--font-mono); }
  .mobile-nav { display: none; background: var(--bg-card); border-bottom: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); position: sticky; top: 53px; z-index: 49; }
  .mobile-nav.open { display: block; }
  .mobile-nav a { display: block; padding: var(--sp-3); color: var(--text-muted); font-size: var(--fs-sm); border-radius: var(--radius-sm); }
  .mobile-nav a.active { color: var(--green); background: var(--green-soft); }
  .main { padding: var(--sp-4); }
  .stat .stat-value { font-size: var(--fs-lg); }
  .heatmap { grid-template-columns: repeat(12, 1fr); }
}
@media (max-width: 600px) {
  .continue-hero { flex-direction: column; align-items: stretch; text-align: center; }
  .node-card { flex-wrap: wrap; }
  .phase-head { flex-wrap: wrap; }
  .phase-head .ph-score { margin-left: 0; width: 100%; }
  .q-actions .btn { width: 100%; }
  .hero { padding-top: var(--sp-7); }
}
