/* ==========================================================================
   English Mastery — design system
   Plain CSS, no build step. Custom properties carry theme (light/dark).
   ========================================================================== */

/* ---- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
img, picture, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

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

/* ---- Theme tokens -------------------------------------------------------
   Light palette lives on bare :root. Dark overrides apply when the OS
   prefers dark AND no explicit choice was made, OR when data-theme="dark"
   is set explicitly (the toggle always wins). */
:root {
  /* Warm paper, not pure white — lower blue-light and a softer top end of
     contrast (~11:1 vs. ~15:1) for readers sitting with a lesson for a
     long stretch. See ARCHITECTURE.md "Design tokens" for why this
     deliberately diverges from the pure-white/#1f2937 brand spec. */
  --bg: #faf8f4;
  --fg: #3a352e;
  --card: #fffdfa;
  --muted-bg: #f1ece3;
  --muted-fg: #6f6a62;
  --border: #e6e1d8;
  --overlay: rgba(58, 48, 35, 0.38);

  --brand-primary: #1e3a5f;
  --brand-primary-fg: #faf8f4;
  --brand-accent: #d96612;
  --brand-accent-fg: #faf8f4;
  /* --brand-accent is for graphics (icons, borders, focus ring — 3:1 floor);
     --brand-accent-strong is for text-bearing button backgrounds (4.5:1
     floor). One value can't clear both bars without dulling the accent. */
  --brand-accent-strong: #b8530c;

  --concept-color: #c25e10;
  --example-color: #0a6f9e;
  --golden-color: #b07d10;
  --important-color: #1e3a5f;
  --warning-color: #c4342c;
  --note-color: #6f6a62;
  --framework-bg: #f1ece3;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --reading-width: 42rem;
  --header-height: 4rem;

  --shadow-sm: 0 1px 2px rgba(60, 50, 35, 0.06), 0 1px 1px rgba(60, 50, 35, 0.04);
  --shadow-md: 0 8px 20px -6px rgba(60, 50, 35, 0.16), 0 2px 6px -2px rgba(60, 50, 35, 0.07);
}

/* Dark tokens are duplicated across the media-query block and
   [data-theme="dark"] on purpose — the explicit toggle must win over the
   OS setting, and CSS custom properties don't otherwise let one override
   the other. Keep the two blocks byte-identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161a20;
    --fg: #c8ccd3;
    --card: #1c2129;
    --muted-bg: #202631;
    --muted-fg: #949aa4;
    --border: #2c333d;
    --overlay: rgba(0, 0, 0, 0.6);

    --brand-primary: #7fb0d8;
    --brand-primary-fg: #161a20;
    --brand-accent: #f0913f;
    --brand-accent-fg: #161a20;
    --brand-accent-strong: #f0913f;

    --concept-color: #f0913f;
    --example-color: #5aabdb;
    --golden-color: #e0a33c;
    --important-color: #7fb0d8;
    --warning-color: #ec8078;
    --note-color: #949aa4;
    --framework-bg: #202631;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.5), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #161a20;
  --fg: #c8ccd3;
  --card: #1c2129;
  --muted-bg: #202631;
  --muted-fg: #949aa4;
  --border: #2c333d;
  --overlay: rgba(0, 0, 0, 0.6);

  --brand-primary: #7fb0d8;
  --brand-primary-fg: #161a20;
  --brand-accent: #f0913f;
  --brand-accent-fg: #161a20;
  --brand-accent-strong: #f0913f;

  --concept-color: #f0913f;
  --example-color: #5aabdb;
  --golden-color: #e0a33c;
  --important-color: #7fb0d8;
  --warning-color: #ec8078;
  --note-color: #949aa4;
  --framework-bg: #202631;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.5), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
}

html { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: color-mix(in oklab, var(--brand-accent) 30%, transparent); }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* ---- Icons --------------------------------------------------------------
   Inline SVGs from scripts/lib/icons.js. `.icon` sizes to the current
   font-size so a single markup shape works inside buttons, badges, and
   headings alike — bump size with a wrapper's font-size, not per-icon CSS. */
.icon { width: 1em; height: 1em; flex-shrink: 0; display: inline-block; vertical-align: -0.15em; }

