:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #263332; background: #fff; font-synthesis: none; line-height: 1.7;
  --accent: #087f5b; --accent-dark: #066247; --accent-soft: #e7f4ee;
  --muted: #64716f; --border: #dfe5e2; --sidebar: 286px; --header: 64px;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
button { border: 1px solid var(--border); border-radius: 5px; background: #fff; color: inherit; padding: 9px 15px; line-height: 1.4; font-size: .875rem; font-weight: 600; }
button:hover { background: #f1f5f3; border-color: #bdccc4; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent-dark); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #08885e; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 15px; z-index: 60; background: #fff; padding: 12px 20px; }
.skip-link:focus { top: 8px; }
.site-header { height: var(--header); position: fixed; inset: 0 0 auto; display: flex; align-items: center; gap: 32px; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--border); z-index: 30; }
.brand-group { display: flex; align-items: center; gap: 12px; width: calc(var(--sidebar) - 28px); flex-shrink: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #22332d; text-decoration: none; font-size: 1.05rem; font-weight: 750; letter-spacing: -.025em; }
.brand-mark { background: var(--accent); color: #fff; font: 700 17px/31px ui-monospace, monospace; width: 33px; height: 33px; text-align: center; border-radius: 6px; }
.header-caption { font-size: .8rem; color: var(--muted); }
.header-links { display: flex; align-items: center; gap: 25px; margin-left: auto; font-size: .85rem; }
.header-links a { color: var(--muted); text-decoration: none; }
.header-links a:hover { color: var(--accent); }
.text-button { border: 0; background: transparent; color: var(--accent-dark); padding: 0; font: inherit; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { background: transparent; }
.header-links button { text-decoration: none; font-size: .85rem; padding: 7px 10px; border-radius: 4px; }
.header-links button[aria-pressed=true] { background: var(--accent-soft); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; border: 0; padding: 6px; width: 36px; height: 36px; font-size: 26px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
#menu-toggle, #menu-close { display: none; }
.course-sidebar { position: fixed; top: var(--header); bottom: 0; left: 0; width: var(--sidebar); display: flex; flex-direction: column; background: #f6f8f7; border-right: 1px solid var(--border); z-index: 20; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 25px 22px 16px; }
.eyebrow { margin: 0; color: var(--muted); font-size: .7rem; font-weight: 650; letter-spacing: .075em; line-height: 1.5; }
.sidebar-heading h2 { font-size: 1rem; margin: 4px 0 0; font-weight: 700; }
.lesson-search { display: flex; align-items: center; gap: 8px; margin: 0 18px 20px; border: 1px solid #d9e0dc; background: #fff; padding: 0 10px; border-radius: 5px; color: #71817a; }
.lesson-search input { border: 0; background: transparent; width: 100%; min-width: 0; padding: 9px 0; font-size: .8rem; color: #263332; }
.lesson-search:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.lesson-search input:focus { outline: none; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-bottom: 18px; }
.chapter { margin: 0 10px 4px; }
.chapter > summary { display: grid; grid-template-columns: 23px 1fr 12px; gap: 8px; align-items: start; list-style: none; font-size: .8rem; line-height: 1.45; padding: 11px 10px; border-radius: 4px; color: #45534c; font-weight: 600; }
.chapter > summary::-webkit-details-marker { display: none; }
.chapter > summary::after { content: '›'; font-size: 19px; line-height: 1; transition: transform .12s; }
.chapter[open] > summary::after { transform: rotate(90deg); }
.chapter > summary:hover { background: #e9eeeb; }
.chapter.current > summary { color: #1c382b; }
.chapter-number { color: #7c8982; font-size: .7rem; padding-top: 2px; font-variant-numeric: tabular-nums; }
.chapter-lessons { padding-bottom: 6px; }
.lesson-link { display: flex; align-items: baseline; gap: 8px; width: 100%; border: 0; border-radius: 4px; background: transparent; padding: 8px 12px 8px 41px; text-align: left; color: #59665f; font-size: .79rem; line-height: 1.5; font-weight: 400; }
.lesson-link:hover { background: #eaf0ec; }
.lesson-link[aria-current=page] { background: #deeee4; color: #095c3c; font-weight: 650; box-shadow: inset 3px 0 var(--accent); }
.lesson-link .read-mark { margin-left: auto; color: var(--accent); font-size: .72rem; }
.chapter-review { font-weight: 600; color: var(--accent-dark); margin-top: 3px; }
.search-empty { font-size: .85rem; padding: 0 22px; color: var(--muted); }
.bank-links { padding: 20px 20px 0; margin-top: 16px; border-top: 1px solid var(--border); }
.bank-links p { margin-bottom: 8px; }
.bank-links button { display: flex; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; padding: 9px 0; font-size: .8rem; font-weight: 500; text-align: left; color: #4f6257; }
.bank-links button[aria-current=page] { color: var(--accent-dark); font-weight: 750; }
.sidebar-progress { border-top: 1px solid var(--border); padding: 16px 22px 14px; background: #f6f8f7; }
.sidebar-progress > div { display: flex; justify-content: space-between; gap: 10px; font-size: .74rem; color: #53635a; }
progress { display: block; width: 100%; height: 4px; appearance: none; border: 0; border-radius: 8px; overflow: hidden; margin: 10px 0; background: #e0e7e2; }
progress::-webkit-progress-bar { background: #e0e7e2; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.sidebar-progress .small { font-size: .68rem; }
.main-content { margin-left: var(--sidebar); padding: calc(var(--header) + 42px) clamp(28px, 4.8vw, 80px) 20px; min-height: 100vh; }
#app { max-width: 920px; margin: 0 auto; }
.page-heading { margin-bottom: 26px; }
.page-heading .eyebrow { color: #67786e; letter-spacing: .025em; text-transform: none; font-size: .78rem; }
h1 { margin: 13px 0 12px; font-size: clamp(1.85rem, 2.8vw, 2.6rem); line-height: 1.18; letter-spacing: -.035em; font-weight: 650; color: #23372c; text-wrap: balance; }
.page-description { color: #647169; font-size: 1rem; line-height: 1.7; max-width: 75ch; margin: 0; }
.view-navigation { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); margin-bottom: 28px; gap: 10px; }
.view-navigation > div { display: flex; gap: 22px; }
.view-navigation button { border: 0; border-radius: 0; border-bottom: 3px solid transparent; padding: 12px 2px; background: transparent; color: var(--muted); font-size: .9rem; }
.view-navigation button[aria-pressed=true] { color: var(--accent-dark); border-bottom-color: var(--accent); }
#practice-count { display: inline-block; margin-left: 5px; font-size: .7rem; background: #edf2ef; padding: 1px 7px; border-radius: 10px; }
#concept-position { color: var(--muted); font-size: .75rem; }
.lesson-pager { display: flex; justify-content: space-between; margin-bottom: 22px; }
.lesson-pager button { font-size: .8rem; padding: 8px 13px; }
.chapter-overview { margin: 0 0 24px; color: var(--muted); font-size: .85rem; }
.chapter-overview summary { font-size: .8rem; }
.chapter-overview p { padding-left: 16px; border-left: 2px solid var(--border); }
.concept-card { font-size: 1rem; }
.concept-card > p { max-width: 78ch; margin: 0 0 19px; }
.concept-card .recap { font-size: .82rem; color: var(--muted); margin-bottom: 25px; }
.concept-card h2 { font-size: 1.3rem; font-weight: 650; letter-spacing: -.02em; margin: 0 0 17px; line-height: 1.4; }
.lesson-diagram { margin: 30px 0 38px; }
.lesson-diagram img { display: block; width: 100%; max-width: 840px; height: auto; border-radius: 4px; }
figcaption { color: var(--muted); font-size: .78rem; margin: 12px 0 0; max-width: 85ch; }
.worked-example { padding: 25px; background: #f5f7f6; border: 1px solid #e7ece8; border-radius: 6px; margin: 34px 0; }
.worked-example h3 { margin: 0 0 10px; color: #536259; font-size: .75rem; font-weight: 600; }
.code-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { min-width: 0; }
pre, textarea, code { font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
pre, textarea { font-size: .84rem; line-height: 1.8; tab-size: 2; }
pre { margin: 0; padding: 18px; background: #fff; color: #263c32; border: 1px solid #dde5df; border-radius: 4px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.worked-example ol { padding-left: 24px; margin: 22px 0 0; font-size: .93rem; }
.worked-example li { padding-left: 4px; margin: 10px 0; }
.worked-example li::marker { color: var(--accent); font-weight: 650; }
.teach-back { margin: 36px 0; padding: 2px 0 2px 20px; border-left: 3px solid #b7d9c5; }
.teach-back p { margin: 0 0 14px; }
summary { color: #375646; font-weight: 550; }
.teach-back summary { font-size: .86rem; }
.teach-back details p { margin: 16px 0 0; font-size: .93rem; }
.step-practice { margin: 38px 0; }
.practice-links { display: grid; gap: 0; }
.practice-links button { border: 0; border-bottom: 1px solid #e8ede9; border-radius: 0; padding: 13px 0; background: transparent; color: var(--accent-dark); text-align: left; display: flex; align-items: center; gap: 14px; font-weight: 500; }
.practice-links button:hover { background: #f5f9f6; }
.practice-kind { width: 57px; flex-shrink: 0; color: #708178; font-size: .7rem; }
.practice-links button::after { content: '→'; margin-left: auto; }
.concept-actions { display: flex; justify-content: space-between; gap: 15px; padding-top: 28px; border-top: 1px solid var(--border); margin-top: 35px; }
.small { color: var(--muted); font-size: .78rem; line-height: 1.65; margin: 10px 0; }
.concept-card > .small { margin-top: 14px; font-size: .74rem; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.practice-context { font-size: .9rem; color: var(--muted); margin: 0 0 22px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 15px; }
.modes { display: flex; padding: 4px; background: #f1f4f2; border-radius: 5px; gap: 3px; }
.modes button { background: transparent; border: 0; color: var(--muted); padding: 8px 11px; font-size: .79rem; }
.modes button[aria-pressed=true] { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 3px #182e1710; }
.modes span { font-size: .7rem; margin-left: 4px; }
.scope-label, .topic-label, .jump-label { display: flex; align-items: center; gap: 9px; font-size: .75rem; color: var(--muted); }
select { color: #344c3e; background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 8px 24px 8px 10px; max-width: 100%; min-width: 0; font-size: .8rem; }
.progress-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; font-size: .72rem; color: var(--muted); }
.progress-row p { margin: 0; }
#progress { margin: 9px 0 29px; height: 3px; }
.question-heading { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; margin-bottom: 24px; }
.question-heading h2 { font-size: 1.4rem; line-height: 1.4; font-weight: 650; margin: 7px 0 0; letter-spacing: -.02em; }
.jump-label { max-width: 40%; flex-shrink: 0; flex-direction: column; align-items: flex-start; gap: 4px; }
.contract { font-size: .82rem; color: var(--muted); margin-bottom: 15px; }
.contract p { margin: 10px 0 18px; }
.output-contract { background: #eff6f1; padding: 13px 17px; font-size: .82rem; border-left: 3px solid #90bfa1; margin: 0 0 25px; }
.panel-heading { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.panel-heading h3, .panel-heading label { font-size: .9rem; font-weight: 650; margin: 0; }
.panel-heading span { font-size: .72rem; color: var(--muted); }
textarea { display: block; width: 100%; min-height: 260px; resize: vertical; padding: 18px; border: 1px solid #a9bdb0; border-radius: 4px; background: #fcfdfc; color: #23392c; }
textarea::placeholder { color: #88988d; }
#c-code { display: block; min-height: 210px; }
#case-details { margin-top: 15px; font-size: .8rem; }
.case { padding: 12px 0; border-top: 1px solid var(--border); }
.case h4 { margin: 5px 0; font-size: .9rem; }
.case p { font-size: .76rem; overflow-wrap: anywhere; }
.case table { font-size: .73rem; border-collapse: collapse; width: 100%; table-layout: fixed; }
.case td, .case th { padding: 6px; text-align: left; border-bottom: 1px solid #e7ece8; overflow-wrap: anywhere; }
.case details { font-size: .75rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 1rem; font-weight: 500; line-height: 1.8; white-space: pre-wrap; padding: 0; margin-bottom: 16px; }
.option { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--border); padding: 14px 17px; margin: 10px 0; border-radius: 5px; font-size: .93rem; cursor: pointer; }
.option:hover { background: #f7f9f7; }
.option:has(input:checked) { border-color: var(--accent); background: #f0f8f3; }
.option input { accent-color: var(--accent); margin-top: 7px; flex-shrink: 0; }
.option.correct { border-color: #7eb999; background: #eff8f2; }
.option.wrong { border-color: #cf9b8b; background: #fff4f0; }
.feedback, .hint, .solution { margin-top: 22px; padding: 17px 20px; border: 1px solid var(--border); border-radius: 5px; font-size: .9rem; overflow-wrap: anywhere; }
.feedback p { margin: 0; }
.feedback ul { margin: 8px 0 0; padding-left: 22px; }
.feedback.success { background: #edf8f0; border-color: #a5ceb2; color: #235d37; }
.feedback.error { background: #fff4ef; border-color: #dfb39d; color: #853a23; }
.feedback.info, .hint { background: #f0f5f8; border-color: #c8d9e2; color: #36576b; }
.solution { background: #f7f9f7; }
.solution h3 { margin: 0; font-size: 1rem; }
.solution p { font-size: .82rem; }
.actions { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-top: 25px; }
.action-group { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { font-size: .8rem; }
#trace-panel { margin-top: 30px; border-top: 1px solid var(--border); padding-top: 16px; font-size: .85rem; }
#trace-panel label { display: inline-flex; align-items: center; gap: 10px; margin: 10px 8px 10px 0; }
#trace-panel h3 { margin: 10px 0; font-size: 1.2rem; }
#trace-state { margin-top: 14px; max-height: 530px; overflow: auto; }
.summary { padding: 35px 20px; background: #f4f8f5; border: 1px solid var(--border); border-radius: 5px; text-align: center; }
.summary h2 { font-size: 1.6rem; font-weight: 600; }
.summary button { margin: 7px; }
.reference > details { border-bottom: 1px solid var(--border); padding: 21px 0; }
.reference > details:first-child { padding-top: 0; }
.reference > details > summary { font-size: 1rem; }
.reference details[open] > summary { margin-bottom: 20px; }
.reference-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.reference h3 { font-size: 1rem; margin: 0 0 10px; }
.reference p { font-size: .9rem; overflow-wrap: anywhere; }
.reference code { font-size: .84em; background: #f0f4f1; padding: 2px 4px; }
.import-label { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; }
.import-label input { max-width: 100%; }
.danger { color: #a34432; font-size: .8rem; }
.notice { max-width: 920px; margin: 16px auto; border-left: 3px solid #8dad97; background: #f0f6f2; padding: 18px; }
.notice button { margin-left: 12px; }
.page-footer { display: flex; justify-content: space-between; gap: 15px; padding: 24px 0 12px; border-top: 1px solid #e9eeea; margin-top: 55px; font-size: .7rem; color: #7a877e; }
.sidebar-backdrop { position: fixed; inset: var(--header) 0 0; background: #172c2259; z-index: 35; border: 0; border-radius: 0; padding: 0; }
.sidebar-backdrop:hover { background: #172c2259; }
[tabindex='-1']:focus { outline: none; }
#main-content, #concept-card, #exercise { scroll-margin-top: 88px; }
@media (min-width: 1500px) { :root { --sidebar: 300px; } .main-content { padding-right: max(60px, calc((100vw - 1350px) / 2)); padding-left: max(60px, calc((100vw - 1350px) / 2)); } }
@media (max-width: 1150px) { :root { --sidebar: 260px; } .site-header { gap: 10px; padding: 0 20px; } .brand-group { width: calc(var(--sidebar) - 20px); } .main-content { padding-left: 32px; padding-right: 32px; } .header-caption { display: none; } .worked-example .code-panels { grid-template-columns: 1fr; } .question-heading { flex-direction: column; gap: 14px; } .jump-label { max-width: 100%; flex-direction: row; align-items: center; } }
@media (max-width: 820px) {
  :root { --sidebar: min(310px, 86vw); --header: 60px; }
  .site-header { padding: 0 18px; gap: 14px; }
  .brand-group { width: auto; gap: 9px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 29px; height: 29px; line-height: 28px; font-size: 15px; }
  .header-links { gap: 12px; }
  .header-links a { font-size: .75rem; }
  #menu-toggle, #menu-close { display: inline-flex; }
  .course-sidebar { visibility: hidden; transform: translateX(-100%); z-index: 40; box-shadow: 10px 0 35px #16312220; }
  body.sidebar-open .course-sidebar { visibility: visible; transform: translateX(0); }
  body.sidebar-open { overflow: hidden; }
  .main-content { margin-left: 0; padding: calc(var(--header) + 30px) 28px 15px; }
  .worked-example .code-panels { grid-template-columns: 1fr 1fr; }
  .chapter > summary { font-size: .85rem; }
  .lesson-link { font-size: .83rem; padding-top: 10px; padding-bottom: 10px; }
}
@media (max-width: 560px) {
  .site-header { padding: 0 12px; }
  .header-links a { display: none; }
  .header-links button { padding: 8px 5px; font-size: .8rem; }
  .main-content { padding-left: 20px; padding-right: 20px; }
  .page-heading { margin-bottom: 18px; }
  h1 { font-size: 1.9rem; }
  .page-description { font-size: .94rem; }
  .view-navigation { margin-bottom: 22px; }
  #concept-position { font-size: .68rem; }
  .view-navigation > div { gap: 18px; }
  .concept-card { font-size: .95rem; }
  .worked-example { padding: 19px 16px; margin: 28px -4px; }
  .code-panels, .worked-example .code-panels, .reference-grid { grid-template-columns: 1fr; }
  .lesson-diagram { margin: 27px -4px; }
  .concept-actions { flex-wrap: wrap; }
  .concept-actions button { font-size: .78rem; padding: 10px 12px; }
  .concept-actions .primary { margin-left: auto; }
  .toolbar { gap: 13px; }
  .modes { width: 100%; }
  .modes button { flex: 1; }
  .progress-row { flex-direction: column; gap: 2px; }
  .jump-label { width: 100%; }
  .jump-label select { flex: 1; }
  .actions { gap: 20px; }
  .actions > .action-group:last-child { width: 100%; justify-content: space-between; }
  .page-footer { flex-direction: column; gap: 3px; }
  pre, textarea { font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
@media print { .site-header, .course-sidebar, .view-navigation, .lesson-pager, .concept-actions, .practice-links, .page-footer { display: none !important; } .main-content { margin: 0; padding: 0; } .worked-example, figure { break-inside: avoid; } }
