:root {
  --ink: #082e3a;
  --muted: #526d75;
  --paper: #f4faf9;
  --surface: #ffffff;
  --surface-2: #eaf2f1;
  --canal: #176b9b;
  --canal-dark: #082e3a;
  --jade: #20998f;
  --jade-soft: #dff3f1;
  --sun: #f2c94c;
  --sun-soft: #fff6d8;
  --coral: #f15a3a;
  --plum: #7a4771;
  --line: #c8d8d7;
  --line-dark: #9db4b4;
  --focus: #146fdd;
  --shadow: 0 18px 50px rgba(13, 55, 67, 0.11);
  --display: "Barlow Condensed", "Arial Narrow", "Noto Sans SC", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Noto Sans SC", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 82px;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(15, 136, 124, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 136, 124, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.56;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--canal); text-underline-offset: 0.16em; }
a:hover { color: var(--coral); }
code, pre { font-family: var(--mono); }
code { font-size: 0.9em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--focus);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  display: grid;
  grid-template-columns: 250px 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.65rem 1.25rem;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--canal);
  color: #fff;
  border-radius: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-family: var(--display); font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand small { color: var(--muted); font-size: 0.76rem; }

.header-path {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 0;
}

.header-path span {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 1.5rem;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 700;
}

.header-path span:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line-dark);
}

.header-path b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.65rem;
}

