/* ===== Design tokens ===== */
:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef0f7;
  --text: #1a1d29;
  --text-soft: #565d75;
  --text-faint: #8b91a7;
  --border: #e4e7f0;
  --border-soft: #eef0f7;
  --brand: #2f6df6;
  --brand-2: #7b3ff2;
  --brand-soft: #eaf0ff;
  --accent: #15c08a;
  --h2-gold: #b8860b;
  --h2-gold-light: #d4af37;
  --h2-gold-border: #c9a227;
  --warn: #f0a020;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 28px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.14);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 312px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Fraunces', Georgia, serif;
}

[data-theme="dark"] {
  --bg: #0c0e16;
  --bg-elev: #14171f;
  --bg-soft: #1b1f2a;
  --text: #eef1f8;
  --text-soft: #aab2c5;
  --text-faint: #6f7790;
  --border: #262b38;
  --border-soft: #1d222e;
  --brand: #5b8cff;
  --brand-2: #a06bff;
  --brand-soft: #1a2238;
  --accent: #2bd49b;
  --h2-gold: #d4af37;
  --h2-gold-light: #f0d060;
  --h2-gold-border: #e8c547;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 50px rgba(0,0,0,.5);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

/* ===== Topbar (mobile) ===== */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 60;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { font-weight: 700; font-size: 1.05rem; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.icon-btn:active { transform: scale(.94); }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 50;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: .9rem; letter-spacing: .5px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 16px rgba(47,109,246,.35);
}
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { font-size: .78rem; color: var(--text-faint); }

/* Progress card */
.progress-card {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.progress-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; font-weight: 600; margin-bottom: 10px;
}
.progress-top span:last-child { color: var(--brand); font-weight: 700; }
.progress-bar {
  height: 8px; border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.progress-meta { margin-top: 8px; font-size: .76rem; color: var(--text-faint); }

/* Nav */
.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-module { margin-bottom: 6px; }
.nav-module-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint);
  padding: 12px 10px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: .9rem;
  color: var(--text-soft);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
  transition: background .18s, color .18s;
}
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.nav-check {
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  font-size: .6rem; color: #fff;
  transition: all .2s;
}
.nav-link.done .nav-check {
  background: var(--accent);
  border-color: var(--accent);
}
.nav-link-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reset-btn {
  margin-top: auto;
  padding: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  border-radius: 9px;
  font-size: .8rem; font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}
.reset-btn:hover { color: var(--danger); border-color: var(--danger); }

.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}

/* ===== Content ===== */
.content {
  flex: 1;
  min-width: 0;
  position: relative;
  padding: 0 0 80px;
}
.theme-toggle-desktop {
  position: fixed;
  top: 20px; right: 24px;
  z-index: 30;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
  transition: transform .15s;
}
.theme-toggle-desktop:hover { transform: translateY(-2px); }

/* Hero */
.hero {
  position: relative;
  padding: 80px 8vw 64px;
  overflow: hidden;
  background:
    radial-gradient(900px 400px at 80% -10%, rgba(123,63,242,.18), transparent 60%),
    radial-gradient(700px 360px at 10% 0%, rgba(47,109,246,.18), transparent 55%);
  border-bottom: 1px solid var(--border);
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .78rem; font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 6px 14px; border-radius: 99px;
  margin-bottom: 20px;
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -.02em;
  max-width: 16ch;
  margin-bottom: 18px;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: 1.12rem; color: var(--text-soft);
  max-width: 56ch; margin-bottom: 30px;
}
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px; border-radius: 12px;
  font-weight: 600; font-size: .95rem; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 22px rgba(47,109,246,.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(47,109,246,.45); }
.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-soft); }

.hero-stats { display: flex; gap: 36px; margin-top: 44px; flex-wrap: wrap; }
.hero-stat .num {
  font-family: var(--display);
  font-size: 2rem; font-weight: 600; color: var(--text);
}
.hero-stat .lbl { font-size: .82rem; color: var(--text-faint); }

