/* Learning Portal — Second Brain's palette, typefaces, and components, with a
   Codecademy-style catalog, syllabus, and learning environment. 16px rem scale. */
:root {
  color-scheme: light;
  --bg: #f2efe9;
  --bg-2: #eae6de;
  --surface: #fbfaf7;
  --field: #f6f4ef;
  --sheet: #ffffff;
  --ink: #1c1a17;
  --ink-2: #4a463f;
  --ink-3: #6f6a61;
  --muted: #7d766b;
  --muted-2: #a49d90;
  --faint: #c4bdb0;
  --line: #ded9cf;
  --line-soft: #e8e3da;
  --wash: #f0ece4;
  --study: #3f6b57;
  --study-soft: #e3ebe5;
  --break: #b0703f;
  --break-soft: #f5e9de;
  --learn: #4f6f86;
  --learn-soft: #e3ebf1;
  --danger: #a1524f;
  --danger-soft: #f6e6e4;
  --good: #3e7a57;
  --good-bg: #e9f3ec;
  --warn: #7a6a35;
  --warn-bg: #f7f1df;
  --code-bg: #f6f4ef;
  --code-ink: #2a2723;
  --tok-keyword: #8a4b2a;
  --tok-string: #3f6b57;
  --tok-number: #8a5d00;
  --tok-comment: #8e877b;
  --tok-function: #4f6f86;
  --tok-tag: #9b4d47;
  --tok-attr: #6b5a8e;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.04), 0 12px 32px rgba(28, 26, 23, 0.05);
  --shadow-lift: 0 2px 4px rgba(28, 26, 23, 0.05), 0 22px 46px rgba(28, 26, 23, 0.11);
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius: 12px;
  --radius-sm: 8px;
  --serif: "Newsreader", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141311;
  --bg-2: #1a1917;
  --surface: #1e1d1a;
  --field: #242320;
  --sheet: #1b1a18;
  --ink: #ece7dd;
  --ink-2: #cbc5b9;
  --ink-3: #aaa397;
  --muted: #918b80;
  --muted-2: #736d63;
  --faint: #5b564e;
  --line: #393732;
  --line-soft: #2c2a26;
  --wash: #262420;
  --study: #72ab8e;
  --study-soft: #24352b;
  --break: #d2965f;
  --break-soft: #3a2c20;
  --learn: #8fb0c6;
  --learn-soft: #23303a;
  --danger: #d08079;
  --danger-soft: #3a2422;
  --good: #85bd91;
  --good-bg: #243329;
  --warn: #d9c88a;
  --warn-bg: #343020;
  --code-bg: #191816;
  --code-ink: #e4ded3;
  --tok-keyword: #e0a271;
  --tok-string: #9ccaa9;
  --tok-number: #e3c77e;
  --tok-comment: #7d776c;
  --tok-function: #a7c3d8;
  --tok-tag: #e39a93;
  --tok-attr: #c2b2e6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 12px 32px rgba(0, 0, 0, 0.22);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.25), 0 22px 46px rgba(0, 0, 0, 0.4);
}

html { font-size: 100%; }
html[data-text="lg"] { font-size: 112.5%; }
html[data-text="xl"] { font-size: 125%; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; scroll-padding-top: 6rem; }
body {
  min-width: 320px; margin: 0;
  background: radial-gradient(ellipse at 86% 4%, color-mix(in srgb, var(--learn) 8%, transparent), transparent 28rem), var(--bg);
  color: var(--ink); font-family: var(--sans); font-size: 1rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased; transition: background-color 240ms ease, color 240ms ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--study); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
code { font-family: var(--mono); font-size: 0.875em; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--study) 70%, transparent); outline-offset: 2px; border-radius: 4px; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 1.05rem; height: 1.05rem; }
.icon-xs { width: 0.9rem; height: 0.9rem; }
.tone-danger { color: var(--danger); }
.tone-warn { color: var(--warn); }
.tone-good { color: var(--good); }
.muted-text { color: var(--muted); font-size: 0.875rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; }

.page-shell { width: min(1240px, calc(100% - 4rem)); margin: 0 auto; }
.skip-link { position: absolute; z-index: 60; top: 10px; left: 10px; padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); transform: translateY(-160%); transition: transform 200ms var(--ease); }
.skip-link:focus { transform: translateY(0); }

/* Top bar -------------------------------------------------------------------- */
.topbar {
  position: sticky; z-index: 10; top: 0; display: flex; min-height: 4.5rem; align-items: center; justify-content: space-between; gap: 1.25rem;
  border-bottom: 1px solid var(--line-soft); background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: inline-flex; flex: none; align-items: center; gap: 0.65rem; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border-radius: 11px; background: var(--study); color: var(--bg); transition: transform 300ms var(--spring); }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.05); }
.brand-mark svg { width: 1.55rem; height: 1.55rem; }
.brand-name { font-family: var(--serif); font-size: 1.4rem; font-weight: 500; letter-spacing: -0.01em; }
.main-nav { display: flex; align-items: center; justify-content: center; gap: 0.2rem; }
.nav-link {
  position: relative; display: inline-flex; min-height: 2.5rem; align-items: center; gap: 0.35rem; padding: 0 0.8rem; border-radius: 999px;
  color: var(--ink-3); font-size: 0.9375rem; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color 200ms ease, color 200ms ease, transform 200ms var(--ease);
}
.nav-link:hover { background: var(--wash); color: var(--ink); }
.nav-link:active { transform: scale(0.96); }
.nav-link.is-active { background: var(--study-soft); color: var(--study); }
.nav-badge { display: inline-grid; min-width: 1.2rem; height: 1.2rem; place-items: center; padding: 0 0.3rem; border-radius: 999px; background: var(--break); color: var(--surface); font-size: 0.75rem; font-weight: 700; line-height: 1; animation: pop-in 420ms var(--spring) both; }
.top-actions { display: flex; flex: none; align-items: center; gap: 0.3rem; }
.icon-button {
  display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink-3); cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, transform 180ms var(--ease);
}
.icon-button:hover { border-color: var(--line); background: var(--surface); color: var(--study); }
.icon-button:active { transform: scale(0.92); }
.icon-button[aria-expanded="true"] { border-color: var(--line); background: var(--surface); color: var(--study); }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }
[data-action="theme"] .icon { transition: transform 500ms var(--spring); }
[data-action="theme"]:hover .icon { transform: rotate(40deg); }

.sync-pill { display: inline-flex; align-items: center; gap: 0.45rem; margin-right: 0.3rem; padding: 0.3rem 0.7rem; border: 1px solid var(--line-soft); border-radius: 999px; color: var(--muted); font-size: 0.8125rem; cursor: default; white-space: nowrap; }
.sync-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--muted-2); }
.sync-pill[data-status="synced"] .sync-dot { background: var(--good); }
.sync-pill[data-status="saving"] .sync-dot, .sync-pill[data-status="loading"] .sync-dot { background: var(--break); animation: pulse 1s ease-in-out infinite; }
.sync-pill[data-status="offline"] .sync-dot { background: var(--warn); }
.sync-pill[data-status="error"] { color: var(--danger); }
.sync-pill[data-status="error"] .sync-dot { background: var(--danger); animation: pulse 1.4s ease-in-out infinite; }

.menu { position: relative; }
.menu-panel { position: absolute; z-index: 30; top: calc(100% + 0.5rem); right: 0; width: 17.5rem; padding: 0.4rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lift); transform-origin: top right; animation: menu-in 200ms var(--ease) both; }
.menu-up .menu-panel { top: auto; right: auto; bottom: calc(100% + 0.6rem); left: 0; transform-origin: bottom left; }
.menu-note { margin: 0; padding: 0.6rem 0.7rem 0.5rem; color: var(--muted); font-size: 0.8125rem; line-height: 1.45; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 0.6rem; padding: 0.6rem 0.7rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); cursor: pointer; font-size: 0.9375rem; text-align: left; text-decoration: none; transition: background-color 150ms ease, color 150ms ease; }
.menu-item:hover { background: var(--wash); color: var(--ink); }
.apps-panel { width: 18.5rem; }
.app-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.6rem; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; transition: background-color 150ms ease; }
.app-item:hover { background: var(--wash); color: var(--ink); }
.app-item img { width: 2.25rem; height: 2.25rem; flex: none; border-radius: 10px; transition: transform 300ms var(--spring); }
.app-item:hover img { transform: rotate(-6deg) scale(1.05); }
.app-item span { display: grid; line-height: 1.3; }
.app-item strong { font-size: 0.9375rem; font-weight: 600; }
.app-item small { color: var(--muted); font-size: 0.8125rem; }
.app-item.is-current { background: var(--study-soft); }
.app-item.is-current small { color: var(--study); }