/* ---- Skip link ----------------------------------------------------------*/
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--brand-primary);
  color: var(--brand-primary-fg);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: top 0.15s ease;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---- Layout helpers ------------------------------------------------------*/
.container { max-width: 80rem; margin-inline: auto; padding-inline: 1rem; }
.container-md { max-width: 56rem; margin-inline: auto; padding-inline: 1rem; }
.container-sm { max-width: 42rem; margin-inline: auto; padding-inline: 1rem; }
@media (min-width: 640px) {
  .container, .container-md, .container-sm { padding-inline: 1.5rem; }
}

.section { padding-block: 3.5rem; }
.section-tight { padding-block: 2.5rem; }
.border-y { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.bg-muted { background: color-mix(in oklab, var(--muted-bg) 60%, transparent); }

/* ---- Reading progress bar -------------------------------------------- */
#reading-progress {
  position: sticky;
  top: var(--header-height);
  z-index: 39;
  height: 3px;
  width: 100%;
  background: transparent;
}
#reading-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-accent);
  transition: width 0.1s linear;
}

/* ---- Header ---------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.site-header-inner {
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  padding-inline: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
@media (min-width: 640px) { .site-header-inner { padding-inline: 1.5rem; } }

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.125rem;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}
.brand-mark { width: 1.35rem; height: 1.35rem; color: var(--brand-accent); }

.main-nav { display: none; align-items: center; gap: 1.5rem; }
@media (min-width: 900px) { .main-nav { display: flex; } }
.main-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-fg);
  text-decoration: none;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--fg); }

.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.mobile-nav-toggle { display: inline-flex; }
@media (min-width: 900px) { .mobile-nav-toggle { display: none; } }
.icon-menu-close { display: none; }
.mobile-nav-toggle.open .icon-menu-open { display: none; }
.mobile-nav-toggle.open .icon-menu-close { display: inline-block; }

.mobile-nav {
  display: none;
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem 1rem;
}
.mobile-nav.open { display: block; }
.mobile-nav ul { display: flex; flex-direction: column; gap: 0.25rem; }
.mobile-nav a {
  display: block;
  padding: 0.5rem;
  border-radius: 0.375rem;
  text-decoration: none;
  color: var(--fg);
  font-weight: 500;
  font-size: 0.9375rem;
}
.mobile-nav a:hover { background: var(--muted-bg); }
@media (min-width: 900px) { .mobile-nav { display: none !important; } }

/* ---- Buttons ------------------------------------------------------------*/
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  text-decoration: none;
  background: none;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--brand-primary); color: var(--brand-primary-fg); box-shadow: var(--shadow-sm); }
.btn-accent { background: var(--brand-accent-strong); color: var(--brand-accent-fg); box-shadow: var(--shadow-sm); }
.btn-accent:hover, .btn-primary:hover { opacity: 1; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-outline { border-color: var(--border); background: var(--card); color: var(--fg); }
.btn-outline:hover { background: var(--muted-bg); opacity: 1; border-color: color-mix(in oklab, var(--brand-accent) 40%, var(--border)); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--muted-bg); opacity: 1; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.375rem;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 1.05rem;
  transition: background-color 0.15s ease;
}
.icon-btn:hover { background: var(--muted-bg); }