.header-path span.complete { color: var(--jade); }
.header-path span.complete b { background: var(--jade); border-color: var(--jade); color: #fff; }

.language-tabs, .category-tabs, .recipe-tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.language-tabs button,
.category-tabs button,
.recipe-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-family: var(--display);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.language-tabs button.active,
.category-tabs button.active,
.recipe-tabs button.active {
  background: var(--canal-dark);
  color: #fff;
}

.section-jumps {
  display: inline-flex;
  border: 1px solid var(--line-dark);
  background: var(--surface);
}
.section-jumps a {
  padding: 0.58rem 0.78rem;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}
.section-jumps a + a { border-left: 1px solid var(--line); }
.section-jumps a.active, .section-jumps a:hover { background: var(--canal-dark); color: #fff; }

.shell {
  width: min(1550px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 265px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  padding: 2.1rem 1.25rem 1.35rem;
  background: rgba(255, 255, 255, 0.9);
  border-right: 1px solid var(--line);
}

.rail-intro span,
.stage-kicker span,
.module-head > span,
.panel-label,
.cheatsheet-head span,
.atlas-head > div > span,
.additional-head span,
.worked-note > span {
  color: var(--jade);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rail-intro p { margin: 0.55rem 0 1.55rem; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.rail nav { display: grid; gap: 0.45rem; }

.rail nav a {
  display: grid;
  grid-template-columns: 35px 1fr;
  column-gap: 0.65rem;
  align-items: center;
  padding: 0.72rem;
  color: var(--muted);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.rail nav a > span {
  grid-row: 1 / 3;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--line-dark);
}

.rail nav strong { color: var(--ink); font-family: var(--display); font-size: 0.92rem; }
.rail nav small { font-size: 0.76rem; }
.rail nav a.active { background: var(--jade-soft); border-left-color: var(--jade); color: var(--canal); }
.rail nav a.active > span, .rail nav a.active strong { color: var(--canal); }
.rail nav a.complete > span { color: var(--jade); }
.rail nav a.complete > span::after { content: "✓"; display: block; margin-top: 0.15rem; font-weight: 700; }

.case-link {
  position: relative;
  display: block;
  margin-top: 1.7rem;
  padding: 1rem;
  background: var(--canal-dark);
  color: #fff;
  text-decoration: none;
  overflow: hidden;
}

.case-link::after {
  content: "";
  position: absolute;
  inset: auto -25% -65% 18%;
  height: 100px;
  border: 2px solid rgba(91, 218, 205, 0.42);
  border-radius: 50%;
}

.case-link span, .case-link strong, .case-link small { position: relative; z-index: 1; display: block; }
.case-link span { color: #80d8cf; font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; }
.case-link strong { margin: 0.3rem 0; font-family: var(--display); font-size: 0.88rem; }
.case-link small { color: #c7e9e6; }
.case-link:hover { color: #fff; }

.rail-progress { margin-top: auto; padding-top: 1.25rem; }
.rail-progress > div:first-child { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.72rem; }
.progress-segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 0.65rem; }
.progress-segments span { min-width: 0; display: grid; justify-items: center; gap: 0.28rem; padding: 0.55rem 0.18rem; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.progress-segments i { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--line-dark); border-radius: 50%; color: transparent; font-style: normal; font-size: 0.72rem; }
.progress-segments b { font-family: var(--display); font-size: 0.67rem; text-transform: uppercase; }
.progress-segments span.complete { border-color: var(--jade); background: var(--jade-soft); color: var(--ink); }
.progress-segments span.complete i { border-color: var(--jade); background: var(--jade); color: #fff; }
.text-button { border: 0; background: none; color: var(--muted); padding: 0.65rem 0; text-align: left; font-size: 0.78rem; cursor: pointer; }
.text-button:hover { color: var(--coral); }

main { min-width: 0; width: 100%; }
.stage { scroll-margin-top: 72px; }

.stage-opening {
  position: relative;
  padding: clamp(3.5rem, 7vw, 7rem) clamp(1.5rem, 5vw, 5.5rem) 2.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.stage-kicker { display: flex; gap: 0.85rem; align-items: center; margin-bottom: 1.5rem; }
.stage-kicker em { color: var(--muted); font-style: normal; font-size: 0.88rem; }

.opening-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(250px, 0.65fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: end;
}

h1, h2, h3, h4, p { overflow-wrap: anywhere; }
h1, h2, h3, h4 { font-family: var(--display); }

h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(2.6rem, 5.5vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.lede { max-width: 760px; margin: 1.4rem 0 0; color: var(--muted); font-size: clamp(1.05rem, 1.5vw, 1.28rem); }

.brief-card {
  border-top: 4px solid var(--sun);
  padding: 1.1rem 0 0;
}
.brief-card > span { color: var(--coral); font-family: var(--mono); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; }
.brief-card p { margin: 0.45rem 0 0; font-size: 0.93rem; }
.brief-card a { display: inline-block; margin-top: 0.9rem; padding: 0.48rem 0.65rem; background: var(--ink); color: #fff; font-family: var(--display); font-size: 0.82rem; font-weight: 800; text-decoration: none; text-transform: uppercase; }

.water-path { width: 100%; height: auto; margin-top: 2.25rem; overflow: visible; }
.water-path path { fill: none; stroke: var(--jade); stroke-width: 3; stroke-dasharray: 100; animation: trace 1.4s ease-out both; }
.water-path circle { fill: var(--paper); stroke: var(--coral); stroke-width: 4; }
@keyframes trace { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

.compact-opening { padding-top: 4.5rem; padding-bottom: 3.8rem; }
.stage-title { max-width: 900px; margin: 0; font-size: clamp(2.2rem, 4.2vw, 4.2rem); line-height: 1.03; letter-spacing: -0.045em; }

.stage-critique > .stage-opening { background: var(--canal-dark); color: #fff; }
.stage-critique .stage-opening .lede, .stage-critique .stage-opening .stage-kicker em { color: #bdd7db; }
.stage-critique .stage-opening .stage-kicker span { color: #65d2c7; }
.stage-redesign > .stage-opening { background: var(--sun-soft); }

.module {
  margin: clamp(1.2rem, 3vw, 2.5rem);
  padding: clamp(1.4rem, 4vw, 3.8rem);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(13, 55, 67, 0.03);
}

.module-head {
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  padding-bottom: 1.65rem;
  border-bottom: 1px solid var(--line);
}

.module-head h2 { max-width: 800px; margin: 0; font-size: clamp(1.8rem, 3.2vw, 3.1rem); line-height: 1.08; letter-spacing: -0.035em; }
.module-head p { max-width: 780px; margin: 0.65rem 0 0; color: var(--muted); }

.example-student-grid { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 1.1rem; margin: 1.8rem 0; }
.case-panel, .work-panel { padding: 1.35rem; border: 1px solid var(--line); background: var(--surface); }
.case-panel { background: #edf5fb; border-top: 5px solid var(--canal); }
.work-panel { background: #fff9e8; border-top: 5px solid var(--sun); }
.case-panel h3 { margin: 1rem 0; font-size: 1.35rem; line-height: 1.15; }
.case-panel h3 span { color: var(--canal); font-size: 1rem; font-weight: 600; }
.case-panel dl { margin: 0; }
.case-panel dl div { display: grid; grid-template-columns: 82px 1fr; gap: 0.65rem; padding: 0.6rem 0; border-top: 1px solid rgba(11, 82, 105, 0.15); }
.case-panel dt { font-family: var(--display); font-size: 0.78rem; font-weight: 800; }
.case-panel dd { margin: 0; color: var(--muted); font-size: 0.9rem; }

.form-grid, .evidence-workspace, .redesign-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
label { color: var(--ink); font-family: var(--display); font-size: 0.82rem; font-weight: 700; }
input, textarea, select {
  width: 100%;
  display: block;
  margin-top: 0.4rem;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0.72rem 0.8rem;
  font-family: var(--body);
  font-size: 0.94rem;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #829299; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 7px;
  padding: 0.72rem 1rem;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}
.button-primary { margin-top: 1rem; background: var(--canal-dark); color: #fff; }
.button-primary:hover { background: var(--coral); }
.button-secondary { margin-top: 1.1rem; border: 1px solid var(--canal); background: #fff; color: var(--canal); }

.code-card { margin-top: 1.5rem; background: #102d39; color: #e9f5f5; border: 1px solid #254b58; box-shadow: var(--shadow); }
.code-bar { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.65rem 0.85rem 0.65rem 1rem; border-bottom: 1px solid #345562; font-family: var(--mono); font-size: 0.78rem; }
.code-bar button { border: 1px solid #64bfb7; border-radius: 5px; background: transparent; color: #83ded5; padding: 0.4rem 0.62rem; font-family: var(--display); font-size: 0.73rem; font-weight: 700; cursor: pointer; }
.code-bar button:hover { background: #64bfb7; color: #0b2f39; }
pre { margin: 0; white-space: pre-wrap; overflow: auto; }
.code-card pre { max-height: 420px; padding: 1.25rem; font-size: 0.79rem; line-height: 1.7; }
.code-card.compact pre { max-height: 310px; }

.three-moves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 1.8rem 0; background: var(--line); border: 1px solid var(--line); }
.three-moves article { min-height: 175px; padding: 1.25rem; background: #fff; }
.three-moves b { color: var(--jade); font-family: var(--mono); font-size: 0.75rem; }
.three-moves h3 { margin: 1.2rem 0 0.35rem; font-size: 1.2rem; }
.three-moves p { margin: 0; color: var(--muted); font-size: 0.91rem; }

.demo-module { background: #eaf4f3; }
.demo-browser { margin-top: 1.8rem; border: 1px solid #587985; background: #fff; box-shadow: var(--shadow); }
.browser-bar { display: flex; align-items: center; gap: 0.42rem; min-height: 46px; padding: 0 0.9rem; background: var(--canal-dark); color: #cfe6e6; font-family: var(--mono); font-size: 0.72rem; }
.browser-bar i { width: 9px; height: 9px; border-radius: 50%; background: #5a7c87; }
.browser-bar i:first-child { background: var(--coral); }
.browser-bar i:nth-child(2) { background: var(--sun); }
.browser-bar i:nth-child(3) { background: #63c7a2; }
.browser-bar span { margin-left: 0.45rem; }
.browser-bar a { margin-left: auto; color: #83ded5; }
.demo-browser iframe { display: block; width: 100%; height: 980px; border: 0; background: #fff; }

.stage-complete {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  margin-top: 1.5rem;
  padding: 1rem;
  border: 2px solid var(--line-dark);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.stage-complete:hover { border-color: var(--jade); background: var(--jade-soft); }
.stage-complete .complete-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 2px solid var(--line-dark); border-radius: 50%; color: transparent; font: 800 1.2rem var(--display); }
.stage-complete span { font-family: var(--body); font-size: 0.9rem; font-weight: 400; }
.stage-complete b { display: block; font-family: var(--display); font-size: 1.03rem; text-transform: uppercase; }
.stage-complete small { display: block; margin-top: 0.18rem; color: var(--muted); font-size: 0.82rem; }
.stage-complete .complete-state { min-width: 94px; padding: 0.35rem 0.5rem; border: 1px solid var(--line); color: var(--muted); font: 600 0.68rem var(--mono); text-align: center; text-transform: uppercase; }
.stage-complete[aria-pressed="true"] { border-color: var(--jade); background: var(--jade-soft); }
.stage-complete[aria-pressed="true"] .complete-icon { border-color: var(--jade); background: var(--jade); color: #fff; }
.stage-complete[aria-pressed="true"] .complete-state { border-color: var(--jade); background: var(--jade); color: #fff; }
.final-three input { width: 24px; height: 24px; flex: 0 0 auto; margin: 0.05rem 0 0; accent-color: var(--sun); }

.pipeline-tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 1.8rem; border: 1px solid var(--line); }
.pipeline-tabs button { display: flex; align-items: center; gap: 0.6rem; border: 0; border-right: 1px solid var(--line); background: #f8fbfa; color: var(--muted); padding: 0.8rem; font-family: var(--display); font-size: 0.82rem; font-weight: 800; cursor: pointer; }
.pipeline-tabs button:last-child { border-right: 0; }
.pipeline-tabs button b { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line-dark); border-radius: 50%; font-family: var(--mono); font-size: 0.68rem; }
.pipeline-tabs button.active { background: var(--canal); color: #fff; }
.pipeline-tabs button.active b { border-color: #80d8cf; }

.pipeline-content { min-height: 240px; display: grid; grid-template-columns: 0.75fr 1.25fr; gap: 2rem; padding: 1.6rem; background: #eaf2f1; border: 1px solid var(--line); border-top: 0; }
.pipeline-content h3 { margin: 0; font-size: 1.35rem; }
.pipeline-content .level-copy p { color: var(--muted); }
.pipeline-content ul { margin: 0; padding-left: 1.2rem; }
.pipeline-content li { margin-bottom: 0.55rem; }
.pipeline-content label { align-self: stretch; }
.pipeline-content textarea { min-height: 155px; }

.cheatsheet-head, .atlas-head, .additional-head { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin: 2.7rem 0 1rem; }
.cheatsheet-head h3, .atlas-head h3, .additional-head h3 { max-width: 730px; margin: 0.25rem 0 0; font-size: clamp(1.35rem, 2.4vw, 2.1rem); line-height: 1.12; }
.cheatsheet-head > a { flex: none; font-size: 0.83rem; font-weight: 700; }

.figure-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.textbook-figure { margin: 0; display: flex; flex-direction: column; border: 1px solid var(--line); background: #fff; }
.figure-button { position: relative; min-height: 380px; display: grid; place-items: center; border: 0; border-bottom: 1px solid var(--line); background: #f6f7f4; padding: 1rem; cursor: zoom-in; overflow: hidden; }
.figure-button::after { content: "Open full figure"; position: absolute; right: 0.7rem; bottom: 0.7rem; padding: 0.35rem 0.5rem; border-radius: 4px; background: rgba(23, 38, 47, 0.88); color: #fff; font-family: var(--mono); font-size: 0.62rem; opacity: 0; transform: translateY(5px); transition: 0.2s ease; }
.figure-button:hover::after, .figure-button:focus-visible::after { opacity: 1; transform: none; }
.figure-button img { max-width: 100%; max-height: 470px; object-fit: contain; }
.textbook-figure figcaption { display: grid; gap: 0.45rem; padding: 1rem; }
.textbook-figure figcaption b { font-family: var(--display); }
.textbook-figure figcaption span { color: var(--muted); font-size: 0.88rem; }
.textbook-figure figcaption a { width: fit-content; font-size: 0.78rem; font-weight: 700; }
.figure-credit, .microcopy { color: var(--muted); font-size: 0.77rem; line-height: 1.45; }

.worked-note { margin-top: 1.5rem; padding: 1.25rem 1.35rem; border-left: 5px solid var(--canal); background: #edf5fb; }
.worked-note p { margin: 0.7rem 0 0; font-size: 0.93rem; }

.decision-tree { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.8rem; padding-bottom: 32px; }
.decision-tree::after { content: ""; position: absolute; left: 16%; right: 16%; bottom: 12px; border-bottom: 1px solid var(--line-dark); }
.decision-tree button { position: relative; min-height: 145px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 0.25rem; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 1rem; text-align: left; cursor: pointer; }
.decision-tree button::after { content: ""; position: absolute; left: 50%; bottom: -21px; height: 20px; border-left: 1px solid var(--line-dark); }
.decision-tree button span { font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; }
.decision-tree button b { font-family: var(--display); font-size: 1.15rem; }
.decision-tree button small { color: var(--muted); font-size: 0.76rem; }
.decision-tree button.active { color: #fff; transform: translateY(-4px); box-shadow: var(--shadow); }
.decision-tree button.active small { color: rgba(255, 255, 255, 0.78); }
.root-compare.active { background: var(--canal); border-color: var(--canal); }
.root-variation.active { background: var(--jade); border-color: var(--jade); }
.root-structure.active { background: var(--plum); border-color: var(--plum); }
.decision-stem { display: grid; place-items: center; margin-bottom: 1.3rem; }
.decision-stem span { padding: 0.55rem 0.85rem; background: var(--sun); color: #2f270f; font-family: var(--display); font-size: 0.78rem; font-weight: 800; }
.decision-stem i { height: 16px; border-left: 1px solid var(--line-dark); }
.decision-stem small { color: var(--muted); font-size: 0.74rem; }

.idiom-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.idiom-family { grid-column: 1 / -1; margin-top: 0.6rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); color: var(--coral); font-family: var(--mono); font-size: 0.71rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.idiom-card { min-width: 0; display: grid; grid-template-rows: 118px auto; border: 1px solid var(--line); background: #fff; }
.mini-chart { display: grid; place-items: center; min-height: 105px; padding: 0.65rem; background: #f2f6f5; border-bottom: 1px solid var(--line); }
.mini-chart svg { width: 100%; height: 100%; max-height: 98px; overflow: visible; }
.idiom-copy { padding: 0.85rem; }
.idiom-copy h4 { margin: 0; font-size: 0.95rem; }
.idiom-copy p { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.79rem; line-height: 1.4; }
.idiom-copy small { display: block; margin-top: 0.45rem; color: var(--coral); font-size: 0.7rem; }

.algorithm-ribbon { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 0.75rem; align-items: center; margin: 1.7rem 0; }
.algorithm-ribbon span { min-height: 90px; display: grid; align-content: center; padding: 1rem; background: var(--canal-dark); color: #dceff0; font-size: 0.83rem; }
.algorithm-ribbon b { display: block; color: #6ed2c8; font-family: var(--display); font-size: 0.95rem; }
.algorithm-ribbon i { color: var(--coral); font-style: normal; font-size: 1.4rem; }

.recipe-lab { display: grid; grid-template-columns: 0.7fr 1.3fr; border: 1px solid var(--line); background: #fff; }
.recipe-figure { display: grid; grid-template-rows: auto 1fr auto; min-height: 340px; padding: 1.1rem; background: var(--sun-soft); }
.recipe-figure > span, .recipe-figure > small { font-family: var(--mono); font-size: 0.68rem; }
.recipe-figure > div { display: grid; place-items: center; }
.recipe-figure svg { width: 100%; max-width: 330px; }
.recipe-code { min-width: 0; padding: 1rem; background: #102d39; color: #e9f5f5; }
.recipe-tabs { margin-bottom: 0.7rem; background: #1a414f; border-color: #345562; }
.recipe-tabs button { color: #c5dfe1; }
.recipe-code pre { max-height: 285px; padding: 0.5rem; font-size: 0.77rem; line-height: 1.65; }

.atlas-head p { max-width: 720px; margin: 0.55rem 0 0; color: var(--muted); }
.atlas-head label { width: min(290px, 100%); }
.atlas-controls { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.language-tabs button span { opacity: 0.65; font-family: var(--mono); font-size: 0.64rem; }
.category-tabs { flex-wrap: wrap; justify-content: flex-end; }

.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.tool-card { min-width: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr); min-height: 145px; border: 1px solid var(--line); background: #fff; }
.tool-card .mini-chart { min-height: 100%; border: 0; border-right: 1px solid var(--line); }
.tool-card .mini-chart svg { max-height: 78px; }
.tool-copy { min-width: 0; padding: 0.85rem; }
.tool-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.45rem; }
.tool-meta span { padding: 0.13rem 0.35rem; background: var(--surface-2); color: var(--muted); font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase; }
.tool-copy h4 { margin: 0; font-size: 0.94rem; }
.tool-copy p { margin: 0.35rem 0; color: var(--muted); font-size: 0.77rem; line-height: 1.35; }
.tool-copy a { font-size: 0.72rem; font-weight: 700; }
.empty-tools { grid-column: 1 / -1; padding: 2rem; border: 1px dashed var(--line-dark); color: var(--muted); text-align: center; }

.governance-three, .evidence-bands, .final-three, .source-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.8rem; }
.governance-three article { display: flex; flex-direction: column; min-height: 285px; padding: 1.25rem; background: var(--canal-dark); color: #fff; }
.governance-three article > span { color: #6ed2c8; font-family: var(--mono); font-size: 0.72rem; }
.governance-three h3 { margin: 1.2rem 0 0.55rem; font-size: 1.18rem; line-height: 1.2; }
.governance-three p { margin: 0; color: #c3dadd; font-size: 0.88rem; }
.governance-three article > div { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: auto; padding-top: 1rem; }
.governance-three a { padding: 0.28rem 0.45rem; border: 1px solid #5d8790; color: #7ed9d0; font-size: 0.72rem; text-decoration: none; }
.citation-model { border-left-color: var(--coral); background: #fff3ee; }
.evidence-workspace { margin-top: 1.2rem; padding: 1.25rem; background: #fff9e8; border: 1px solid #efd68d; }
.additional-data { margin-top: 2rem; padding-top: 0.2rem; border-top: 1px solid var(--line); }
.evidence-bands article { min-height: 170px; padding: 1rem; border-top: 4px solid var(--jade); background: #eff6f5; }
.evidence-bands b { font-family: var(--display); }
.evidence-bands p { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.85rem; }
.additional-data .form-grid { margin-top: 1rem; padding: 1.25rem; border: 1px solid var(--line); }

.before-after { display: grid; grid-template-columns: 1fr 48px 1fr; align-items: stretch; margin: 1.8rem 0; }
.before-after article { padding: 1.35rem; border: 1px solid var(--line); background: #fff; }
.before-after article:first-child { border-top: 5px solid var(--coral); }
.before-after article:last-child { border-top: 5px solid var(--jade); }
.before-after article > span { color: var(--muted); font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; }
.before-after h3 { margin: 0.8rem 0 0.45rem; font-size: 1.25rem; }
.before-after p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.change-mark { display: grid; place-items: center; color: var(--coral); font-size: 1.7rem; }
.redesign-form { margin: 1.5rem 0; padding: 1.25rem; background: #edf5fb; border: 1px solid #b8cfda; }

.final-module { background: var(--canal-dark); color: #fff; border-color: var(--canal-dark); }
.final-module .module-head { border-bottom-color: #42616b; }
.final-module .module-head > span { color: #6ed2c8; }
.final-module .module-head p { color: #c1d5d8; }
.final-three label { min-height: 185px; display: flex; gap: 0.75rem; align-items: flex-start; padding: 1.1rem; background: #123d4b; color: #fff; border: 1px solid #42616b; cursor: pointer; }
.final-three label:has(input:checked) { border-color: #6ed2c8; background: #154b53; }
.final-three span { font-family: var(--body); }
.final-three b { display: block; font-family: var(--display); font-size: 1rem; }
.final-three small { display: block; margin-top: 0.55rem; color: #c5dadd; font-size: 0.8rem; line-height: 1.4; }
.final-actions { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; margin-top: 1rem; }
.final-actions .button-primary { margin: 0; background: var(--sun); color: #2d250e; }
.final-actions .stage-complete { margin: 0; background: #154b53; border-color: #6ed2c8; color: #fff; }
.final-actions .stage-complete small { color: #c5dadd; }
.final-actions .stage-complete[aria-pressed="true"] { background: #17645f; }

.sources-module { margin-bottom: 4rem; }
.source-three article { padding-left: 1rem; border-left: 4px solid var(--canal); }
.source-three article:nth-child(2) { border-left-color: var(--jade); }
.source-three article:nth-child(3) { border-left-color: var(--sun); }
.source-three h3 { margin: 0 0 0.7rem; font-size: 1rem; }
.source-three a { display: block; margin: 0.45rem 0; font-size: 0.8rem; }

.figure-dialog { width: min(1050px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 1rem; border: 0; background: #fff; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32); }
.figure-dialog::backdrop { background: rgba(4, 26, 34, 0.78); }
.figure-dialog img { display: block; max-width: 100%; max-height: calc(100vh - 7rem); margin: auto; }
.figure-dialog p { margin: 0.65rem 3rem 0 0; font-family: var(--mono); font-size: 0.75rem; }
.dialog-close { position: sticky; float: right; top: 0.4rem; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--canal-dark); color: #fff; font-size: 1.35rem; cursor: pointer; }

#toast {
  position: fixed;
  z-index: 60;
  right: 1.2rem;
  bottom: 1.2rem;
  max-width: 320px;
  padding: 0.75rem 0.9rem;
  background: var(--ink);
  color: #fff;
  border-left: 4px solid var(--sun);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 0.2s ease;
  pointer-events: none;
  font-size: 0.85rem;
}
#toast.show { opacity: 1; transform: none; }

@media (max-width: 1200px) {
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .site-header { grid-template-columns: 220px 1fr auto; }
  .header-path span { padding-inline: 0.8rem; }
}

@media (max-width: 980px) {
  html { scroll-padding-top: 126px; }
  .site-header { grid-template-columns: 1fr auto; }
  .header-path { display: none; }
  .shell { display: block; }
  .rail { top: 72px; height: 54px; z-index: 25; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-intro, .case-link, .rail-progress, .rail > .text-button { display: none; }
  .rail nav { height: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
  .rail nav a { grid-template-columns: auto 1fr; justify-content: center; border-left: 0; border-bottom: 3px solid transparent; padding: 0.45rem; }
  .rail nav a.active { border-bottom-color: var(--jade); }
  .rail nav a > span { grid-row: 1; }
  .rail nav small { display: none; }
  .stage { scroll-margin-top: 126px; }
  .opening-grid, .example-student-grid { grid-template-columns: 1fr; }
  .brief-card { max-width: 550px; }
  .module-head { grid-template-columns: 125px minmax(0, 1fr); }
  .idiom-gallery { grid-template-columns: 1fr 1fr; }
  .tool-card { grid-template-columns: 92px minmax(0, 1fr); }
}

@media (max-width: 740px) {
  body { font-size: 16px; background-size: 24px 24px; }
  .site-header { min-height: 66px; padding: 0.55rem 0.75rem; }
  .brand { gap: 0.55rem; }
  .brand-mark { width: 38px; height: 38px; }
  .brand small { display: none; }
  .section-jumps a { padding-inline: 0.58rem; }
  .rail { top: 66px; }
  .rail nav a { grid-template-columns: 1fr; text-align: center; }
  .rail nav a > span { display: none; }
  .stage-opening { padding-inline: 1.15rem; }
  h1 { font-size: clamp(2.35rem, 13vw, 4rem); }
  .module { margin: 0.8rem; padding: 1.15rem; }
  .module-head { grid-template-columns: 1fr; gap: 0.55rem; }
  .form-grid, .evidence-workspace, .redesign-form { grid-template-columns: 1fr; }
  .three-moves, .figure-grid, .decision-tree, .idiom-gallery, .tool-grid, .governance-three, .evidence-bands, .final-three, .source-three { grid-template-columns: 1fr; }
  .three-moves article { min-height: auto; }
  .pipeline-tabs { grid-template-columns: 1fr 1fr; }
  .pipeline-tabs button:nth-child(2) { border-right: 0; }
  .pipeline-tabs button:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .pipeline-content { grid-template-columns: 1fr; gap: 1rem; }
  .figure-button { min-height: 280px; }
  .decision-tree { padding-bottom: 0; }
  .decision-tree::after, .decision-tree button::after { display: none; }
  .decision-tree button { min-height: 100px; }
  .decision-stem { margin-top: 0.7rem; }
  .algorithm-ribbon { grid-template-columns: 1fr; }
  .algorithm-ribbon i { transform: rotate(90deg); justify-self: center; }
  .recipe-lab { grid-template-columns: 1fr; }
  .atlas-head { align-items: stretch; flex-direction: column; }
  .atlas-head label { width: 100%; }
  .atlas-controls { align-items: stretch; flex-direction: column; }
  .language-tabs, .category-tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; border-radius: 8px; }
  .category-tabs { grid-template-columns: 1fr; }
  .language-tabs button, .category-tabs button { border-radius: 5px; }
  .tool-card { grid-template-columns: 84px minmax(0, 1fr); }
  .before-after { grid-template-columns: 1fr; }
  .change-mark { transform: rotate(90deg); min-height: 45px; }
  .final-actions { grid-template-columns: 1fr; }
  .demo-browser iframe { height: 690px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

@media print {
  .site-header, .rail, .section-jumps, .code-bar button, #showTools, #toast { display: none !important; }
  .shell { display: block; }
  .module { box-shadow: none; break-inside: avoid; }
  .demo-browser iframe { height: 600px; }
}
