:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --panel: #ffffff;
  --panel-soft: #f1f5ef;
  --text: #16201d;
  --muted: #5d6b66;
  --line: #d9dfd6;
  --accent: #0f766e;
  --accent-strong: #0b4f4a;
  --accent-soft: #d8efea;
  --blue: #1f5f9f;
  --gold: #8a5a00;
  --red: #a4362a;
  --green: #2f6f45;
  --code-bg: #10201d;
  --code-text: #ecf7f2;
  --shadow: 0 12px 28px rgba(22, 32, 29, 0.08);
  --radius: 8px;
  --topbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    color-scheme: dark;
    --bg: #101513;
    --panel: #17201d;
    --panel-soft: #1d2925;
    --text: #eef4ef;
    --muted: #aebbb5;
    --line: #314039;
    --accent: #4db6a9;
    --accent-strong: #7bd3c8;
    --accent-soft: #173b38;
    --blue: #75a7dc;
    --gold: #d3a13d;
    --red: #e47d70;
    --green: #7ab886;
    --code-bg: #07100e;
    --code-text: #ecf7f2;
    --shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --panel: #17201d;
  --panel-soft: #1d2925;
  --text: #eef4ef;
  --muted: #aebbb5;
  --line: #314039;
  --accent: #4db6a9;
  --accent-strong: #7bd3c8;
  --accent-soft: #173b38;
  --blue: #75a7dc;
  --gold: #d3a13d;
  --red: #e47d70;
  --green: #7ab886;
  --code-bg: #07100e;
  --code-text: #ecf7f2;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.58;
}

a { color: var(--accent-strong); }
a:hover { text-decoration-thickness: 2px; }

code, pre, kbd {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

pre {
  margin: 1rem 0;
  padding: 1rem;
  overflow: auto;
  color: var(--code-text);
  background: var(--code-bg);
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--line), transparent 40%);
}

code {
  padding: 0.12rem 0.25rem;
  background: color-mix(in srgb, var(--accent-soft), transparent 35%);
  border-radius: 4px;
}

pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.7rem;
  text-align: left;
  vertical-align: top;
}

th { color: var(--muted); font-weight: 700; }

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 20;
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.skip-link:focus { top: 0.75rem; }

.nowrap { white-space: nowrap; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--panel), transparent 6%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand-text { font-weight: 800; white-space: nowrap; }
.brand-sub { color: var(--muted); font-weight: 650; margin-left: 0.25rem; }
.topbar-spacer { flex: 1; }

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--accent); }

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  background: currentColor;
  content: "";
}

.hamburger::before { transform: translateY(-6px); }
.hamburger::after { transform: translateY(4px); }
.theme-icon { font-size: 1rem; font-weight: 800; }