/* ---- Badges ---------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
}
.badge-muted { background: var(--muted-bg); border-color: transparent; color: var(--muted-fg); }
.badge-accent { background: var(--brand-accent); border-color: transparent; color: var(--brand-accent-fg); }
.badge-icon .icon { opacity: 0.75; }

/* ---- Cards ------------------------------------------------------------*/
.card {
  display: block;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: color-mix(in oklab, var(--brand-accent) 60%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .card-grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .card-grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

.level-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.level-card-title { font-family: var(--font-serif); font-size: 1.125rem; font-weight: 600; margin-bottom: 0.35rem; }
.level-card-tagline { font-size: 0.875rem; color: var(--muted-fg); }

.lesson-card-top { display: flex; align-items: center; justify-content: space-between; font-size: 0.75rem; color: var(--muted-fg); margin-bottom: 0.5rem; }
.lesson-card-time { display: inline-flex; align-items: center; gap: 0.3rem; }
.lesson-card-title { font-family: var(--font-serif); font-size: 1rem; font-weight: 600; margin-bottom: 0.35rem; }
.lesson-card-desc {
  font-size: 0.875rem;
  color: var(--muted-fg);
  margin-bottom: 0.6rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.module-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem; gap: 1rem; }
.module-card-title { font-weight: 600; }
.module-card-desc { font-size: 0.875rem; color: var(--muted-fg); line-height: 1.6; }

/* ---- Typography ---------------------------------------------------------*/
.h1 { font-family: var(--font-serif); font-weight: 700; font-size: 2rem; line-height: 1.2; letter-spacing: -0.015em; }
.h2 { font-family: var(--font-serif); font-weight: 600; font-size: 1.5rem; letter-spacing: -0.01em; }
.lede { color: var(--muted-fg); font-size: 1.0625rem; max-width: 42rem; line-height: 1.65; }
.muted { color: var(--muted-fg); }
.small { font-size: 0.875rem; }
.xs { font-size: 0.75rem; }

/* ---- Breadcrumbs ----------------------------------------------------- */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--muted-fg); }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { color: var(--fg); }
.breadcrumbs [aria-current="page"] { color: var(--fg); }
.breadcrumbs .sep { color: var(--border); }

/* ---- Lesson prose ------------------------------------------------------ */
.prose { max-width: var(--reading-width); font-size: 1.03rem; }
.prose h2 { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; margin: 2.75rem 0 1rem; scroll-margin-top: 6rem; padding-top: 0.25rem; border-top: 1px solid var(--border); }
.prose h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.prose h3 { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; margin: 2.25rem 0 0.75rem; scroll-margin-top: 6rem; }
.prose p { margin-bottom: 1.1rem; line-height: 1.8; }
.prose ul { margin: 0 0 1.1rem 1.25rem; list-style: disc; }
.prose li { margin-bottom: 0.35rem; line-height: 1.75; }

/* Ordered lists (numbered questions, steps) get a circular index badge
   instead of the default "1." marker — this is what makes a practice/
   assessment section (many small ol's) read as a clean worksheet instead
   of a wall of numbered text. The number itself is rendered server-side
   as real text in a `.li-num` span (see content.js's `list()` renderer
   override) rather than a CSS counter, specifically so a list continuing
   from an earlier one (marked's <ol start="8">, e.g. Lesson 1's Part B
   picking up from Part A's 7 questions) always shows the correct number —
   Chrome does not reliably apply `start` to the implicit list-item counter. */
