* { box-sizing: border-box; }
html { scroll-padding-block-start: 24px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.75 var(--font-sans);
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; top: -100px; left: 12px; z-index: 10; background: var(--paper); padding: 10px; }
.skip:focus { top: 10px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner, .footer {
  width: min(100%, 1440px);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 48px);
}
.topbar-inner { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font: 700 14px/1.4 var(--font-sans); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  background: var(--accent);
  color: var(--paper);
  font: 700 15px/1 var(--font-mono);
}
.topbar nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 32px); font-size: 14px; color: var(--muted); }
.topbar nav a { white-space: nowrap; }
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-block: 22px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.footer a, .secondary, .route-note a { color: var(--accent); }
.footer a, .route-note a { text-decoration: underline; text-underline-offset: .2em; }

.wrap { width: min(100%, 1232px); margin-inline: auto; padding-inline: clamp(16px, 4vw, 48px); }
.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  align-items: center;
  gap: clamp(28px, 6vw, 88px);
  padding-block: clamp(34px, 6vw, 80px) clamp(36px, 5vw, 64px);
}
.hero-copy h1 {
  margin: 10px 0 16px;
  font-size: clamp(38px, 5.35vw, 72px);
  font-weight: 760;
  line-height: 1.12;
  letter-spacing: -.052em;
}
.label { color: var(--accent); font-size: 13px; font-weight: 650; }
.intro { max-width: 34rem; color: var(--muted); font-size: clamp(15px, 1.6vw, 18px); margin: 0; }
.small, .progress-note { color: var(--muted); font-size: 13px; }
.hero .small { margin: 14px 0 0; }
.actions { display: flex; align-items: center; gap: 12px 22px; flex-wrap: wrap; margin: 20px 0 0; }
.primary, .secondary { display: inline-flex; align-items: center; gap: 14px; min-height: 44px; font-size: 14px; font-weight: 650; }
.primary { padding: 9px 15px; border-radius: 5px; color: white; background: var(--accent); }
.primary:hover { background: var(--accent-strong); text-decoration: none; }
.hero-loop {
  margin: 0;
  padding: clamp(15px, 2.5vw, 25px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
  font-size: 14px;
}
.hero-loop figcaption { color: var(--muted); font-weight: 650; margin-bottom: 12px; }
.hero-loop ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.hero-loop li { display: flex; gap: 12px; align-items: baseline; padding: 8px 10px; border-left: 2px solid var(--accent); background: var(--paper); }
.hero-loop li strong { flex: none; color: var(--accent); }
.hero-loop code { font: .92em var(--font-mono); }
.hero-loop p { color: var(--accent); font-size: 13px; margin: 12px 0 0; }
.hero-loop p span { margin-right: 6px; }

.section { padding-block: 32px 44px; }
.section + .section { border-top: 1px solid var(--line); }
.section h2 { font-size: clamp(23px, 2.7vw, 30px); line-height: 1.35; letter-spacing: -.026em; margin: 0 0 9px; }
.section-title { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 7px 15px; margin-bottom: 15px; }
.section-title h2, .section-title p { margin: 0; }
.section-lead, .route-note { color: var(--muted); margin: 0; }
.route-note { font-size: 13px; margin-top: 13px; }
.roadmap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; }
.roadmap-group { min-width: 0; border: 1px solid var(--line); border-radius: 7px; }
.roadmap-group > summary {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 71px;
  padding: 10px 15px;
  list-style: none;
}
.roadmap-group > summary::-webkit-details-marker { display: none; }
.roadmap-group > summary:hover, .roadmap-group[open] > summary { background: var(--soft); }
.roadmap-group > summary small, .chapter-name small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.roadmap-chevron {
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border: solid var(--accent);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.roadmap-group[open] .roadmap-chevron { transform: rotate(225deg); }
.chapter-num { color: var(--accent); font: 500 13px/1.4 var(--font-mono); }
.roadmap-chapters { padding-inline: 15px; border-top: 1px solid var(--line); }
.chapter-row { display: grid; grid-template-columns: 27px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 0; }
.chapter-row + .chapter-row { border-top: 1px solid var(--line); }
.chapter-name { font-size: 14px; font-weight: 620; }
.chapter-row .arrow { color: var(--accent); }

.cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 22px; }
.case { min-width: 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.case :is(img, video) { display: block; width: 100%; aspect-ratio: 1.75; object-fit: cover; border-radius: 6px; background: var(--soft); }
.case video { background: var(--dark); object-fit: contain; }
.case h3 { font-size: 18px; line-height: 1.5; margin: 12px 0 6px; }
.case p { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.case-links { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--accent); font-size: 13px; }
.starter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  background: var(--soft);
  padding: clamp(15px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.starter > * { min-width: 0; }
.starter p { font-size: 14px; color: var(--muted); margin: 0; }
.starter pre, .reading pre { margin: 0; color: var(--on-dark); background: var(--dark); border-radius: 6px; padding: 14px 16px; overflow: auto; }
.starter code, .reading code { font-family: var(--font-mono); }
.starter code { font-size: 13px; }

.lesson-layout {
  width: min(100%, 1440px);
  margin-inline: auto;
  padding: 32px clamp(16px, 4vw, 48px) 64px;
  display: grid;
  grid-template-columns: minmax(155px, 213px) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 38px);
}
.course-nav, .lesson-toc { align-self: start; }
.course-nav { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; border-right: 1px solid var(--line); padding-right: 12px; font-size: 13px; }
.course-nav summary, .toc-box summary { font-size: 14px; font-weight: 700; }
.course-nav nav { margin-top: 9px; }
.course-nav a { display: block; padding: 7px 8px; margin-block: 2px; line-height: 1.55; color: var(--muted); border-radius: 4px; overflow-wrap: anywhere; }
.course-nav a:hover { background: var(--soft); }
.course-nav .lesson-link { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 5px; }
.lesson-link > span:first-child { font: 500 12px/1.7 var(--font-mono); }
.course-nav a[aria-current="page"] { color: var(--accent); background: var(--tint); font-weight: 650; }
.nav-group { margin: 12px 8px 4px; color: var(--ink); font-size: 12px; font-weight: 650; }

.reading { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(125px, 157px); gap: 0 clamp(16px, 2.4vw, 32px); align-items: start; }
.reading-content { min-width: 0; grid-column: 1; }
.lesson-heading { grid-column: 1; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 21px; }
.lesson-heading h1 {
  font-size: clamp(29px, 4vw, 47px);
  font-weight: 755;
  line-height: 1.22;
  letter-spacing: -.045em;
  margin: 8px 0 10px;
  text-wrap: balance;
}
.lesson-heading p { color: var(--muted); margin: 0; }
.lesson-toc {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding-left: 13px;
  font-size: 13px;
}
.lesson-toc nav > .toc > ul { list-style: none; margin: 8px 0 4px; padding: 0; }
.toc ul { padding-inline-start: 13px; }
.toc li { margin-block: 6px; line-height: 1.5; }
.toc a { color: var(--muted); display: block; padding: 2px 0; overflow-wrap: anywhere; }
.toc a:hover { color: var(--accent); }

.reading article { font-size: 16px; line-height: 1.88; }
.reading article > :first-child { margin-top: 0; }
.reading article h2 { font-size: clamp(22px, 2.6vw, 27px); line-height: 1.4; letter-spacing: -.025em; margin: 34px 0 13px; }
.reading article h3 { font-size: 19px; line-height: 1.45; margin: 24px 0 11px; }
.reading article p { margin: 0 0 14px; }
.reading article a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.reading article li + li { margin-top: 5px; }
.reading article blockquote { margin: 20px 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--soft); color: var(--muted); }
.reading article blockquote p:last-child { margin-bottom: 0; }
.reading :not(pre) > code { background: var(--tint); padding: 2px 4px; border-radius: 3px; font-size: .88em; overflow-wrap: anywhere; }
.reading pre { position: relative; padding: 41px 16px 15px; margin: 16px 0; line-height: 1.65; }
.reading pre code { font-size: 13px; }
.copy-code { position: absolute; top: 7px; right: 8px; padding: 2px 8px; border-radius: 4px; border: 1px solid #506682; background: #263e5c; color: var(--on-dark); font-size: 12px; }
.copy-code:focus-visible { outline-color: white; }
.reading table { display: block; max-width: 100%; overflow: auto; border-collapse: collapse; font-size: 14px; margin-block: 20px; }
.reading th, .reading td { min-width: 82px; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.reading th { background: var(--soft); }
.reading img { max-width: 100%; height: auto; }
.reading article details:not(.demo-steps) { margin: 15px 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 5px; }
.reading article details > p:last-child { margin-bottom: 0; }
.course-figure { margin: 20px 0 25px; }
.course-figure img { display: block; width: min(100%, 640px); height: auto; margin-inline: auto; }
.course-figure figcaption { max-width: 640px; margin: 8px auto 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.lab-note { background: var(--soft); padding: 14px 17px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; color: var(--muted); margin-top: 24px; }
.lab-note a { text-decoration: underline; color: var(--accent); }
.lesson-bottom { margin-top: 25px; }
.finish-label { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.finish-label input { width: 18px; height: 18px; accent-color: var(--accent); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 18px; color: var(--accent); font-size: 14px; }

.lesson-demo { margin: 24px 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.demo-label { padding: 9px 14px; color: var(--accent); font-size: 12px; font-weight: 650; border-bottom: 1px solid var(--line); }
.lesson-demo video { display: block; width: 100%; max-height: 560px; aspect-ratio: 4/3; object-fit: contain; background: var(--dark); }
.lesson-demo figcaption { padding: 13px 15px 10px; }
.lesson-demo figcaption > strong { display: block; font-size: 17px; line-height: 1.45; margin-bottom: 5px; }
.lesson-demo figcaption p { font-size: 14px; margin: 6px 0; }
.lesson-demo .demo-scope, .lesson-demo .demo-source { font-size: 12px; color: var(--muted); }
.demo-steps { padding: 10px 14px 13px; border-top: 1px solid var(--line); font-size: 13px; }
.demo-steps summary { font-weight: 650; }
.demo-steps ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow: auto; }
.demo-steps button { width: 100%; text-align: left; border: 0; border-radius: 4px; background: transparent; color: var(--ink); padding: 7px; line-height: 1.55; font-size: 13px; overflow-wrap: anywhere; }
.demo-steps button:hover, .demo-steps button[aria-current="true"] { background: var(--tint); }
.demo-steps button span { color: var(--accent); margin-right: 6px; font-variant-numeric: tabular-nums; }
.answer { border-left: 3px solid var(--accent) !important; background: var(--soft); }
.answer summary { font-weight: 650; }

@media (max-width: 1099px) {
  .reading { display: block; }
  .lesson-toc { position: static; max-height: none; padding: 8px 13px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 19px; background: var(--surface); }
}
@media (max-width: 760px) {
  .topbar-inner { min-height: 54px; }
  .topbar nav { font-size: 12px; gap: 12px; }
  .topbar nav .repo { display: none; }
  .hero { grid-template-columns: 1fr; gap: 22px; }
  .section { padding-block: 24px 32px; }
  .lesson-layout { display: block; padding-block: 15px 40px; }
  .course-nav { position: static; max-height: none; border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; margin-bottom: 20px; background: var(--surface); }
  .course-nav details[open] nav { max-height: min(55vh, 450px); overflow: auto; }
  .reading article li { overflow-wrap: anywhere; }
  .starter { grid-template-columns: 1fr; }
}
@media (max-width: 530px) {
  .roadmap, .cases { grid-template-columns: 1fr; }
  .roadmap-group > summary { min-height: 60px; }
  .case :is(img, video) { aspect-ratio: 2; }
  .hero-copy h1 { font-size: clamp(36px, 10vw, 52px); }
  .actions { gap: 4px 14px; }
}
