/* =========================================================================
   Blue Pearl Learn — design system
   Mobile-first. Tokens first. Light and dark from one source.
   ========================================================================= */

:root {
  /* Neutrals carry a slight blue cast so the accent feels native. */
  --c-bg:          #ffffff;
  --c-surface:     #f7f8fa;
  --c-surface-2:   #eef0f4;
  --c-border:      #dfe3ea;
  --c-text:        #10141c;
  --c-text-muted:  #5a6472;

  /* One accent, used for action and progress only — never decoration. */
  --c-accent:      #1457d6;
  --c-accent-weak: #e8effc;
  --c-accent-text: #ffffff;
  --c-success:     #0f7b4d;
  --c-focus:       #f59e0b;

  --step--1: clamp(0.82rem, 0.79rem + 0.15vw, 0.89rem);
  --step-0:  clamp(1rem, 0.96rem + 0.2vw, 1.09rem);
  --step-1:  clamp(1.2rem, 1.12rem + 0.4vw, 1.45rem);
  --step-2:  clamp(1.45rem, 1.3rem + 0.75vw, 1.95rem);
  --step-3:  clamp(1.75rem, 1.45rem + 1.5vw, 2.75rem);

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 2px rgba(16, 20, 28, 0.06), 0 4px 12px rgba(16, 20, 28, 0.05);

  --measure: 68ch;
  --wrap:    90rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg:          #0d1117;
    --c-surface:     #151b23;
    --c-surface-2:   #1d242e;
    --c-border:      #2a323d;
    --c-text:        #e9edf3;
    --c-text-muted:  #9aa6b6;
    --c-accent:      #6ea3ff;
    --c-accent-weak: #16243d;
    --c-accent-text: #0d1117;
    --c-success:     #46c08a;
    --shadow:        0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --c-bg:          #0d1117;
  --c-surface:     #151b23;
  --c-surface-2:   #1d242e;
  --c-border:      #2a323d;
  --c-text:        #e9edf3;
  --c-text-muted:  #9aa6b6;
  --c-accent:      #6ea3ff;
  --c-accent-weak: #16243d;
  --c-accent-text: #0d1117;
  --c-success:     #46c08a;
  --shadow:        0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font: var(--step-0)/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", sans-serif;
  /* Tamil glyphs need a slightly taller line box than Latin alone. */
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--sp-3); font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p  { margin: 0 0 var(--sp-4); }

a { color: var(--c-accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* One visible focus treatment everywhere, on a hue no state reuses. */
:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

img, svg { max-width: 100%; height: auto; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -4rem;
  z-index: 100;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-accent);
  color: var(--c-accent-text);
  border-radius: var(--radius-sm);
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--sp-3); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--c-bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 3.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  color: var(--c-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 1.75rem; height: 1.75rem;
  border-radius: var(--radius-sm);
  background: var(--c-accent);
  color: var(--c-accent-text);
  font-size: 0.8rem;
  font-weight: 700;
}

.site-nav { margin-inline-start: auto; }
.site-nav ul {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0; padding: 0;
  list-style: none;
}
.site-nav a {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 550;
  text-decoration: none;
}
.site-nav a:hover { background: var(--c-surface-2); color: var(--c-text); }
.site-nav a[aria-current="page"] { color: var(--c-text); background: var(--c-surface-2); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem; height: 2.25rem;
  padding: 0;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text-muted);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--c-surface-2); color: var(--c-text); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  /* 44px min target — touch first. */
  min-height: 2.75rem;
  padding: var(--sp-3) var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn--primary { background: var(--c-accent); color: var(--c-accent-text); }
.btn--primary:hover { background: color-mix(in srgb, var(--c-accent) 85%, #000); }
.btn--ghost {
  background: transparent;
  border-color: var(--c-border);
  color: var(--c-text);
}
.btn--ghost:hover { background: var(--c-surface-2); }
.btn[aria-disabled="true"], .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Hero ---------- */

.hero { padding-block: var(--sp-7) var(--sp-6); }
.hero__title { max-width: 18ch; margin-bottom: var(--sp-4); }
.hero__lede {
  max-width: 52ch;
  font-size: var(--step-1);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-5);
}
.hero__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* ---------- Track cards ---------- */

.section { padding-block: var(--sp-6); }
.section__head { margin-bottom: var(--sp-5); }
.section__head p { color: var(--c-text-muted); margin: 0; max-width: var(--measure); }

.track-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
  margin: 0; padding: 0;
  list-style: none;
}
@media (min-width: 40rem) { .track-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .track-grid { grid-template-columns: repeat(3, 1fr); } }

.track-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  height: 100%;
  padding: var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.track-card:hover { border-color: var(--c-accent); transform: translateY(-2px); }
.track-card__level {
  align-self: flex-start;
  padding: var(--sp-1) var(--sp-2);
  border-radius: 999px;
  background: var(--c-accent-weak);
  color: var(--c-accent);
  font-size: var(--step--1);
  font-weight: 600;
}
.track-card__title { margin: 0; font-size: var(--step-1); }
.track-card__summary { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); flex: 1; }
.track-card__meta {
  margin-top: var(--sp-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
}

/* ---------- Breadcrumb ---------- */

.breadcrumb { padding-block: var(--sp-4) 0; font-size: var(--step--1); }
.breadcrumb ol {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  margin: 0; padding: 0; list-style: none;
  color: var(--c-text-muted);
}
.breadcrumb li::after { content: "/"; margin-inline-start: var(--sp-2); opacity: 0.5; }
.breadcrumb li:last-child::after { content: none; }

/* ---------- Lesson list ---------- */

.lesson-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2); }