/* Layout ------------------------------------------------------------------- */
main { min-height: calc(100vh - 5rem); outline: none; }
.view { padding: clamp(2rem, 4.5vw, 3.5rem) 0 5rem; }
.view-narrow { max-width: 44rem; }
.view-loading { display: flex; justify-content: center; gap: 0.5rem; padding: 7rem 0; }
.view-loading span { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--study); animation: bounce 900ms var(--ease) infinite; }
.view-loading span:nth-child(2) { animation-delay: 120ms; }
.view-loading span:nth-child(3) { animation-delay: 240ms; background: var(--break); }
.block { margin-top: 2.5rem; }
.eyebrow { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 1rem; color: var(--study); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.eyebrow-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--break); animation: pulse 2.4s ease-in-out infinite; }
.view h1, .page-head h1 { max-width: 54rem; margin-bottom: 0.9rem; font-family: var(--serif); font-size: clamp(2.4rem, 5.5vw, 4rem); font-weight: 400; letter-spacing: -0.04em; line-height: 1.02; }
.lead { max-width: 46rem; margin: 0; color: var(--ink-3); font-size: 1.125rem; line-height: 1.6; }
.page-head { margin-bottom: 2rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.section-head h2 { margin: 0; font-family: var(--serif); font-size: 1.75rem; font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; }
.section-head p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.5; }
.section-head > :last-child:not(:first-child) { flex: none; }
.link-arrow { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.9375rem; font-weight: 500; text-decoration: none; }
.link-arrow:hover { text-decoration: underline; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: border-color 200ms ease, box-shadow 260ms var(--ease), transform 260ms var(--ease), background-color 240ms ease; }
.empty-state { display: grid; justify-items: start; gap: 0.9rem; padding: 2rem; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--ink-3); }
.empty-state p { margin: 0; max-width: 36rem; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-bottom: 1.25rem; color: var(--muted); font-size: 0.875rem; }
.breadcrumb a { color: var(--ink-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--study); text-decoration: underline; }

/* Progress, rings, chips -------------------------------------------------- */
.progress { position: relative; height: 0.6rem; overflow: hidden; border-radius: 999px; background: var(--line-soft); }
.progress-sm { height: 0.4rem; }
.progress > span { position: absolute; inset: 0 auto 0 0; width: var(--pct); border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--study) 75%, var(--surface)), var(--study)); transition: width 600ms var(--ease); }
.progress[data-tone="good"] > span { background: var(--good); }
.is-entering .progress > span { animation: grow 1000ms var(--ease) both; animation-delay: 250ms; }
.ring { transition: transform 500ms var(--spring); overflow: visible; }
.ring-track { fill: none; stroke: var(--line-soft); }
.ring-value { fill: none; stroke: var(--study); stroke-linecap: round; transition: stroke-dashoffset 700ms var(--ease); }
.ring[data-tone="warn"] .ring-value { stroke: var(--break); }
.ring[data-tone="good"] .ring-value { stroke: var(--good); }
.is-entering .ring-value { animation: ring-in 1100ms var(--ease) both; animation-delay: 200ms; }
.chip { display: inline-flex; min-height: 1.6rem; align-items: center; gap: 0.35rem; padding: 0.1rem 0.6rem; border: 1px solid transparent; border-radius: 999px; background: var(--wash); color: var(--ink-3); font-size: 0.8125rem; font-weight: 500; line-height: 1.3; text-decoration: none; white-space: nowrap; transition: background-color 180ms ease, color 180ms ease, transform 180ms var(--ease); }
a.chip:hover { transform: translateY(-1px); color: var(--study); }
.chip-primer { background: var(--break-soft); color: var(--break); }
.chip-tag { background: var(--learn-soft); color: var(--learn); }
.chip-earned { background: var(--good-bg); color: var(--good); }
.chip-score[data-tone="good"] { background: var(--good-bg); color: var(--good); }
.chip-score[data-tone="ok"] { background: var(--study-soft); color: var(--study); }
.chip-score[data-tone="low"] { background: var(--break-soft); color: var(--break); }
.chip-rating[data-rating="got"] { background: var(--good-bg); color: var(--good); }
.chip-rating[data-rating="review"] { background: var(--break-soft); color: var(--break); }
.chip-level { gap: 0.4rem; background: transparent; border-color: var(--line); }
.level-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 0.7rem; }
.level-bars i { display: block; width: 3px; border-radius: 1px; background: var(--faint); }
.level-bars i:nth-child(1) { height: 40%; } .level-bars i:nth-child(2) { height: 70%; } .level-bars i:nth-child(3) { height: 100%; }
.chip-level[data-level="beginner"] .level-bars i:nth-child(1),
.chip-level[data-level="intermediate"] .level-bars i:nth-child(-n+2),
.chip-level[data-level="advanced"] .level-bars i { background: var(--study); }
.meta-item { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.8125rem; white-space: nowrap; }
.lesson-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.8rem; margin: 0; }
.mini-dot { display: inline-block; width: 0.45rem; height: 0.45rem; flex: none; border-radius: 50%; background: var(--faint); }

.status-mark { display: inline-grid; width: 1.75rem; height: 1.75rem; flex: none; place-items: center; border: 1.6px solid var(--faint); border-radius: 50%; color: var(--bg); }
.status-mark.is-done { border-color: var(--study); background: var(--study); }
.status-mark.is-done .icon { width: 1rem; height: 1rem; stroke-width: 2.6; }
.status-mark.is-progress { border-color: transparent; }