/* Lesson */
.lesson {
  display: none;
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 8vw 0;
  animation: fade .4s ease;
  transition: max-width .4s ease, padding .4s ease;
}
.lesson.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.lesson-breadcrumb {
  font-size: .8rem; color: var(--text-faint);
  margin-bottom: 14px; font-weight: 500;
}
.lesson-meta {
  display: flex; align-items: center; gap: 14px;
  font-size: .82rem; color: var(--text-faint);
  margin-bottom: 8px;
}
.lesson-meta .chip {
  background: var(--bg-soft); padding: 4px 12px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 6px;
}
.lesson h2 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 600; letter-spacing: -.015em;
  margin: 6px 0 28px;
  line-height: 1.15;
}
.lesson h3 {
  font-size: 1.5rem; font-weight: 700;
  margin: 48px 0 16px;
  letter-spacing: -.015em;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--h2-gold-border);
  scroll-margin-top: 24px;
}
.lesson h3 .h-num {
  display: inline-block;
  font-family: var(--display);
  color: var(--h2-gold);
  margin-right: 10px;
  font-weight: 600;
}
.lesson h4 {
  font-size: 1.18rem; font-weight: 700;
  margin: 32px 0 10px;
  letter-spacing: -.01em;
  scroll-margin-top: 24px;
}
.lesson h4 .h-num { color: var(--brand-2); margin-right: 8px; font-weight: 700; }
.lesson h5 {
  font-size: 1.02rem; font-weight: 700;
  margin: 22px 0 8px;
  color: var(--text);
  scroll-margin-top: 24px;
}
.lesson h5::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  margin-right: 10px;
  vertical-align: middle;
}

/* Level-3 sections (e.g. 3.2.1 Informational) — clickable + glow */
.l3-section {
  position: relative;
  border-radius: 14px;
  margin: 10px 0 26px;
  padding: 14px 18px 18px;
  border: 2px solid transparent;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  transition: background .3s ease, box-shadow .35s ease, width .4s ease, padding .4s ease;
}
.l3-section::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(
    135deg,
    var(--brand) 0%,
    var(--brand-2) 45%,
    var(--accent) 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
  z-index: 0;
}
.l3-section.is-active::before,
.l3-section.is-spotlight::before {
  opacity: 1;
  animation: l3-glow-pulse 2.4s ease-in-out infinite;
}
/* Heading 2 (h3) sections — golden border glow */
.l3-section-h2::before {
  background: linear-gradient(
    135deg,
    var(--h2-gold) 0%,
    var(--h2-gold-light) 50%,
    var(--h2-gold-border) 100%
  );
}
.l3-section-h2.is-active,
.l3-section-h2.is-spotlight {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--h2-gold-border) 35%, transparent),
    0 0 24px color-mix(in srgb, var(--h2-gold) 40%, transparent),
    0 0 44px color-mix(in srgb, var(--h2-gold-light) 22%, transparent),
    0 24px 64px rgba(0, 0, 0, 0.35);
}
.l3-section.is-active,
.l3-section.is-spotlight {
  background: var(--bg-elev);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent),
    0 0 24px color-mix(in srgb, var(--brand) 32%, transparent),
    0 0 44px color-mix(in srgb, var(--brand-2) 18%, transparent),
    0 24px 64px rgba(0, 0, 0, 0.35);
}
@keyframes l3-glow-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
.l3-section > * { position: relative; z-index: 1; }
.lesson-body h4.l3-heading,
.lesson-body h3.l3-heading {
  cursor: pointer;
  margin-top: 0;
  padding: 6px 8px;
  margin-left: -8px;
  margin-right: -8px;
  border-radius: 10px;
  transition: color .2s ease, background .2s ease;
}
.lesson-body h3.l3-heading {
  padding-bottom: 14px;
  border-bottom-color: var(--h2-gold-border);
}
.lesson-body h4.l3-heading:hover {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}
.lesson-body h3.l3-heading:hover {
  color: var(--h2-gold);
  background: color-mix(in srgb, var(--h2-gold) 12%, transparent);
}
.l3-section.is-active h4.l3-heading,
.l3-section.is-spotlight h4.l3-heading {
  color: var(--brand);
}
.l3-section.is-active h3.l3-heading,
.l3-section.is-spotlight h3.l3-heading {
  color: var(--h2-gold);
  border-bottom-color: var(--h2-gold-border);
}