.lesson-list__item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.lesson-list__item:hover { border-color: var(--c-accent); }
.lesson-list__num {
  flex: none;
  display: grid; place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.lesson-list__body { min-width: 0; }
.lesson-list__title { display: block; font-weight: 600; }
.lesson-list__summary {
  display: block;
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
.lesson-list__time { flex: none; margin-inline-start: auto; color: var(--c-text-muted); font-size: var(--step--1); }
@media (max-width: 30rem) { .lesson-list__time { display: none; } }

/* ---------- Lesson page ---------- */

.lesson { padding-block: var(--sp-5) var(--sp-8); }
.lesson__header { margin-bottom: var(--sp-5); }
.lesson__eyebrow {
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.lesson__summary { font-size: var(--step-1); color: var(--c-text-muted); max-width: var(--measure); }

/* Progress reads as information, not as a game score. */
.progress { margin-bottom: var(--sp-5); }
.progress__track {
  height: 4px;
  border-radius: 999px;
  background: var(--c-surface-2);
  overflow: hidden;
}
.progress__fill { height: 100%; background: var(--c-accent); border-radius: inherit; }
.progress__label {
  margin-top: var(--sp-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--sp-4); }
.prose h2 { margin-top: var(--sp-6); scroll-margin-top: 5rem; }
.prose h3 { margin-top: var(--sp-5); scroll-margin-top: 5rem; }
.prose ul, .prose ol { padding-inline-start: var(--sp-5); }
.prose li + li { margin-top: var(--sp-2); }
.prose strong { font-weight: 650; }

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--c-surface-2);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

/* Code blocks scroll on their own so the page never overflows sideways. */
.code {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  overflow: hidden;
}
.code__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
.code__lang { font-weight: 600; }
.code__copy {
  margin-inline-start: auto;
  min-height: 2rem;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  color: var(--c-text-muted);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
}
.code__copy:hover { color: var(--c-text); }
.code pre {
  margin: 0;
  padding: var(--sp-4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: var(--step--1);
  line-height: 1.7;
  tab-size: 2;
}

.callout {
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-inline-start: 3px solid var(--c-accent);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
}
.callout__title { font-weight: 650; margin-bottom: var(--sp-1); }
.callout > :last-child { margin-bottom: 0; }

/* Check-your-understanding: feedback, not scoring. */
.check {
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.check__q { font-weight: 650; margin-bottom: var(--sp-4); }
.check__options { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.check__option {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  cursor: pointer;
}
.check__option:hover { border-color: var(--c-accent); }
.check__option input { margin: 0.35em 0 0; accent-color: var(--c-accent); flex: none; }
.check__option[data-state="correct"] { border-color: var(--c-success); background: color-mix(in srgb, var(--c-success) 10%, var(--c-bg)); }
.check__option[data-state="wrong"] { border-color: #d14343; background: color-mix(in srgb, #d14343 8%, var(--c-bg)); }

.check__feedback { margin-top: var(--sp-4); font-size: var(--step--1); }
.check__feedback:empty { margin: 0; }

/* ---------- Lesson footer nav ---------- */

.lesson-nav {
  display: grid;
  gap: var(--sp-3);
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--c-border);
}
@media (min-width: 40rem) {
  .lesson-nav { grid-template-columns: 1fr 1fr; }
  .lesson-nav__next { justify-self: end; text-align: end; }
}
.lesson-nav a {
  display: block;
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.lesson-nav a:hover { border-color: var(--c-accent); }
.lesson-nav__dir { display: block; color: var(--c-text-muted); font-size: var(--step--1); margin-bottom: var(--sp-1); }
.lesson-nav__title { font-weight: 600; }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: var(--sp-8);
  padding-block: var(--sp-6);
  border-top: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
.site-footer__inner { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: flex-start; justify-content: space-between; }
.site-footer p { margin: 0; }
.site-footer nav { margin-inline-start: auto; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin: 0; padding: 0; list-style: none; }

/* ---------- Empty / 404 ---------- */

.notice { padding-block: var(--sp-8); text-align: center; }
.notice p { color: var(--c-text-muted); max-width: 44ch; margin-inline: auto; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================================
   Figures, steppers and hotspots
   ========================================================================= */

.figure {
  display: block;
  width: 100%;
  height: auto;
  margin-inline: auto;
  color: var(--c-text-muted);
  overflow: visible;
}

.figure__box {
  fill: var(--c-surface);
  stroke: var(--c-border);
  stroke-width: 1.5;
  transition: fill 0.2s ease, stroke 0.2s ease;
}
.figure__label { fill: var(--c-text); font-size: 15px; font-weight: 650; }
.figure__sub   { fill: var(--c-text-muted); font-size: 12px; }
.figure__mono {
  fill: var(--c-text);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
}
.figure__arrow, .figure__tick {
  stroke: var(--c-border);
  stroke-width: 1.5;
  fill: none;
}

/* The one highlighted state, shared by every figure. */
.figure__stage[data-active="true"] .figure__box {
  fill: var(--c-accent-weak);
  stroke: var(--c-accent);
  stroke-width: 2;
}
.figure__stage[data-active="true"] .figure__label { fill: var(--c-accent); }

/* Figures scroll rather than squash on a narrow phone. */
.steps__figure, .hotspot__stage {
  margin-bottom: var(--sp-5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.steps__figure .figure { min-width: 34rem; }
@media (min-width: 46rem) { .steps__figure .figure { min-width: 0; } }

/* ---------- Steps ---------- */

.steps {
  margin-block: var(--sp-6);
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.steps__heading { margin-top: 0; font-size: var(--step-1); }

.steps__list {
  margin: 0; padding: 0;
  list-style: none;
  counter-reset: none;
  display: grid;
  gap: var(--sp-3);
}
.steps__item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
}
.steps__num {
  flex: none;
  display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem;
  border-radius: 50%;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 650;
}
.steps__title { margin: 0 0 var(--sp-1); font-size: var(--step-0); }
.steps__text { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); }

/* Driven by JS only; without it every step stays visible. */
.steps[data-enhanced="true"] .steps__item { display: none; }
.steps[data-enhanced="true"] .steps__item[data-active="true"] { display: flex; }
.steps[data-enhanced="true"] .steps__item[data-active="true"] .steps__num {
  background: var(--c-accent);
  color: var(--c-accent-text);
}

.steps__controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.steps__count {
  margin: 0;
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  text-align: center;
  flex: 1;
}

/* ---------- Hotspot ---------- */

.hotspot {
  margin-block: var(--sp-6);
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.hotspot__heading { margin-top: 0; font-size: var(--step-1); }
.hotspot__intro { color: var(--c-text-muted); font-size: var(--step--1); }
.hotspot__progress {
  margin: 0 0 var(--sp-4);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.hotspot__spots { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-3); }
.hotspot__spot {
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
}
.hotspot__static { margin: 0 0 var(--sp-1); }
.hotspot__detail { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); }

.hotspot__reveal {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
.hotspot__reveal:hover { border-color: var(--c-accent); }

/* With JS the label becomes the button and details stay hidden until found. */
.hotspot[data-enhanced="true"] .hotspot__static { display: none; }
.hotspot[data-enhanced="true"] .hotspot__detail { display: none; }
.hotspot[data-enhanced="true"] .hotspot__spot[data-found="true"] .hotspot__detail { display: block; margin-top: var(--sp-3); }
.hotspot[data-enhanced="true"] .hotspot__spot[data-found="true"] {
  border-color: var(--c-accent);
  background: var(--c-accent-weak);
}
.hotspot[data-enhanced="true"] .hotspot__spot[data-found="true"] .hotspot__reveal {
  border-color: transparent;
  background: transparent;
  color: var(--c-accent);
  cursor: default;
}

/* ---------- Mock phone ---------- */

.phone {
  max-width: 22rem;
  margin-inline: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
  overflow: hidden;
}
.phone__bar {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
.phone__sender { font-weight: 600; }
.phone__bubble { padding: var(--sp-4); }
.phone__bubble p { margin: 0 0 var(--sp-3); font-size: var(--step--1); line-height: 1.6; }
.phone__bubble p:last-child { margin-bottom: 0; }

/* A tappable region inside the mock message. */
.mark {
  border-radius: 4px;
  padding: 0.1em 0.2em;
  box-shadow: inset 0 -2px 0 var(--c-border);
  transition: background-color 0.2s ease;
}
.phone[data-enhanced="true"] .mark { cursor: pointer; }
.phone[data-enhanced="true"] .mark:hover { background: var(--c-surface-2); }
.mark[data-active="true"] {
  background: var(--c-accent-weak);
  box-shadow: inset 0 -2px 0 var(--c-accent);
  color: var(--c-accent);
  font-weight: 600;
}

/* Language switch sits in the header nav and reads as an action, not a tab. */
.lang-switch {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.lang-switch:hover { border-color: var(--c-accent); color: var(--c-accent); }

/* =========================================================================
   Forms and auth
   ========================================================================= */

.auth { max-width: 26rem; padding-block: var(--sp-7) var(--sp-8); }
.auth__lede { color: var(--c-text-muted); margin-bottom: var(--sp-5); }
.auth__form { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.auth__alt { color: var(--c-text-muted); font-size: var(--step--1); }

.field { display: grid; gap: var(--sp-2); }
.field__label { font-weight: 600; font-size: var(--step--1); }
.field__input {
  width: 100%;
  min-height: 2.75rem;
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
}
.field__input:hover { border-color: var(--c-text-muted); }
.field__input[aria-invalid="true"] { border-color: #d14343; }
.field__hint  { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); }
.field__error { margin: 0; color: #d14343; font-size: var(--step--1); font-weight: 550; }

.alert {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid #d14343;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #d14343 8%, var(--c-bg));
  font-size: var(--step--1);
}

/* ---------- Completion ---------- */

.complete-form { margin-top: var(--sp-6); }
.complete-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 2.75rem;
  padding: var(--sp-3) var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.complete-btn:hover { border-color: var(--c-accent); }
.complete-btn[data-done="true"] {
  border-color: var(--c-success);
  background: color-mix(in srgb, var(--c-success) 10%, var(--c-bg));
  color: var(--c-success);
}

.complete-prompt {
  margin-top: var(--sp-6);
  padding: var(--sp-4);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
.complete-prompt p { margin: 0; }

/* A completed lesson in the track list. */
.lesson-list__item[data-done="true"] .lesson-list__num {
  background: var(--c-success);
  color: #fff;
}

.track-progress {
  margin-bottom: var(--sp-5);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

/* A form styled to sit in the nav beside links, because sign-out must POST. */
.nav-form { margin: 0; }
.nav-link-btn {
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text-muted);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 550;
  cursor: pointer;
}
.nav-link-btn:hover { background: var(--c-surface-2); color: var(--c-text); }

.notice-box {
  padding: var(--sp-4);
  border: 1px solid var(--c-success);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c-success) 8%, var(--c-bg));
  font-size: var(--step--1);
}

/* =========================================================================
   Admin
   ========================================================================= */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-6);
  padding: 0;
  list-style: none;
}
.stat {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
.stat__n {
  display: block;
  color: var(--c-text);
  font-size: var(--step-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Tables scroll rather than squash on a phone. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.table th, .table td {
  padding: var(--sp-3);
  text-align: start;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.table th { font-weight: 650; white-space: nowrap; }
.table code { font-size: 0.9em; }
.muted { color: var(--c-text-muted); }

.pill {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
}
.pill--published { background: color-mix(in srgb, var(--c-success) 18%, var(--c-bg)); color: var(--c-success); }
.pill--draft     { background: var(--c-accent-weak); color: var(--c-accent); }

.admin-group {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.admin-group legend {
  padding-inline: var(--sp-2);
  font-weight: 650;
}
.admin-row { display: grid; gap: var(--sp-4); }
@media (min-width: 40rem) { .admin-row { grid-template-columns: 1fr 1fr; } }

.admin-lang {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
  display: grid;
  gap: var(--sp-3);
}
.admin-lang__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--step-0);
}

.field__input--mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: var(--step--1);
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
textarea.field__input { resize: vertical; min-height: 3rem; }

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  position: sticky;
  bottom: 0;
  padding: var(--sp-4) 0;
  background: color-mix(in srgb, var(--c-bg) 92%, transparent);
  backdrop-filter: blur(6px);
}

/* Block tools in the lesson editor. */
.block-tools { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.btn-small {
  min-height: 2.25rem;
  min-width: 2.25rem;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
}
.btn-small:hover:not(:disabled) { border-color: var(--c-accent); color: var(--c-accent); }
.btn-small:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-small--danger:hover:not(:disabled) { border-color: #d14343; color: #d14343; }
.hidden-form { display: none; }

.table__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* ---------- Search ---------- */

.search-form { max-width: 34rem; margin-bottom: var(--sp-5); display: grid; gap: var(--sp-2); }
.search-form__row { display: flex; gap: var(--sp-2); }
.search-form__row .field__input { flex: 1; min-width: 0; }
.search-count {
  color: var(--c-text-muted);
  font-size: var(--step--1);
  margin-bottom: var(--sp-4);
}
/* A result has no position number, so the circle would be empty. */
.lesson-list__item--result { padding-inline-start: var(--sp-4); }

/* =========================================================================
   Subject layout — sidebar plus lesson
   ========================================================================= */

.subject-layout {
  padding-block: var(--sp-4) var(--sp-8);
  /* The article is first in source order for heading order and the skip link;
     flex order puts the contents back above it on a narrow screen. */
  display: flex;
  flex-direction: column;
}
.subject-layout__main { order: 2; }
.subject-nav { order: 1; }

.subject-nav {
  margin-bottom: var(--sp-5);
  padding: var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
.subject-nav__title {
  margin: 0 0 var(--sp-3);
  font-size: var(--step-0);
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.subject-nav__topics,
.subject-nav__lessons { margin: 0; padding: 0; list-style: none; }
.subject-nav__topics > li + li { margin-top: var(--sp-1); }

.subject-nav__summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
}
.subject-nav__summary:hover { background: var(--c-surface-2); }
.subject-nav__name { flex: 1; min-width: 0; }
.subject-nav__count {
  flex: none;
  color: var(--c-text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.subject-nav__lessons {
  margin-top: var(--sp-1);
  /* Indents the lessons under their topic without a nested border. */
  padding-inline-start: var(--sp-3);
}

.subject-nav__link {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-inline-start: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--c-text-muted);
  font-size: var(--step--1);
  text-decoration: none;
}
.subject-nav__link:hover { background: var(--c-surface-2); color: var(--c-text); }

/* Same treatment the header nav already uses for the current page. */
.subject-nav__link[aria-current="page"] {
  background: var(--c-surface-2);
  border-inline-start-color: var(--c-accent);
  color: var(--c-text);
  font-weight: 600;
}

.subject-nav__marker {
  flex: none;
  width: 1.25rem;
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.subject-nav__text { min-width: 0; }

@media (min-width: 64rem) {
  .subject-layout {
    display: grid;
    /* minmax(0, 1fr) stops a wide code block widening the whole grid. */
    grid-template-columns: 18rem minmax(0, 1fr);
    gap: var(--sp-6);
    align-items: start;
  }

  /* Explicit columns, because the article precedes the nav in the markup. */
  .subject-nav          { grid-column: 1; grid-row: 1; }
  .subject-layout__main { grid-column: 2; grid-row: 1; }

  .subject-nav {
    position: sticky;
    /* Clears the sticky site header. */
    top: var(--sp-5);
    max-height: calc(100vh - var(--sp-8));
    overflow-y: auto;
    margin-bottom: 0;
  }

  /* Pairs with minmax(0, 1fr): without it the article refuses to shrink. */
  .subject-layout__main { min-width: 0; }
}

/* A topic nested inside its subject on the groupings page. */
.admin-group--nested {
  margin-top: var(--sp-4);
  margin-inline-start: var(--sp-4);
  background: var(--c-bg);
}

/* Search pagination. */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

/* ---------- Find My Path ---------- */

.pathfinder { padding-block: var(--sp-6) var(--sp-8); }
.pathfinder__inner { max-width: 40rem; }
.pathfinder__intro { color: var(--c-text-muted); }
.pathfinder__eyebrow {
  margin-bottom: var(--sp-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pathfinder__prompt { font-size: var(--step-2); text-wrap: balance; }
.pathfinder__hint { color: var(--c-text-muted); font-size: var(--step--1); }
.pathfinder__lede { color: var(--c-text-muted); font-size: var(--step-1); }

.pathfinder__options {
  display: grid;
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
  padding: 0;
  list-style: none;
}
/* Whole-row targets well above 44px, for thumbs on a phone. */
.pathfinder__option {
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text);
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.pathfinder__option::after { content: "→"; margin-inline-start: auto; padding-inline-start: var(--sp-3); color: var(--c-text-muted); }
.pathfinder__option:hover { border-color: var(--c-accent); background: var(--c-accent-weak); }
.pathfinder__option:hover::after { color: var(--c-accent); }

.pathfinder__panel {
  margin-block: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
.pathfinder__subhead { font-size: var(--step-1); margin-top: var(--sp-5); }
.pathfinder__panel .pathfinder__subhead { margin-top: 0; }
.pathfinder__reasons { margin: 0 0 var(--sp-4); padding-inline-start: var(--sp-5); }
.pathfinder__reasons li + li { margin-top: var(--sp-2); }
.pathfinder__told { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); }

.pathfinder__notice {
  padding: var(--sp-3) var(--sp-4);
  border-inline-start: 3px solid var(--c-accent);
  background: var(--c-accent-weak);
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
}

.pathfinder__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }
.pathfinder__back { margin-top: var(--sp-5); color: var(--c-text-muted); font-size: var(--step--1); }

/* =========================================================================
   Mobile header, code fixes, compact lesson contents
   ========================================================================= */

/* Nothing may push the page wider than the phone. */
html, body { overflow-x: clip; }
.site-header__inner { flex-wrap: wrap; }
.brand { flex: none; white-space: nowrap; }

.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: auto;
  min-height: 2.75rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
}
.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle__bars { position: relative; }
.nav-toggle__bars::before,
.nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -6px; }
.nav-toggle__bars::after  { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after  { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 52rem) {
  /* Without JS: links wrap onto a second row, all reachable. */
  .site-nav { flex-basis: 100%; margin-inline-start: 0; }
  .site-nav ul { flex-wrap: wrap; gap: var(--sp-1); padding-bottom: var(--sp-2); }

  /* With JS: a menu button and a full-width panel. */
  .js .nav-toggle:not([hidden]) { display: inline-flex; }
  .js .site-nav { display: none; }
  .js .site-nav[data-open] { display: block; }
  .js .site-nav ul {
    flex-direction: column;
    align-items: stretch;
    padding-block: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--c-border);
  }
  .js .site-nav a,
  .js .site-nav .nav-link-btn {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    font-size: var(--step-0);
  }
  .js .site-nav .lang-switch { justify-content: flex-start; }
}

/* Code: show exactly what a learner must type — no ">=" drawn as "≥". */
.code pre,
.prose code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
/* The inline-code chip must not paint every line of a code block. */
.code pre code { padding: 0; background: none; border-radius: 0; font-size: inherit; }

/* The progress bar gets its own row beneath the breadcrumb. */
.lesson .progress { margin-top: var(--sp-4); }

/* Lesson contents: a folded "Course contents" bar on phones. */
.subject-nav__toggle { display: none; }
@media (max-width: 63.99rem) {
  .subject-nav__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.75rem;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
  }
  .subject-nav__toggle::-webkit-details-marker { display: none; }
  .subject-nav__toggle::after { content: "▾"; color: var(--c-text-muted); transition: transform 0.2s ease; }
  .subject-nav__drawer[open] > .subject-nav__toggle::after { transform: rotate(180deg); }
  .subject-nav__drawer[open] > .subject-nav__toggle { margin-bottom: var(--sp-3); }
  .subject-nav .subject-nav__title { display: none; }
  .subject-nav__link, .subject-nav__summary { min-height: 2.75rem; align-items: center; }
}

/* ---------- Student-only content ---------- */

.student-block {
  margin-block: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--c-accent);
  border-radius: var(--radius);
  background: var(--c-accent-weak);
}
.student-block__label {
  margin: 0 0 var(--sp-3);
  color: var(--c-accent);
  font-size: var(--step--1);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.student-locked {
  margin-block: var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  font-size: var(--step--1);
}
.student-locked__title { font-weight: 650; }
.student-locked > :last-child { margin-bottom: 0; }

/* =========================================================================
   Staff dashboard
   ========================================================================= */

.admin-page { padding-block: var(--sp-5) var(--sp-8); }
.admin-back { margin: 0 0 var(--sp-3); font-size: var(--step--1); }

.admin-hero {
  display: grid;
  gap: var(--sp-5);
  align-items: end;
  margin-bottom: var(--sp-6);
}
@media (min-width: 56rem) { .admin-hero { grid-template-columns: 1fr auto; } }
.admin-hero h1 { margin-bottom: var(--sp-1); }
.admin-hero p { margin: 0; }
.admin-hero__eyebrow {
  color: var(--c-accent);
  font-size: var(--step--1);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--c-text-muted);
  font-size: var(--step--1);
}
@media (min-width: 40rem) { .kpis { grid-template-columns: repeat(4, minmax(7rem, 1fr)); } }
.kpis li {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.kpis__n {
  display: block;
  color: var(--c-text);
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--sp-3);
  margin: 0 0 var(--sp-7);
  padding: 0;
  list-style: none;
}
.action-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--sp-3);
  align-items: center;
  height: 100%;
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
  color: var(--c-text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.action-card:hover { border-color: var(--c-accent); transform: translateY(-2px); }
.action-card__icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--c-accent-weak);
  color: var(--c-accent);
  font-weight: 700;
}
.action-card__title { font-weight: 650; }
.action-card__meta { color: var(--c-text-muted); font-size: var(--step--1); }
.action-card--primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-text); }
.action-card--primary .action-card__meta { color: color-mix(in srgb, var(--c-accent-text) 80%, transparent); }
.action-card--primary .action-card__icon { background: color-mix(in srgb, var(--c-accent-text) 20%, transparent); color: var(--c-accent-text); }

.lessons-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.lessons-head h2 { margin: 0; }
.lesson-filter { flex: 1 1 16rem; max-width: 24rem; }

.subject-block {
  margin-bottom: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
}
.subject-block__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: baseline;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  list-style: none;
}
.subject-block__head::-webkit-details-marker { display: none; }
.subject-block__head::before { content: "▸"; margin-inline-end: var(--sp-2); color: var(--c-text-muted); transition: transform 0.15s ease; }
.subject-block[open] > .subject-block__head::before { transform: rotate(90deg); }
.subject-block__name { flex: 1; font-size: var(--step-1); font-weight: 650; }
.subject-block[open] { padding-bottom: var(--sp-3); }

.topic-label {
  margin: var(--sp-4) var(--sp-5) var(--sp-2);
  color: var(--c-text-muted);
  font-size: var(--step--1);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lesson-rows { margin: 0 var(--sp-3); padding: 0; list-style: none; }
.lesson-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-1) var(--sp-4);
  align-items: center;
  padding: var(--sp-3) var(--sp-2);
  border-top: 1px solid var(--c-border);
}
@media (min-width: 48rem) { .lesson-row { grid-template-columns: minmax(0, 1fr) 12rem auto; } }
.lesson-row:hover { background: var(--c-surface); }
.lesson-row__main { min-width: 0; color: var(--c-text); text-decoration: none; }
.lesson-row__title { display: block; font-weight: 600; }
.lesson-row__slug { color: var(--c-text-muted); font-size: 0.8em; }
.lesson-row__meta { font-size: var(--step--1); }
.lesson-row__actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }
@media (max-width: 47.99rem) { .lesson-row__meta { grid-column: 1; } .lesson-row__actions { grid-row: 1 / span 2; grid-column: 2; } }

/* Cards and split layout for the people pages. */
.card {
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
  box-shadow: var(--shadow);
}
.card__title { margin-top: 0; font-size: var(--step-1); }
.form-card { display: grid; gap: var(--sp-4); align-content: start; }
.admin-split { display: grid; gap: var(--sp-5); align-items: start; }
@media (min-width: 56rem) { .admin-split { grid-template-columns: minmax(18rem, 2fr) 3fr; } }

.people { margin: 0; padding: 0; list-style: none; }
.people__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--c-border);
}
.people__main { display: grid; flex: 1; min-width: 0; }
.people__main .muted { font-size: var(--step--1); }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--c-accent-weak);
  color: var(--c-accent);
  font-weight: 700;
}
.empty { padding: var(--sp-5); text-align: center; color: var(--c-text-muted); }
.notice-box--warn { border-color: var(--c-focus); background: color-mix(in srgb, var(--c-focus) 10%, var(--c-bg)); }
code.secret { font-size: 1.05em; font-weight: 700; letter-spacing: 0.05em; }

/* =========================================================================
   Course landing page
   ========================================================================= */

.course-hero {
  padding-block: var(--sp-4) var(--sp-7);
  background:
    radial-gradient(60rem 22rem at 90% -10%, color-mix(in srgb, var(--c-accent) 14%, transparent), transparent 70%),
    var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.course-hero__eyebrow {
  margin: var(--sp-5) 0 var(--sp-2);
  color: var(--c-accent);
  font-size: var(--step--1);
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.course-hero__title { font-size: var(--step-3); margin-bottom: var(--sp-3); }
.course-hero__lede { max-width: var(--measure); color: var(--c-text-muted); font-size: var(--step-1); }
.course-progress { max-width: 32rem; margin-block: var(--sp-4); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-4) 0 var(--sp-5);
  padding: 0;
  list-style: none;
}
.chips li {
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-bg);
  font-size: var(--step--1);
  font-weight: 550;
}

.btn--lg { min-height: 3.25rem; padding-inline: var(--sp-6); font-size: var(--step-0); }

.syllabus { display: grid; gap: var(--sp-3); margin: var(--sp-5) 0 0; padding: 0; list-style: none; }
.syllabus__topic details {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
}
.syllabus__topic details[open] { box-shadow: var(--shadow); }
.syllabus__head {
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  list-style: none;
}
.syllabus__head::-webkit-details-marker { display: none; }
.syllabus__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--c-accent-weak);
  color: var(--c-accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.syllabus__text { display: grid; flex: 1; min-width: 0; }
.syllabus__title { font-weight: 650; }
.syllabus__summary { color: var(--c-text-muted); font-size: var(--step--1); }
.syllabus__count { flex: none; color: var(--c-text-muted); font-size: var(--step--1); white-space: nowrap; }
.syllabus__lessons {
  margin: 0;
  padding: 0 var(--sp-5) var(--sp-4) calc(var(--sp-5) + 2.25rem + var(--sp-4));
  list-style: none;
}
.syllabus__lessons a {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  min-height: 2.75rem;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  text-decoration: none;
}
.syllabus__lessons a:hover { background: var(--c-surface-2); }
.syllabus__tick {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--c-border);
  border-radius: 50%;
  color: var(--c-accent-text);
  font-size: 0.7rem;
  font-weight: 700;
}
.syllabus__lessons a[data-done] .syllabus__tick { background: var(--c-success); border-color: var(--c-success); }
@media (max-width: 40rem) {
  .syllabus__lessons { padding-inline-start: var(--sp-5); }
  .syllabus__count { display: none; }
}

.faq__item {
  max-width: var(--measure);
  border-bottom: 1px solid var(--c-border);
}
.faq__item summary {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: 3rem;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary::after { content: "+"; color: var(--c-accent); font-size: 1.4em; transition: transform 0.2s ease; }
.faq__item[open] summary::after { transform: rotate(45deg); }
.faq__item p { color: var(--c-text-muted); }

/* =========================================================================
   Animated concept figures (partials/figures/c-*.php)
   CSS-only, theme-aware, and still under prefers-reduced-motion.
   ========================================================================= */

.anim-figure {
  margin: var(--sp-5) 0;
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.anim-figure__art { overflow-x: auto; }
.anim-figure svg { display: block; width: 100%; max-width: 40rem; height: auto; margin-inline: auto; }
.anim-figure figcaption { margin-top: var(--sp-3); color: var(--c-text-muted); font-size: var(--step--1); text-align: center; }

.fg-box    { fill: var(--c-bg); stroke: var(--c-border); stroke-width: 2; }
.fg-accent { fill: var(--c-accent-weak); stroke: var(--c-accent); stroke-width: 2; }
.fg-text   { fill: var(--c-text); font: 600 15px ui-monospace, Consolas, monospace; }
.fg-label  { fill: var(--c-text-muted); font: 500 12px system-ui, sans-serif; }
.fg-code   { fill: var(--c-accent); font: 700 14px ui-monospace, Consolas, monospace; }
.fg-line   { stroke: var(--c-text-muted); stroke-width: 2; fill: none; }
.fg-arrow  { stroke: var(--c-accent); stroke-width: 3; fill: none; }
.fg-dot    { fill: var(--c-accent); }
.fg-ok     { fill: color-mix(in srgb, var(--c-success) 18%, var(--c-bg)); stroke: var(--c-success); stroke-width: 2; }

/* Draw a path from nothing, then hold. */
@keyframes fg-draw   { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
.fg-draw { stroke-dasharray: 400; animation: fg-draw 1.6s ease-out 0.4s both; }

/* Fade/slide in, staggered with --d. */
@keyframes fg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fg-in { opacity: 0; animation: fg-in 0.5s ease-out both; animation-delay: var(--d, 0s); transform-box: fill-box; }

/* A highlight that walks along positions 0..4 (array index figure). */
@keyframes fg-walk {
  0%, 12%  { transform: translateX(0); }
  20%, 32% { transform: translateX(80px); }
  40%, 52% { transform: translateX(160px); }
  60%, 72% { transform: translateX(240px); }
  80%, 100%{ transform: translateX(320px); }
}
.fg-walk { animation: fg-walk 6s ease-in-out infinite; }

/* A dot travelling around the loop flowchart. */
@keyframes fg-orbit { from { offset-distance: 0%; } to { offset-distance: 100%; } }
.fg-orbit { offset-rotate: 0deg; animation: fg-orbit 5s linear infinite; }

/* Grid cells filling row by row (2D array figure). */
@keyframes fg-fill { 0% { fill: var(--c-bg); } 30%, 100% { fill: var(--c-accent-weak); } }
.fg-fill { animation: fg-fill 0.6s ease-out both; animation-delay: var(--d, 0s); }

/* Stack frames pushed then popped (recursion figure): 8s loop. */
@keyframes fg-push-pop {
  0%   { opacity: 0; transform: translateY(-12px); }
  8%   { opacity: 1; transform: none; }
  70%  { opacity: 1; transform: none; }
  78%, 100% { opacity: 0; transform: translateY(-12px); }
}
.fg-frame { opacity: 0; animation: fg-push-pop 8s ease-in-out infinite; animation-delay: var(--d, 0s); transform-box: fill-box; }

@keyframes fg-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.fg-pulse { animation: fg-pulse 2.2s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .fg-draw, .fg-in, .fg-walk, .fg-orbit, .fg-fill, .fg-frame, .fg-pulse {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
  }
  .fg-orbit { display: none; }
}

/* ---------- Human-readable site map ---------- */
.sitemap-page__h { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: baseline; margin-top: var(--sp-6); }
.sitemap-page__h .muted { font-size: var(--step--1); font-weight: 500; }
.sitemap-page__top { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); padding: 0; list-style: none; }
.sitemap-page__grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.sitemap-page__grid h3 { font-size: var(--step-0); margin-bottom: var(--sp-2); }
.sitemap-page__grid ul { margin: 0; padding-inline-start: var(--sp-4); font-size: var(--step--1); }
.sitemap-page__grid li { margin-block: var(--sp-1); }
.sitemap-page__xml { margin-top: var(--sp-7); font-size: var(--step--1); }

/* =========================================================================
   Course catalogue (/courses)
   ========================================================================= */

.catalog-hero {
  padding-block: var(--sp-4) var(--sp-6);
  background:
    radial-gradient(60rem 22rem at 85% -10%, color-mix(in srgb, var(--c-accent) 14%, transparent), transparent 70%),
    var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.catalog-hero__title { margin-top: var(--sp-5); max-width: 22ch; text-wrap: balance; }
.catalog-hero__lede { max-width: var(--measure); color: var(--c-text-muted); font-size: var(--step-1); }
.catalog-hero__help { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin: var(--sp-4) 0 0; color: var(--c-text-muted); }

.chips--nav a {
  display: inline-flex;
  gap: var(--sp-2);
  align-items: center;
  min-height: 2.5rem;
  padding: var(--sp-1) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
}
.chips--nav { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-block: var(--sp-5) var(--sp-3); }
.chips--nav a:hover { border-color: var(--c-accent); color: var(--c-accent); }
.chips__n {
  display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .3rem;
  border-radius: 999px; background: var(--c-accent-weak); color: var(--c-accent); font-size: .75rem;
}

.catalog-area { scroll-margin-top: 4.5rem; }
.catalog-area__head { max-width: var(--measure); margin-bottom: var(--sp-4); }
.catalog-area__head p { color: var(--c-text-muted); margin: 0; }
.catalog-soon {
  padding: var(--sp-4) var(--sp-5);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text-muted);
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.course-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.course-card:hover { border-color: var(--c-accent); transform: translateY(-2px); }
.course-card__level { margin: 0; color: var(--c-accent); font-size: var(--step--1); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.course-card__title { margin: 0; font-size: var(--step-2); }
.course-card__title a { color: var(--c-text); text-decoration: none; }
.course-card__title a:hover { color: var(--c-accent); }
.course-card__summary { margin: 0; color: var(--c-text-muted); }
.course-card__facts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.course-card__facts li { padding: 0.15rem var(--sp-3); border-radius: 999px; background: var(--c-surface-2); font-size: var(--step--1); font-weight: 550; }
.course-card__covers { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); flex: 1; }
.course-card__cta { align-self: flex-start; margin-top: var(--sp-2); }

.classroom-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
  padding: 0;
  list-style: none;
}
.classroom-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
}
.classroom-list__name { font-weight: 600; }
.classroom-list__area { color: var(--c-text-muted); font-size: var(--step--1); white-space: nowrap; }

/* A folded course-contents drawer always shows its bar, so it can be opened
   even on a wide screen without JavaScript. */
.subject-nav__drawer:not([open]) > .subject-nav__toggle { display: flex; align-items: center; min-height: 2.75rem; font-weight: 650; cursor: pointer; }


/* =========================================================================
   Home page: the whole platform (every learning area), not one course.
   ========================================================================= */
.home-hero {
  padding-block: var(--sp-7);
  background:
    radial-gradient(60rem 24rem at 90% -20%, color-mix(in srgb, var(--c-accent) 16%, transparent), transparent 70%),
    var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.home-hero__eyebrow { color: var(--c-accent); font-weight: 650; margin: 0 0 var(--sp-3); }
.home-hero__title { font-size: var(--step-3); max-width: 32ch; margin-bottom: var(--sp-4); text-wrap: balance; }
.home-hero__lede { max-width: 75ch; color: var(--c-text-muted); font-size: var(--step-0); line-height: 1.7; margin-bottom: var(--sp-5); }

.area-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--sp-5);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
}
.area-card {
  height: 100%;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 1rem;
  padding: var(--sp-5);
  transition: transform 0.25s cubic-bezier(.2,.7,.3,1), box-shadow 0.25s ease, border-color 0.2s ease;
}
.area-card:hover, .area-card:focus-within {
  border-color: var(--c-accent);
  transform: translateY(-4px);
  box-shadow: 0 14px 30px -18px color-mix(in srgb, var(--c-accent) 55%, transparent);
}
.area-card__n { margin: 0; color: var(--c-accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.area-card__title { font-size: var(--step-1); margin: var(--sp-1) 0 var(--sp-2); }
.area-card__title a { color: inherit; text-decoration: none; }
.area-card__title a:hover { text-decoration: underline; }
.area-card__summary { color: var(--c-text-muted); margin-bottom: var(--sp-3); }
.area-card__label { margin: var(--sp-4) 0 var(--sp-1); font-size: 0.875rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-text-muted); }
.area-card__courses { list-style: none; margin: 0; padding: 0; }
.area-card__courses li { display: flex; justify-content: space-between; gap: var(--sp-2); align-items: center; min-height: 2.75rem; border-top: 1px solid var(--c-border); }
.area-card__courses a { font-weight: 600; }
.area-card__courses span { color: var(--c-text-muted); font-size: 0.875rem; white-space: nowrap; }
.area-card__classroom { margin: 0; color: var(--c-text-muted); font-size: 0.95rem; }

/* How it works: roomy step cards instead of three tight columns. */
.home-how { background: var(--c-surface); border-block: 1px solid var(--c-border); padding-block: var(--sp-8); }
.how-steps {
  list-style: none; margin: 0; padding: 0; counter-reset: step;
  display: grid; gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}
.how-steps li {
  counter-increment: step;
  background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 1rem;
  padding: var(--sp-6) var(--sp-5);
  transition: transform 0.25s cubic-bezier(.2,.7,.3,1), border-color 0.2s ease;
}
.how-steps li:hover { transform: translateY(-4px); border-color: var(--c-accent); }
.how-steps li::before {
  content: counter(step);
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem; border-radius: 50%;
  background: var(--c-accent); color: var(--c-accent-text); font-weight: 700; font-size: var(--step-1);
  margin-bottom: var(--sp-4);
}
.how-steps h3 { font-size: var(--step-1); margin-bottom: var(--sp-2); }
.how-steps p { color: var(--c-text-muted); margin: 0; line-height: 1.7; }

/* Classroom call-out: a full-width band with breathing room. */
.home-classroom {
  display: grid; gap: var(--sp-5); align-items: center;
  margin-block: var(--sp-8);
  padding: var(--sp-7) var(--sp-6);
  border-radius: 1.25rem;
  background:
    radial-gradient(40rem 18rem at 100% 0%, color-mix(in srgb, var(--c-accent) 18%, transparent), transparent 70%),
    var(--c-accent-weak);
  border: 1px solid var(--c-border);
}
@media (min-width: 56rem) { .home-classroom { grid-template-columns: 1.6fr 1fr; padding-inline: var(--sp-7); } }
.home-classroom h2 { margin-bottom: var(--sp-3); }
.home-classroom p { color: var(--c-text-muted); max-width: 70ch; line-height: 1.7; margin: 0; }
.home-classroom__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: flex-start; }
@media (min-width: 56rem) { .home-classroom__actions { justify-content: flex-end; } }

/* FAQ everywhere: full width, answers as cards in a two-column grid. */
.faq > h2 { margin-bottom: var(--sp-5); }
.faq { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); align-items: start; }
.faq > h2 { grid-column: 1 / -1; }
.faq__item {
  max-width: none;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 0.875rem;
  padding: 0 var(--sp-4);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.faq__item:hover { border-color: var(--c-accent); }
.faq__item[open] { border-color: var(--c-accent); box-shadow: 0 10px 24px -20px var(--c-accent); }
.faq__item summary { padding-block: var(--sp-3); cursor: pointer; }
.faq__item p { margin: 0 0 var(--sp-4); line-height: 1.7; }

/* Footer: visible name, address, phone (NAP) and the official profiles. */
.site-footer__brand { font-weight: 650; color: var(--c-text); margin-bottom: var(--sp-2) !important; }
.site-footer__nap { font-style: normal; line-height: 1.7; }
.site-footer nav { display: grid; gap: var(--sp-3); margin-inline-start: 0; }
.site-footer ul a { display: inline-flex; align-items: center; min-height: 2.75rem; }

/* Scroll reveal: pure CSS, only where supported, never for reduced motion.
   Cards keep their space from the start, so nothing shifts (CLS stays 0). */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .area-card, .how-steps li, .faq__item, .course-card, .home-classroom {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 35%;
    }
  }
}
@keyframes reveal { from { translate: 0 2rem; scale: 0.97; } to { translate: 0 0; scale: 1; } }
@media (prefers-reduced-motion: reduce) {
  .area-card, .how-steps li, .faq__item { transition: none; }
  .area-card:hover, .how-steps li:hover { transform: none; }
}