/* Buttons and inputs ------------------------------------------------------- */
.button { position: relative; display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; gap: 0.45rem; padding: 0 1.1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 0.9375rem; font-weight: 500; text-decoration: none; white-space: nowrap; transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, transform 180ms var(--ease), box-shadow 220ms var(--ease), opacity 180ms ease; }
.button:hover { border-color: var(--study); color: var(--study); transform: translateY(-1px); }
.button:active { transform: translateY(0) scale(0.97); }
.button-primary { border-color: var(--study); background: var(--study); color: var(--bg); box-shadow: 0 6px 16px color-mix(in srgb, var(--study) 25%, transparent); }
.button-primary:hover { background: color-mix(in srgb, var(--study) 88%, black); color: var(--bg); box-shadow: 0 10px 22px color-mix(in srgb, var(--study) 30%, transparent); }
[data-theme="dark"] .button-primary:hover { background: color-mix(in srgb, var(--study) 88%, white); }
.button-quiet { background: transparent; }
.button-sm { min-height: 2.1rem; padding: 0 0.85rem; font-size: 0.875rem; }
.button-lg { min-height: 3.1rem; padding: 0 1.5rem; font-size: 1rem; }
.button-block { width: 100%; }
.button[disabled] { cursor: not-allowed; opacity: 0.55; transform: none; }
.field { display: grid; align-content: start; gap: 0.35rem; color: var(--ink-3); font-size: 0.875rem; font-weight: 500; }
.input { width: 100%; min-height: 2.75rem; padding: 0.55rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sheet); color: var(--ink); font-size: 1rem; line-height: 1.4; transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease; }
.input:hover { border-color: color-mix(in srgb, var(--study) 35%, var(--line)); }
.input:focus { border-color: var(--study); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--study) 18%, transparent); }
.input-sm { min-height: 2.1rem; padding: 0.25rem 0.6rem; font-size: 0.875rem; }
textarea.input { min-height: 5.5rem; resize: vertical; }
.search { position: relative; display: block; color: var(--muted); }
.search .icon { position: absolute; top: 50%; left: 0.95rem; transform: translateY(-50%); }
.search .input { padding-left: 2.7rem; border-radius: 999px; }
.search-lg { max-width: 40rem; margin-top: 1.5rem; }
.search-lg .input { min-height: 3.25rem; font-size: 1.0625rem; box-shadow: var(--shadow); }
.segments { display: inline-flex; flex-wrap: wrap; padding: 0.2rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); }
.segment { position: relative; display: inline-flex; min-height: 2.25rem; align-items: center; gap: 0.35rem; padding: 0 0.95rem; border: 0; border-radius: 999px; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 0.9375rem; transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease; }
.segment:hover { color: var(--ink); }
.segment.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segment-count { display: inline-grid; min-width: 1.4rem; place-items: center; padding: 0 0.35rem; border-radius: 999px; background: var(--wash); color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.filter-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.search-empty { margin: 1rem 0 0; color: var(--muted); }

/* Home ---------------------------------------------------------------------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem); align-items: start; gap: 1.5rem; }
.home-main { min-width: 0; }
.home-side { display: grid; gap: 1.25rem; }
.resume-card, .welcome-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2rem; padding: clamp(1.4rem, 3vw, 2.2rem); border-left: 4px solid var(--study); }
.welcome-card { grid-template-columns: minmax(0, 1fr); }
.welcome-card h2, .resume-title { margin: 0 0 0.6rem; font-family: var(--serif); font-size: clamp(1.7rem, 3vw, 2.3rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.12; }
.welcome-card p { color: var(--ink-3); max-width: 40rem; }
.resume-course { margin: 0 0 0.35rem; color: var(--muted); font-size: 0.875rem; font-weight: 500; }
.resume-course a { color: var(--learn); text-decoration: none; }
.resume-exercise { margin: 0 0 1rem; color: var(--ink-3); }
.resume-progress { display: flex; align-items: center; gap: 0.75rem; max-width: 26rem; margin-bottom: 1.25rem; }
.resume-progress .progress { flex: 1; }
.resume-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.resume-art { position: relative; display: grid; place-items: center; }
.resume-art-label { position: absolute; font-family: var(--serif); font-size: 2.3rem; line-height: 1; }
.resume-art-label small { font-size: 1rem; color: var(--muted); }
.week-card, .side-card { padding: 1.25rem 1.3rem; }
.side-card h3 { margin: 0 0 0.6rem; font-family: var(--serif); font-size: 1.3rem; font-weight: 400; line-height: 1.2; }
.side-card .eyebrow { margin-bottom: 0.5rem; }
.side-card .button { margin-top: 0.9rem; }
.week-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.week-head h2 { margin: 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 400; }
.week-head .eyebrow { margin-bottom: 0.3rem; }
.week-target { display: grid; gap: 0.2rem; color: var(--muted); font-size: 0.75rem; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; margin: 1.1rem 0 0.75rem; padding: 0; list-style: none; }
.week-day { display: grid; justify-items: center; gap: 0.3rem; }
.week-dot { display: grid; width: 2rem; height: 2rem; place-items: center; border: 1.6px solid var(--line); border-radius: 50%; color: var(--bg); transition: background-color 300ms ease, border-color 300ms ease; }
.week-day.is-active .week-dot { border-color: var(--study); background: var(--study); animation: check-pop 420ms var(--spring) both; }
.week-day.is-today .week-dot { border-color: var(--break); border-width: 2px; }
.week-day.is-today.is-active .week-dot { border-color: var(--study); }
.week-day.is-future .week-dot { border-style: dashed; }
.week-label { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.week-day.is-today .week-label { color: var(--break); }
.week-status { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 1rem; color: var(--ink-3); font-size: 0.9375rem; }
.streak-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; padding: 0.9rem 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.streak-stat { display: flex; align-items: center; gap: 0.5rem; color: var(--ink-3); font-size: 0.875rem; }
.streak-stat .icon { color: var(--break); width: 1.5rem; height: 1.5rem; }
.streak-stat strong { display: block; color: var(--ink); font-family: var(--serif); font-size: 1.5rem; font-weight: 400; line-height: 1; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0.9rem 0 0; }
.mini-stats div { display: grid; }
.mini-stats dt { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.mini-stats dd { margin: 0; font-family: var(--serif); font-size: 1.5rem; }

/* Course cards --------------------------------------------------------------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.course-grid-lg { grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1.25rem; }
.course-card, .path-card { position: relative; display: flex; flex-direction: column; gap: 0.35rem; padding: 1.2rem 1.25rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: border-color 200ms ease, box-shadow 260ms var(--ease), transform 260ms var(--ease); }
.course-card:hover, .path-card:hover { border-color: color-mix(in srgb, var(--study) 45%, var(--line)); box-shadow: var(--shadow-lift); transform: translateY(-3px); }
.course-card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.course-card .button, .course-card a:not(.course-card-link) { position: relative; z-index: 2; }
.course-card h3, .path-card h3 { margin: 0; font-family: var(--serif); font-size: 1.45rem; font-weight: 400; letter-spacing: -0.015em; line-height: 1.15; }
.course-kind { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; color: var(--learn); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.course-summary { display: -webkit-box; margin: 0.15rem 0 0.4rem; overflow: hidden; color: var(--ink-3); font-size: 0.9375rem; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.course-facts { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: auto 0 0; color: var(--muted); font-size: 0.8125rem; }
.course-facts span + span::before { margin-right: 0.9rem; content: "·"; margin-left: -0.55rem; }
.course-progress { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.75rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.course-progress .progress { flex: 1; }
.course-resume { align-self: flex-start; margin-top: 0.75rem; }
.course-band { position: relative; height: 4.5rem; margin: -1.2rem -1.25rem 0.9rem; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: var(--band, var(--study-soft)); }
.course-band::after { position: absolute; right: -1.5rem; bottom: -2.5rem; width: 7rem; height: 7rem; border: 14px solid color-mix(in srgb, var(--band-ink, var(--study)) 18%, transparent); border-radius: 50%; content: ""; }
.course-band-code { position: absolute; bottom: 0.65rem; left: 1.25rem; color: var(--band-ink, var(--study)); font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.06em; }
[data-track="ORI"], [data-track="DATA"] { --band: var(--study-soft); --band-ink: var(--study); }
[data-track="FND"], [data-track="AI"] { --band: var(--break-soft); --band-ink: var(--break); }
[data-track="MATH"], [data-track="NET"] { --band: var(--learn-soft); --band-ink: var(--learn); }
[data-track="FE"], [data-track="GFX"] { --band: var(--warn-bg); --band-ink: var(--warn); }
[data-track="BE"], [data-track="OPS"] { --band: var(--danger-soft); --band-ink: var(--danger); }

/* Lesson rows ------------------------------------------------------------------ */
.lesson-list { display: grid; gap: 0.5rem; }
.lesson-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.9rem; padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; transition: border-color 180ms ease, transform 220ms var(--ease), box-shadow 220ms var(--ease); }
.lesson-row:hover { border-color: color-mix(in srgb, var(--study) 45%, var(--line)); box-shadow: var(--shadow); transform: translateX(3px); color: inherit; }
.lesson-row-icon, .syllabus-icon { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border-radius: 10px; background: var(--learn-soft); color: var(--learn); }
.lesson-row-body { display: grid; gap: 0.15rem; min-width: 0; }
.lesson-row-kicker, .syllabus-kicker { margin: 0; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.lesson-row-title { color: var(--ink); font-weight: 500; line-height: 1.35; }
.lesson-row-go { color: var(--muted); }

/* Course hero and syllabus -------------------------------------------------------- */
.course-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem); align-items: center; gap: 2rem; margin-bottom: 2.5rem; padding: clamp(1.5rem, 4vw, 2.75rem); border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(135deg, var(--band, var(--study-soft)), var(--surface) 70%); box-shadow: var(--shadow); }
.course-hero.is-path { --band: var(--learn-soft); }
.course-hero h1 { margin: 0.4rem 0 0.4rem; }
.course-subtitle { margin: 0 0 1rem; color: var(--ink-3); font-family: var(--serif); font-size: 1.3rem; font-style: italic; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 0.75rem 1.75rem; margin: 1.6rem 0 0; padding: 0; list-style: none; }
.hero-facts li { display: flex; align-items: center; gap: 0.6rem; color: var(--band-ink, var(--study)); }
.hero-facts span { display: grid; color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }
.hero-facts strong { color: var(--ink); font-size: 1rem; font-weight: 600; }
.course-hero-side { display: grid; gap: 0.9rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hero-progress { display: flex; align-items: center; gap: 1rem; }
.hero-progress p { margin: 0; }
.hero-progress-value { font-family: var(--serif); font-size: 2.2rem; line-height: 1; }
.hero-next { margin: 0; color: var(--ink-3); font-size: 0.875rem; line-height: 1.45; }
.course-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem); align-items: start; gap: 1.5rem; }
.course-side { position: sticky; top: 5.75rem; display: grid; gap: 1rem; }
.syllabus-wide { max-width: 56rem; }
.module { margin-bottom: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: border-color 200ms ease; }
.module[open] { border-color: color-mix(in srgb, var(--study) 30%, var(--line)); }
.module > summary { list-style: none; cursor: pointer; }
.module > summary::-webkit-details-marker { display: none; }
.module-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-radius: var(--radius); }
.module-head:hover .module-title { color: var(--study); }
.module-number { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border: 1.6px solid var(--line); border-radius: 50%; color: var(--ink-2); font-family: var(--serif); font-size: 1.2rem; }
.module.is-done .module-number { border-color: var(--study); background: var(--study); color: var(--bg); }
.module-title-wrap { display: grid; gap: 0.1rem; min-width: 0; }
.module-kicker { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.module-title { font-family: var(--serif); font-size: 1.3rem; line-height: 1.2; transition: color 180ms ease; }
.module-facts { color: var(--muted); font-size: 0.8125rem; }
.module-progress { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.module-chevron { color: var(--muted); transition: transform 250ms var(--ease); }
.module[open] .module-chevron { transform: rotate(180deg); }
.syllabus-list { margin: 0; padding: 0 1.2rem 0.6rem; list-style: none; border-top: 1px solid var(--line-soft); animation: expand 280ms var(--ease) both; }
.syllabus-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.9rem; padding: 0.9rem 0; border-top: 1px solid var(--line-soft); }
.syllabus-item:first-child { border-top: 0; }
.syllabus-quiz .syllabus-icon { background: var(--break-soft); color: var(--break); }
.syllabus-doc .syllabus-icon { background: var(--study-soft); color: var(--study); }
.syllabus-body { display: grid; gap: 0.2rem; min-width: 0; }
.syllabus-title { color: var(--ink); font-weight: 500; line-height: 1.35; text-decoration: none; }
.syllabus-title:hover { color: var(--study); text-decoration: underline; }
.syllabus-item.is-done .syllabus-title { color: var(--ink-3); }
.syllabus-end { display: flex; align-items: center; gap: 0.75rem; }
.readiness-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0; color: var(--warn); font-size: 0.8125rem; }
.readiness-note a { color: var(--warn); font-family: var(--mono); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.mini-list { display: grid; gap: 0.1rem; margin: 0; padding: 0; list-style: none; }
.mini-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; padding: 0.4rem 0; border-top: 1px solid var(--line-soft); font-size: 0.9375rem; }
.mini-list li:first-child { border-top: 0; }
.mini-list li .muted-text { flex-basis: 100%; padding-left: 1.4rem; font-size: 0.8125rem; line-height: 1.35; }
.mini-list li.is-current a { color: var(--ink); font-weight: 600; }