.progress-pill {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.module-nav {
  padding: 0.9rem;
  overflow: auto;
}

.nav-item,
.nav-course-toggle {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0.6rem;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.nav-item:hover,
.nav-course-toggle:hover,
.nav-item[aria-current="page"] {
  background: var(--panel-soft);
  border-color: var(--line);
}

.nav-home { margin-bottom: 0.7rem; }

.nav-num {
  min-width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.nav-text { flex: 1; min-width: 0; font-weight: 700; line-height: 1.25; }
.nav-mins { color: var(--muted); font-weight: 550; font-size: 0.78rem; }
.nav-check { min-width: 1.1rem; color: var(--green); font-weight: 900; }

.nav-course { margin: 0.35rem 0 0.75rem; }
.nav-course-toggle { align-items: center; }
.nav-course-caret::before { content: "v"; color: var(--muted); font-weight: 800; }
.nav-course.is-collapsed .nav-course-caret::before { content: ">"; }
.nav-course.is-collapsed .nav-course-list { display: none; }
.nav-level {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.28rem 0.42rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}
.nav-course-name { flex: 1; font-weight: 800; }
.nav-course-count { color: var(--muted); font-size: 0.82rem; }

.sidebar-foot {
  margin-top: auto;
  padding: 0.9rem;
  border-top: 1px solid var(--line);
}

.progress-track {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--panel-soft);
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.content {
  width: 100%;
  max-width: 1060px;
  padding: 2rem clamp(1rem, 3vw, 3rem) 4rem;
}

.content:focus { outline: none; }

.home-title,
.module-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.home-lede,
.module-lede {
  max-width: 820px;
  color: var(--muted);
  font-size: 1.12rem;
  margin: 1rem 0 0;
}

.home-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0 1.75rem;
}

.home-map {
  margin: 1.5rem 0 1.75rem;
}

.home-map-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.home-map-head h2 { margin: 0; }

.home-map-head p {
  max-width: 44ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.course-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.map-track {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  min-height: 8rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.map-track + .map-track::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -0.8rem;
  width: 0.8rem;
  border-top: 2px solid var(--line);
}

.map-step {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.map-track h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.map-track p {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.map-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.map-tags span {
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.visual-guide-section {
  margin: 1.5rem 0 1.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.visual-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.visual-card {
  display: grid;
  gap: 0.65rem;
  min-height: 12rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.visual-card h3 {
  margin: 0;
  font-size: 1rem;
}

.visual-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.visual-diagram {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 4.25rem;
  overflow: hidden;
}

.visual-node {
  flex: 1 1 0;
  min-width: 0;
  min-height: 3rem;
  display: grid;
  place-items: center;
  padding: 0.45rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent), var(--line) 72%);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: clamp(0.68rem, 0.6rem + 0.2vw, 0.78rem);
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.visual-link {
  flex: 0 0 1.1rem;
  border-top: 2px solid var(--line);
}

.visual-link::after {
  content: "";
  display: block;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: auto;
  margin-top: -0.28rem;
  border-top: 2px solid var(--line);
  border-right: 2px solid var(--line);
  transform: rotate(45deg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.home-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.home-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.home-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.home-tab-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.home-course-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0 0.35rem;
}

.course-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.28rem 0.5rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.home-course-title { margin: 0; font-size: 1.4rem; }
.home-course-progress { color: var(--muted); font-size: 0.9rem; margin-left: auto; }
.home-course-blurb { color: var(--muted); margin-top: 0; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}

.home-card {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}

.home-card:hover { border-color: var(--accent); }
.home-card-top { display: flex; gap: 0.65rem; align-items: flex-start; }
.home-card-num {
  min-width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}
.home-card-title { font-weight: 850; line-height: 1.25; }
.home-card-summary { color: var(--muted); font-size: 0.92rem; }
.home-card-foot { margin-top: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 0.84rem; }

.module-header {
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.6rem;
}

.module-eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

section { margin: 2rem 0; }
h2 { margin: 0 0 0.65rem; font-size: 1.65rem; line-height: 1.2; }
h3 { margin-top: 1.5rem; font-size: 1.18rem; }
ul, ol { padding-left: 1.35rem; }
li + li { margin-top: 0.35rem; }

.callout {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
}

.callout-title {
  margin-top: 0;
  font-weight: 850;
}

.callout-note { border-left-color: var(--blue); }
.callout-tip { border-left-color: var(--green); }
.callout-warning { border-left-color: var(--gold); }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.tag-reading { background: color-mix(in srgb, var(--blue), transparent 82%); color: var(--blue); }
.tag-lab { background: color-mix(in srgb, var(--green), transparent 82%); color: var(--green); }
.tag-project { background: color-mix(in srgb, var(--gold), transparent 80%); color: var(--gold); }

.lab,
.quiz {
  margin: 1.1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lab-title,
.quiz-q {
  margin-top: 0;
  font-weight: 850;
}

.objective { color: var(--muted); margin-top: -0.35rem; }

.lab-frame {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel-soft);
}

.lab-frame p {
  margin: 0 0 0.65rem;
  color: var(--muted);
}

.lab-frame h4 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.lab-frame ol {
  margin: 0;
  padding-left: 1.2rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  gap: 1rem;
  align-items: start;
}

.field { display: grid; gap: 0.35rem; margin-bottom: 0.75rem; }
.field label { font-weight: 800; }
textarea,
input[type="number"],
input[type="text"],
input[type="range"],
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0.65rem;
  font: inherit;
}

textarea { min-height: 7rem; resize: vertical; }
input[type="range"] { padding: 0; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.metric {
  min-height: 5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.metric-label { color: var(--muted); font-size: 0.8rem; font-weight: 800; }
.metric-value { margin-top: 0.25rem; font-size: 1.35rem; font-weight: 900; line-height: 1.1; }
.metric-note { margin-top: 0.3rem; color: var(--muted); font-size: 0.82rem; }

.bar-list { display: grid; gap: 0.4rem; margin-top: 0.8rem; }
.bar-row {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 4.5rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.86rem;
}
.bar-track { height: 0.55rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }

.tabs {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.tab-btn[aria-selected="true"] {
  background: var(--panel);
  border-color: var(--line);
}

.tab-panel { padding: 1rem; }

.copy-wrap { position: relative; }
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.quiz-options {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.quiz-option {
  width: 100%;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 1.5rem;
  gap: 0.65rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0.6rem;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.quiz-option:hover:not(:disabled) { border-color: var(--accent); }
.opt-key {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-soft);
  font-weight: 900;
}
.quiz-option.correct { border-color: var(--green); }
.quiz-option.incorrect { border-color: var(--red); }
.opt-mark { font-weight: 900; }
.quiz-feedback {
  margin-top: 0.85rem;
  padding: 0.8rem;
  border-radius: 8px;
  background: var(--panel-soft);
}

.term {
  border-bottom: 1px dotted var(--accent-strong);
  cursor: help;
}

.term-pop {
  position: absolute;
  z-index: 30;
  max-width: 320px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

.term-pop-name {
  display: block;
  font-weight: 900;
  margin-bottom: 0.25rem;
}

.glossary-search { margin-bottom: 1rem; }
.glossary-list { display: grid; gap: 0.75rem; }
.glossary-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0.8rem;
}
.glossary-entry dt { font-weight: 900; }
.glossary-entry dd { margin: 0.25rem 0 0; color: var(--muted); }

.module-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  margin-top: 2.5rem;
  padding-top: 1rem;
}

.pager { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.file-banner {
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--gold), transparent 80%);
  border-bottom: 1px solid var(--line);
}

.error-box {
  padding: 1rem;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: color-mix(in srgb, var(--red), transparent 88%);
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: min(86vw, 340px);
    transform: translateX(-105%);
    transition: transform 160ms ease;
    z-index: 15;
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim {
    position: fixed;
    inset: var(--topbar-h) 0 0;
    z-index: 14;
    background: rgba(0, 0, 0, 0.32);
  }
  .content { max-width: none; min-width: 0; overflow-wrap: anywhere; }
  .brand-sub { display: none; }
  .progress-pill { display: none; }
  .calc-grid { grid-template-columns: 1fr; }
  .home-course-progress { margin-left: 0; }
  .home-map-head { display: block; }
  .home-map-head p { margin-top: 0.35rem; }
  .course-map { grid-template-columns: 1fr; }
  .visual-guide { grid-template-columns: 1fr; }
  .map-track + .map-track::before {
    top: -0.8rem;
    left: 1.9rem;
    width: 0;
    height: 0.8rem;
    border-top: 0;
    border-left: 2px solid var(--line);
  }
}

@media (max-width: 560px) {
  .topbar { padding: 0 0.6rem; }
  .brand-text { font-size: 0.95rem; }
  .home-title,
  .module-header h1 { font-size: 2.1rem; }
  .home-lede,
  .module-lede { font-size: 1rem; }
  .result-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 4rem minmax(0, 1fr) 3.6rem; }
}

.expert-upgrade {
  margin-top: 2rem;
  border-top: 1px solid var(--border, #d8dee4);
  padding-top: 1.25rem;
}
.expert-upgrade h3 {
  margin-top: 1rem;
}

.first-principles-path {
  margin: 1.5rem 0;
  padding: 1.25rem;
  border: 1px solid var(--border, #d8dee4);
  border-radius: 8px;
  background: var(--surface, #fff);
}
.first-principles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.first-principles-grid h3,
.teach-back h3 {
  margin-bottom: 0.35rem;
}
.teach-back {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #d8dee4);
}


/* Tiny Course Design System overrides */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius-1: 6px;
  --radius-2: 8px;
  --shadow-1: 0 10px 24px rgba(22, 32, 29, 0.07);
  --shadow-2: 0 18px 42px rgba(22, 32, 29, 0.10);
  --focus: color-mix(in srgb, var(--accent) 32%, white);
  --color-bg: var(--bg);
  --color-surface: var(--panel);
  --color-surface-muted: var(--panel-soft);
  --color-text: var(--text);
  --color-muted: var(--muted);
  --color-border: var(--line);
  --color-brand: var(--accent);
  --color-brand-strong: var(--accent-strong);
  --color-brand-soft: var(--accent-soft);
  --color-accent: var(--blue);
  --color-accent-text: var(--blue);
  --color-focus: var(--focus);
  --color-success: var(--green);
  --color-warning: var(--gold);
  --color-danger: var(--red);
  --target-min: 44px;
  --measure: 76ch;
}
html { scroll-behavior: smooth; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.topbar {
  min-height: var(--topbar-h);
}
.brand-mark,
.icon-btn,
.btn,
.home-tab,
.home-card,
.nav-item,
.nav-course-toggle,
.nav-num,
.tab-btn,
.copy-btn,
.quiz-option,
.glossary-entry,
.lab,
.quiz,
.tabs,
.term-pop {
  border-radius: var(--radius-2);
}
.content {
  max-width: 1120px;
}
.home-title,
.module-header h1 {
  max-width: 15ch;
}
.home-lede,
.module-lede,
.content p,
.content li {
  max-width: var(--measure);
}
.home-card {
  min-height: 178px;
  box-shadow: 0 1px 0 rgba(22, 32, 29, 0.03);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.home-card:hover {
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}
.home-card.is-complete {
  border-color: color-mix(in srgb, var(--green) 42%, var(--line));
}
.home-card.is-complete .home-card-num {
  background: color-mix(in srgb, var(--green) 16%, var(--panel));
  color: var(--green);
}
.nav-item.is-complete .nav-num {
  background: color-mix(in srgb, var(--green) 16%, var(--panel));
  color: var(--green);
}
.callout,
.lab,
.quiz,
.tabs {
  box-shadow: 0 1px 0 rgba(22, 32, 29, 0.03);
}
.first-principles-path {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: linear-gradient(180deg, var(--accent-soft), var(--panel) 62%);
}
.first-principles-path > h2 {
  color: var(--accent-strong);
}
.first-principles-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  padding: var(--space-4);
  background: var(--panel);
}
.teach-back {
  border-top: 0;
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-2) var(--radius-2) 0;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--gold), transparent 88%);
}
.expert-upgrade {
  border-top: 0;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-2) var(--radius-2) 0;
  padding: var(--space-4) 0 var(--space-4) var(--space-4);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, var(--panel)), transparent 72%);
}
.quiz-option {
  min-height: var(--target-min);
}
textarea:focus-visible,
input[type="number"]:focus-visible,
input[type="text"]:focus-visible,
input[type="range"]:focus-visible,
input[type="search"]:focus-visible {
  border-color: var(--accent);
}
@media (max-width: 560px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-card { min-height: auto; }
}


.lesson-diagram {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  gap: var(--space-4);
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: var(--space-4);
  margin: var(--space-5) 0;
  box-shadow: var(--shadow);
}
.lesson-diagram h2 { margin-top: 0; }
.diagram-note-grid { display: grid; gap: var(--space-3); }
.diagram-note-grid > div { border: 1px solid var(--line); border-radius: 8px; padding: var(--space-3); background: var(--panel-soft); }
.diagram-note-grid h3 { margin: 0 0 0.35rem; font-size: 0.95rem; }
.diagram-art { margin: 0; }
.diagram-art img, .visual-sheet img { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: white; display: block; }
.diagram-art figcaption, .visual-sheet figcaption { color: var(--muted); font-size: 0.86rem; margin-top: var(--space-2); }
.lesson-diagram,
.lesson-diagram * {
  box-sizing: border-box;
}

.lesson-diagram-copy,
.diagram-note-grid,
.diagram-note-grid > div,
.diagram-art,
.diagram-art img,
.diagram-art figcaption {
  min-width: 0;
  max-width: 100%;
}

.lesson-diagram p,
.diagram-note-grid p,
.diagram-art figcaption {
  overflow-wrap: anywhere;
}

.diagram-art img {
  height: auto;
  object-fit: contain;
}
.visual-sheet { margin: 0 0 var(--space-4); }
.lab-insight { margin-top: 0.85rem; padding: 0.85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.lab-insight h4 { margin: 0 0 0.4rem; }
@media (max-width: 820px) { .lesson-diagram { grid-template-columns: minmax(0, 1fr); padding: var(--space-3); } }


.real-world-anchor {
  margin: var(--space-5, 24px) 0;
  padding: var(--space-4, 16px);
  border: 1px solid var(--color-border, #d8ded6);
  border-radius: var(--radius-2, 8px);
  background: var(--color-surface-muted, #f6f8f4);
}

.real-world-anchor h2 {
  margin-top: 0;
}

.build-project {
  margin: var(--space-5, 24px) 0;
  padding: var(--space-4, 16px);
  border: 1px solid var(--color-border, #d8ded6);
  border-left: 4px solid var(--color-brand, #2f6f4f);
  border-radius: var(--radius-2, 8px);
  background: var(--color-brand-soft, #eef5f0);
}

.build-project h2 {
  margin-top: 0;
}

.build-project ol {
  margin: var(--space-3, 12px) 0;
  padding-left: var(--space-5, 24px);
  display: grid;
  gap: var(--space-2, 8px);
}

.build-project .project-goal {
  font-weight: 600;
}

.build-project .project-check,
.build-project .project-stretch {
  margin: var(--space-2, 8px) 0 0;
}

.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3, 12px);
}

.anchor-grid > div {
  min-width: 0;
  padding: var(--space-3, 12px);
  border: 1px solid var(--color-border, #d8ded6);
  border-radius: var(--radius-1, 6px);
  background: var(--color-surface, #fff);
}

.anchor-grid h3 {
  margin-top: 0;
  font-size: 1rem;
}

.anchor-grid p {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .anchor-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile containment guard: diagrams, tables, and code should never widen the page. */
.content,
.module-content,
.content > .module-content,
.module-content article,
.main-column,
.module-header,
.lesson-diagram,
.real-world-anchor,
.first-principles-path,
.expert-upgrade,
.module-check-pack {
  min-width: 0;
  max-width: 100%;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

@media (max-width: 760px) {
  table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  th,
  td {
    overflow-wrap: anywhere;
  }
}

/* Figure-it-out cards: bold lead + tight bullets */
.first-principles-grid .card-lead { font-weight: 600; margin: 0 0 8px; }
.first-principles-grid .card-points { margin: 0; padding-left: 18px; }
.first-principles-grid .card-points li { margin: 4px 0; }


/* diagram-fullwidth: rich infographic gets the whole content width, not a cramped side column */
.lesson-diagram { grid-template-columns: minmax(0, 1fr); }
.lesson-diagram .diagram-art { order: -1; width: 100%; max-width: 920px; margin: 0 auto var(--space-3); }
.lesson-diagram .diagram-art img { width: 100%; height: auto; }

/* self-assessment rubric block (pedagogy upgrade) */
.self-check{margin-top:14px;border:1px solid var(--line,#dce3ee);border-radius:var(--radius-2,12px);padding:14px 16px;background:var(--soft-2,#f1f5fb)}
.self-check h3{margin:0 0 8px}
.self-check p{margin:6px 0}
table.rubric{width:100%;border-collapse:collapse;margin:8px 0;font-size:.92rem}
table.rubric th,table.rubric td{text-align:left;border:1px solid var(--line,#dce3ee);padding:6px 9px;vertical-align:top}
table.rubric th{background:var(--paper,#fff);font-weight:600}