.breadcrumb__home { vertical-align: -0.15em; margin-inline-end: 0.3em; }

/* One-click start: straight to a course's first lesson. */
.quick-start { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.quick-start__label { font-weight: 650; margin-inline-end: var(--sp-1); }
.quick-start__chip {
  display: inline-flex; align-items: center; gap: 0.35em; min-height: 2.75rem;
  padding: 0 var(--sp-4); border-radius: 999px;
  background: var(--c-bg); border: 1px solid var(--c-border);
  font-weight: 600; text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.quick-start__chip:hover { border-color: var(--c-accent); transform: translateY(-2px); }
.area-card__course { display: flex; flex-direction: column; }
.area-card__start { font-weight: 650; white-space: nowrap; min-height: 2.75rem; display: inline-flex; align-items: center; }
@media (prefers-reduced-motion: reduce) { .quick-start__chip:hover { transform: none; } }

/* =========================================================================
   Layered lessons and practice tasks (Phase 3)
   Layers 1-3 are open sections; 4-5 are <details>. A lesson without layers
   never uses any of this.
   ========================================================================= */
.layer { margin-block: var(--sp-6); }
.layer__title {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--step-1); font-weight: 700; line-height: 1.3;
  margin: 0 0 var(--sp-3);
}
.layer__n {
  flex: none; display: inline-grid; place-items: center;
  inline-size: 1.75rem; block-size: 1.75rem; border-radius: 50%;
  background: var(--c-accent-weak); color: var(--c-accent);
  font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.layer--deep {
  border: 1px solid var(--c-border); border-radius: 0.875rem;
  background: var(--c-surface); padding: 0 var(--sp-4);
}
.layer--deep > summary {
  cursor: pointer; list-style: none; min-height: 2.75rem; margin: 0; padding-block: var(--sp-3);
}
.layer--deep > summary::-webkit-details-marker { display: none; }
.layer--deep > summary::after { content: "+"; margin-inline-start: auto; color: var(--c-accent); font-size: 1.4em; line-height: 1; transition: transform 0.2s ease; }
.layer--deep[open] > summary::after { transform: rotate(45deg); }
.layer__body { padding-bottom: var(--sp-4); }
.layer__body > * + * { margin-top: var(--sp-4); }

.preview-banner {
  margin: 0 0 var(--sp-5); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-focus); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c-focus) 14%, var(--c-bg)); font-size: var(--step--1);
}