/* Paths -------------------------------------------------------------------------- */
.path-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1.25rem; }
.path-card.is-done { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }

/* Catalog ------------------------------------------------------------------------- */
.catalog-head { padding-bottom: 0.5rem; }

/* Review ----------------------------------------------------------------------- */
.review-tabs { margin-bottom: 1.5rem; }
.deck { max-width: 46rem; }
.deck-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.deck-source { font-size: 0.875rem; text-decoration: none; }
.deck-done { display: grid; justify-items: center; gap: 0.5rem; max-width: 34rem; padding: 2.5rem 2rem; text-align: center; }
.deck-done > .icon { width: 2.5rem; height: 2.5rem; color: var(--break); }
.deck-done h2 { margin: 0; font-family: var(--serif); font-size: 2rem; font-weight: 400; }
.note-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 1rem; }
.note-card { padding: 1.2rem 1.25rem; }
.note-card h3 { margin: 0.2rem 0 0.5rem; font-family: var(--serif); font-size: 1.25rem; font-weight: 400; }
.note-card h3 a { color: var(--ink); text-decoration: none; }
.note-body { margin: 0; color: var(--ink-3); font-size: 0.9375rem; white-space: pre-line; }

/* Progress page ------------------------------------------------------------------ */
.profile-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.name-form { display: flex; align-items: flex-end; gap: 0.6rem; }
.name-form .field { min-width: 14rem; }
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; }
.stat { display: flex; flex-direction: column; gap: 0.25rem; padding: 1.1rem 1.15rem; }
.stat-icon { color: var(--learn); }
.stat-value { margin: 0.4rem 0 0; font-family: var(--serif); font-size: 2rem; line-height: 1.05; }
.stat-label { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.35; }
.block.card { padding: 1.4rem; }
.heatmap-wrap { overflow-x: auto; padding-bottom: 0.25rem; }
.heatmap-months, .heatmap { display: grid; grid-template-columns: repeat(26, 0.95rem); gap: 0.22rem; min-width: max-content; }
.heatmap-months { margin-bottom: 0.3rem; color: var(--muted); font-size: 0.6875rem; }
.heatmap { grid-template-rows: repeat(7, 0.95rem); }
.heat { display: block; width: 0.95rem; height: 0.95rem; border-radius: 3px; background: var(--line-soft); }
.heat[data-level="-1"] { background: transparent; }
.heat[data-level="1"] { background: color-mix(in srgb, var(--study) 30%, var(--line-soft)); }
.heat[data-level="2"] { background: color-mix(in srgb, var(--study) 55%, var(--line-soft)); }
.heat[data-level="3"] { background: color-mix(in srgb, var(--study) 80%, var(--line-soft)); }
.heat[data-level="4"] { background: var(--study); }
.heatmap-legend { display: flex; align-items: center; gap: 0.25rem; margin: 0.75rem 0 0; color: var(--muted); font-size: 0.75rem; }
.heatmap-legend span:first-child { margin-right: 0.3rem; } .heatmap-legend span:last-child { margin-left: 0.3rem; }
.progress-columns { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.5rem; }
.track-progress { display: grid; gap: 0.2rem; margin: 0; padding: 0; list-style: none; }
.track-progress li { display: grid; grid-template-columns: minmax(0, 1fr) 3rem; align-items: center; gap: 0.35rem 0.75rem; padding: 0.55rem 0; border-top: 1px solid var(--line-soft); }
.track-progress li:first-child { border-top: 0; }
.track-progress a { display: flex; grid-column: 1 / -1; justify-content: space-between; gap: 0.5rem; color: var(--ink); text-decoration: none; }
.track-progress a:hover .track-progress-name { color: var(--study); }
.track-progress-count { color: var(--muted); font-size: 0.8125rem; }
.track-progress-pct { color: var(--muted); font-size: 0.8125rem; font-weight: 600; text-align: right; }
.recent-list li .muted-text { padding-left: 1.4rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 0.9rem; }
.badge { display: grid; align-content: start; gap: 0.3rem; padding: 1.1rem; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--ink-3); }
.badge h3 { margin: 0.35rem 0 0; color: var(--ink-2); font-size: 1rem; font-weight: 600; }
.badge p { margin: 0 0 0.5rem; font-size: 0.8125rem; line-height: 1.4; }
.badge-icon { display: grid; width: 2.6rem; height: 2.6rem; place-items: center; border-radius: 50%; background: var(--wash); color: var(--muted-2); }
.badge.is-earned { border-style: solid; border-color: color-mix(in srgb, var(--break) 40%, var(--line)); background: var(--surface); box-shadow: var(--shadow); }
.badge.is-earned .badge-icon { background: var(--break-soft); color: var(--break); }
.badge.is-earned h3 { color: var(--ink); }
.badge .chip { justify-self: start; }
.badge-count { color: var(--muted); font-size: 0.75rem; font-weight: 600; }