.prose ol {
  list-style: none;
  margin: 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.prose ol > li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  line-height: 1.65;
}
.li-num {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 9999px;
  background: var(--muted-bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.li-body > p:last-child { margin-bottom: 0; }
.prose blockquote { border-left: 2px solid var(--border); padding-left: 1rem; margin: 1rem 0; color: var(--muted-fg); font-style: italic; }
.prose a { color: var(--brand-primary); text-decoration: underline; text-underline-offset: 2px; }
.prose code { background: var(--muted-bg); border-radius: 0.25rem; padding: 0.1rem 0.35rem; font-family: var(--font-mono); font-size: 0.875em; }
.prose pre { background: var(--muted-bg); border: 1px solid var(--border); border-radius: 0.5rem; padding: 1rem; overflow-x: auto; margin: 1rem 0; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: 0.9375rem; }
.prose-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 0.5rem; margin: 1.25rem 0; }
.prose-table-wrap table { margin: 0; }
.prose th { text-align: left; background: var(--muted-bg); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.prose td { padding: 0.5rem 0.75rem; border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent); vertical-align: top; }
mark.collocation { background: color-mix(in oklab, var(--brand-accent) 22%, transparent); color: inherit; border-radius: 0.2rem; padding: 0 0.15rem; }

/* ---- Callouts (content blocks) ----------------------------------------- */
.callout { border-radius: 0.625rem; padding: 1.15rem 1.3rem; margin: 1.75rem 0; box-shadow: var(--shadow-sm); }
.callout-title { display: flex; align-items: center; gap: 0.55rem; font-weight: 600; font-size: 0.875rem; margin-bottom: 0.6rem; }
.callout-glyph { width: 1.15rem; height: 1.15rem; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-body { font-size: 0.975rem; line-height: 1.7; }

.callout-concept { border-left: 4px solid var(--concept-color); background: color-mix(in oklab, var(--concept-color) 6%, var(--bg)); }
.callout-concept .callout-glyph { color: var(--concept-color); }
.callout-example { border-left: 4px solid var(--example-color); background: color-mix(in oklab, var(--example-color) 6%, var(--bg)); }
.callout-example .callout-glyph { color: var(--example-color); }
.callout-important { border-left: 4px solid var(--important-color); background: color-mix(in oklab, var(--important-color) 6%, var(--bg)); }
.callout-important .callout-glyph { color: var(--important-color); }
.callout-warning { border-left: 4px solid var(--warning-color); background: color-mix(in oklab, var(--warning-color) 6%, var(--bg)); }
.callout-warning .callout-glyph { color: var(--warning-color); }
.callout-note { border: 1px dashed var(--border); background: transparent; box-shadow: none; }
.callout-note .callout-glyph { color: var(--note-color); }
.callout-golden { border-left: 4px solid var(--golden-color); background: color-mix(in oklab, var(--golden-color) 8%, var(--bg)); }
.callout-golden .callout-glyph { color: var(--golden-color); }
.callout-framework { border: 1px solid var(--border); background: var(--framework-bg); box-shadow: none; }

.golden-rule-text { font-family: var(--font-serif); font-size: 1.1875rem; font-weight: 500; font-style: italic; line-height: 1.5; margin: 0; }

.framework-steps { display: flex; flex-direction: column; align-items: stretch; font-size: 0.9rem; }
.framework-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.framework-step-index {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--brand-primary);
  color: var(--brand-primary-fg);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.framework-arrow { display: flex; justify-content: center; color: var(--muted-fg); padding: 0.1rem 0; }
.framework-arrow .icon { width: 0.9rem; height: 0.9rem; }

/* ---- Vocabulary --------------------------------------------------------*/
.vocab-entry { border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; padding: 0.9rem 1.1rem; margin: 0.75rem 0; box-shadow: var(--shadow-sm); }
.vocab-word { font-family: var(--font-serif); font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.2rem; }
.vocab-pos { font-size: 0.75rem; font-style: italic; color: var(--muted-fg); margin-left: 0.5rem; font-weight: 400; font-family: var(--font-sans); }
.vocab-meaning { font-size: 0.9375rem; margin-bottom: 0.2rem; }
.vocab-example { font-size: 0.875rem; font-style: italic; color: var(--muted-fg); margin: 0; }
.vocab-list { display: flex; flex-direction: column; }
.vocab-list-item { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.vocab-list-item:first-child { padding-top: 0; }
.vocab-appears { font-size: 0.75rem; color: var(--muted-fg); margin-top: 0.5rem; }
.vocab-appears a { color: var(--brand-primary); text-decoration: underline; text-underline-offset: 2px; }

/* ---- Learning objectives box --------------------------------------------*/
.objectives-box { border-left: 4px solid var(--brand-accent); background: color-mix(in oklab, var(--brand-accent) 6%, var(--bg)); border-radius: 0.625rem; padding: 1.15rem 1.3rem; margin-bottom: 2.25rem; box-shadow: var(--shadow-sm); }
.objectives-box .callout-glyph { color: var(--brand-accent); }
.objectives-box p.callout-title { margin-bottom: 0.6rem; }
.objectives-box ul { list-style: none; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9375rem; }
.objectives-box li { display: flex; align-items: flex-start; gap: 0.55rem; line-height: 1.5; }
.objectives-box li .icon { color: var(--brand-accent); flex-shrink: 0; margin-top: 0.2em; }

/* ---- Lesson layout ------------------------------------------------------*/
.lesson-layout { display: grid; grid-template-columns: 1fr; gap: 2.5rem; }
@media (min-width: 1024px) { .lesson-layout { grid-template-columns: minmax(0, 1fr) 14rem; } }
.lesson-article { max-width: var(--reading-width); margin-inline: auto; width: 100%; }
@media (min-width: 1024px) { .lesson-article { margin-inline: 0; } }

.lesson-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.lesson-desc { color: var(--muted-fg); margin-top: 0.75rem; max-width: 42rem; }
.lesson-eyebrow { font-size: 0.875rem; color: var(--muted-fg); }

.lesson-toc { position: sticky; top: 6rem; display: none; max-height: calc(100vh - 7rem); overflow-y: auto; }
@media (min-width: 1024px) { .lesson-toc { display: block; } }
.lesson-toc-title { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted-fg); margin-bottom: 0.75rem; }
.lesson-toc ul { display: flex; flex-direction: column; gap: 0.35rem; border-left: 1px solid var(--border); font-size: 0.875rem; }
.lesson-toc a { display: block; padding: 0.1rem 0 0.1rem 0.75rem; margin-left: -1px; border-left: 2px solid transparent; text-decoration: none; color: var(--muted-fg); }
.lesson-toc a:hover { color: var(--fg); }
.lesson-toc a.active { border-left-color: var(--brand-accent); color: var(--fg); }
.lesson-toc .depth-3 { padding-left: 1.5rem; }

.lesson-footer-bar { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 1.5rem; margin-top: 2.5rem; gap: 1rem; flex-wrap: wrap; }

.lesson-nav { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.lesson-nav-link { display: flex; flex-direction: column; gap: 0.2rem; border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; padding: 0.9rem 1rem; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); transition: border-color 0.15s ease, transform 0.15s ease; }
.lesson-nav-link:hover { border-color: color-mix(in oklab, var(--brand-accent) 60%, var(--border)); transform: translateY(-2px); }
.lesson-nav-link.next { text-align: right; align-items: flex-end; }
.lesson-nav-eyebrow { font-size: 0.75rem; color: var(--muted-fg); display: flex; align-items: center; gap: 0.3rem; }
.lesson-nav-title { font-weight: 500; }

/* ---- Journey / course overview ------------------------------------------*/
.journey { display: flex; flex-direction: column; }
.journey-item { display: flex; align-items: center; gap: 1rem; border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; padding: 0.75rem 1rem; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); transition: border-color 0.15s ease, transform 0.15s ease; }
.journey-item:hover { border-color: color-mix(in oklab, var(--brand-accent) 60%, var(--border)); transform: translateX(2px); }
.journey-index { flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 9999px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted-fg); }
.journey-row { display: flex; flex: 1; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.journey-connector { width: 1px; height: 0.5rem; background: var(--border); margin-left: 1.75rem; }

.outline-item { position: relative; padding-left: 2.5rem; }
.outline-marker { position: absolute; left: 0; top: 0; width: 1.75rem; height: 1.75rem; border-radius: 9999px; border: 1px solid var(--border); background: var(--card); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted-fg); }
.outline-connector { position: absolute; left: 13px; top: 2rem; bottom: -1.5rem; width: 1px; background: var(--border); }
.outline-modules { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.outline-module { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem; border: 1px solid var(--border); background: var(--card); border-radius: 0.375rem; padding: 0.6rem 1rem; text-decoration: none; color: inherit; font-size: 0.875rem; }
.outline-module:hover { border-color: color-mix(in oklab, var(--brand-accent) 60%, var(--border)); }
.outline-module .name { font-weight: 500; color: var(--fg); }
.outline-module .desc { color: var(--muted-fg); }

/* ---- Reading progression grid -------------------------------------------*/
.progression-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .progression-grid { grid-template-columns: 1fr 1fr; } }
.progression-item { border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; padding: 1.1rem 1.25rem; }
.progression-label { font-size: 0.875rem; font-weight: 600; color: var(--brand-primary); margin-bottom: 0.25rem; }
.progression-text { font-size: 0.875rem; color: var(--muted-fg); line-height: 1.6; }