.practice {
  border: 1px solid var(--c-border); border-radius: 0.875rem;
  background: var(--c-surface); padding: var(--sp-4);
}
.practice > * + * { margin-top: var(--sp-3); }
.practice__task { margin: 0; font-weight: 650; }
.practice__label { display: block; margin-bottom: var(--sp-1); color: var(--c-text-muted); font-size: var(--step--1); font-weight: 600; }
.practice__code {
  display: block; inline-size: 100%; min-block-size: 6rem; resize: vertical;
  padding: var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-bg); color: var(--c-text);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: var(--step-0); line-height: 1.6; tab-size: 4;
}
.practice__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.practice__actions[hidden], .practice__consent[hidden], .practice__output[hidden], .practice__note[hidden] { display: none; }
.practice__note { margin: var(--sp-2) 0 0; color: var(--c-text-muted); font-size: var(--step--1); }
.practice__consent { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--c-accent); border-radius: var(--radius-sm); background: var(--c-accent-weak); }
.practice__consent p { margin: 0 0 var(--sp-3); }
.practice__consent .btn + .btn { margin-inline-start: var(--sp-2); }
.practice__result { margin: 0; min-block-size: 1.5rem; font-weight: 600; }
.practice__result[data-state="pass"] { color: var(--c-success); }
.practice__result[data-state="fail"] { color: var(--c-text); }
.practice__output {
  margin: 0; padding: var(--sp-3); overflow-x: auto; white-space: pre-wrap;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-bg);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: var(--step--1); line-height: 1.6;
  max-block-size: 16rem;
}
.practice__output[data-error] { border-color: var(--c-focus); }
.practice__more { border-top: 1px solid var(--c-border); padding-top: var(--sp-2); }
.practice__more > summary { cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; font-weight: 600; }
.practice__more pre { margin: var(--sp-2) 0; padding: var(--sp-3); overflow-x: auto; border-radius: var(--radius-sm); background: var(--c-bg); border: 1px solid var(--c-border); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: var(--step--1); }
.practice__var { margin: var(--sp-2) 0; color: var(--c-text-muted); font-size: var(--step--1); }