/* Resources --------------------------------------------------------------------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 0.9rem; margin-top: 1rem; }
.doc-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.9rem; padding: 1rem 1.1rem; color: inherit; text-decoration: none; }
.doc-card:hover { border-color: color-mix(in srgb, var(--study) 45%, var(--line)); box-shadow: var(--shadow-lift); transform: translateY(-2px); color: inherit; }
.doc-icon { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border-radius: 10px; background: var(--study-soft); color: var(--study); }
.doc-card[data-kind="project"] .doc-icon { background: var(--break-soft); color: var(--break); }
.doc-card[data-kind="glossary"] .doc-icon, .doc-card[data-kind="sources"] .doc-icon { background: var(--learn-soft); color: var(--learn); }
.doc-body { display: grid; gap: 0.2rem; min-width: 0; }
.doc-title { color: var(--ink); font-weight: 600; line-height: 1.3; }
.doc-summary { color: var(--ink-3); font-size: 0.875rem; line-height: 1.45; }
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 17rem); align-items: start; gap: 1.5rem; }
.reader-main { padding: clamp(1.25rem, 3vw, 2.25rem); min-width: 0; }
.reader-main h1 { margin: 0.3rem 0 1.25rem; font-size: clamp(2rem, 4vw, 2.8rem); }
.reader-side { position: sticky; top: 5.75rem; display: grid; gap: 1rem; }
.reader-toc { max-height: calc(100vh - 8rem); overflow-y: auto; }

/* Prose (lessons and documents) ---------------------------------------------------- */
.prose { color: var(--ink-2); font-size: 1.0625rem; line-height: 1.72; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2, .prose h3, .prose h4 { color: var(--ink); scroll-margin-top: 6rem; }
.prose h2 { margin: 2.2rem 0 0.8rem; font-family: var(--serif); font-size: 1.75rem; font-weight: 400; letter-spacing: -0.015em; line-height: 1.2; }
.prose h3 { margin: 1.8rem 0 0.6rem; font-size: 1.2rem; font-weight: 600; line-height: 1.3; }
.prose h4 { margin: 1.4rem 0 0.4rem; font-size: 1.05rem; font-weight: 600; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--line); }
.prose :not(pre) > code { padding: 0.1em 0.38em; border: 1px solid var(--line-soft); border-radius: 5px; background: var(--code-bg); color: var(--code-ink); font-size: 0.86em; }
.prose blockquote { margin: 1.25rem 0; padding: 0.2rem 0 0.2rem 1.1rem; border-left: 3px solid var(--line); color: var(--ink-3); }
.prose img { max-width: 100%; }
.table-wrap { margin: 1.25rem 0; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sheet); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.5; }
.prose th, .prose td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.prose thead th { background: var(--field); color: var(--ink-2); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; }
.prose tbody tr:last-child td { border-bottom: 0; }
.dead-link { border-bottom: 1px dotted var(--faint); }
.math-display { display: block; margin: 1.25rem 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.katex { font-size: 1.08em; }
.callout { margin: 1.25rem 0; padding: 0.9rem 1.1rem; border: 1px solid transparent; border-left-width: 4px; border-radius: var(--radius-sm); background: var(--learn-soft); color: var(--ink-2); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { margin: 0 0 0.35rem !important; color: var(--learn); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.callout[data-kind="note"] { border-left-color: var(--learn); }
.callout[data-kind="tip"] { border-left-color: var(--study); background: var(--study-soft); }
.callout[data-kind="tip"] .callout-title { color: var(--study); }
.callout[data-kind="important"] { border-left-color: var(--break); background: var(--break-soft); }
.callout[data-kind="important"] .callout-title { color: var(--break); }
.callout[data-kind="warning"] { border-left-color: var(--warn); background: var(--warn-bg); }
.callout[data-kind="warning"] .callout-title { color: var(--warn); }
.callout[data-kind="caution"] { border-left-color: var(--danger); background: var(--danger-soft); }
.callout[data-kind="caution"] .callout-title { color: var(--danger); }
details.hint { margin: 1rem 0; padding: 0.15rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
details.hint > summary { margin: 0 -1rem; padding: 0.7rem 1rem; color: var(--ink-2); font-weight: 500; list-style: none; cursor: pointer; }
details.hint > summary::-webkit-details-marker { display: none; }
details.hint > summary::before { display: inline-block; margin-right: 0.5rem; color: var(--muted); content: "▸"; transition: transform 200ms var(--ease); }
details.hint[open] > summary::before { transform: rotate(90deg); }
details.hint[open] { padding-bottom: 0.6rem; }

.code-block { margin: 1.25rem 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--code-bg); }
.code-block figcaption { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.3rem 0.5rem 0.3rem 0.9rem; border-bottom: 1px solid var(--line-soft); background: color-mix(in srgb, var(--code-bg) 70%, var(--line-soft)); }
.code-lang { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.code-tools { display: inline-flex; gap: 0.25rem; }
.code-tool { padding: 0.25rem 0.6rem; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 0.8125rem; font-weight: 500; transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.code-tool:hover { border-color: var(--line); background: var(--surface); color: var(--study); }
.code-open { color: var(--study); }
.code-block.is-runnable { border-color: color-mix(in srgb, var(--study) 35%, var(--line)); }
.code-block pre { margin: 0; padding: 0.95rem 1rem; overflow-x: auto; color: var(--code-ink); font-family: var(--mono); font-size: 0.875rem; line-height: 1.6; tab-size: 2; }
.code-block code { font-size: inherit; }
.diagram { margin: 1.5rem 0; padding: 1rem; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sheet); text-align: center; }
.diagram-source { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 0.8125rem; text-align: left; white-space: pre-wrap; }
.diagram.is-rendered svg { max-width: 100%; height: auto; }
.plain-fallback { white-space: pre-wrap; font-family: var(--mono); font-size: 0.875rem; }

/* highlight.js tokens using the palette */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-literal, .hljs-type { color: var(--tok-keyword); }
.hljs-string, .hljs-regexp, .hljs-symbol, .hljs-template-variable, .hljs-addition { color: var(--tok-string); }
.hljs-number, .hljs-meta { color: var(--tok-number); }
.hljs-comment, .hljs-quote { color: var(--tok-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title, .hljs-section { color: var(--tok-function); }
.hljs-tag, .hljs-name, .hljs-selector-id, .hljs-selector-class, .hljs-deletion { color: var(--tok-tag); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-property, .hljs-params { color: var(--tok-attr); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 600; }

/* Quiz and flashcards -------------------------------------------------------------- */
.quiz { margin: 1.5rem 0; padding: 1.2rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.quiz-label { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.6rem; color: var(--break); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.quiz-question { margin-bottom: 0.9rem; color: var(--ink); font-size: 1.0625rem; font-weight: 500; line-height: 1.5; }
.quiz-question p { margin: 0; }
.quiz-options { display: grid; gap: 0.5rem; }
.quiz-option { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.8rem; width: 100%; padding: 0.7rem 0.85rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--sheet); color: var(--ink-2); cursor: pointer; font-size: 0.9875rem; line-height: 1.45; text-align: left; transition: border-color 160ms ease, background-color 160ms ease, transform 160ms var(--ease); }
.quiz-option:hover:not(:disabled) { border-color: color-mix(in srgb, var(--study) 50%, var(--line)); transform: translateX(2px); }
.quiz-option:disabled { cursor: default; }
.quiz-letter { display: grid; width: 1.8rem; height: 1.8rem; place-items: center; border: 1.5px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 0.8125rem; font-weight: 600; transition: all 160ms ease; }
.quiz-text p { margin: 0; }
.quiz-option.is-selected { border-color: var(--study); background: var(--study-soft); }
.quiz-option.is-selected .quiz-letter { border-color: var(--study); background: var(--study); color: var(--bg); }
.quiz-option.is-right { border-color: var(--good); background: var(--good-bg); }
.quiz-option.is-right .quiz-letter { border-color: var(--good); background: var(--good); color: var(--bg); }
.quiz-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); animation: shake 380ms var(--ease); }
.quiz-option.is-wrong .quiz-letter { border-color: var(--danger); background: var(--danger); color: var(--bg); }
.quiz-feedback { position: relative; margin-top: 0.85rem; padding: 0.75rem 0.95rem; border-radius: var(--radius-sm); font-size: 0.9375rem; line-height: 1.55; animation: expand 260ms var(--ease) both; }
.quiz-feedback[data-tone="good"] { background: var(--good-bg); color: var(--ink-2); }
.quiz-feedback[data-tone="good"] strong { color: var(--good); }
.quiz-feedback[data-tone="bad"] { background: var(--danger-soft); color: var(--ink-2); }
.quiz-feedback[data-tone="bad"] strong { color: var(--danger); }
.quiz-feedback p { display: inline; margin: 0; }
.quiz-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.9rem; }
.quiz-done { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--good); font-size: 0.875rem; font-weight: 500; }
.quiz.is-correct { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.quiz.flash { animation: flash 1200ms var(--ease); }
.flashcard { position: relative; margin: 1rem 0; padding: 1.25rem 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: border-color 200ms ease; }
.flashcard-lg { min-height: 16rem; display: flex; flex-direction: column; padding: 1.75rem; }
.flashcard-lg .flashcard-front { font-size: 1.25rem; }
.flashcard-lg .flashcard-actions { margin-top: auto; }
.flashcard-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.flashcard-count { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.flashcard-front { color: var(--ink); font-family: var(--serif); font-size: 1.2rem; line-height: 1.4; }
.flashcard-back { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); color: var(--ink-2); font-size: 1rem; animation: flip-in 380ms var(--ease) both; }
.flashcard-back > :last-child { margin-bottom: 0; }
.flashcard-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.flashcard-rate { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; }
.flashcard[data-rating="got"] { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.flashcard[data-rating="review"] { border-color: color-mix(in srgb, var(--break) 45%, var(--line)); }

/* Learning environment (lesson.html) ----------------------------------------------- */
body.le-page { height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg); }
.le-root { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; }
.le-root > .le-header, .le-root > .le-tabs, .le-root > .le-footer { flex: none; }
.le-root > .le-main { flex: 1 1 auto; }
.le-header { position: relative; z-index: 15; display: flex; align-items: center; gap: 0.75rem; min-height: 3.6rem; padding: 0 0.9rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.le-menu-button { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.4rem; padding: 0 0.85rem 0 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--sheet); color: var(--ink-2); cursor: pointer; font-weight: 500; transition: border-color 160ms ease, color 160ms ease; }
.le-menu-button:hover, .le-menu-button[aria-expanded="true"] { border-color: var(--study); color: var(--study); }
.le-brand .brand-mark { width: 2.1rem; height: 2.1rem; border-radius: 9px; }
.le-brand .brand-mark svg { width: 1.35rem; height: 1.35rem; }
.le-crumbs { display: flex; flex: 1 1 auto; align-items: center; gap: 0.35rem; min-width: 0; color: var(--muted); font-size: 0.9375rem; }
.le-crumbs a { flex: none; color: var(--ink-3); font-weight: 500; text-decoration: none; }
.le-crumbs a:hover { color: var(--study); }
.le-crumb-lesson { overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.le-head-progress { display: flex; flex: 0 1 11rem; align-items: center; gap: 0.5rem; }
.le-head-progress .progress { flex: 1; }
.le-head-pct { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.le-actions { display: flex; flex: none; align-items: center; gap: 0.2rem; }
.le-tabs { display: none; }
.le-main { position: relative; display: grid; min-height: 0; overflow: hidden; }
.le-main[data-layout="split"] { grid-template-columns: minmax(22rem, 42%) minmax(0, 1fr); }
.le-main[data-layout="article"] { grid-template-columns: minmax(0, 1fr); }
.le-main[data-layout="stage"] { grid-template-columns: minmax(0, 1fr); }
.le-narrative { min-height: 0; overflow-y: auto; outline: none; background: var(--bg); scroll-behavior: smooth; }
.le-main[data-layout="split"] .le-narrative { border-right: 1px solid var(--line); background: var(--surface); }
.le-narrative-inner { max-width: 46rem; margin: 0 auto; padding: 2rem clamp(1.25rem, 3vw, 2.5rem) 4rem; }
.le-main[data-layout="article"] .le-narrative-inner { max-width: 50rem; padding-top: 2.75rem; }
.le-main[data-layout="split"] .prose { font-size: 1rem; }
.le-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0 0 0.6rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.le-kicker-tag { padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--study-soft); color: var(--study); }
.le-kicker-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.le-title { margin: 0 0 1.4rem; font-family: var(--serif); font-size: clamp(1.9rem, 3.2vw, 2.6rem); font-weight: 400; letter-spacing: -0.025em; line-height: 1.1; }
.le-title-number { color: var(--muted-2); }
.le-up-next { margin: 2.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 0.9375rem; }
.le-up-next a { font-weight: 500; }
.lesson-card { display: grid; gap: 1rem; margin: 0 0 1.75rem; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
.lesson-card-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; }
.lesson-card-label { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.lesson-card-prereqs ul { display: grid; gap: 0.25rem; margin: 0 0 0.4rem; padding: 0; list-style: none; }
.lesson-card-prereqs li { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.9375rem; }
.lesson-card-prereqs li a { font-family: var(--mono); font-size: 0.8125rem; }
.lesson-card-prereqs li span:last-child { color: var(--ink-3); }
.lesson-card-prereqs li.is-done .icon { color: var(--good); }
.lesson-card-prereqs p { margin: 0; font-size: 0.875rem; }
.lesson-card-done { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: var(--good); font-size: 0.9375rem; }

.instructions { margin: 2rem 0 0; padding: 1.15rem 1.2rem; border: 1px solid color-mix(in srgb, var(--study) 35%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--study-soft) 55%, var(--sheet)); transition: border-color 300ms ease, background-color 300ms ease; }
.instructions.is-complete { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); background: var(--good-bg); }
.instructions.is-nudged { animation: nudge 520ms var(--ease); }
.instructions-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.instructions-head h2 { margin: 0; color: var(--ink); font-size: 0.875rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.instructions-count { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.task-list { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.task { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 0.7rem; padding: 0.4rem 0; }
.task-check { display: grid; width: 1.6rem; height: 1.6rem; place-items: center; margin-top: 0.05rem; border: 1.6px solid var(--faint); border-radius: 50%; background: var(--sheet); color: var(--muted); font-size: 0.75rem; font-weight: 700; transition: background-color 250ms ease, border-color 250ms ease; }
.task.is-done .task-check { border-color: var(--good); background: var(--good); color: var(--bg); animation: check-pop 380ms var(--spring); }
.task-label { display: flex; align-items: flex-start; gap: 0.55rem; color: var(--ink-2); font-size: 0.9875rem; line-height: 1.5; }
.task-label input { width: 1.1rem; height: 1.1rem; margin-top: 0.22rem; flex: none; accent-color: var(--good); cursor: pointer; }
.task-link { padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.task-link:hover { color: var(--study); text-decoration: underline; }
.task.is-done .task-label { color: var(--ink-3); }
.instructions-done { display: flex; align-items: center; gap: 0.4rem; margin: 0.6rem 0 0; color: var(--good); font-weight: 500; }
.instructions-note { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.875rem; }

/* Workspace */
.le-workspace { display: grid; grid-template-rows: minmax(0, 1.25fr) minmax(9rem, 1fr); min-height: 0; background: var(--bg-2); }
.le-workspace.is-pinged .ws-editor { animation: ping 700ms var(--ease); }
.ws-editor { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; border-bottom: 1px solid var(--line); background: var(--code-bg); }
.ws-tabs { display: flex; gap: 0.1rem; overflow-x: auto; padding: 0.4rem 0.5rem 0; border-bottom: 1px solid var(--line); background: var(--bg-2); scrollbar-width: thin; }
.ws-tab { position: relative; display: inline-flex; flex: none; align-items: center; gap: 0.4rem; padding: 0.45rem 0.9rem; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); cursor: pointer; font-family: var(--mono); font-size: 0.8125rem; }
.ws-tab:hover { color: var(--ink); }
.ws-tab.is-active { border-color: var(--line); background: var(--code-bg); color: var(--ink); margin-bottom: -1px; }
.ws-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--break); }
.ws-code { position: relative; min-height: 0; overflow: hidden; }
.ws-code .CodeMirror { height: 100%; background: var(--code-bg); color: var(--code-ink); font-family: var(--mono); font-size: 0.875rem; line-height: 1.6; }
.ws-textarea { width: 100%; height: 100%; padding: 0.9rem 1rem; border: 0; outline: none; resize: none; background: var(--code-bg); color: var(--code-ink); font-family: var(--mono); font-size: 0.875rem; line-height: 1.6; tab-size: 2; white-space: pre; }
.ws-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.75rem; border-top: 1px solid var(--line-soft); background: var(--surface); }
.button-run { min-height: 2.3rem; padding: 0 1.1rem 0 0.9rem; border-color: var(--study); background: var(--study); color: var(--bg); box-shadow: 0 4px 12px color-mix(in srgb, var(--study) 25%, transparent); }
.button-run:hover { background: color-mix(in srgb, var(--study) 88%, black); color: var(--bg); }
[data-theme="dark"] .button-run:hover { background: color-mix(in srgb, var(--study) 88%, white); }
.is-running .button-run { opacity: 0.75; }
.is-running .button-run .icon { animation: pulse 900ms ease-in-out infinite; }
.ws-hint { color: var(--muted); font-size: 0.75rem; }
.ws-spacer { flex: 1; }
.ws-tool { padding: 0.3rem 0.65rem; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 0.8125rem; font-weight: 500; }
.ws-tool:hover { border-color: var(--line); background: var(--sheet); color: var(--study); }
.ws-output { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: var(--sheet); }
.ws-output-head { display: flex; align-items: center; justify-content: space-between; padding: 0.35rem 0.5rem 0.35rem 0.9rem; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.ws-output-title { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.ws-output-body { display: flex; min-height: 0; flex-direction: column; overflow: auto; }
.ws-empty { margin: auto; padding: 1.5rem; color: var(--muted); font-size: 0.9375rem; text-align: center; }
.ws-log { flex: 1; overflow: auto; padding: 0.6rem 0; font-family: var(--mono); font-size: 0.84rem; }
.ws-line { margin: 0; padding: 0.2rem 0.95rem; border-bottom: 1px solid var(--line-soft); color: var(--code-ink); white-space: pre-wrap; word-break: break-word; font-family: inherit; animation: line-in 200ms var(--ease) both; }
.ws-line.is-error { background: var(--danger-soft); color: var(--danger); }
.ws-line.is-warn { background: var(--warn-bg); color: var(--warn); }
.ws-line.is-meta { border-bottom: 0; color: var(--muted); font-family: var(--sans); font-size: 0.8125rem; font-style: italic; }
.ws-browser { display: flex; flex: 1; min-height: 12rem; flex-direction: column; }
.ws-browser-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line-soft); background: var(--field); }
.ws-browser-dots { display: inline-flex; gap: 0.3rem; }
.ws-browser-dots i { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--faint); }
.ws-browser-url { flex: 1; padding: 0.15rem 0.7rem; border-radius: 999px; background: var(--sheet); color: var(--muted); font-family: var(--mono); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-frame { flex: 1; width: 100%; min-height: 10rem; border: 0; background: #fff; }
.ws-mini-console { max-height: 8rem; overflow: auto; border-top: 1px solid var(--line); }

/* CodeMirror theme from tokens */
.CodeMirror-gutters { border-right: 1px solid var(--line-soft); background: var(--code-bg); }
.CodeMirror-linenumber { color: var(--muted-2); }
.CodeMirror-cursor { border-left-color: var(--ink); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: color-mix(in srgb, var(--study) 22%, transparent) !important; }
.CodeMirror-activeline-background { background: var(--wash); }
.CodeMirror-matchingbracket { color: var(--study) !important; text-decoration: underline; }
.cm-s-default .cm-keyword { color: var(--tok-keyword); }
.cm-s-default .cm-string, .cm-s-default .cm-string-2 { color: var(--tok-string); }
.cm-s-default .cm-number, .cm-s-default .cm-atom { color: var(--tok-number); }
.cm-s-default .cm-comment { color: var(--tok-comment); font-style: italic; }
.cm-s-default .cm-def, .cm-s-default .cm-variable-2 { color: var(--tok-function); }
.cm-s-default .cm-variable, .cm-s-default .cm-property { color: var(--code-ink); }
.cm-s-default .cm-tag { color: var(--tok-tag); }
.cm-s-default .cm-attribute, .cm-s-default .cm-qualifier { color: var(--tok-attr); }
.cm-s-default .cm-operator, .cm-s-default .cm-bracket { color: var(--ink-3); }

/* Stage (quiz, completion) */
.le-stage { min-height: 0; overflow-y: auto; }
.stage-inner { max-width: 44rem; margin: 0 auto; padding: 3rem clamp(1.25rem, 4vw, 2rem) 4rem; }
.stage-inner h1 { margin: 0.5rem 0 0.6rem; font-family: var(--serif); font-size: clamp(2.1rem, 4vw, 3rem); font-weight: 400; letter-spacing: -0.03em; line-height: 1.05; }
.stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.75rem; }
.quiz-steps { display: flex; gap: 0.35rem; margin: 1rem 0 0.6rem; }
.quiz-step { flex: 1; height: 0.4rem; border-radius: 999px; background: var(--line-soft); transition: background-color 300ms ease; }
.quiz-step.is-current { background: var(--study); }
.quiz-step.is-right { background: var(--good); }
.quiz-step.is-wrong { background: var(--danger); }
.quiz-position { margin: 0; color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.quiz-stage .quiz { padding: 1.5rem; }
.quiz-stage .quiz-question { font-family: var(--serif); font-size: 1.5rem; font-weight: 400; line-height: 1.3; }
.result-stage, .complete-stage { text-align: center; }
.result-stage .le-kicker, .complete-stage .le-kicker { justify-content: center; }
.result-stage .lead, .complete-stage .lead { margin: 0 auto; }
.result-stage .stage-actions, .complete-stage .stage-actions { justify-content: center; }
.result-ring { position: relative; display: inline-grid; place-items: center; margin: 0.5rem 0 0.75rem; }
.result-value { position: absolute; font-family: var(--serif); font-size: 2.6rem; line-height: 1; }
.result-value small { color: var(--muted); font-size: 1.1rem; }
.result-list { display: grid; gap: 0.4rem; margin: 1.75rem 0 0; padding: 0; list-style: none; text-align: left; }
.result-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 0.7rem; padding: 0.65rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.9375rem; }
.result-mark { display: grid; width: 1.4rem; height: 1.4rem; place-items: center; border-radius: 50%; color: var(--bg); }
.result-list .is-right .result-mark { background: var(--good); }
.result-list .is-wrong .result-mark { background: var(--danger); }
.complete-badge { display: inline-grid; width: 7rem; height: 7rem; place-items: center; margin: 0 auto 1rem; border-radius: 50%; }
.complete-badge.is-done { background: var(--study); color: var(--bg); box-shadow: 0 18px 40px color-mix(in srgb, var(--study) 35%, transparent); animation: badge-in 700ms var(--spring) both; }
.complete-badge.is-done .icon { width: 3.4rem; height: 3.4rem; stroke-width: 2.4; }
.complete-banner { display: inline-flex; align-items: center; gap: 0.5rem; margin: 1.25rem 0 0; padding: 0.55rem 1rem; border-radius: 999px; background: var(--break-soft); color: var(--break); font-weight: 600; }
.complete-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin: 1.75rem 0 0; }
.complete-stats div { padding: 0.9rem 0.6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.complete-stats dt { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.complete-stats dd { margin: 0.2rem 0 0; font-family: var(--serif); font-size: 1.6rem; }
.complete-remaining { margin: 1.5rem auto 0; padding: 1rem 1.2rem; max-width: 30rem; border: 1px dashed var(--line); border-radius: var(--radius); text-align: left; }
.complete-remaining p { margin: 0 0 0.4rem; color: var(--ink-3); font-weight: 500; }
.complete-remaining ul { margin: 0; padding-left: 1.2rem; }

/* Footer */
.le-footer { position: relative; z-index: 14; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.75rem; min-height: 4rem; padding: 0.5rem 0.9rem; border-top: 1px solid var(--line); background: var(--surface); }
.le-foot-center { display: flex; align-items: center; gap: 0.75rem; }
.le-count { min-width: 3.5rem; color: var(--ink-3); font-family: var(--mono); font-size: 0.875rem; font-weight: 500; text-align: center; }
.le-foot-right { justify-self: end; color: var(--muted); font-size: 0.875rem; }
.le-foot-right span { display: inline-flex; align-items: center; gap: 0.3rem; }
[data-le="next"].is-locked { border-color: var(--line); background: var(--wash); color: var(--muted); box-shadow: none; }
[data-le="next"].is-locked:hover { color: var(--ink-3); transform: none; }
[data-le="next"].is-ready { animation: ready 1.8s var(--ease) 1; }

/* Drawer and notes panels */
.le-scrim { position: fixed; z-index: 24; inset: 0; background: color-mix(in srgb, var(--ink) 28%, transparent); animation: fade-in 200ms ease both; }
.le-drawer, .le-notes { position: fixed; z-index: 25; top: 0; bottom: 0; display: flex; width: min(26rem, 92vw); flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lift); }
.le-drawer { left: 0; border-right: 1px solid var(--line); animation: slide-left 280ms var(--ease) both; }
.le-notes { right: 0; gap: 0.75rem; padding-bottom: 1rem; border-left: 1px solid var(--line); animation: slide-right 280ms var(--ease) both; }
.le-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; padding: 1.1rem 1.1rem 0.75rem; }
.le-panel-head .eyebrow { margin-bottom: 0.25rem; }
.le-panel-head h2 { margin: 0; font-family: var(--serif); font-size: 1.5rem; font-weight: 400; line-height: 1.15; }
.le-panel-head h2 a { color: var(--ink); text-decoration: none; }
.le-notes-input { flex: 1; margin: 0 1.1rem; width: auto; min-height: 12rem; resize: none; font-size: 0.9875rem; line-height: 1.6; }
.le-notes-status { margin: 0 1.1rem; min-height: 1.2rem; }
.drawer-progress { display: flex; align-items: center; gap: 0.6rem; padding: 0 1.1rem 0.9rem; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.drawer-progress .progress { flex: 1; }
.drawer-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0.6rem 2rem; }
.drawer-module > summary { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.65rem 0.5rem; border-radius: var(--radius-sm); color: var(--ink); font-weight: 600; list-style: none; cursor: pointer; }
.drawer-module > summary::-webkit-details-marker { display: none; }
.drawer-module > summary:hover { background: var(--wash); }
.drawer-module-count { color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.drawer-lessons, .drawer-exercises { margin: 0; padding: 0; list-style: none; }
.drawer-lesson > a, .drawer-exercises a { display: grid; grid-template-columns: 1.4rem minmax(0, 1fr); align-items: start; gap: 0.5rem; padding: 0.45rem 0.5rem; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 0.9rem; line-height: 1.4; text-decoration: none; }
.drawer-lesson > a:hover, .drawer-exercises a:hover { background: var(--wash); color: var(--ink); }
.drawer-lesson.is-current > a { background: var(--study-soft); color: var(--study); font-weight: 600; }
.drawer-lesson.is-done > a { color: var(--ink-3); }
.drawer-mark { display: grid; width: 1.25rem; height: 1.25rem; place-items: center; margin-top: 0.05rem; border-radius: 50%; color: var(--muted); font-size: 0.6875rem; font-weight: 700; }
.drawer-lesson.is-done > a .drawer-mark, .drawer-exercises .is-done .drawer-mark { background: var(--study); color: var(--bg); }
.drawer-exercises { margin: 0.2rem 0 0.4rem 1.2rem; padding-left: 0.6rem; border-left: 2px solid var(--line-soft); }
.drawer-exercises a { font-size: 0.85rem; }
.drawer-exercises .is-current a { background: var(--wash); color: var(--ink); font-weight: 600; }
.drawer-exercises .drawer-mark { border: 1.4px solid var(--line); }
.drawer-exercises .is-done .drawer-mark { border-color: var(--study); }

/* Toasts --------------------------------------------------------------------------- */
.toast-region { position: fixed; z-index: 50; right: 1.25rem; bottom: 1.25rem; display: grid; justify-items: end; gap: 0.6rem; pointer-events: none; }
.le-page .toast-region { bottom: 5rem; }
.toast { position: relative; display: flex; max-width: min(26rem, calc(100vw - 2.5rem)); align-items: center; gap: 0.9rem; overflow: hidden; padding: 0.8rem 1rem; border-radius: var(--radius); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lift); font-size: 0.9375rem; pointer-events: auto; animation: toast-in 360ms var(--spring) both; }
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-leaving { animation: toast-out 260ms var(--ease) forwards; }
.toast-action { flex: none; padding: 0.3rem 0.7rem; border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent); border-radius: 999px; background: transparent; color: inherit; cursor: pointer; font-weight: 600; }
.toast-timer { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: color-mix(in srgb, var(--bg) 40%, transparent); transform-origin: left; animation: timer var(--toast-duration) linear forwards; }

/* Auth ----------------------------------------------------------------------------- */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 1.5rem; }
.auth-card { width: min(26rem, 100%); padding: 2.25rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lift); animation: rise-in 500ms var(--ease) both; }
.auth-card h1 { margin: 2rem 0 0.4rem; font-family: var(--serif); font-size: 2.8rem; font-weight: 400; letter-spacing: -0.035em; line-height: 1; }
.auth-card .lead { margin-bottom: 1.5rem; font-size: 1rem; }
.auth-form { display: grid; gap: 1rem; }
.auth-form .button { margin-top: 0.4rem; }
.auth-message { margin: 1rem 0 0; color: var(--ink-3); font-size: 0.9375rem; }
.auth-message[data-kind="error"] { color: var(--danger); }

/* Motion --------------------------------------------------------------------------- */
.burst { position: absolute; inset: 50%; pointer-events: none; }
.burst i { position: absolute; width: 5px; height: 5px; margin: -2.5px; border-radius: 50%; background: var(--study); animation: burst 620ms var(--ease) forwards; }
.burst i:nth-child(even) { background: var(--break); }
.quiz-feedback, .task, .flashcard-actions { position: relative; }
.confetti { position: fixed; z-index: 70; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -1rem; left: var(--x); width: 0.55rem; height: 0.85rem; border-radius: 2px; animation: confetti var(--d) var(--ease) var(--delay) forwards; }
.flash { animation: flash 1200ms var(--ease); }
.is-entering [data-reveal] { animation: rise-in 620ms var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes expand { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { width: 0; } }
@keyframes ring-in { from { stroke-dashoffset: var(--circ); } to { stroke-dashoffset: var(--offset); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.8); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-8px); opacity: 1; } }
@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes check-pop { 0% { transform: scale(0.75); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes burst { from { opacity: 1; transform: rotate(var(--a)) translateX(0); } to { opacity: 0; transform: rotate(var(--a)) translateX(22px) scale(0.4); } }
@keyframes flash { 0% { background-color: color-mix(in srgb, var(--study) 16%, transparent); } 100% { background-color: transparent; } }
@keyframes menu-in { from { opacity: 0; transform: scale(0.95) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes flip-in { from { opacity: 0; transform: rotateX(-12deg) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes nudge { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes ping { 0% { box-shadow: inset 0 0 0 0 color-mix(in srgb, var(--study) 0%, transparent); } 30% { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--study) 55%, transparent); } 100% { box-shadow: inset 0 0 0 0 transparent; } }
@keyframes ready { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--study) 45%, transparent); } 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes line-in { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
@keyframes slide-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes slide-right { from { transform: translateX(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes badge-in { from { opacity: 0; transform: scale(0.4) rotate(-20deg); } to { opacity: 1; transform: none; } }
@keyframes confetti { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0.2; transform: translateY(105vh) rotate(var(--r)); } }

/* Responsive ------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; gap: 0.25rem 1rem; padding: 0.75rem 0 0.5rem; }
  .main-nav { order: 3; width: calc(100% + 2rem); margin: 0 -1rem; padding: 0 1rem 0.2rem; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .home-grid, .course-layout, .reader-layout, .progress-columns { grid-template-columns: minmax(0, 1fr); }
  .course-side, .reader-side { position: static; }
  .course-hero { grid-template-columns: minmax(0, 1fr); }
  .le-head-progress { display: none; }
}
@media (max-width: 900px) {
  .le-tabs:not([hidden]) { display: flex; gap: 0.25rem; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); background: var(--surface); }
  .le-tab { flex: 1; min-height: 2.2rem; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--ink-3); cursor: pointer; font-weight: 500; }
  .le-tab.is-active { border-color: var(--line); background: var(--sheet); color: var(--ink); box-shadow: var(--shadow); }
  .le-main[data-layout="split"] { grid-template-columns: minmax(0, 1fr); }
  .le-main[data-layout="split"][data-pane="learn"] .le-workspace { display: none; }
  .le-main[data-layout="split"][data-pane="code"] .le-narrative { display: none; }
  .le-main[data-layout="split"] .le-narrative { border-right: 0; }
  .le-crumbs > a, .le-crumbs > .icon { display: none; }
  .le-foot-right { display: none; }
  .le-footer { grid-template-columns: auto 1fr; }
  .le-foot-center { justify-self: end; }
}
@media (max-width: 640px) {
  .page-shell { width: calc(100% - 2rem); }
  .brand-name { font-size: 1.25rem; }
  .sync-pill .sync-text { display: none; }
  .sync-pill { padding: 0.45rem; margin-right: 0; }
  .view { padding-top: 1.75rem; }
  .resume-card { grid-template-columns: minmax(0, 1fr); }
  .resume-art { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .section-head { flex-wrap: wrap; align-items: flex-start; }
  .module-head { grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.7rem; padding: 0.9rem; }
  .module-progress .ring { display: none; }
  .module-chevron { display: none; }
  .syllabus-list { padding: 0 0.9rem 0.5rem; }
  .syllabus-item { grid-template-columns: minmax(0, 1fr) auto; }
  .syllabus-icon, .lesson-row-icon { display: none; }
  .syllabus-end .button { display: none; }
  .lesson-row { grid-template-columns: minmax(0, 1fr) auto; }
  .complete-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .le-header { gap: 0.4rem; padding: 0 0.5rem; }
  .le-menu-button span, .le-brand, .le-actions [data-action="text-size"] { display: none; }
  .le-menu-button { padding: 0 0.6rem; }
  .le-foot-left .button span { display: none; }
  .le-foot-center { gap: 0.4rem; }
  .le-foot-center .button { padding: 0 0.85rem; }
  .le-workspace { grid-template-rows: minmax(14rem, 1.2fr) minmax(10rem, 1fr); }
  .toast-region { right: 1rem; bottom: 1rem; left: 1rem; justify-items: stretch; }
  .toast { max-width: none; }
  .name-form { width: 100%; }
  .name-form .field { flex: 1; min-width: 0; }
  .auth-card { padding: 1.5rem; }
}

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