:root {
  --paper: #f8f6ef;
  --white: #fffdf8;
  --ink: #242d27;
  --muted: #69756a;
  --green: #294f43;
  --green-deep: #17221c;
  --lime: #c7e4a7;
  --orange: #ad5638;
  --cyan: #b9cbc1;
  --border: #dedfd9;
  color-scheme: light;
  --sidebar: #f0f1ec;
  --surface: #fffdf8;
  --surface-soft: #f2f4ec;
  --surface-muted: #e8ede2;
  --surface-code: #efede2;
  --surface-note: #eee6d8;
  --surface-callout: #f0f4e9;
  --text-soft: #62675e;
  --text-reading: #41483f;
  --text-strong: #17281d;
  --accent-link: #923f2b;
  --accent-ink: #385134;
  --control-border: #d0d4ca;
  --focus: #d98953;
  --surface-hover: #e4eadf;
  --accent-wash: #e7ecdf;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "Avenir Next", Avenir, "Helvetica Neue", sans-serif;
  --serif: Iowan Old Style, Baskerville, Georgia, serif;
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.7 var(--sans);
}
button,
select,
textarea {
  font: inherit;
}
button {
  color: inherit;
  cursor: pointer;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
a {
  color: #9f4027;
  text-underline-offset: 4px;
}
button:focus-visible,
a:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #e59757;
  outline-offset: 3px;
}
h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}
.skip {
  position: fixed;
  z-index: 30;
  top: -100px;
  left: 20px;
  padding: 10px 16px;
  background: var(--white);
}
.skip:focus {
  top: 10px;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 250px;
  padding: 30px 22px 26px;
  background: #f0f1ec;
  color: var(--ink);
  border-right: 1px solid var(--border);
}
.sidebar > * {
  position: relative;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.9px;
  white-space: nowrap;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  padding-bottom: 4px;
  background: #262e28;
  color: var(--white);
  border-radius: 2px;
  font: 29px/1 var(--serif);
}
.brand-light {
  font-weight: 400;
  color: #70766d;
}
.brand-dot {
  color: #49694b;
}
.course-label {
  margin: 16px 0 44px;
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: 1.7px;
}
.course-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 12px;
  border: 1px solid #d0d4ca;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
}
.course-switch:hover {
  background: #e4eadf;
}
.chapter-picker {
  display: block;
  margin-top: 25px;
  color: var(--muted);
  font: 10px var(--mono);
  letter-spacing: 1px;
}
.chapter-picker select {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px 28px 12px 10px;
  border: 1px solid #cbd0c5;
  border-radius: 4px;
  background: #fafbf8;
  color: var(--ink);
  font: 12px var(--sans);
}
.chapter-label {
  margin-top: 56px;
  color: #49694b;
  font: 10px var(--mono);
  letter-spacing: 1.2px;
}
.chapter-label span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
}
.side-title {
  max-width: 215px;
  margin: 13px 0 8px;
  font: 500 26px/1.2 var(--sans);
  letter-spacing: -0.6px;
}
.chapter-summary {
  color: var(--muted);
  font-size: 11px;
}
.sidebar-bottom {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid #d1d5cb;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}
.progress-label strong {
  color: #49694b;
  font: 11px var(--mono);
}
progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 12px;
  border: none;
  border-radius: 0;
  background: #d6dccf;
  accent-color: #49694b;
}
progress::-webkit-progress-bar {
  background: #d6dccf;
}
progress::-webkit-progress-value {
  background: #49694b;
}
.sidebar-bottom p {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 11px;
}
.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #626b5d;
  font: 10px var(--mono);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.page {
  min-width: 0;
  margin-left: 250px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
  padding: 0 clamp(24px, 5vw, 72px);
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  font: 11px var(--mono);
}
.muted,
.top-right {
  color: var(--muted);
}
.breadcrumb {
  margin: 0 13px;
  color: #aeafa2;
}
.topbar strong {
  color: var(--ink);
  font-weight: 600;
}
.top-right {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #719070;
}
.edition {
  margin-left: 14px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  color: #535d52;
  font: 10px var(--mono);
}
main {
  width: min(100%, 1120px);
  margin: auto;
  padding: 60px clamp(24px, 5vw, 72px) 90px;
}
.chapter-kicker {
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--muted);
  font: 10px var(--mono);
  letter-spacing: 1.3px;
  text-transform: uppercase;
}
.pill {
  padding: 6px 9px;
  background: #e7ecdf;
  color: #385134;
  font: 10px var(--mono);
  letter-spacing: 0;
}
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 38px;
  align-items: center;
  margin: 36px 0 0;
  padding: 12px 0 44px;
  color: var(--ink);
}
.hero > * {
  position: relative;
}
.hero h1 {
  max-width: 740px;
  margin: 0 0 19px;
  font: 500 clamp(52px, 5.4vw, 82px)/1.02 var(--sans);
  letter-spacing: -4px;
  text-wrap: balance;
}
.hero h1 span {
  color: #607a51;
  font-style: normal;
}
.hero p {
  max-width: 610px;
  margin-bottom: 24px;
  color: #62675e;
  font: 18px/1.7 var(--sans);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 27px;
}
.hero-actions a {
  display: inline-flex;
  gap: 15px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid #242a23;
  border-radius: 5px;
  background: #242a23;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.hero-actions a + a {
  border: 1px solid #d2d6cd;
  background: transparent;
  color: var(--ink);
}
.hero-actions a:hover {
  transform: translateY(-2px);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 21px;
  color: var(--muted);
  font: 10px/1.8 var(--mono);
}
.hero-art {
  padding: 24px 20px;
  border: 1px solid #d4d9cd;
  border-radius: 7px;
  background: #f2f5ed;
  box-shadow: 7px 7px 0 #e7ebdf;
  transform: rotate(3deg);
  font: 11px/1.8 var(--mono);
}
.hero-art small {
  color: #64705b;
  font: 9px var(--mono);
  letter-spacing: 1px;
}
.hero-art pre {
  padding: 18px 0;
  border: 0;
  background: none;
  font-size: 11px;
}
.hero-art .rust-stamp {
  padding-top: 16px;
  border-top: 1px dashed #c4ccba;
  color: #526644;
}
.hero-art .rust-stamp span {
  display: block;
  font: 9px/1.6 var(--mono);
  letter-spacing: 1px;
}
.chapter-article {
  width: min(100%, 820px);
  margin: auto;
}
.chapter-opening {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  padding: 25px 0;
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  color: var(--orange);
  font: 10px var(--mono);
  letter-spacing: 1.3px;
}
.chapter-opening .eyebrow {
  margin: 0;
  white-space: nowrap;
}
.chapter-opening p {
  max-width: 455px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.topic-section {
  position: relative;
  padding: 70px 0 60px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 24px;
}
.topic-index {
  margin-bottom: 14px;
  color: var(--orange);
  font: 10px var(--mono);
  letter-spacing: 1.3px;
}
.topic-index span {
  margin: 0 5px;
  color: #aab0a2;
}
.topic-section h2,
.chapter-lab h2 {
  margin: 0 0 15px;
  font: 500 clamp(30px, 3.2vw, 42px)/1.15 var(--sans);
  letter-spacing: -1.5px;
  text-wrap: balance;
}
.topic-intro {
  margin-bottom: 14px;
  font: 21px/1.55 var(--sans);
  color: #344653;
}
.topic-lead {
  margin: 0 0 32px;
  padding: 0;
  border: 0;
  background: none;
  color: #687163;
  font-size: 14px;
  line-height: 1.7;
}
.reading {
  max-width: 730px;
}
.reading h3 {
  margin: 33px 0 9px;
  color: var(--orange);
  font: 700 11px var(--mono);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.reading p,
.reading li {
  color: #41483f;
  font-size: 16px;
  line-height: 1.9;
}
.reading strong {
  color: #17281d;
}
.reading ul,
.reading ol {
  padding-left: 25px;
}
code {
  padding: 2px 5px;
  background: #edf0e7;
  color: #405a35;
  font: 0.9em var(--mono);
  overflow-wrap: anywhere;
}
pre {
  overflow: auto;
  margin: 16px 0;
  padding: 20px;
  border: 1px solid var(--border);
  background: #efede2;
  color: #293d31;
  font: 12px/1.75 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre code {
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
}
aside:not(.sidebar) {
  margin: 22px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--orange);
  background: #eee6d8;
  font-size: 13px;
}
.article-figure,
.trace-figure,
.example-figure {
  margin: 32px 0 0;
}
.article-figure figcaption,
.trace-figure figcaption,
.example-figure figcaption {
  font: 11px var(--mono);
}
.flowchart.article-figure {
  position: relative;
  overflow: hidden;
  padding: 27px;
  background: #202b27;
  color: #f8f9fb;
  border-radius: 8px;
}
.flowchart.article-figure::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background:
    repeating-linear-gradient(0deg, transparent 0 28px, #b6c7d9 29px 30px),
    repeating-linear-gradient(90deg, transparent 0 28px, #b6c7d9 29px 30px);
}
.flowchart figcaption {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 25px;
  font: 600 15px var(--sans);
}
.flowchart figcaption small {
  flex: none;
  color: #e7b284;
  font: 10px var(--mono);
  letter-spacing: 1px;
}
.diagram-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.flowchart .diagram-node {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 174px;
  padding: 16px 13px;
  border: 1px solid #62766b;
  background: #30423a;
}
.diagram-node small,
.trace-step > small {
  display: block;
  margin-bottom: 14px;
  color: #e6ad7c;
  font: 10px var(--mono);
  letter-spacing: 1px;
}
.diagram-node strong {
  display: block;
  color: #fff8ea;
  font: 700 13px/1.35 var(--sans);
  overflow-wrap: anywhere;
}
.diagram-node p {
  margin: 10px 0 0;
  color: #d9e7f5;
  font-size: 11px;
  line-height: 1.55;
}
.flowchart .diagram-node + .diagram-node::before {
  content: "→";
  position: absolute;
  top: 47%;
  left: -16px;
  color: #e8b17d;
  font: 18px var(--mono);
}
.diagram-steps.is-visible .diagram-node,
.trace-steps.is-visible .trace-step {
  animation: rise-in 0.5s ease both;
  animation-delay: calc(var(--step, 0) * 90ms);
}
@keyframes rise-in {
  from {
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.mermaid-source {
  position: relative;
  margin-top: 20px;
  padding-top: 13px;
  border-top: 1px solid #607997;
  color: #c3e3f4;
  font: 11px var(--mono);
}
.mermaid-source summary {
  cursor: pointer;
}
.mermaid-source pre {
  border-color: #607997;
  background: #12243b;
  color: #e6eef8;
}
.trace-figure {
  padding: 24px;
  border: 1px solid #d5ddcc;
  background: #f0f4e9;
}
.trace-figure figcaption {
  margin-bottom: 17px;
  color: #2b4f73;
  font-weight: 600;
}
.trace-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.trace-step {
  min-width: 0;
  padding: 14px;
  border-top: 3px solid var(--orange);
  background: #fff;
}
.trace-step > small {
  color: var(--orange);
}
.trace-step code {
  display: block;
  margin-bottom: 10px;
  padding: 0;
  background: none;
  color: #a5472e;
  font-size: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.trace-step strong {
  display: block;
  font-size: 12px;
}
.trace-step p {
  margin: 7px 0 0;
  color: #5a665d;
  font-size: 11px;
  line-height: 1.55;
}
.example-figure {
  border-top: 1px solid var(--border);
  padding-top: 22px;
}
.example-figure summary {
  margin-bottom: 16px;
  color: #3b5332;
  font-size: 14px;
  cursor: pointer;
}
.example-figure pre {
  margin: 0;
  border: 0;
  border-left: 4px solid var(--orange);
  background: #202925;
  color: #edf3e8;
}
.reasoning {
  display: grid;
  gap: 7px;
  margin: 16px 0 0;
  padding-left: 23px;
  color: #536052;
  font-size: 12px;
}
.article-source {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.lesson-practice {
  border: 1px solid #d4ddc7;
  border-radius: 6px;
  background: var(--surface-callout);
}
.lesson-practice h3 {
  margin: 0 0 10px;
  font: 600 16px var(--sans);
}
.lesson-practice p {
  margin-bottom: 12px;
}
.lesson-practice .practice-note {
  color: #697260;
  font-size: 12px;
}
.lesson-practice summary {
  cursor: pointer;
  font-size: 12px;
}
.example-output {
  margin-top: 16px;
}
.example-output small {
  font: 10px var(--mono);
  color: var(--muted);
}
.example-output pre {
  margin-top: 8px;
  border-left: 0;
  background: #eef2e8;
  color: #30432a;
}
.study-guide {
  max-width: 820px;
  margin: 0 auto 22px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: #626b5d;
  font-size: 13px;
}
.study-guide summary {
  cursor: pointer;
  color: #35462d;
}
.study-guide p {
  max-width: 720px;
  margin: 15px 0 0;
}
.chapter-lab {
  margin: 65px 0 0;
  padding: clamp(24px, 4vw, 43px);
  background: #1d2925;
  color: #f7f8fb;
  border-radius: 10px;
  scroll-margin-top: 24px;
}
.chapter-lab .topic-index,
.checkpoint .eyebrow {
  color: #e7ab7e;
}
.chapter-lab h2 {
  color: #fff9ed;
}
.chapter-lab .topic-lead {
  padding: 0;
  border: 0;
  background: none;
  color: #cbd9cd;
}
.task-box {
  margin: 25px 0 20px;
  padding: 17px 19px;
  border-left: 3px solid #b6d390;
  background: #2c3e34;
  font-size: 13px;
}
.task-box strong {
  display: block;
  margin-bottom: 5px;
  color: #eeb48d;
  font: 11px var(--mono);
  letter-spacing: 1px;
}
.task-box p {
  margin: 0;
}
.editor-shell {
  overflow: hidden;
  border: 1px solid #52695a;
  background: #141e19;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 15px;
  border-bottom: 1px solid #52695a;
  background: #2c3e34;
  color: #e7eee3;
  font: 11px var(--mono);
}
.editor-toolbar button {
  margin-left: 12px;
  padding: 3px;
  border: 0;
  background: none;
  color: #e4bd93;
  font: 11px var(--mono);
}
.editor-toolbar button:hover {
  text-decoration: underline;
}
.code-area {
  display: flex;
  min-height: 165px;
  padding: 17px 13px 17px 0;
}
.line-numbers {
  min-width: 45px;
  padding-right: 12px;
  border-right: 1px solid #405a49;
  color: #93ad99;
  font: 12px/1.7 var(--mono);
  text-align: right;
  user-select: none;
  white-space: pre;
}
.code-area textarea {
  display: block;
  width: 100%;
  min-height: 147px;
  padding: 0 0 0 14px;
  border: 0;
  background: transparent;
  color: #f4f2e6;
  caret-color: #e9a275;
  font: 12px/1.7 var(--mono);
  tab-size: 4;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}
.runbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin: 17px 0 24px;
}
.runbar small {
  max-width: 460px;
  color: #b5c6b6;
  font-size: 11px;
}
.primary,
.secondary {
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 700;
  font-size: 12px;
}
.primary {
  background: #c7f1a7;
  color: #24351d;
}
.primary:hover {
  background: #dbfac5;
}
.secondary {
  border-color: #bfc5b8;
  background: #fffdf5;
}
.secondary:hover {
  background: #ece8d8;
}
.output-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #c6d7c6;
  font: 10px var(--mono);
  letter-spacing: 1px;
}
.output-head span {
  letter-spacing: 0;
}
#output {
  min-height: 55px;
  margin: 8px 0;
  border: 1px solid #52695a;
  background: #141e19;
  color: #e7eee3;
}
.feedback {
  margin: 10px 0;
  padding: 11px 14px;
  background: #dbe8d4;
  color: #264333;
  font-size: 12px;
}
.feedback.error {
  background: #f1d7ca;
  color: #793523;
}
.result-details {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 23px;
}
.chapter-lab details {
  color: #d6e3d2;
  font-size: 12px;
}
.chapter-lab summary {
  cursor: pointer;
}
.chapter-lab details pre {
  max-height: 260px;
  border-color: #52695a;
  background: #141e19;
  color: #e7eee3;
  font-size: 11px;
}
.hint-details,
.solution-details {
  margin-top: 16px;
}
.hint-details p,
.solution-details ol {
  color: #d7e0d3;
  font-size: 12px;
}
.checkpoint {
  margin-top: 34px;
  padding-top: 25px;
  border-top: 1px solid #52695a;
}
.checkpoint h3 {
  max-width: 650px;
  margin-bottom: 18px;
  font: 500 23px/1.4 var(--sans);
}
.answers {
  display: grid;
  gap: 8px;
}
.answer {
  padding: 12px 15px;
  border: 1px solid #52695a;
  background: #2c3e34;
  color: #eff5eb;
  font-size: 12px;
  text-align: left;
}
.answer span {
  color: #e6a577;
  font: 11px var(--mono);
}
.answer:hover,
.answer.correct {
  border-color: #c7f1a7;
  background: #3e5746;
}
.answer.wrong {
  border-color: #df987c;
  background: #5c3a32;
}
.lesson-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 820px);
  margin: 34px auto 0;
}
.lesson-footer > span {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 75px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}
dialog {
  width: min(760px, calc(100% - 28px));
  max-height: 85vh;
  padding: 30px;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink);
}
dialog::backdrop {
  background: rgb(15 29 21 / 72%);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: start;
  margin-bottom: 18px;
}
.dialog-head h2 {
  margin: 0;
  font: 500 34px/1.15 var(--sans);
}
.icon-button {
  width: 37px;
  height: 37px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 24px;
}
#curriculum-note {
  color: var(--muted);
  font-size: 13px;
}
.roadmap-row {
  display: flex;
  gap: 20px;
  padding: 15px 0;
  border-top: 1px solid var(--border);
}
.roadmap-row > span {
  color: var(--orange);
  font: 13px var(--mono);
}
.roadmap-row strong {
  font-size: 14px;
}
.roadmap-row p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}
.roadmap-row small,
.roadmap-row a {
  font-size: 11px;
}
#toast {
  position: fixed;
  z-index: 25;
  right: 24px;
  bottom: 24px;
  max-width: 320px;
  padding: 12px 18px;
  background: var(--green-deep);
  color: white;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.2s,
    transform 0.2s;
}
#toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.chapter-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 30px;
  margin: 0;
  padding: 18px 0 24px;
  list-style: none;
  border-bottom: 1px solid var(--border);
}
.chapter-map a {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  color: #4f574a;
  font-size: 13px;
  text-decoration: none;
}
.chapter-map a:hover {
  color: #1f3821;
  text-decoration: underline;
}
.chapter-map span {
  color: #85907b;
  font: 11px/2 var(--mono);
}
@media (max-width: 1100px) {
  .sidebar {
    width: 235px;
    padding-inline: 19px;
  }
  .page {
    margin-left: 235px;
  }
  .hero {
    grid-template-columns: minmax(0, 1fr) 160px;
  }
  .hero-art {
    padding: 16px 12px;
  }
  .flowchart .diagram-node {
    min-height: 190px;
  }
}
@media (max-width: 820px) {
  .sidebar {
    position: relative;
    inset: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 22px;
  }
  .sidebar::before,
  .course-label,
  .chapter-label,
  .side-title,
  .chapter-summary,
  .sidebar-bottom p,
  .text-button {
    display: none;
  }
  .brand {
    font-size: 17px;
  }
  .course-switch {
    width: auto;
    margin-left: auto;
    padding: 9px;
  }
  .chapter-picker {
    width: min(240px, 100%);
    margin: 0;
    font-size: 9px;
  }
  .chapter-picker select {
    margin-top: 2px;
    padding: 7px;
  }
  .sidebar-bottom {
    width: 110px;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .progress-label {
    font-size: 9px;
  }
  .progress-label strong {
    font-size: 9px;
  }
  progress {
    height: 4px;
    margin-top: 4px;
  }
  .page {
    margin-left: 0;
  }
  .topbar {
    height: 48px;
  }
  main {
    padding-top: 36px;
  }
}
@media (max-width: 650px) {
  .sidebar {
    gap: 10px;
    padding: 12px 17px;
  }
  .brand {
    width: 100%;
  }
  .course-switch {
    order: 2;
    margin-left: 0;
  }
  .chapter-picker {
    order: 3;
    flex: 1;
    min-width: 160px;
  }
  .sidebar-bottom {
    order: 4;
    width: 100%;
  }
  .sidebar-bottom .progress-label {
    justify-content: flex-start;
    gap: 13px;
  }
  .sidebar-bottom progress {
    width: 100%;
  }
  .topbar {
    padding-inline: 18px;
  }
  .top-right {
    font-size: 9px;
  }
  .edition {
    margin-left: 2px;
  }
  main {
    padding: 30px 18px 65px;
  }
  .chapter-kicker {
    font-size: 8px;
  }
  .hero {
    display: block;
    min-height: 0;
    margin-top: 27px;
    padding: 0 0 32px;
  }
  .hero-art {
    display: none;
  }
  .hero h1 {
    font-size: clamp(51px, 13vw, 78px);
    letter-spacing: -2.8px;
  }
  .hero p {
    font-size: 18px;
  }
  .hero-meta {
    font-size: 9px;
  }
  .chapter-map {
    grid-template-columns: 1fr;
  }
  .chapter-opening {
    display: block;
  }
  .chapter-opening p {
    margin-top: 6px;
    text-align: left;
  }
  .topic-section {
    padding: 52px 0;
  }
  .topic-section h2,
  .chapter-lab h2 {
    font-size: 38px;
  }
  .topic-intro {
    font-size: 20px;
  }
  .flowchart.article-figure {
    padding: 18px;
  }
  .flowchart figcaption {
    align-items: flex-start;
    font-size: 13px;
  }
  .flowchart figcaption small {
    font-size: 8px;
  }
  .diagram-steps,
  .trace-steps {
    grid-template-columns: 1fr;
  }
  .flowchart .diagram-node {
    min-height: 0;
    padding: 13px;
  }
  .flowchart .diagram-node + .diagram-node::before {
    top: -18px;
    left: 50%;
    transform: rotate(90deg);
  }
  .trace-figure {
    padding: 16px;
  }
  .trace-step {
    padding: 13px;
  }
  .chapter-lab {
    margin-top: 40px;
    padding: 22px 17px;
  }
  .editor-toolbar {
    font-size: 9px;
  }
  .editor-toolbar button {
    margin-left: 5px;
    font-size: 9px;
  }
  .runbar {
    align-items: flex-start;
  }
  .runbar small {
    font-size: 10px;
  }
  .lesson-footer {
    flex-wrap: wrap;
  }
  .lesson-footer > span {
    order: 3;
    width: 100%;
  }
  .site-footer {
    flex-direction: column;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  text-align: left;
}
.theme-toggle:hover {
  background: var(--surface-hover);
}
.theme-toggle [data-theme-icon] {
  width: 17px;
  color: var(--orange);
  font-size: 16px;
  text-align: center;
}
@media (max-width: 820px) {
  .theme-toggle {
    width: auto;
    padding: 9px 10px;
  }
}
@media (max-width: 650px) {
  .theme-toggle {
    order: 2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111814;
  --white: #1b241e;
  --ink: #e7eee8;
  --muted: #b5c0b5;
  --green: #95b99e;
  --green-deep: #101712;
  --lime: #d0e8b1;
  --orange: #e39a71;
  --cyan: #9dc9be;
  --border: #39483d;
  --sidebar: #19221c;
  --surface: #1b251f;
  --surface-soft: #202d25;
  --surface-muted: #29382d;
  --surface-code: #18221c;
  --surface-note: #2a3028;
  --surface-callout: #212e26;
  --text-soft: #b6c2b6;
  --text-reading: #d3ded4;
  --text-strong: #e8f0e8;
  --accent-link: #f0ad81;
  --accent-ink: #d2e7c0;
  --control-border: #45574a;
  --focus: #f2b579;
  --surface-hover: #2b3a2f;
  --accent-wash: #29382d;
}
:root[data-theme="dark"] a {
  color: var(--accent-link);
}
:root[data-theme="dark"] button:focus-visible,
:root[data-theme="dark"] a:focus-visible,
:root[data-theme="dark"] textarea:focus-visible,
:root[data-theme="dark"] select:focus-visible,
:root[data-theme="dark"] summary:focus-visible {
  outline-color: var(--focus);
}
:root[data-theme="dark"] .sidebar {
  background: var(--sidebar);
}
:root[data-theme="dark"] .brand-icon {
  background: #26372c;
  color: var(--lime);
}
:root[data-theme="dark"] .brand-light,
:root[data-theme="dark"] .text-button {
  color: var(--muted);
}
:root[data-theme="dark"] .brand-dot,
:root[data-theme="dark"] .chapter-label,
:root[data-theme="dark"] .progress-label strong {
  color: var(--orange);
}
:root[data-theme="dark"] .course-switch,
:root[data-theme="dark"] .chapter-picker select,
:root[data-theme="dark"] .theme-toggle {
  border-color: var(--control-border);
  background: var(--surface);
  color: var(--ink);
}
:root[data-theme="dark"] .course-switch:hover,
:root[data-theme="dark"] .theme-toggle:hover {
  background: var(--surface-hover);
}
:root[data-theme="dark"] .sidebar-bottom {
  border-color: var(--border);
}
:root[data-theme="dark"] progress,
:root[data-theme="dark"] progress::-webkit-progress-bar {
  background: #2c392f;
}
:root[data-theme="dark"] progress {
  accent-color: var(--orange);
}
:root[data-theme="dark"] progress::-webkit-progress-value {
  background: var(--orange);
}
:root[data-theme="dark"] .breadcrumb {
  color: #87958a;
}
:root[data-theme="dark"] .edition {
  color: var(--text-soft);
}
:root[data-theme="dark"] .pill {
  background: var(--accent-wash);
  color: var(--accent-ink);
}
:root[data-theme="dark"] .hero h1 span {
  color: #b5d294;
}
:root[data-theme="dark"] .hero p {
  color: var(--text-soft);
}
:root[data-theme="dark"] .hero-actions a {
  border-color: #b8d69f;
  background: #b8d69f;
  color: #18231b;
}
:root[data-theme="dark"] .hero-actions a + a {
  border-color: var(--control-border);
  background: transparent;
  color: var(--ink);
}
:root[data-theme="dark"] .hero-art {
  border-color: #3b5244;
  background: #1a2921;
  box-shadow: 7px 7px 0 #0c120e;
  color: #dbe8dc;
}
:root[data-theme="dark"] .hero-art small {
  color: #b2c5af;
}
:root[data-theme="dark"] .hero-art .rust-stamp {
  border-color: #536653;
  color: #efb18a;
}
:root[data-theme="dark"] .topic-index span {
  color: #829184;
}
:root[data-theme="dark"] .topic-intro {
  color: #c6d4cb;
}
:root[data-theme="dark"] .topic-lead,
:root[data-theme="dark"] .reading p,
:root[data-theme="dark"] .reading li,
:root[data-theme="dark"] .study-guide,
:root[data-theme="dark"] .reasoning {
  color: var(--text-reading);
}
:root[data-theme="dark"] .reading strong {
  color: var(--text-strong);
}
:root[data-theme="dark"] code {
  background: #28352b;
  color: #d1e6b5;
}
:root[data-theme="dark"] pre {
  border-color: var(--border);
  background: var(--surface-code);
  color: #dce8dd;
}
:root[data-theme="dark"] aside:not(.sidebar) {
  background: var(--surface-note);
  color: var(--ink);
}
:root[data-theme="dark"] .trace-figure {
  border-color: #3c5142;
  background: #1c2921;
}
:root[data-theme="dark"] .trace-figure figcaption {
  color: #bed4c1;
}
:root[data-theme="dark"] .trace-step {
  background: #26352b;
}
:root[data-theme="dark"] .trace-step code {
  color: #f0ad81;
}
:root[data-theme="dark"] .trace-step p {
  color: #c0cdc1;
}
:root[data-theme="dark"] .example-figure summary,
:root[data-theme="dark"] .study-guide summary {
  color: #cce2b5;
}
:root[data-theme="dark"] .lesson-practice {
  border-color: #3c5142;
  background: var(--surface-callout);
}
:root[data-theme="dark"] .lesson-practice .practice-note {
  color: var(--text-soft);
}
:root[data-theme="dark"] .example-output pre {
  background: #26352b;
  color: #dce8dd;
}
:root[data-theme="dark"] .secondary {
  border-color: var(--control-border);
  background: var(--surface);
  color: var(--ink);
}
:root[data-theme="dark"] .secondary:hover {
  background: var(--surface-hover);
}
:root[data-theme="dark"] dialog {
  background: var(--surface);
  color: var(--ink);
}
:root[data-theme="dark"] .chapter-map a {
  color: var(--text-reading);
}
:root[data-theme="dark"] .chapter-map a:hover {
  color: var(--lime);
}
:root[data-theme="dark"] .chapter-map span {
  color: #a2b09f;
}
:root[data-theme="dark"] ::selection {
  background: #45634e;
  color: #f1f5ef;
}
