:root {
  --bg: #f7f8f6;
  --paper: #ffffff;
  --ink: #1b2422;
  --muted: #65716e;
  --line: #d8dfdc;
  --strong-line: #aebdb8;
  --teal: #007c74;
  --teal-soft: #e8f5f2;
  --blue: #285da8;
  --blue-soft: #e8f1ff;
  --green: #287a3e;
  --green-soft: #ecf8ee;
  --amber: #a46300;
  --amber-soft: #fff2df;
  --red: #b43a31;
  --red-soft: #fff0ee;
  --shadow: 0 16px 42px rgba(27, 36, 34, 0.08);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(0, 124, 116, 0.1), rgba(247, 248, 246, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

code,
pre {
  font-family: var(--mono);
}

p code,
li code,
dd code,
h2 code,
h3 code,
.check-note code {
  background: var(--blue-soft);
  color: var(--blue);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.92em;
}

/* ---------- Page frame ---------- */

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.header-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header-links .site-identity {
  text-align: left;
}

.quiet-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  color: var(--teal);
  text-decoration: none;
  font-weight: 750;
  background: var(--paper);
}

.quiet-link:hover {
  background: var(--teal-soft);
}

.lesson-title {
  text-align: right;
}

.lesson-title p,
.lesson-title h1,
.hero-panel h2,
.hero-panel p,
.panel h2,
.panel h3,
.section-heading p,
.example-box h3,
.example-box p {
  margin: 0;
}

.lesson-title p {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-title h1 {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  line-height: 1.2;
}

.lesson-title h1,
.hero-panel h2,
.panel h2,
.panel h3 {
  letter-spacing: 0;
}

.lesson-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.lesson-shell > * {
  min-width: 0;
}

.lesson-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.step-link {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.step-link:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.step-link small {
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.step-link.next {
  text-align: right;
  margin-left: auto;
}

.step-link span {
  font-weight: 800;
}

/* ---------- Panels ---------- */

.hero-panel,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 24px;
  align-items: center;
  padding: clamp(20px, 4vw, 34px);
}

.hero-panel.single {
  grid-template-columns: 1fr;
}

.hero-panel h2 {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.06;
  max-width: 760px;
}

.hero-panel p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  max-width: 720px;
}

.panel {
  padding: 18px;
}

.panel h2 {
  font-size: 1.06rem;
  line-height: 1.25;
}

.panel > p,
.panel-intro {
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 0 0;
  max-width: 860px;
}

.section-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.section-heading p {
  color: var(--muted);
  line-height: 1.45;
}

.big-idea {
  border-left: 4px solid var(--teal);
  background: var(--teal-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
  line-height: 1.55;
}

.big-idea strong {
  color: var(--teal);
}

.big-idea p {
  margin: 0;
}

.big-idea p + p {
  margin-top: 8px;
}

/* ---------- Code blocks ---------- */

pre {
  margin: 12px 0 0;
  padding: 12px;
  max-width: 100%;
  overflow: auto;
  border-radius: var(--radius);
  background: #17201e;
  color: #f7fbfa;
  line-height: 1.5;
}

/* ---------- Live identity checks ---------- */

.check-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.check-row[data-pass="true"] {
  border-color: rgba(40, 122, 62, 0.45);
}

.check-code {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.check-pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 850;
  background: var(--red-soft);
  color: var(--red);
}

.check-row[data-pass="true"] .check-pill {
  background: var(--green-soft);
  color: var(--green);
}

.check-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.checks-caption {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Object graph diagram ---------- */

.graph-scroll {
  margin-top: 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(rgba(27, 36, 34, 0.07) 1px, transparent 1px) 0 0 / 18px 18px,
    #fbfcfc;
}

.learning-grid > *,
.two-column > *,
.three-column > *,
.hierarchy-layout > *,
.dom-links-layout > *,
.example-box {
  min-width: 0;
}

.graph-wrap {
  position: relative;
  width: max-content;
  min-width: 100%;
  padding: 26px;
}

.graph-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.arrow-label {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fbfcfc;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.graph-grid {
  display: grid;
  gap: 64px 74px;
  align-items: start;
  justify-items: start;
}

.graph-node {
  position: relative;
  display: grid;
  gap: 3px;
  min-width: 128px;
  padding: 10px 13px;
  border: 1.6px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(27, 36, 34, 0.07);
}

.graph-node .node-name {
  font-family: var(--mono);
  font-weight: 850;
  font-size: 0.9rem;
  white-space: nowrap;
}

.graph-node .node-role {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.graph-node .node-meta {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.graph-node.instance {
  border-color: var(--green);
  background: var(--green-soft);
}

.graph-node.instance .node-role {
  color: var(--green);
}

.graph-node.proto {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.graph-node.proto .node-role {
  color: var(--teal);
}

.graph-node.ctor {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.graph-node.ctor .node-role {
  color: var(--blue);
}

.graph-node.null-node {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-weight: 700;
}

.legend i {
  width: 26px;
  height: 0;
  border-top: 2.4px solid currentColor;
}

.legend .teal {
  color: var(--teal);
}

.legend .blue {
  color: var(--blue);
}

.legend .amber {
  color: var(--amber);
}

.legend i.dashed {
  border-top-style: dashed;
}

/* ---------- Scenario / choice tabs ---------- */

.scenario-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.scenario-tab {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfc;
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 750;
  font-size: 0.86rem;
}

.scenario-tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

/* ---------- Two/three column helper ---------- */

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.example-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.example-box h3 {
  font-size: 0.98rem;
}

.example-box p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- Learning grid (lesson 1) ---------- */

.learning-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.mini-dom {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.mini-dom button,
.mini-dom input,
.mini-dom p {
  min-height: 42px;
  margin: 0;
  border-radius: var(--radius);
  border: 1px solid var(--strong-line);
  background: var(--paper);
  color: var(--ink);
  display: flex;
  align-items: center;
  padding: 0 12px;
}

.mini-dom button {
  justify-content: center;
  border-color: var(--teal);
  background: var(--teal-soft);
  font-weight: 800;
}

.choice-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.choice-card {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
}

.choice-card.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.choice-card span {
  font-family: var(--mono);
  font-weight: 800;
}

.choice-card small,
dd {
  color: var(--muted);
  line-height: 1.45;
}

.lookup-row {
  margin-top: 14px;
}

.lookup-row label,
.field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lookup-row select,
.field-label select,
.field-label input {
  min-height: 42px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 10px;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: none;
}

.result-box {
  min-height: 130px;
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fbfcfc;
  display: grid;
  gap: 9px;
}

.result-title {
  font-weight: 850;
}

.result-path {
  font-family: var(--mono);
  color: var(--blue);
  overflow-wrap: anywhere;
}

.result-note {
  color: var(--muted);
  line-height: 1.45;
}

.simple-chain {
  display: grid;
  gap: 10px;
}

.chain-step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.chain-step.found {
  border-color: var(--green);
  background: var(--green-soft);
}

.chain-step.missing {
  opacity: 0.72;
}

.step-number {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 850;
}

.step-name {
  font-family: var(--mono);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.step-explain {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.step-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.chain-step.found .step-badge {
  background: var(--green);
  color: #fff;
}

dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 0;
}

dt {
  font-weight: 850;
}

dd {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

/* ---------- Hierarchy tree (lesson 3) ---------- */

.hierarchy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.tree-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.tree-scroll {
  margin-top: 12px;
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  padding: 12px;
}

.ctor-tree,
.ctor-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ctor-tree ul {
  margin-left: 13px;
  padding-left: 15px;
  border-left: 2px solid var(--line);
}

.ctor-tree li {
  margin: 3px 0;
}

.tree-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
}

.tree-toggle {
  width: 21px;
  height: 21px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}

.tree-spacer {
  width: 21px;
  flex: none;
}

.tree-name {
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 0.87rem;
  font-weight: 750;
  color: var(--ink);
  text-align: left;
  overflow-wrap: anywhere;
}

.tree-name:hover {
  background: var(--teal-soft);
}

.tree-name.selected {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.tree-count {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.detail-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 12px;
}

.detail-chain {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.detail-chain-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 700;
}

.detail-chain-item .depth-arrow {
  color: var(--teal);
  font-weight: 900;
}

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.member-chip {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fbfcfc;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
}

.member-chip.more {
  color: var(--muted);
  border-style: dashed;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.stat-card {
  flex: 1 1 150px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.stat-card b {
  display: block;
  font-size: 1.5rem;
  color: var(--teal);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

/* ---------- DOM link explorer (lesson 4) ---------- */

.dom-links-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

.rendered-sample {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
}

.rendered-sample h4,
.rendered-sample p,
.rendered-sample ul {
  margin: 0 0 8px;
}

.rendered-sample ul {
  padding-left: 20px;
}

.rendered-sample em {
  color: var(--teal);
  font-style: normal;
  font-weight: 750;
}

.node-tree {
  margin-top: 12px;
  display: grid;
  gap: 4px;
}

.node-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  border: 1.4px solid var(--strong-line);
  border-radius: 7px;
  background: var(--paper);
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 750;
  color: var(--ink);
  text-align: left;
}

.node-box .node-kind {
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--blue);
}

.node-box.text-node {
  border-style: dashed;
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 650;
}

.node-box.text-node .node-kind {
  color: var(--amber);
}

.node-box:hover {
  border-color: var(--teal);
}

.node-box.selected {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.node-box.selected .node-kind {
  color: rgba(255, 255, 255, 0.85);
}

.node-box.related {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.link-rows {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  gap: 4px 14px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.link-row:hover {
  border-color: var(--blue);
}

.link-row .link-code {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--blue);
}

.link-row .link-value {
  font-family: var(--mono);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.link-row .link-value.null-value {
  color: var(--muted);
}

.link-row.section-break {
  background: transparent;
  border: none;
  padding: 10px 0 0;
}

.link-row.section-break .link-code {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.03em;
}

.child-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.child-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 2px 9px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 750;
}

.child-chip.text-chip {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-soft);
}

/* ---------- BOM cards (lesson 5) ---------- */

.bom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.bom-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  display: grid;
  gap: 8px;
  align-content: start;
}

.bom-card h3 {
  font-family: var(--mono);
  font-size: 0.95rem;
}

.bom-card .bom-type {
  width: fit-content;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 850;
}

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

.bom-card .bom-live {
  display: grid;
  gap: 4px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.bom-card .bom-live span {
  color: var(--teal);
  font-weight: 800;
}

/* ---------- Window chain strip ---------- */

.chain-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
}

.chain-strip .strip-node {
  padding: 8px 13px;
  border: 1.5px solid var(--teal);
  border-radius: var(--radius);
  background: var(--teal-soft);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.88rem;
}

.chain-strip .strip-node.start {
  border-color: var(--green);
  background: var(--green-soft);
}

.chain-strip .strip-node.end {
  border-style: dashed;
  border-color: var(--strong-line);
  background: transparent;
  color: var(--muted);
}

.chain-strip .strip-arrow {
  color: var(--teal);
  font-weight: 900;
  font-family: var(--mono);
}

/* ---------- Home page ---------- */

.map-panel .three-column {
  align-items: stretch;
}

.lesson-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.lesson-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 6px 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  text-decoration: none;
  color: var(--ink);
}

.lesson-card:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.lesson-card .card-number {
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
}

.lesson-card .card-number.tool {
  background: var(--blue);
}

.lesson-card h3 {
  margin: 0;
  font-size: 1rem;
  align-self: center;
}

.lesson-card p {
  margin: 0;
  grid-column: 2;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* ---------- Interactive prototype lab (lesson 6) ---------- */

.lab-shell {
  width: min(1240px, calc(100% - 32px));
}

.lab-jump {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.lab-jump a {
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--teal);
  text-decoration: none;
  text-align: center;
  font-weight: 800;
}

.lab-jump a:hover {
  background: var(--teal-soft);
}

.lab-station {
  scroll-margin-top: 18px;
  min-width: 0;
}

.station-heading {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.station-heading p {
  max-width: 880px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.station-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
}

.trace-controls,
.universe-controls {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.primary-action,
.quiet-action,
.sandbox-actions button {
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
}

.primary-action {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-action:hover {
  background: #006a63;
}

.quiet-action,
.sandbox-actions button {
  border: 1px solid var(--strong-line);
  background: var(--paper);
  color: var(--ink);
}

.quiet-action:hover,
.sandbox-actions button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.quiet-action:disabled {
  cursor: default;
  opacity: 0.5;
}

.trace-stage {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  min-width: 0;
}

.lab-message {
  min-height: 48px;
  color: var(--muted);
  line-height: 1.5;
}

.lab-message strong {
  display: block;
  color: var(--ink);
}

.trace-steps {
  display: flex;
  align-items: stretch;
  gap: 9px;
  overflow-x: auto;
  padding: 3px 2px 8px;
}

.trace-step {
  position: relative;
  min-width: 190px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
}

.trace-step::after {
  content: "\2192";
  position: absolute;
  right: -9px;
  top: 50%;
  z-index: 1;
  color: var(--teal);
  font-weight: 900;
  transform: translate(50%, -50%);
}

.trace-step:last-child::after {
  display: none;
}

.trace-step.found {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 3px rgba(40, 122, 62, 0.12);
}

.trace-step.end {
  border-style: dashed;
  color: var(--muted);
}

.trace-step-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.trace-step strong,
.trace-step small {
  display: block;
}

.trace-step strong {
  font-family: var(--mono);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.trace-step small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.trace-status {
  grid-column: 1 / -1;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.73rem;
  font-weight: 850;
}

.trace-step.found .trace-status {
  background: var(--green);
  color: #fff;
}

.next-step {
  width: fit-content;
}

.sandbox-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 16px;
  margin-top: 16px;
}

.sandbox-objects {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px minmax(180px, 1fr) 90px minmax(120px, 0.55fr);
  gap: 8px;
  align-items: stretch;
}

.sandbox-object {
  min-height: 170px;
  padding: 13px;
  border: 1.5px solid var(--teal);
  border-radius: var(--radius);
  background: var(--teal-soft);
}

.sandbox-object.end {
  min-height: 0;
  display: grid;
  align-content: center;
  border-style: dashed;
  border-color: var(--strong-line);
  background: #fbfcfc;
}

.sandbox-object > strong,
.sandbox-object > small {
  display: block;
}

.sandbox-object > strong {
  font-family: var(--mono);
}

.sandbox-object > small {
  margin-top: 4px;
  color: var(--muted);
}

.sandbox-object ul {
  display: grid;
  gap: 6px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.sandbox-object li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--paper);
  font-size: 0.8rem;
}

.sandbox-object li.watched {
  outline: 2px solid var(--green);
  background: var(--green-soft);
}

.sandbox-object li span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.sandbox-arrow {
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--teal);
  text-align: center;
}

.sandbox-arrow span {
  font-family: var(--mono);
  font-size: 0.7rem;
}

.sandbox-arrow b {
  font-size: 1.4rem;
  transform: rotate(-90deg);
}

.sandbox-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.sandbox-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sandbox-explanation {
  padding: 16px;
  border-left: 4px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--amber-soft);
  line-height: 1.5;
}

.sandbox-explanation strong {
  display: block;
}

.sandbox-explanation p {
  margin: 9px 0 0;
  color: var(--muted);
}

.concept-note {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-top: 14px;
  padding: 11px 13px;
  border-left: 4px solid var(--blue);
  background: var(--blue-soft);
  line-height: 1.45;
}

.concept-note strong {
  font-family: var(--mono);
  white-space: nowrap;
}

.concept-note span {
  color: var(--muted);
}

.universe-chain {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 14px;
  padding-bottom: 8px;
  overflow-x: auto;
}

.universe-node {
  min-width: 174px;
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}

.universe-node:hover,
.universe-node.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.universe-node.start {
  border-color: var(--blue);
}

.universe-node.end {
  min-width: 110px;
  border-style: dashed;
  color: var(--muted);
}

.universe-node small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.universe-node strong {
  font-family: var(--mono);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.universe-node span {
  color: var(--muted);
  font-size: 0.76rem;
}

.universe-arrow {
  align-self: center;
  color: var(--teal);
  font-weight: 900;
}

.member-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  margin-top: 10px;
  padding: 14px 0 10px;
  border-top: 1px solid var(--line);
}

.member-heading h3,
.member-heading p {
  margin: 0;
}

.member-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.member-legend {
  display: flex;
  gap: 11px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.member-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.kind-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  background: var(--blue);
}

.kind-dot.property {
  background: var(--green);
}

.kind-dot.accessor {
  background: var(--amber);
}

.kind-dot.symbol {
  background: var(--red);
}

.universe-members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding: 2px;
}

.universe-member {
  min-height: 72px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 5px 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.universe-member .kind-dot {
  margin-top: 4px;
}

.universe-member strong,
.universe-member small {
  display: block;
  overflow-wrap: anywhere;
}

.universe-member strong {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.universe-member small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.universe-member > code {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 0.73rem;
  overflow-wrap: anywhere;
}

.member-kind-label {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 800;
}

.lab-empty {
  grid-column: 1 / -1;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.four-ideas {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.four-ideas > div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  line-height: 1.45;
}

.four-ideas strong {
  color: var(--teal);
}

.lab-sample {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .hierarchy-layout,
  .dom-links-layout,
  .sandbox-layout {
    grid-template-columns: 1fr;
  }

  .sandbox-objects {
    grid-template-columns: 1fr;
  }

  .sandbox-arrow b {
    transform: none;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 880px) {
  .lesson-header,
  .hero-panel,
  .learning-grid,
  .two-column,
  .three-column,
  dl,
  .trace-controls,
  .universe-controls,
  .four-ideas {
    grid-template-columns: 1fr;
  }

  .lesson-title {
    text-align: left;
  }
}

@media (max-width: 620px) {
  .lesson-header {
    display: grid;
  }

  .chain-step {
    grid-template-columns: 1fr;
  }

  .step-number {
    width: 30px;
    height: 30px;
  }

  .lesson-footer {
    flex-direction: column;
  }

  .step-link.next {
    margin-left: 0;
  }

  .lab-jump,
  .sandbox-controls {
    grid-template-columns: 1fr;
  }

  .sandbox-actions {
    grid-column: 1;
  }

  .concept-note,
  .member-heading {
    align-items: stretch;
    flex-direction: column;
  }
}