/* ---- Stats row ------------------------------------------------------- */
.stats-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card { display: flex; align-items: center; gap: 1rem; border: 1px solid var(--border); background: var(--card); border-radius: 0.75rem; padding: 1.25rem; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 1.5rem; font-weight: 600; }
.stat-label { font-size: 0.875rem; color: var(--muted-fg); }

/* ---- Hero -------------------------------------------------------------*/
.hero { text-align: center; padding-block: 5rem; }
.hero h1 { max-width: 40rem; margin-inline: auto; }
.hero p { margin: 1.5rem auto 0; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 2rem; }

/* ---- Progress bar -------------------------------------------------------*/
.progress-track { position: relative; height: 0.5rem; width: 100%; border-radius: 9999px; background: var(--muted-bg); overflow: hidden; }
.progress-fill { position: absolute; inset: 0; background: var(--brand-accent); border-radius: 9999px; transition: width 0.4s ease; width: 0%; }

/* ---- Filters / forms ---------------------------------------------------*/
.filter-bar { display: flex; flex-direction: column; gap: 0.75rem; }
@media (min-width: 640px) { .filter-bar { flex-direction: row; align-items: center; } }
.text-input, .select-input {
  height: 2.5rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 0 0.75rem;
  font-size: 0.875rem;
}
.text-input { flex: 1; }