/* Spotlight overlay — dims main area, sidebar stays clear */
.l3-spotlight {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s ease, visibility .32s ease;
}
.l3-spotlight.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
.l3-spotlight-backdrop {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 70;
  background: rgba(8, 10, 18, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.l3-spotlight-stage {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px 0;
  box-sizing: border-box;
  pointer-events: none;
}
.l3-spotlight-stage .l3-section {
  pointer-events: auto;
  width: 70%;
  max-width: 70%;
  height: auto;
  max-height: calc(100% - 100px);
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0 auto;
  padding: clamp(24px, 3vh, 40px) clamp(28px, 4vw, 56px);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
/* Full-width spotlight typography & layout */
.l3-spotlight-stage .l3-section h4.l3-heading,
.l3-spotlight-stage .l3-section h3.l3-heading {
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  margin-bottom: clamp(16px, 2vh, 28px);
  padding: 10px 12px;
}
.l3-spotlight-stage .l3-section h3.l3-heading {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  border-bottom: 2px solid var(--h2-gold-border);
  padding-bottom: clamp(14px, 1.8vh, 22px);
}
.l3-spotlight-stage .l3-section h5 {
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
  margin-top: clamp(20px, 2.5vh, 32px);
}
.l3-spotlight-stage .l3-section p {
  font-size: clamp(1rem, 1.15vw, 1.15rem);
  line-height: 1.75;
  margin-bottom: clamp(14px, 1.5vh, 20px);
  max-width: none;
}
.l3-spotlight-stage .l3-section p.lead {
  font-size: clamp(1.12rem, 1.5vw, 1.35rem);
  line-height: 1.65;
}
.l3-spotlight-stage .l3-section ul,
.l3-spotlight-stage .l3-section ol {
  font-size: clamp(1rem, 1.1vw, 1.12rem);
  margin-bottom: clamp(16px, 2vh, 24px);
  padding-left: clamp(22px, 2vw, 32px);
}
.l3-spotlight-stage .l3-section li {
  margin-bottom: clamp(8px, 1vh, 12px);
}
.l3-spotlight-stage .l3-section .step-grid,
.l3-spotlight-stage .l3-section .intent-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: clamp(14px, 2vw, 24px);
  margin: clamp(20px, 2.5vh, 32px) 0;
}
.l3-spotlight-stage .l3-section .step-card,
.l3-spotlight-stage .l3-section .intent-card {
  padding: clamp(18px, 2vw, 26px);
}
.l3-spotlight-stage .l3-section .step-card h4,
.l3-spotlight-stage .l3-section .intent-card h4 {
  font-size: clamp(1rem, 1.2vw, 1.15rem);
}
.l3-spotlight-stage .l3-section .step-card p,
.l3-spotlight-stage .l3-section .intent-card p {
  font-size: clamp(.92rem, 1vw, 1.05rem);
}
.l3-spotlight-stage .l3-section .compare {
  gap: clamp(16px, 2vw, 28px);
  margin: clamp(20px, 2.5vh, 32px) 0;
}
.l3-spotlight-stage .l3-section .compare-col {
  padding: clamp(18px, 2vw, 28px);
}
.l3-spotlight-stage .l3-section .callout {
  padding: clamp(18px, 2vw, 24px) clamp(20px, 2.5vw, 28px);
  font-size: clamp(.95rem, 1.1vw, 1.08rem);
  margin: clamp(22px, 2.5vh, 32px) 0;
}
.l3-spotlight-stage .l3-section pre.code {
  padding: clamp(18px, 2vw, 24px);
  margin-bottom: clamp(18px, 2vh, 26px);
}
.l3-spotlight-stage .l3-section pre.code code {
  font-size: clamp(.84rem, 1vw, .95rem);
}
.l3-spotlight-stage .l3-section .table-wrap {
  margin-bottom: clamp(20px, 2.5vh, 32px);
}
.l3-spotlight-stage .l3-section table {
  font-size: clamp(.9rem, 1.05vw, 1.02rem);
}
.l3-spotlight-stage .l3-section thead th,
.l3-spotlight-stage .l3-section tbody td {
  padding: clamp(12px, 1.2vw, 16px) clamp(14px, 1.5vw, 20px);
}
.l3-spotlight-stage .l3-section dl {
  font-size: clamp(1rem, 1.1vw, 1.12rem);
}
.l3-spotlight-stage .l3-section .takeaways {
  padding: clamp(22px, 2.5vw, 32px);
  margin-top: clamp(28px, 3vh, 40px);
}
@media (min-width: 1100px) {
  .l3-spotlight-stage .l3-section .compare {
    grid-template-columns: repeat(2, 1fr);
  }
  .l3-spotlight-stage .l3-section .intent-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
/* Spotlight prev/next navigation */
.l3-spotlight-nav {
  position: fixed;
  bottom: clamp(16px, 3vh, 28px);
  left: var(--sidebar-w);
  right: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
  padding: 0 clamp(16px, 3vw, 40px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s ease;
}
.l3-spotlight.is-open .l3-spotlight-nav {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.l3-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background .2s, border-color .2s, transform .15s, opacity .2s;
}
.l3-nav-btn:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  transform: translateY(-2px);
}
.l3-nav-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.l3-nav-arrow { font-size: 1.1rem; line-height: 1; }
.l3-nav-meta {
  text-align: center;
  min-width: min(280px, 40vw);
}
.l3-nav-counter {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.l3-nav-title {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.l3-spotlight-open {
  overflow: hidden;
}
body.l3-spotlight-open .sidebar {
  z-index: 100;
}

@media (max-width: 920px) {
  .l3-spotlight-backdrop,
  .l3-spotlight-stage,
  .l3-spotlight-nav {
    left: 0;
  }
  .l3-spotlight-stage {
    padding: 50px 0;
  }
  .l3-spotlight-nav {
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .l3-nav-btn {
    padding: 10px 14px;
    font-size: .85rem;
  }
  .l3-nav-meta { min-width: 100%; order: -1; }
  .l3-spotlight-stage .l3-section {
    width: 70%;
    max-width: 70%;
    max-height: calc(100% - 100px);
    padding: 24px 20px 28px;
    border-radius: 10px;
  }
  .l3-spotlight-stage .l3-section .intent-grid {
    grid-template-columns: 1fr;
  }
}

/* inside cards keep h4 compact */
.step-card h4, .intent-card h4, .compare-col h4 { font-size: 1rem; margin: 0 0 6px; }
.step-card h4 { margin-bottom: 6px; }

/* Tables */
.lesson .table-wrap { overflow-x: auto; margin: 0 0 22px; }
.lesson table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.lesson thead th {
  background: var(--bg-soft);
  text-align: left;
  font-weight: 700;
  color: var(--text);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.lesson tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-soft);
  vertical-align: top;
}
.lesson tbody tr:last-child td { border-bottom: none; }

/* Definition list */
.lesson dl { margin: 0 0 20px; }
.lesson dt { font-weight: 700; color: var(--text); margin-top: 14px; }
.lesson dd { margin: 4px 0 0; color: var(--text-soft); }

/* Key takeaways box */
.takeaways {
  margin: 32px 0 0;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.takeaways h4 {
  margin: 0 0 12px;
  font-size: .82rem; letter-spacing: .6px; text-transform: uppercase;
  color: var(--brand);
}
.takeaways ul { margin: 0 0 0 4px; list-style: none; }
.takeaways li {
  position: relative; padding-left: 28px; margin-bottom: 10px;
  color: var(--text-soft);
}
.takeaways li::before {
  content: "✓";
  position: absolute; left: 0; top: 0;
  width: 18px; height: 18px;
  background: var(--accent); color: #fff;
  border-radius: 50%; font-size: .65rem; font-weight: 700;
  display: grid; place-items: center;
}

/* Chapter contents (mini TOC) */
.chapter-toc {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  padding: 18px 20px;
  margin: 0 0 30px;
}
.chapter-toc .toc-title {
  font-size: .76rem; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px;
}
.chapter-toc ol { margin: 0 0 0 18px; color: var(--text-soft); }
.chapter-toc li { margin-bottom: 5px; }
.chapter-toc a { color: var(--text-soft); text-decoration: none; }
.chapter-toc a:hover { color: var(--brand); text-decoration: underline; }
.lesson p { margin-bottom: 16px; color: var(--text-soft); }
.lesson p.lead {
  font-size: 1.18rem; color: var(--text);
  line-height: 1.6; margin-bottom: 24px;
}
.lesson ul, .lesson ol { margin: 0 0 18px 22px; color: var(--text-soft); }
.lesson li { margin-bottom: 8px; }
.lesson strong { color: var(--text); font-weight: 650; }
.lesson code:not(.code code) {
  background: var(--bg-soft);
  padding: 2px 7px; border-radius: 6px;
  font-size: .88em;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  color: var(--brand-2);
}
[data-theme="dark"] .lesson code:not(.code code) { color: #c9a6ff; }

/* Code blocks */
pre.code {
  background: #0d1117;
  border: 1px solid #1f2733;
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 20px;
}
pre.code code {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: .86rem;
  line-height: 1.6;
  color: #c9d4e3;
  white-space: pre;
}

/* Callouts */
.callout {
  border-radius: 12px;
  padding: 16px 18px;
  margin: 22px 0;
  font-size: .94rem;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.callout strong { color: var(--text); }
.callout ul { margin: 10px 0 0 20px; }
.callout-tip { border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); }
.callout-note { border-left: 4px solid var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--bg-elev)); }
.callout-warn { border-left: 4px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--bg-elev)); }

/* Step / intent / compare grids */
.step-grid, .intent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin: 20px 0;
}
.step-card, .intent-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.step-num {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: .8rem;
  margin-bottom: 12px;
}
.step-card p, .intent-card p { margin: 0; font-size: .9rem; }
.intent-card .badge {
  display: inline-block;
  font-size: .72rem; font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 10px; border-radius: 99px;
  margin-bottom: 8px;
}

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.compare-col {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.compare-col.bad { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.compare-col.good { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.compare-col h4 { margin-bottom: 8px; }
.compare-col ul { margin: 8px 0 0 18px; font-size: .88rem; }

/* Quiz */
.quiz {
  margin: 40px 0 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.quiz-label {
  font-size: .74rem; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--brand);
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.quiz-q { font-size: 1.12rem; font-weight: 650; margin-bottom: 18px; color: var(--text); }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg);
  cursor: pointer; font-family: inherit; font-size: .94rem;
  color: var(--text); text-align: left; width: 100%;
  transition: all .18s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.quiz-opt .marker {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid var(--border);
  display: grid; place-items: center; font-size: .7rem; font-weight: 700;
}
.quiz-opt.correct { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.quiz-opt.correct .marker { background: var(--accent); border-color: var(--accent); color: #fff; }
.quiz-opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--bg)); }
.quiz-opt.wrong .marker { background: var(--danger); border-color: var(--danger); color: #fff; }
.quiz-opt:disabled { cursor: default; }
.quiz-feedback {
  margin-top: 16px; padding: 14px 16px;
  border-radius: 11px; font-size: .9rem;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.ok { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.quiz-feedback.no { background: color-mix(in srgb, var(--danger) 10%, var(--bg)); color: var(--text); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

/* Lesson footer / nav */
.lesson-footer {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 20px;
}
.complete-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 26px;
  border-radius: 12px;
  font-weight: 650; font-size: 1rem; font-family: inherit;
  cursor: pointer;
  border: 2px solid var(--accent);
  background: transparent; color: var(--accent);
  transition: all .2s;
  align-self: flex-start;
}
.complete-btn:hover { background: var(--accent); color: #fff; }
.complete-btn.done {
  background: var(--accent); color: #fff;
}
.lesson-pager { display: flex; justify-content: space-between; gap: 12px; }
.pager-btn {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 18px; border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer; font-family: inherit;
  color: var(--text); text-align: left;
  transition: all .18s; max-width: 48%;
}
.pager-btn:hover:not(:disabled) { border-color: var(--brand); transform: translateY(-2px); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-btn.next { text-align: right; align-items: flex-end; }
.pager-dir { font-size: .72rem; color: var(--text-faint); font-weight: 600; }
.pager-title { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Completion banner */
.finish-banner {
  display: none;
  max-width: 820px; margin: 30px auto 0;
  padding: 0 8vw;
}
.finish-banner.show { display: block; }
.finish-inner {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border-radius: var(--radius);
  padding: 32px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.finish-inner h3 { font-family: var(--display); font-size: 1.8rem; margin-bottom: 8px; color:#fff; }
.finish-inner p { color: rgba(255,255,255,.9); margin: 0; }

/* ===== Responsive ===== */
@media (max-width: 920px) {
  .topbar { display: flex; }
  .theme-toggle-desktop { display: none; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.show { display: block; opacity: 1; pointer-events: auto; }
  .hero { padding: 48px 6vw 44px; }
  .lesson { padding: 36px 6vw 0; }
  .finish-banner { padding: 0 6vw; }
  .hero-stats { gap: 24px; }
}
@media (max-width: 560px) {
  .compare, .lesson-pager { grid-template-columns: 1fr; flex-direction: column; }
  .pager-btn { max-width: 100%; }
  .hero h1 { font-size: 2rem; }
}

/* ===== Back to courses link (course player sidebar) ===== */
.back-to-courses {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-faint);
  text-decoration: none;
  padding: 6px 10px;
  margin: -4px -10px 2px;
  border-radius: 8px;
  transition: color .2s, background .2s;
  align-self: flex-start;
}
.back-to-courses:hover {
  color: var(--brand);
  background: var(--bg-soft);
}

/* ===== Landing page (course collection) ===== */
.landing-body {
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(123,63,242,.16), transparent 60%),
    radial-gradient(800px 460px at 5% 0%, rgba(47,109,246,.16), transparent 55%),
    var(--bg);
  min-height: 100vh;
}
.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 6vw, 80px);
  max-width: 1240px;
  margin: 0 auto;
}
.landing-brand { display: flex; align-items: center; gap: 12px; }
.landing-theme {
  position: static;
  box-shadow: var(--shadow);
}
.landing {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(20px, 6vw, 80px) 80px;
}
.landing-hero {
  padding: clamp(40px, 8vh, 90px) 0 clamp(32px, 5vh, 56px);
  max-width: 760px;
}
.landing-hero h1 {
  font-family: var(--display);
  font-size: clamp(2.2rem, 5.5vw, 3.8rem);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: 18px;
}
.landing-hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-hero p {
  font-size: 1.14rem;
  color: var(--text-soft);
  max-width: 58ch;
}

.collection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.collection-head h2 {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
}
.collection-sub { font-size: .9rem; color: var(--text-faint); }

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: clamp(16px, 2vw, 24px);
}
.course-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .25s ease, border-color .2s ease;
  position: relative;
  overflow: hidden;
}
.course-card.is-available { cursor: pointer; }
.course-card.is-available:hover {
  transform: translateY(-4px);
  border-color: var(--brand);
  box-shadow: var(--shadow-lg);
}
.course-card.is-soon { opacity: .72; }
.course-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.course-icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  font-size: 1.6rem;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
}
.course-badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 99px;
}
.course-badge.available {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elev));
}
.course-badge.soon {
  color: var(--text-faint);
  background: var(--bg-soft);
}
.course-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 8px;
}
.course-tagline {
  font-size: .94rem;
  color: var(--text-soft);
  margin-bottom: 18px;
  flex: 1;
}
.course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.course-meta-item {
  font-size: .76rem;
  color: var(--text-faint);
  background: var(--bg-soft);
  padding: 4px 10px;
  border-radius: 99px;
}
.course-cta {
  font-size: .9rem;
  font-weight: 650;
  color: var(--brand);
}
.course-card.is-soon .course-cta { color: var(--text-faint); }

.landing-footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-size: .88rem;
  color: var(--text-faint);
}

@media (max-width: 920px) {
  .landing-theme { display: inline-grid; }
}