/* The runner iframe is invisible: it only hosts the sandbox. */
.runner-frame { position: absolute; inline-size: 0; block-size: 0; border: 0; visibility: hidden; }

/* =========================================================================
   Free notes page: search, filter chips, file cards
   ========================================================================= */
.fn-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); margin: var(--sp-4) 0 0; padding: 0; list-style: none; color: var(--c-text-muted); }
.fn-stats strong { color: var(--c-text); }
.fn-search { display: flex; gap: var(--sp-2); max-width: 38rem; margin-top: var(--sp-4); }
.fn-search .field__input { flex: 1; min-width: 0; }

.fn-filters { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.fn-filters[hidden] { display: none; }
.fn-filters__group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.fn-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 2.5rem; padding: 0 var(--sp-4);
  border: 1px solid var(--c-border); border-radius: 999px;
  background: var(--c-bg); color: var(--c-text); font: inherit; font-size: var(--step--1); cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.fn-chip:hover { border-color: var(--c-accent); color: var(--c-accent); }
.fn-chip[aria-pressed="true"] { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-text); }
.fn-chip__n { font-size: 0.75rem; opacity: 0.8; }

.fn-count { margin: 0 0 var(--sp-4); color: var(--c-text-muted); font-size: var(--step--1); }

.fn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: var(--sp-4); margin: 0; padding: 0; list-style: none; }
.fn-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; gap: var(--sp-3) var(--sp-4); align-items: start;
  padding: var(--sp-4); border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-bg); box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.fn-card[hidden] { display: none; }