/* ---- Empty states -------------------------------------------------------*/
.empty-state { border: 1px dashed var(--border); border-radius: 0.5rem; padding: 2.5rem; text-align: center; color: var(--muted-fg); font-size: 0.9375rem; }

/* ---- Search dialog ------------------------------------------------------*/
.search-trigger { display: none; color: var(--muted-fg); }
.search-trigger kbd { margin-left: 0.4rem; border: 1px solid var(--border); background: var(--muted-bg); border-radius: 0.25rem; padding: 0.05rem 0.35rem; font-size: 0.6875rem; }
@media (min-width: 640px) {
  .search-trigger { display: inline-flex; }
  .search-icon-btn { display: none; }
}
#search-dialog { border: none; padding: 0; background: transparent; max-width: none; max-height: none; width: 100%; height: 100%; }
#search-dialog::backdrop { background: var(--overlay); }
.search-panel { width: min(90vw, 36rem); margin: 6rem auto 0; background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem; overflow: hidden; box-shadow: var(--shadow-md); }
.search-input-row { display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--border); padding: 0 1rem; }
#search-input { flex: 1; border: none; background: transparent; height: 3rem; font-size: 0.9375rem; outline: none; color: var(--fg); }
#search-results { max-height: 22rem; overflow-y: auto; padding: 0.5rem; }
.search-result { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.6rem 0.75rem; border-radius: 0.375rem; text-decoration: none; color: inherit; }
.search-result:hover, .search-result.active { background: var(--muted-bg); }
.search-result-title { font-weight: 500; font-size: 0.875rem; }
.search-result-desc { font-size: 0.75rem; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 2rem; text-align: center; font-size: 0.875rem; color: var(--muted-fg); }

/* ---- Footer ---------------------------------------------------------- */
.site-footer { margin-top: auto; border-top: 1px solid var(--border); padding-block: 2.5rem; }
.site-footer-inner { display: flex; flex-direction: column; align-items: center; gap: 1rem; font-size: 0.875rem; color: var(--muted-fg); text-align: center; }
@media (min-width: 640px) { .site-footer-inner { flex-direction: row; justify-content: space-between; text-align: left; } }
.site-footer nav { display: flex; gap: 1.25rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--fg); }

/* ---- 404 ---------------------------------------------------------------*/
.not-found { max-width: 28rem; margin-inline: auto; text-align: center; padding-block: 6rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }

/* ---- Skills / progress dashboard ----------------------------------------*/
.skill-row { border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; padding: 1rem; margin-bottom: 0.75rem; box-shadow: var(--shadow-sm); }
.skill-row-top { display: flex; align-items: center; justify-content: space-between; font-size: 0.875rem; margin-bottom: 0.4rem; }
.dashboard-card { border: 1px solid var(--border); background: var(--card); border-radius: 0.75rem; padding: 1.5rem; box-shadow: var(--shadow-sm); }
.dashboard-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.9375rem; }
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1.5rem; }
@media (min-width: 640px) { .dashboard-grid { grid-template-columns: repeat(3, 1fr); } }
.dashboard-tile { border: 1px solid var(--border); background: var(--card); border-radius: 0.5rem; padding: 1.25rem; box-shadow: var(--shadow-sm); }
.dashboard-tile-label { font-size: 0.75rem; color: var(--muted-fg); margin-bottom: 0.3rem; }
.dashboard-tile-value { font-family: var(--font-serif); font-size: 1.125rem; font-weight: 600; }
.dashboard-tile-icon { display: flex; align-items: center; gap: 0.85rem; }
.dashboard-tile-icon-glyph { width: 1.5rem; height: 1.5rem; color: var(--brand-accent); flex-shrink: 0; }
