:root {
  color-scheme: dark;
  --bg: #09101e;
  --surface: #131e32;
  --surface-alt: #192840;
  --code: #0b1527;
  --text: #f1f5ff;
  --muted: #b4c2d8;
  --line: #2d3e59;
  --accent: #92adff;
  --accent-strong: #b6c6ff;
  --mint: #75dccc;
  --shadow: 0 18px 48px rgba(0, 0, 0, .24);
  --glow: rgba(87, 123, 250, .15);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-alt: #eef3fc;
  --code: #16223a;
  --text: #16223b;
  --muted: #53627a;
  --line: #dbe3ef;
  --accent: #3159d9;
  --accent-strong: #2446b8;
  --mint: #0b806f;
  --shadow: 0 18px 46px rgba(30, 56, 99, .08);
  --glow: rgba(87, 123, 250, .07);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }
body {
  margin: 0; min-width: 320px;
  font: 16px/1.65 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse 85% 48% at 80% -12%, var(--glow), transparent 75%), var(--bg);
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.18; letter-spacing: -.035em; }
h1 { font-size: clamp(2.25rem, 4.9vw, 4.5rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.15rem); }
a { color: var(--accent); text-underline-offset: 4px; }
a:hover { color: var(--accent-strong); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--mint); outline-offset: 4px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.container-wide { width: min(1330px, calc(100% - 3.5rem)); margin-inline: auto; }
.eyebrow { color: var(--mint); font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; margin: 0; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 720px; }
.skip-link { position: fixed; left: 12px; top: -110px; z-index: 100; padding: .7rem 1rem; background: var(--surface); border-radius: .5rem; }
.skip-link:focus { top: 12px; }
.site-header { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 91%, transparent); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 76px; }
.brand { color: var(--text); display: inline-flex; align-items: center; gap: .8rem; font-weight: 800; font-size: 1.1rem; letter-spacing: -.025em; text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; font-weight: 900; background: linear-gradient(135deg, #4b6fff, #61c5ff); color: white; box-shadow: 0 0 22px rgba(87, 130, 255, .18); }
.brand-muted { font-weight: 450; color: var(--muted); }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: 1.5rem; }
.top-nav a { font-size: .92rem; text-decoration: none; color: var(--muted); }
.top-nav a:hover { color: var(--text); }
/* Native disclosure keeps navigation keyboard/touch accessible without JavaScript. */
.mobile-nav { display: none; }
.mobile-nav summary {
  cursor: pointer; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .9rem; font-weight: 700; min-height: 44px;
  align-items: center; justify-content: center;
}
.mobile-nav[open] summary { border-color: var(--mint); }
.mobile-menu-links {
  position: absolute; top: calc(100% + .5rem); right: 0; z-index: 60;
  width: min(310px, calc(100vw - 2rem)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: .45rem; box-shadow: var(--shadow);
}
.mobile-menu-links a {
  display: flex; min-height: 44px; align-items: center;
  padding: .6rem .85rem; border-radius: 9px;
  color: var(--text); text-decoration: none; font-weight: 650;
}
.mobile-menu-links a:hover, .mobile-menu-links a:focus-visible {
  background: var(--surface-alt); color: var(--accent);
}
.theme-button { border: 1px solid var(--line); color: var(--text); background: var(--surface); border-radius: 10px; padding: .5rem .75rem; font: inherit; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.theme-button:hover, .copy-button:hover { border-color: var(--accent); }
.hero { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); align-items: center; gap: clamp(2rem, 5vw, 6rem); padding: clamp(3.25rem, 7vw, 7rem) 0 4.5rem; }
.hero h1 { margin: 1.2rem 0 1.4rem; font-weight: 830; max-width: 790px; }
.hero h1 span { background: linear-gradient(90deg, #93aeff, #8adbd5); color: transparent; -webkit-background-clip: text; background-clip: text; }
.hero .lead { margin: 0 0 2rem; max-width: 660px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px var(--mint); }
.hero-buttons { display: flex; flex-wrap: wrap; gap: .9rem; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: .75rem; padding: .9rem 1.35rem; border-radius: 12px; text-decoration: none; font-weight: 750; font-size: .95rem; }
.primary-button { background: linear-gradient(125deg, #6c88ff, #4a7cec); color: #fff; box-shadow: 0 10px 28px rgba(52, 103, 245, .18); }
.primary-button:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.secondary-button:hover { color: var(--text); border-color: var(--accent); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 2.5rem; color: var(--muted); font-size: .86rem; }
.hero-stats strong { color: var(--text); }
.hero-terminal { background: var(--code); border: 1px solid #304462; border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; transform: rotate(1deg); }
.terminal-heading { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: .9rem 1.25rem; background: #17233a; color: #bdcbe0; font: .83rem ui-monospace, SFMono-Regular, Consolas, monospace; border-bottom: 1px solid #2d3c57; }
.terminal-heading span:first-child { color: #ff8b91; letter-spacing: .2em; }
.hero-terminal pre { margin: 0; padding: 1.7rem; min-height: 210px; font-size: clamp(.8rem, 1.2vw, .96rem); line-height: 1.85; color: #d9e8ff; overflow-x: auto; }
.terminal-result { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-top: 1px solid #2d3c57; background: #101e32; color: #a7c9e9; font-size: .82rem; }
.terminal-result code { color: #8ce6c4; }
.search-area { margin: 0 auto 5rem; padding: 2.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.7rem; }
.section-heading h2 { margin: .35rem 0 0; }
.section-heading > p { color: var(--muted); margin: 0; }
#lesson-search { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 13px; color: var(--text); padding: 1rem 1.1rem; font: inherit; }
#lesson-search::placeholder { color: var(--muted); opacity: .85; }
#search-status { font-size: .88rem; color: var(--muted); margin: .65rem 0 0; }
.search-results { padding: 0; margin: .7rem 0 0; list-style: none; display: grid; gap: .4rem; }
.search-results:empty { display: none; }
.search-results a { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); }
.search-results a:hover { border-color: var(--accent); background: var(--surface-alt); }
.search-results small { color: var(--muted); }
.chapters { padding-bottom: 5.5rem; }
.chapter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.15rem; }
.chapter-tile { position: relative; display: flex; flex-direction: column; min-height: 245px; padding: 1.65rem; text-decoration: none; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.chapter-tile:hover { color: var(--text); transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.chapter-tile h3 { margin: .8rem 0 .55rem; font-size: 1.35rem; }
.chapter-tile p { margin: 0 0 1.5rem; color: var(--muted); font-size: .91rem; }
.chapter-action { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: .9rem; border-top: 1px solid var(--line); color: var(--accent); font-size: .89rem; font-weight: 750; }
.compat-panel { display: grid; grid-template-columns: 1.2fr .6fr; gap: 3rem; align-items: center; margin-bottom: 6rem; border: 1px solid var(--line); background: var(--surface-alt); padding: 2.1rem; border-radius: 20px; }
.compat-panel h2 { margin: .5rem 0 1rem; }
.compat-panel p { color: var(--muted); margin: .55rem 0; }
.compat-panel strong { color: var(--text); }
.compat-links { display: grid; gap: .6rem; }
.compat-links a { display: block; padding: .9rem 1rem; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-weight: 650; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .84rem; }
.footer-inner { padding: 1.5rem 0; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.chapter-page { padding-block: 2rem 5rem; }
.breadcrumbs { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; font-size: .84rem; color: var(--muted); margin: .4rem 0 2.5rem; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs [aria-current] { color: var(--text); }
.page-heading { margin-bottom: 3rem; max-width: 850px; }
.page-heading h1 { font-size: clamp(2.3rem, 4vw, 3.7rem); margin: .7rem 0 1rem; }
.page-heading .lead { margin: 0 0 1.5rem; }
.guide-links { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .91rem; font-weight: 700; }
.chapter-list h2 { margin-bottom: 1.5rem; }
.lesson-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.lesson-card { min-width: 0; display: flex; align-items: center; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; color: var(--text); text-decoration: none; transition: border-color .18s, background .18s; }
.lesson-card:hover { border-color: var(--accent); background: var(--surface-alt); color: var(--text); }
.lesson-number { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--surface-alt); border: 1px solid var(--line); color: var(--accent); font: 700 .9rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.lesson-description { display: grid; gap: .25rem; min-width: 0; }
.lesson-description strong { font-size: 1rem; }
.lesson-description > span { color: var(--muted); font-size: .85rem; }
.lesson-arrow { color: var(--accent); margin-left: auto; }
.fine-print { color: var(--muted); font-size: .83rem; margin: 2rem 0; }
.detail-layout { display: grid; grid-template-columns: minmax(220px, 255px) minmax(0, 1fr); gap: 2.4rem; align-items: start; padding: 2.2rem 0 5rem; }
.sidebar { position: sticky; top: 105px; max-height: calc(100vh - 125px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; }
.sidebar-heading { display: grid; gap: .4rem; padding: .5rem .65rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: .55rem; }
.sidebar-heading strong { font-size: .95rem; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a { display: flex; gap: .7rem; align-items: center; border-radius: 9px; padding: .58rem .65rem; color: var(--muted); text-decoration: none; font-size: .87rem; }
.sidebar nav a span { font: 750 .78rem ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--accent); }
.sidebar nav a:hover { background: var(--surface-alt); color: var(--text); }
.sidebar nav a.active { background: var(--surface-alt); color: var(--text); box-shadow: inset 3px 0 var(--accent); font-weight: 750; }
.sidebar-return { display: block; font-size: .85rem; padding: 1rem .65rem .3rem; border-top: 1px solid var(--line); margin-top: .8rem; text-decoration: none; }
.lesson-main { min-width: 0; }
.lesson-main .breadcrumbs { margin-bottom: 2rem; }
.lesson-heading { margin-bottom: 2.4rem; }
.lesson-heading h1 { font-size: clamp(2.25rem, 4vw, 3.5rem); }
.code-grid { display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(0, .78fr); gap: 1rem; align-items: stretch; }
.code-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); display: flex; flex-direction: column; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font: 700 .94rem ui-monospace, SFMono-Regular, Consolas, monospace; margin: .18rem 0 0; overflow-wrap: anywhere; letter-spacing: -.01em; }
.panel-heading .eyebrow { font-size: .65rem; }
.copy-button { flex: none; font: 700 .8rem system-ui, sans-serif; padding: .45rem .7rem; border-radius: 8px; color: var(--text); background: var(--surface-alt); border: 1px solid var(--line); cursor: pointer; }
.verified-tag { padding: .25rem .55rem; border: 1px solid var(--mint); border-radius: 50px; color: var(--mint); font-size: .72rem; font-weight: 700; }
.code-panel pre { margin: 0; flex: 1; max-height: 580px; overflow: auto; background: var(--code); padding: 1.3rem; font: .84rem/1.8 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; color: #e2ecff; tab-size: 4; }
.code-panel pre code { white-space: pre; }
.panel-footer { padding: .7rem 1.2rem; border-top: 1px solid var(--line); font-size: .82rem; }
.output-note { margin: .5rem 1.2rem; font-size: .8rem; color: var(--muted); }
.run-panel { margin-top: 1.4rem; padding: 1.6rem; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-alt); }
.run-panel h2 { margin: .4rem 0 .6rem; font-size: 1.45rem; }
.run-panel p { margin: .5rem 0; color: var(--muted); }
.run-panel p strong { color: var(--text); }
.commands { display: grid; gap: .55rem; margin: 1.2rem 0; }
.commands code { display: block; overflow-x: auto; padding: .8rem 1rem; border-radius: 10px; background: var(--code); color: #dce7ff; white-space: pre; font: .83rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.step-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.step-nav > a, .step-disabled { display: grid; gap: .3rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); text-decoration: none; }
.step-nav > a:hover { border-color: var(--accent); }
.step-nav > a > span { color: var(--muted); font-size: .8rem; }
.step-nav > a > strong { color: var(--text); }
.step-disabled { color: var(--muted); font-size: .86rem; }
@media (max-width: 1130px) {
  .hero { grid-template-columns: 1fr; gap: 2.4rem; }
  .hero-terminal { max-width: 720px; transform: none; }
  .chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .code-grid { grid-template-columns: 1fr; }
}
@media (max-width: 870px) {
  .detail-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .sidebar nav { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .top-nav { gap: .8rem; }
  .top-nav a { font-size: .82rem; }
}
@media (max-width: 680px) {
  .container-wide { width: min(100% - 2rem, 1330px); }
  .site-header { position: static; }
  .header-inner { flex-wrap: wrap; padding: .8rem 0; gap: .7rem; }
  .top-nav { display: none; }
  .mobile-nav { display: block; position: relative; order: 2; margin-left: auto; }
  .mobile-nav summary { display: flex; }
  .mobile-nav:not([open]) > .mobile-menu-links { display: none; }
  .brand { font-size: 1rem; }
  .theme-button { margin-left: 0; order: 3; min-height: 44px; }
  .hero { padding: 3rem 0; }
  .hero h1 { font-size: clamp(2.1rem, 9vw, 3.2rem); }
  .search-area, .compat-panel { padding: 1.35rem; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: .5rem; }
  .chapter-grid, .lesson-list, .compat-panel, .step-nav { grid-template-columns: 1fr; }
  .chapter-tile { min-height: 205px; }
  .chapter-page, .detail-layout { padding-top: 1.5rem; }
  .sidebar nav { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .page-heading h1 { font-size: 2.25rem; }
  .hero-stats { gap: .75rem; }
  .footer-inner { display: grid; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Non-JavaScript visitors can still follow every chapter and lesson link. */
.theme-button, .copy-button, #lesson-search { display: none; }
html.js-ready .theme-button, html.js-ready .copy-button { display: inline-flex; }
html.js-ready #lesson-search { display: block; }

/* Decorative Scarp syntax colors on the dark code canvas. */
.code-panel .syntax-keyword { color: #b9b5ff; font-weight: 650; }
.code-panel .syntax-string { color: #99e1b4; }
.code-panel .syntax-number { color: #f6c28b; }
.code-panel .syntax-comment { color: #a5b7d0; font-style: italic; }


/* Bilingual explanations use the existing, source-linked chapter curriculum.
   Both languages stay visible without JavaScript and on printed pages. */
.lesson-notes {
  margin-top: 1.45rem;
  padding: clamp(1.1rem, 2.3vw, 1.8rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.notes-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.15rem;
  margin-bottom: 1.2rem;
}
.notes-heading h2 { font-size: 1.55rem; margin: .3rem 0 0; }
.language-switch { display: none; gap: .35rem; padding: .3rem; border: 1px solid var(--line); background: var(--surface-alt); border-radius: 12px; }
html.js-ready .language-switch { display: flex; }
.note-lang-button {
  border: 1px solid transparent; border-radius: 9px;
  padding: .45rem .95rem; background: transparent; color: var(--muted);
  font: 700 .87rem/1.4 system-ui, sans-serif; cursor: pointer;
}
.note-lang-button[aria-pressed="true"] {
  background: var(--surface); color: var(--text);
  border-color: var(--line); box-shadow: 0 3px 10px rgba(0,0,0,.08);
}
.note-content { color: var(--muted); max-width: 88ch; }
.note-content + .note-content { padding-top: 1rem; margin-top: 1.2rem; border-top: 1px dashed var(--line); }
.note-content h3 { margin: 1.25rem 0 .5rem; color: var(--text); font-size: 1.1rem; }
.note-content h3:first-child { margin-top: .3rem; }
.note-content p { margin: .7rem 0 1rem; line-height: 1.8; }
.note-content strong { color: var(--text); }
.note-content code {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .05rem .3rem;
  font: .88em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.note-content .note-command {
  margin: 1rem 0;
  max-width: 100%;
  overflow-x: auto;
  background: var(--code);
  color: #dae8ff;
  border-radius: 10px;
  padding: 1rem;
  font-size: .87rem;
}
.note-content .note-command code {
  border: 0; padding: 0; background: none; color: inherit;
  white-space: pre; overflow-wrap: normal;
}
.practice-challenge {
  background: var(--surface-alt);
  border-left: 3px solid var(--mint);
  border-radius: 0 10px 10px 0;
  padding: .7rem 1rem;
  margin: 1.25rem 0;
}
.practice-challenge p { margin: .3rem 0; }
.notes-provenance { margin: 1.4rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .84rem; color: var(--muted); }
@media (max-width: 680px) {
  .notes-heading { align-items: start; }
  .notes-heading h2 { font-size: 1.35rem; }
  .language-switch { width: 100%; }
  .note-lang-button { flex: 1; }
}
@media print {
  .site-header, .site-footer, .sidebar, .copy-button, .theme-button, .language-switch,
  .step-nav { display: none !important; }
  .detail-layout { display: block; }
  .lesson-notes { break-inside: auto; }
  .note-content[hidden] { display: block !important; }
  .code-panel pre { max-height: none; overflow: visible; white-space: pre-wrap; }
}


/* Optional device-only progress controls. The full course remains visible without JS. */
.progress-dashboard,
.chapter-progress-panel,
.lesson-progress-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.progress-dashboard[hidden], .chapter-progress-panel[hidden],
.lesson-progress-panel[hidden], [data-progress-resume][hidden],
[data-progress-complete][hidden], [data-progress-export][hidden],
[data-progress-import][hidden] { display: none !important; }
.progress-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2rem;
  padding: 1.7rem 2rem;
  margin-bottom: 2rem;
}
.progress-dashboard h2,
.lesson-progress-panel h2 { margin: .3rem 0 .55rem; font-size: 1.45rem; }
.progress-dashboard .progress-disclaimer,
.progress-dashboard .progress-count,
.chapter-progress-panel p,
.lesson-progress-panel p { margin: .35rem 0 .65rem; color: var(--muted); font-size: .88rem; }
.progress-dashboard progress,
.chapter-progress-panel progress {
  display: block; width: min(420px, 100%); height: 13px;
  border-radius: 100px; overflow: hidden; accent-color: var(--mint);
}
.progress-dashboard progress::-webkit-progress-bar,
.chapter-progress-panel progress::-webkit-progress-bar { background: var(--surface-alt); border-radius: 100px; }
.progress-dashboard progress::-webkit-progress-value,
.chapter-progress-panel progress::-webkit-progress-value { background: var(--mint); border-radius: 100px; }
.progress-dashboard progress::-moz-progress-bar,
.chapter-progress-panel progress::-moz-progress-bar { background: var(--mint); }
.progress-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; }
.progress-actions .primary-button, .progress-actions .secondary-button { font-size: .86rem; padding: .7rem 1rem; }
.progress-reset, .progress-toggle {
  cursor: pointer; font: 700 .86rem system-ui, sans-serif;
  border-radius: 10px; padding: .75rem .9rem;
  border: 1px solid var(--line); background: var(--surface-alt); color: var(--text);
}
.progress-toggle { background: var(--mint); color: #102225; border-color: transparent; }
.progress-toggle[aria-pressed="true"] { background: var(--surface-alt); color: var(--text); border-color: var(--mint); }
.progress-reset:hover, .progress-toggle:hover { outline: 1px solid var(--accent); }
.progress-feedback { width: 100%; color: var(--muted); font-size: .82rem; margin: 0; }
.chapter-progress { display: inline-block; color: var(--mint); font-size: .76rem; font-weight: 700; margin-top: auto; }
.chapter-progress:empty { display: none; }
.chapter-progress-panel {
  padding: 1rem 1.3rem; margin: 0 0 2rem;
  display: flex; gap: 1.3rem; justify-content: space-between; align-items: center; flex-wrap: wrap;
}
.chapter-progress-panel strong { display: block; margin: .3rem 0 .5rem; font-size: .96rem; }
.chapter-progress-panel .secondary-button { font-size: .88rem; padding: .7rem 1rem; }
.lesson-progress-panel {
  margin: 1.4rem 0; padding: 1.45rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.2rem;
}
.lesson-progress-panel .progress-actions { justify-content: flex-start; max-width: 400px; }
.completed-mark {
  margin-left: auto; flex: none;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--mint); color: #102225;
  text-align: center; line-height: 21px; font-size: .8rem; font-weight: 900;
}
@media (max-width: 720px) {
  .progress-dashboard { grid-template-columns: 1fr; padding: 1.35rem; gap: 1rem; }
  .progress-actions { justify-content: flex-start; }
  .lesson-progress-panel { display: block; }
  .lesson-progress-panel .progress-actions { margin-top: 1rem; }
}
@media print {
  .progress-dashboard, .chapter-progress-panel, .lesson-progress-panel,
  .chapter-progress { display: none !important; }
}


/* Offline project tutorial, using real compiler-backed sample files. */
.project-feature {
  display: grid;
  grid-template-columns: 1fr minmax(260px, .72fr);
  align-items: center; gap: 2rem; margin-bottom: 3rem;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); padding: clamp(1.4rem, 3vw, 2.5rem);
}
.project-feature h2 { margin: .45rem 0 1rem; }
.project-feature p { color: var(--muted); margin-bottom: 1.4rem; }
.project-feature-command { min-width: 0; background: var(--code); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.project-feature-command > span { display: block; padding: .7rem 1rem; color: #b4c2d8; font-size: .8rem; border-bottom: 1px solid #2d3e59; }
.project-feature-command pre { padding: 1rem; margin: 0; overflow-x: auto; color: #dbeafe; font: .83rem/1.9 ui-monospace, Consolas, monospace; }
.project-steps { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .9rem; margin: 1.5rem 0; }
.project-step { padding: 1.1rem; min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.project-step > span { color: var(--mint); font: 750 .85rem ui-monospace, Consolas, monospace; }
.project-step h2 { margin: .3rem 0 .6rem; font-size: 1.25rem; }
.project-step code { color: var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .83rem; }
.project-warning { color: var(--muted); background: var(--surface-alt); padding: 1rem; border-left: 3px solid var(--mint); border-radius: 0 10px 10px 0; }
.project-source-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; align-items: stretch; margin: 1.5rem 0; }
.project-source-grid .output-panel { grid-column: span 2; }
.project-source-grid .code-panel pre { min-height: 110px; }
.project-page .lesson-notes { margin-bottom: 1.6rem; }
@media (max-width: 850px) {
  .project-feature { grid-template-columns: 1fr; }
  .project-steps { grid-template-columns: 1fr; }
  .project-source-grid { grid-template-columns: 1fr; }
}


/* Source-backed, bilingual checkpoints. No browser compiler is implied. */
.checkpoint-card {
  margin: 1.75rem 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.checkpoint-card h2 { margin: .25rem 0 1rem; font-size: 1.45rem; }
.checkpoint-question { font-size: 1.02rem; font-weight: 650; line-height: 1.65; }
.checkpoint-question [data-checkpoint-lang], .checkpoint-option [data-checkpoint-lang] { margin-right: .55rem; }
.checkpoint-card fieldset { border: 0; padding: 0; min-width: 0; margin: 1.2rem 0; }
.checkpoint-card legend { color: var(--muted); font-weight: 600; margin-bottom: .7rem; }
.checkpoint-options { display: grid; grid-template-columns: 1fr; gap: .65rem; }
.checkpoint-option {
  display: flex; gap: .75rem; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-alt);
  border-radius: 12px; padding: .85rem 1rem; line-height: 1.6;
}
.checkpoint-option:hover, .checkpoint-option:focus-within { border-color: var(--mint); }
.checkpoint-option input { margin-top: .3rem; accent-color: var(--mint); flex: none; }
.checkpoint-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.checkpoint-feedback { margin: 1rem 0 0; font-weight: 650; }
.checkpoint-feedback:empty { display: none; }
.checkpoint-explanation, .checkpoint-fallback {
  margin-top: 1rem; padding: 1rem 1.2rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-alt);
}
.checkpoint-explanation p, .checkpoint-fallback p { margin: .4rem 0; line-height: 1.65; }
.checkpoint-fallback summary { cursor: pointer; font-weight: 700; }
.checkpoint-footnote { color: var(--muted); font-size: .82rem; margin: 1rem 0 0; }
[data-checkpoint-interactive][hidden], [data-checkpoint-fallback][hidden],
[data-checkpoint-explanation][hidden], [data-checkpoint-lang][hidden] {
  display: none !important;
}
@media print {
  .checkpoint-buttons, .checkpoint-feedback { display: none !important; }
  .checkpoint-fallback { display: block !important; }
}

/* Quiz discovery on source-backed chapter pages. */
.chapter-check-count {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
  margin-top: .45rem;
}
.lesson-check-tag {
  display: block;
  margin-top: .3rem;
  font-size: .76rem;
  font-weight: 650;
  color: var(--mint);
}


/* Six source-verified guided coding labs with genuine starter/solution disclosure. */
.lab-index, .lab-detail { padding-block: 2.6rem 4.5rem; }
.lab-index .page-heading, .lab-detail .page-heading { margin-bottom: 2rem; }
.lab-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 2rem 0; }
.lab-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow); text-decoration: none; }
.lab-card:hover, .lab-card:focus-visible { border-color: var(--mint); }
.lab-card h2 { color: var(--text); font-size: 1.35rem; margin: .8rem 0 .5rem; }
.lab-card p { color: var(--muted); margin: 0; }
.lab-open { display: block; margin-top: 1rem; font-weight: 700; color: var(--accent); }
.lab-task { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; margin: 1.5rem 0; }
.lab-task h2 { font-size: 1.35rem; margin: 0 0 .8rem; }
.lab-translations { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.lab-translations p { margin: 0; line-height: 1.75; }
.lab-detail .code-grid { margin: 1.4rem 0; }
.lab-detail .code-panel pre, .lab-reveals pre { overflow-x: auto; white-space: pre; }
.lab-reveals { display: grid; gap: 1rem; margin: 1.5rem 0; }
.lab-reveals details { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 1.2rem 1.4rem; }
.lab-reveals summary { cursor: pointer; font-weight: 750; }
.lab-reveals details[open] { border-color: var(--mint); }
.lab-reveals pre { padding: 1rem; background: var(--code); color: #dbe8ff; border-radius: 10px; }
.lab-reveals p { line-height: 1.75; }
@media (max-width: 950px) { .lab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 650px) { .lab-grid, .lab-translations { grid-template-columns: 1fr; } }


/* Structured chapter pathway: lesson reading, evidence-backed checks, local coding. */
.chapter-path { margin: 2.3rem 0 3.1rem; scroll-margin-top: 105px; }
.chapter-path .section-heading { align-items: start; }
.chapter-path .section-heading p { max-width: 340px; }
.path-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem; margin: 0; padding: 0; list-style: none;
}
.path-step {
  position: relative; min-width: 0; padding: 1.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 15px;
}
.path-step-number {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem;
  color: var(--mint); background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: .55rem; font: 750 .85rem ui-monospace, Consolas, monospace;
}
.path-step h3 { margin: .9rem 0 .6rem; font-size: 1.18rem; }
.path-step h3 span { font-weight: 500; color: var(--muted); }
.path-step > p { color: var(--muted); font-size: .91rem; line-height: 1.7; }
.path-step-link { font-weight: 700; text-underline-offset: 3px; }
.path-step-status { font-size: .8rem !important; margin: .85rem 0 0; }
.path-check-links { margin: .55rem 0 0; padding-left: 1.25rem; }
.path-check-links li { margin-bottom: .55rem; line-height: 1.5; }
.path-check-links a { font-size: .88rem; }
.path-disclaimer { color: var(--muted); font-size: .83rem; max-width: 840px; margin: 1rem 0 0; }
.lesson-path-nav {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: .6rem 1.25rem; margin: 0 0 1.4rem;
  padding: .9rem 1.1rem; border: 1px solid var(--line);
  background: var(--surface-alt); border-radius: 12px; font-size: .88rem;
}
.lesson-path-nav a { font-weight: 650; }
#checkpoint { scroll-margin-top: 105px; }
@media (max-width: 990px) { .path-steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px) {
  .path-steps { grid-template-columns: 1fr; }
  .chapter-path .section-heading { display: block; }
}


/* Compiler-verified, source-located teaching links. No runtime or LSP. */
.reference-explorer {
  margin: 2rem 0; padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 18px;
}
.ref-intro h2 { margin: .45rem 0 .6rem; }
.ref-intro > p:not(.eyebrow) { color: var(--muted); max-width: 900px; }
.ref-live {
  padding: .75rem 1rem; min-height: 3.2rem; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-alt); color: var(--text) !important;
}
.ref-source-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem; align-items: start; margin: 1.2rem 0 1.8rem;
}
.ref-source-panel { min-width: 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.ref-source-panel h3 {
  background: var(--surface-alt); font-size: .88rem; padding: .8rem 1rem;
  margin: 0; letter-spacing: 0;
}
.ref-source-panel pre {
  margin: 0; padding: 1.1rem .8rem; overflow-x: auto;
  color: #dbeafe; background: var(--code); font: .82rem/1.8 ui-monospace, Consolas, monospace;
  tab-size: 4;
}
.ref-code-line::before {
  content: attr(data-line); display: inline-block; width: 2.5em; margin-right: .8em;
  color: #8ca0c4; border-right: 1px solid #3a4c6d; text-align: right; padding-right: .6em;
  user-select: none;
}
.ref-token { border-radius: 3px; color: #aeece4; text-decoration: underline dotted; text-underline-offset: .22em; }
.ref-token:hover, .ref-token:focus-visible { color: #fff; background: #2f5670; }
.ref-token.is-active { background: #195b70; color: #fff; text-decoration: underline solid; }
.ref-list-title { font-size: 1.25rem; margin: 1.5rem 0 .85rem; }
.ref-card-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; }
.ref-card {
  min-width: 0; border: 1px solid var(--line); background: var(--surface-alt);
  padding: 1rem; border-radius: 12px; scroll-margin-top: 110px;
}
.ref-card.is-active, .ref-card:target { border-color: var(--mint); box-shadow: inset 3px 0 var(--mint); }
.ref-card > a { font-size: 1.05rem; color: var(--text); }
.ref-card > a small { color: var(--muted); font-size: .76rem; margin-left: .5rem; }
.ref-card > a.is-active { color: var(--mint); }
.ref-card p { font-size: .83rem; line-height: 1.55; margin: .5rem 0 0; }
.ref-card p[lang="hi"] { color: var(--muted); }
.ref-card-meta { color: var(--muted); overflow-wrap: anywhere; }
.ref-plain-sources { margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.ref-plain-sources summary { cursor: pointer; font-weight: 700; }
@media (max-width: 1000px) { .ref-source-grid, .ref-card-list { grid-template-columns: 1fr; } }
@media (forced-colors: active) { .ref-token.is-active { outline: 2px solid Highlight; } }


/* Local source search: labeled native controls and responsive results. */
.search-controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr); gap: .9rem; }
.search-chapter-control { display: none; }
html.js-ready .search-chapter-control { display: grid; gap: .4rem; }
.search-chapter-control label { color: var(--muted); font-size: .85rem; font-weight: 650; }
#lesson-chapter { width: 100%; min-height: 3.35rem; padding: .8rem; border: 1px solid var(--line);
  border-radius: 13px; background: var(--bg); color: var(--text); font: inherit; }
.search-results a { flex-wrap: wrap; }
.search-results a strong { flex: 1 1 100%; }
.search-results a small { display: block; }
@media (max-width: 680px) { .search-controls { grid-template-columns: 1fr; } }


/* Keyboard discoverability and explicit, user-controlled search sharing. */
.search-help { margin: .7rem 0 .35rem; color: var(--muted); font-size: .84rem; }
.search-help kbd { display: inline-block; padding: 0 .35rem; border: 1px solid var(--line);
  border-radius: 5px; background: var(--bg); font: inherit; font-weight: 750; }
.search-share { display: inline-flex; align-items: center; min-height: 44px;
  margin: .25rem 0; padding: .4rem .7rem; border: 1px solid var(--line);
  border-radius: 9px; font-size: .88rem; font-weight: 700; text-decoration: none; }
.search-share:hover { border-color: var(--accent); background: var(--surface-alt); }
#lesson-chapter:focus-visible { outline: 3px solid var(--mint); outline-offset: 4px; }


/* Compact excerpts come from the verified .srp source indexed by the course. */
.search-code-preview {
  flex: 1 1 100%; min-width: 0; display: block;
  padding: .55rem .75rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--code);
}
.search-results .search-code-preview small {
  display: block; color: var(--mint); font-size: .72rem;
  font-weight: 650; margin-bottom: .2rem;
}
.search-code-preview code {
  display: block; font: .82rem/1.5 ui-monospace, Consolas, monospace;
  color: #e2eaff; white-space: pre-wrap; overflow-wrap: anywhere;
}
@media (forced-colors: active) {
  .search-code-preview { border: 1px solid CanvasText; }
}


/* Optional prediction activity: normal verified output remains visible without JS. */
.output-practice { padding: .8rem 1rem 1rem; border-top: 1px solid var(--line); }
.output-practice > button { width: 100%; }
.output-practice p { margin: .65rem 0; font-size: .88rem; color: var(--muted); }
.output-practice label { display: block; font-size: .9rem; font-weight: 650; margin: .65rem 0 .35rem; }
.output-practice textarea {
  display: block; width: 100%; min-height: 7rem; padding: .8rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); resize: vertical;
  font: .9rem/1.6 ui-monospace, Consolas, monospace; tab-size: 4;
}
.output-practice textarea:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.output-practice-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .85rem; }
.output-practice-actions button { flex: 1 1 155px; }
.output-practice [data-output-feedback] {
  color: var(--text); font-weight: 650; min-height: 1.4rem;
}
@media print { .output-practice { display: none !important; } }


/* Course-order navigation is built from actual verified chapters, with no JS. */
.chapter-journey, .chapter-handoff {
  margin-top: 2rem; padding: clamp(1rem, 3vw, 1.7rem);
  border: 1px solid var(--line); border-radius: 15px;
  background: var(--surface-alt);
}
.chapter-journey h2, .chapter-handoff h2 { font-size: 1.35rem; margin: .3rem 0 .6rem; }
.chapter-journey > p, .chapter-handoff > p:not(.eyebrow) {
  color: var(--muted); margin: 0 0 1rem; font-size: .9rem;
}
.chapter-journey-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.chapter-journey-card, .chapter-journey-end {
  display: grid; align-content: center; gap: .3rem; min-width: 0;
  padding: 1rem; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); text-decoration: none;
}
.chapter-journey-card:hover, .chapter-journey-card:focus-visible {
  border-color: var(--mint); background: var(--surface-alt);
}
.chapter-journey-card span { color: var(--mint); font-size: .82rem; font-weight: 700; }
.chapter-journey-card strong { color: var(--text); overflow-wrap: anywhere; }
.chapter-journey-card small { color: var(--muted); }
.chapter-journey-end { color: var(--muted); font-size: .88rem; }
.chapter-handoff-links { display: flex; flex-wrap: wrap; gap: .8rem; }
.chapter-handoff-links a {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: .65rem .9rem; border: 1px solid var(--line);
  border-radius: 10px; font-size: .88rem; font-weight: 700; text-decoration: none;
  background: var(--surface); color: var(--accent);
}
.chapter-handoff-links a:hover, .chapter-handoff-links a:focus-visible {
  border-color: var(--mint); background: var(--surface-alt);
}
@media (max-width: 680px) {
  .chapter-journey-links { grid-template-columns: 1fr; }
  .chapter-handoff-links { flex-direction: column; }
  .chapter-handoff-links a { width: 100%; }
}
@media (forced-colors: active) {
  .chapter-journey-card, .chapter-handoff-links a { border: 1px solid LinkText; }
}


/* One-page chapter review sourced from the exact same three lesson checkpoints.
   Native details keep every answer reachable with JavaScript disabled. */
.chapter-review {
  margin: 2.3rem 0; border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface); overflow: hidden;
  scroll-margin-top: 110px;
}
.chapter-review > summary {
  display: grid; gap: .35rem; min-height: 64px;
  padding: 1.2rem 1.4rem; cursor: pointer;
  color: var(--text); font-weight: 750; font-size: 1.08rem;
}
.chapter-review > summary::marker { color: var(--accent); }
.chapter-review > summary:hover,
.chapter-review > summary:focus-visible {
  background: var(--surface-alt);
}
.chapter-review > summary small { color: var(--muted); font-size: .82rem; font-weight: 500; }
.chapter-review-content { padding: 0 clamp(.8rem, 3vw, 1.5rem) 1.4rem; }
.chapter-review-content > p { color: var(--muted); line-height: 1.65; font-size: .91rem; }
.chapter-review-entry + .chapter-review-entry {
  border-top: 1px solid var(--line); padding-top: .65rem;
}
.chapter-review-context { display: flex; align-items: baseline; flex-wrap: wrap;
  gap: .3rem .7rem; font-size: .88rem; margin: 1.2rem 0 .1rem; }
.chapter-review-context strong { color: var(--mint); }
.chapter-review-context a { overflow-wrap: anywhere; }
.chapter-review-entry .checkpoint-card { margin: .8rem 0 1.25rem; box-shadow: none; }
.chapter-review-entry .checkpoint-card h2 { font-size: 1.18rem; }
.chapter-review .checkpoint-option { min-height: 44px; }
@media (max-width: 680px) {
  .chapter-review > summary { padding: 1rem; }
  .chapter-review-content { padding: 0 .7rem 1rem; }
  .chapter-review-entry .checkpoint-card { padding: 1rem; }
}


/* Optional second lab exercise. The same semantic HTML works without JavaScript. */
.lab-stretch { margin: 2rem 0; padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface-alt); }
.lab-stretch > header { margin-bottom: 1rem; }
.lab-stretch > header h2 { font-size: 1.4rem; margin: .35rem 0; color: var(--text); }
.lab-stretch > header p:not(.eyebrow) { color: var(--muted); }
.lab-stretch .lab-translations { margin-block: 1rem; line-height: 1.75; }
.lab-stretch .code-grid { margin-block: 1.3rem; }
.lab-stretch .code-panel h3 { font-size: 1.05rem; margin: .25rem 0 0; }
.lab-stretch .run-panel { margin-block: 1.2rem; }
.lab-stretch .lab-reveals { margin-bottom: 0; }
.lab-stretch-indicator { display: block; color: var(--muted); font-size: .85rem; margin-top: .75rem; }
.lab-stretch { scroll-margin-top: 96px; }
@media print { .lab-stretch .copy-button { display: none; } }