.fn-card:hover, .fn-card:focus-within { border-color: var(--c-accent); transform: translateY(-2px); }
.fn-card__body { min-width: 0; }
.fn-card__kind { margin: 0; color: var(--c-accent); font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.fn-card__title { margin: var(--sp-1) 0; font-size: var(--step-0); line-height: 1.3; overflow-wrap: anywhere; }
.fn-card__meta { margin: 0; color: var(--c-text-muted); font-size: var(--step--1); }
.fn-card__dl { grid-column: 1 / -1; justify-content: center; gap: var(--sp-2); }

.fn-badge {
  --b: var(--c-accent);
  display: grid; place-items: center; width: 3.25rem; height: 3.75rem;
  border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--b) 40%, var(--c-bg));
  background: color-mix(in srgb, var(--b) 12%, var(--c-bg)); color: var(--b);
  font-size: 0.72rem; font-weight: 750; letter-spacing: 0.03em;
}
.fn-badge--pdf   { --b: #c62828; }
.fn-badge--doc   { --b: #1457d6; }
.fn-badge--sheet { --b: #0f7b4d; }
.fn-badge--slides{ --b: #c2570c; }
.fn-badge--code  { --b: #7c3aed; }
.fn-badge--image { --b: #0e7490; }
.fn-badge--file  { --b: #5a6472; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fn-badge--pdf   { --b: #ff8a80; }
  :root:not([data-theme="light"]) .fn-badge--doc   { --b: #6ea3ff; }
  :root:not([data-theme="light"]) .fn-badge--sheet { --b: #46c08a; }
  :root:not([data-theme="light"]) .fn-badge--slides{ --b: #ffab70; }
  :root:not([data-theme="light"]) .fn-badge--code  { --b: #b69cff; }
  :root:not([data-theme="light"]) .fn-badge--image { --b: #5fd0e6; }
  :root:not([data-theme="light"]) .fn-badge--file  { --b: #9aa6b6; }
}

.fn-empty { padding: var(--sp-6) var(--sp-4); text-align: center; border: 1px dashed var(--c-border); border-radius: var(--radius); }
.fn-empty[hidden] { display: none; }

.fn-cta {
  display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: center; justify-content: space-between;
  margin-top: var(--sp-7); padding: var(--sp-5); border-radius: var(--radius); background: var(--c-accent-weak);
}
.fn-cta h2 { margin: 0 0 var(--sp-1); font-size: var(--step-1); }
.fn-cta p { margin: 0; }

@media (max-width: 30rem) { .fn-search { flex-direction: column; } }
@media (prefers-reduced-motion: reduce) {
  .fn-card, .fn-chip { transition: none; }
  .fn-card:hover, .fn-card:focus-within { transform: none; }
}
