/* page CSS: reading layout for the guide, the hero window, the lab, code panels, tool cards.
   One ease-out, UI under 300ms, press scale(.97) on this page's controls,
   hover only for a fine pointer, reduced motion keeps colour and drops movement. */
:root { --ease-out-e: cubic-bezier(0.23, 1, 0.32, 1); }

/* hero window: a one-shot training lab. Motion is CSS only, plays once on load,
   ease-out, each step under 300ms, then rests. Reduced motion shows the end state. */
.hero--split .hero__text {
  align-self: stretch;
  display: flex;
  flex-direction: column;
}
.hero-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4) var(--gutter);
  margin: auto 0 0;
  padding-top: var(--s-6);
}
.hero-counts > div { display: grid; gap: 2px; min-width: 0; }
.hero-counts dt {
  font: 400 13px/1.2 var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-counts dd {
  margin: 0;
  font: var(--display-weight) 28px/1 var(--font-display);
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
}

.win {
  background: #0c1020;
  color: #e9edf3;
  border-radius: var(--r-lg, 4px);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgb(17 17 17 / .12), 0 30px 70px -30px rgb(26 75 224 / .28);
  font: 400 14px/1.4 var(--font-text);
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.win__bar {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 14px; flex: 0 0 40px;
  border-bottom: 1px solid rgb(255 255 255 / .08);
  color: #9aa3b5; font-size: 13px;
}
.win__dots { display: flex; gap: 6px; }
.win__dots i { width: 10px; height: 10px; border-radius: 50%; background: #2a3144; }
.win__bar-title { font: 400 13px/1 var(--font-mono); color: #c9d0dc; }
.win__bar-cwd { margin-left: auto; font: 400 13px/1 var(--font-mono); color: #6e7789; }

.win__cmd {
  display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-bottom: 1px solid rgb(255 255 255 / .06);
  font: 400 13px/1 var(--font-mono);
  color: #dbe3ee;
  background: #101628;
  overflow: hidden;
}
.win__prompt { color: #8ec9ff; flex: none; }
.win__cmd-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win__caret {
  width: 7px; height: 14px; background: #8ec9ff; flex: none;
  opacity: 0;
}

.pipe {
  flex: 0 0 auto;
  display: flex; flex-direction: column; justify-content: center;
  gap: 14px;
  padding: 22px 22px 10px;
  min-height: 0;
}
.pipe__row {
  display: grid;
  grid-template-columns: 1fr 16px 1fr 16px 1fr 16px 1fr;
  gap: 8px;
  align-items: center;
}
.pipe__node {
  display: grid; place-items: center;
  min-height: 44px; padding: 8px 6px;
  border-radius: 4px;
  background: #131824;
  border: 1px solid rgb(255 255 255 / .08);
  text-align: center;
  color: #c9d0dc;
}
.pipe__node b {
  font: 500 13px/1.2 var(--font-text);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.pipe__node--start { box-shadow: inset 0 0 0 1px transparent; }
.pipe__line {
  height: 2px;
  background: #2a3144;
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}
.pipe__line::after {
  content: "";
  position: absolute; inset: 0;
  background: #5ab9fc;
  transform: scaleX(0);
  transform-origin: left;
}
.pipe__note {
  margin: 4px 0 0;
  font: 400 13px/1.4 var(--font-text);
  color: #8b93a7;
  display: flex; align-items: center; gap: 10px;
}
.pipe__note .ly-live { color: #8ec9ff; font: 400 13px/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase; }

.plot {
  flex: 1 1 auto;
  margin: 4px 16px 16px;
  padding: 12px 14px 12px;
  border-radius: 4px;
  background: #101628;
  border: 1px solid rgb(255 255 255 / .06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.plot__meta {
  display: flex; justify-content: space-between;
  font: 400 13px/1 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6e7789;
}
.plot__svg { width: 100%; flex: 1 1 auto; height: auto; min-height: 88px; display: block; }
.plot__grid { fill: none; stroke: rgb(255 255 255 / .07); stroke-width: 1; }
.plot__fill { fill: color-mix(in oklab, #1a4be0 32%, transparent); opacity: 0; }
.plot__line {
  fill: none;
  stroke: #8ec9ff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 280;
  stroke-dashoffset: 280;
}

/* one-shot entrance, tied to the page enter already on <html> */
.m-enter .win__cmd-text {
  clip-path: inset(0 100% 0 0);
  animation: win-cmd 240ms var(--ease-out-e) 120ms forwards;
}
.m-enter .win__caret {
  animation: win-caret 240ms var(--ease-out-e) 360ms forwards;
}
.m-enter .pipe__node {
  opacity: 0;
  transform: translateY(6px);
  animation: win-node 220ms var(--ease-out-e) forwards;
}
.m-enter .pipe__node[data-i="1"] { animation-delay: 200ms; }
.m-enter .pipe__node[data-i="2"] { animation-delay: 280ms; }
.m-enter .pipe__node[data-i="3"] { animation-delay: 360ms; }
.m-enter .pipe__node[data-i="4"] { animation-delay: 440ms; }
.m-enter .pipe__node[data-i="5"] { animation-delay: 520ms; }
.m-enter .pipe__node[data-i="6"] { animation-delay: 600ms; }
.m-enter .pipe__node[data-i="7"] { animation-delay: 680ms; }
.m-enter .pipe__node[data-i="8"] { animation-delay: 760ms; }
.m-enter .pipe__line::after {
  animation: win-line 200ms var(--ease-out-e) forwards;
}
.m-enter .pipe__line[data-i="1"]::after { animation-delay: 280ms; }
.m-enter .pipe__line[data-i="2"]::after { animation-delay: 360ms; }
.m-enter .pipe__line[data-i="3"]::after { animation-delay: 440ms; }
.m-enter .pipe__line[data-i="4"]::after { animation-delay: 520ms; }
.m-enter .pipe__line[data-i="5"]::after { animation-delay: 600ms; }
.m-enter .pipe__line[data-i="6"]::after { animation-delay: 680ms; }
.m-enter .pipe__line[data-i="7"]::after { animation-delay: 760ms; }
.m-enter .pipe__node--start {
  animation-name: win-node-start;
}
.m-enter .plot__line {
  animation: win-plot 700ms var(--ease-out-e) 800ms forwards;
}
.m-enter .plot__fill {
  animation: win-fill 500ms var(--ease-out-e) 1100ms forwards;
}

@keyframes win-cmd { to { clip-path: inset(0 0 0 0); } }
@keyframes win-caret { to { opacity: 1; } }
@keyframes win-node {
  to { opacity: 1; transform: none; }
}
@keyframes win-node-start {
  to {
    opacity: 1;
    transform: none;
    background: color-mix(in oklab, #1a4be0 28%, #131824);
    border-color: color-mix(in oklab, #5ab9fc 55%, transparent);
    color: #e9edf3;
  }
}
@keyframes win-line { to { transform: scaleX(1); } }
@keyframes win-plot { to { stroke-dashoffset: 0; } }
@keyframes win-fill { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .m-enter .win__cmd-text,
  .m-enter .win__caret,
  .m-enter .pipe__node,
  .m-enter .pipe__node--start,
  .m-enter .pipe__line::after,
  .m-enter .plot__line,
  .m-enter .plot__fill { animation: none; }
  .win__cmd-text { clip-path: none; }
  .win__caret { opacity: 1; }
  .pipe__node { opacity: 1; transform: none; }
  .pipe__node--start {
    background: color-mix(in oklab, #1a4be0 28%, #131824);
    border-color: color-mix(in oklab, #5ab9fc 55%, transparent);
    color: #e9edf3;
  }
  .pipe__line::after { transform: scaleX(1); }
  .plot__line { stroke-dashoffset: 0; }
  .plot__fill { opacity: 1; }
}

/* contents */
.contents { border-top: 1px solid var(--line); }
.contents__top { align-items: end; margin-bottom: var(--s-7, 56px); }
#contents .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-6); }
#contents .stat { border-top: 1px solid var(--line); padding-top: var(--s-4); display: grid; gap: 6px; }
#contents .t-stat { font-variant-numeric: tabular-nums; }
@media (max-width: 639px) { #contents .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.toc { display: grid; grid-template-columns: 1fr; gap: var(--s-8) var(--s-6); }
.toc__h { font: 500 14px/1.4 var(--font-text); color: var(--muted); margin-bottom: var(--s-3); }
.toc__g ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.toc__a {
  display: flex; align-items: baseline; gap: 12px;
  padding: 12px 0; min-height: 44px; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
  transition: color 150ms ease, transform 160ms var(--ease-out-e);
}
.toc__a .mono, .toc__n { flex: 0 0 2.4em; color: var(--muted); font-size: 13px; }
.toc__a:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .toc__a:hover { color: var(--accent); } }
@media (min-width: 700px) {
  .toc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toc__g:first-child { grid-column: 1 / -1; }
  .toc__g:first-child ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--s-6);
  }
}
@media (min-width: 1280px) {
  .toc { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* statement / iris */
.statement { min-height: 100svh; display: grid; align-items: center; }
.statement .wrap { padding-block: var(--s-10, 96px); }
.statement h2 { font-size: clamp(32px, 4.6vw, 64px); letter-spacing: var(--display-tracking-xl); max-width: 16ch; line-height: 1.05; }
.statement p { max-width: 42ch; font-size: 18px; }

/* guide reading layout */
main > section.guide, main > section#tools, main > section#questions,
main > section.lab, main > section.contents {
  height: auto; min-height: 100svh;
}
main > section.guide > .wrap,
main > section#tools > .wrap,
main > section#questions > .wrap,
main > section.lab > .wrap,
main > section.contents > .wrap { height: auto; }
.guide { border-top: 1px solid var(--line); }
.guide .wrap.grid { align-items: stretch; }
.guide__stick { position: sticky; top: calc(var(--bar, 64px) + 32px); display: grid; gap: var(--s-4); padding-bottom: var(--s-8); }
.guide__no { color: var(--muted); font-size: 14px; }
.guide__no .mono { color: var(--accent); margin-right: 6px; }
.guide__intro { color: var(--muted); max-width: 40ch; }
.guide__when { font-size: 14px; max-width: 42ch; }
.guide__when b { font-weight: 500; display: block; margin-bottom: 4px; }
.fx { padding-block: var(--s-6, 40px); border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--bar, 64px) + 16px); }
.fx:first-child { padding-top: 0; }
.fx:last-child { border-bottom: 0; }
.fx__title {
  display: flex; gap: 14px; align-items: baseline;
  font: 500 22px/1.3 var(--font-display); letter-spacing: -0.01em;
  margin-bottom: var(--s-4);
}
.fx__num { font: 400 14px/1 var(--font-mono); color: var(--accent); text-decoration: none; min-width: 3ch; padding: 15px 0; margin: -15px 0; }
.fx__lead, .fx p, .fx li { max-width: 65ch; }
.fx p { margin: 0 0 1em; }
.fx ul, .fx ol { margin: 0 0 1.2em; padding-left: 1.15em; display: grid; gap: 8px; }
.fx li { padding-left: .1em; }
.fx p code, .fx li code { overflow-wrap: break-word; }
.rule {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md, 4px);
  padding: 16px 18px;
  margin: 0 0 1.2em;
  max-width: 65ch;
}
.rule strong { font-weight: 500; }
.kv { display: grid; gap: 10px; margin: 0 0 1.2em; }
.kv div { display: grid; grid-template-columns: 11em minmax(0, 1fr); gap: var(--s-4); }
.kv dt { color: var(--muted); font-size: 14px; padding-top: 2px; }
.kv dd { margin: 0; max-width: 65ch; }
@media (max-width: 639px) { .kv div { grid-template-columns: 1fr; gap: 4px; } }

.code {
  border: 1px solid var(--line);
  border-radius: var(--r-md, 4px);
  overflow: hidden;
  background: #0c1020;
  margin: 0 0 1.2em;
  min-width: 0;
}
.code__bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
  padding: 0 6px 0 14px; min-height: 44px; height: auto;
  border-bottom: 1px solid rgb(255 255 255 / .08);
  font: 400 13px/1.3 var(--font-mono); color: #8b93a7;
}
.code__bar > span { min-width: 0; flex: 1 1 auto; }
.code pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  white-space: pre; overflow-wrap: normal; word-break: normal;
  font: 400 13px/1.6 var(--font-mono); color: #dbe3ee; tab-size: 4;
  min-width: 0;
}
.code .tk { color: #8ec9ff; }
.code .ts { color: #e0c98a; }
.code .tn { color: #e0a98a; }
.code .tc { color: #7b8494; font-style: italic; }
.code .tb { color: #b9c9d6; }
.code .to { color: #8b93a7; }
.copy {
  position: relative; display: inline-grid; place-items: center;
  flex: none;
  min-width: 76px; height: 44px; min-height: 44px; padding: 0 12px;
  border: 1px solid rgb(255 255 255 / .14); border-radius: 4px;
  background: transparent; color: #e9edf3;
  font: 500 13px/1 var(--font-text); cursor: pointer;
  transition: transform 160ms var(--ease-out-e), background-color 150ms ease, border-color 150ms ease;
}
.copy::before { content: ""; position: absolute; inset: -6px -2px; }
.copy > span { grid-area: 1 / 1; transition: opacity 200ms ease, filter 200ms ease, transform 200ms var(--ease-out-e); }
.copy__b { opacity: 0; filter: blur(2px); transform: scale(0.97); }
.copy.is-done .copy__a { opacity: 0; filter: blur(2px); transform: scale(0.97); }
.copy.is-done .copy__b { opacity: 1; filter: blur(0); transform: none; color: #8ec9ff; }
.copy:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .copy:hover { background: rgb(255 255 255 / .05); border-color: rgb(255 255 255 / .28); }
}

.tools {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  margin: 0 0 1.2em;
}
.tool {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
  transition: transform 160ms var(--ease-out-e);
}
.tool:last-child { border-bottom: 0; }
.tool:active { transform: scale(0.97); }
.tool h3 { font: 500 16px/1.3 var(--font-text); margin: 0 0 4px; }
.tool p { margin: 0; color: var(--muted); font-size: 14px; max-width: 58ch; }
.tool .go { font: 400 13px/1 var(--font-mono); color: var(--accent); align-self: center; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { a.tool:hover h3 { color: var(--accent); } }

.grid-tools {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0; border-top: 1px solid var(--line);
}
.grid-tools .tool { padding: 18px 0; }
@media (max-width: 699px) { .grid-tools { grid-template-columns: 1fr; } }

@media (max-width: 1023px) {
  .hero--split .hero__text { display: flex; }
  .hero-counts {
    margin: var(--s-5) 0 0;
    padding-top: 0;
    gap: var(--s-4);
  }
  .hero-counts dd { font-size: 24px; }
  .pipe { padding: 14px 14px 4px; gap: 10px; }
  .plot { margin: 6px 12px 12px; }
  .plot__svg { height: 72px; }
  .win { min-height: 240px; }
}
@media (max-width: 639px) {
  .hero-counts { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .hero-counts dd { font-size: 20px; }
  .pipe__node { min-height: 44px; padding: 6px 4px; }
  .pipe__node b { font-size: 13px; }
  .pipe__note { font-size: 13px; }
  .win__cmd { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .copy, .toc__a, .tool { transition: none; }
}

@media (max-width: 1023px) {
  .ly-float { display: none; }
}
@media (max-width: 639px) {
  .hero .btn-row { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .hero .btn-row .btn { width: 100%; height: 44px; justify-content: center; }
  .hero .btn--secondary { text-decoration: none; border: 1px solid var(--line-strong); background: transparent; }
}


/* Machina-style tools-per-stage and the usual-start route */
.pipe__thesis {
  margin: 0; padding: 12px 22px 0;
  font: 500 16px/1.3 var(--font-display);
  letter-spacing: -0.02em; color: #e9edf3; flex: none;
}
.pipe__node {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 3px;
}
.pipe__node i {
  font-style: normal;
  font: 400 13px/1.2 var(--font-mono);
  letter-spacing: 0.02em;
  color: #8b93a7;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pipe__node--start i { color: #8ec9ff; }
.pipe__node--later {
  border-style: dashed;
  color: #9aa3b5;
}
.pipe__node--later b { font-weight: 500; }
.pipe__line--skip {
  background-image: repeating-linear-gradient(90deg, #2a3144 0 5px, transparent 5px 8px);
  background-color: transparent;
}
@media (max-width: 639px) {
  .pipe__thesis { padding: 10px 14px 0; font-size: 16px; }
  .pipe__node i { font-size: 13px; }
  .pipe { padding: 14px 12px 8px; gap: 10px; }
}


@media (max-width: 639px) {
  .pipe__row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 8px;
  }
  .pipe__line { display: none; }
  .pipe__node { min-width: 0; }
  .plot { min-height: 96px; margin: 0 12px 12px; }
}


/* Force the Machina hero board to keep its height on a phone, and let the
   hero grow instead of clipping the visual. */
@media (max-width: 1023px) {
  section.hero.hero--split {
    height: auto !important;
    min-height: 100svh !important;
  }
  section.hero.hero--split > .wrap,
  section.hero.hero--split .hero-text,
  section.hero.hero--split .hero__grid {
    height: auto !important;
    min-height: 0 !important;
  }
  section.hero.hero--split .hero__media,
  section.hero.hero--split .run,
  section.hero.hero--split .win {
    height: auto !important;
    min-height: 280px !important;
    flex: 0 0 auto !important;
    overflow: visible !important;
  }
}


/* ---------- sticky on-page bar ---------- */
.toc-bar {
  position: sticky;
  top: var(--nav);
  z-index: 40;
  background: color-mix(in srgb, var(--p-bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.toc-bar__in {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px var(--gut, 24px);
  scrollbar-width: thin;
}
.toc-bar a {
  flex: none;
  height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  font: 500 13px/1 var(--font-mono);
  color: var(--p-muted);
  text-decoration: none;
  border-radius: 2px;
  white-space: nowrap;
}
.toc-bar a.is-on { color: var(--p-ink); background: var(--p-surface); }
.toc-bar a:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .toc-bar a:hover { color: var(--p-ink); }
}


/* Leave room for the fixed nav and the sticky on-page bar. */
.lab-card, .fx, #lab, #contents, #start-here, #tools, #questions, #guide,
.lab-card h3, .decide-form fieldset, .quiz-q, .wrong, :target {
  scroll-margin-top: calc(var(--nav) + 72px);
}
/* ---------- lab ---------- */
.lab { border-top: 1px solid var(--line); }
.lab__head { max-width: 46rem; margin-bottom: var(--s-8, 40px); }
.lab-card {
  border: 1px solid var(--line);
  background: var(--p-bg);
  padding: var(--s-7, 32px);
  margin-bottom: var(--s-7, 32px);
}
.lab-card__h { max-width: 46rem; margin-bottom: var(--s-6, 24px); }
.lab-card__h h3 { font: 500 28px/1.15 var(--font-display); letter-spacing: var(--display-tracking); margin: 0 0 8px; }
.lab-k {
  font: 500 13px/1.3 var(--font-mono);
  color: var(--p-accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-7, 32px);
  align-items: start;
}
.lab-form, .rec-form, .tpl-form, .decide-form { display: grid; gap: var(--s-4, 16px); }
.lab-cost { border: 1px solid var(--line); padding: var(--s-4, 16px); margin: 0; }
.lab-cost legend { font: 500 13px/1.3 var(--font-mono); padding: 0 6px; }
.lab-cost__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4, 16px); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--p-bg);
  font: 500 13px/1 var(--font-mono);
  color: var(--p-ink);
  cursor: pointer;
}
.chip.is-on { background: var(--p-ink); color: var(--p-bg); border-color: var(--p-ink); }
.chip:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--p-ink); }
}

.field input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--p-accent);
  padding: 0;
  border: 0;
  background: transparent;
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }

.lab-result { background: var(--p-surface); padding: var(--s-5, 20px); min-height: 8rem; }
.lab-facts { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.lab-facts li { font-size: 16px; line-height: 1.5; }
.lab-facts strong { display: block; font-weight: 500; font-size: 13px; font-family: var(--font-mono); margin-bottom: 2px; }
.lab-fit { font-weight: 500; margin: 0 0 12px; padding: 12px; border-left: 3px solid var(--p-accent); background: var(--p-bg); }
.lab-fit--ok { border-color: #1a7a3c; }
.lab-fit--tight { border-color: #b36b00; }
.lab-fit--no { border-color: #b42318; }
.lab-note { font-size: 14px; color: var(--p-muted); margin: 0 0 8px; max-width: 62ch; }
.lab-rec { margin: 0 0 12px; font-size: 16px; line-height: 1.5; max-width: 62ch; }
.lab-rec strong { display: block; font-weight: 500; margin-bottom: 4px; font-size: 18px; }

.decide-form fieldset {
  border: 0;
  margin: 0;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.decide-form legend { font-weight: 500; margin-bottom: 4px; padding: 0; }
.decide-form label, .quiz-q label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;
  padding: 8px 0;
  font-size: 16px;
  cursor: pointer;
}
.decide-form input, .quiz-q input { margin-top: 4px; flex: none; accent-color: var(--p-accent); width: 18px; height: 18px; }

.exp { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: var(--s-6, 24px); align-items: start; }
.exp-nav { display: grid; gap: 2px; }
.exp-nav button, .loss-tabs button {
  min-height: 44px;
  text-align: left;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font: 500 13px/1.2 var(--font-mono);
  color: var(--p-muted);
  cursor: pointer;
}
.exp-nav button[aria-selected="true"], .loss-tabs button[aria-selected="true"] {
  color: var(--p-ink);
  background: var(--p-surface);
}
.exp-nav button:active, .loss-tabs button:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .exp-nav button:hover, .loss-tabs button:hover { color: var(--p-ink); }
}
.exp-body h3 { font: 500 22px/1.2 var(--font-display); letter-spacing: var(--display-tracking); margin: 0 0 16px; }
.kv { display: grid; gap: 12px; margin: 0 0 20px; }
.kv > div { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 12px; }
.kv dt { font: 500 13px/1.4 var(--font-mono); color: var(--p-muted); }
.kv dd { margin: 0; font-size: 15px; line-height: 1.45; }
.check { margin: 0 0 20px; padding: 0 0 0 1.1em; }
.check li { margin: 0 0 6px; }

.loss-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.loss-tabs button { min-width: 44px; }
.loss-board { background: #111; color: #fff; padding: 16px 16px 12px; position: relative; }
.loss-meta { display: flex; justify-content: space-between; font: 500 13px/1 var(--font-mono); color: #8b93a7; margin: 0 0 8px; }
.loss-svg { width: 100%; height: 180px; display: block; }
.loss-grid { fill: none; stroke: #2a2a2a; stroke-width: 0.6; }
.loss-series { stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: stroke; paint-order: stroke; }
.loss-series--train { stroke: #ffffff; }
.loss-series--val { stroke: #7aa2ff; }
.loss-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font: 400 13px/1.4 var(--font-text); color: #c8c8c8; }
.swatch { display: inline-block; width: 16px; height: 2px; margin-right: 8px; vertical-align: middle; background: #fff; }
.swatch--val { background: #7aa2ff; }
.loss-tip {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: 36ch;
  margin: 0;
  padding: 8px 10px;
  background: #1e1e1e;
  color: #fff;
  font: 400 13px/1.4 var(--font-text);
  pointer-events: none;
}

.rec-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rec-out { margin-top: var(--s-5, 20px); }
.quiz-q { border-top: 1px solid var(--line); padding: 16px 0; }
.quiz-q p { font-weight: 500; margin: 0 0 8px; }
.quiz-out { min-height: 1.4em; font-size: 14px; color: var(--p-muted); margin: 8px 0 0; }
.quiz-out[data-ok="yes"] { color: #1a7a3c; }
.quiz-out[data-ok="no"] { color: #b42318; }

.wrong {
  margin-top: var(--s-5, 20px);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.wrong summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font: 500 14px/1.3 var(--font-mono);
  list-style: none;
}
.wrong summary::-webkit-details-marker { display: none; }
.wrong summary::before { content: "+"; margin-right: 8px; color: var(--p-accent); }
.wrong[open] summary::before { content: "-"; }
.wrong p, .wrong .check { margin-top: 8px; }
.fx .lab-k { margin-top: 4px; }

@media (max-width: 1023px) {
  .lab-grid, .exp, .rec-form, .lab-cost__row, .kv > div {
    grid-template-columns: 1fr;
  }
  .lab-card { padding: var(--s-5, 20px); }
  .exp-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .kv dt { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .loss-series { transition: none !important; }
  .toc-bar, .chip, .copy, .exp-nav button, .loss-tabs button, .toc-bar a {
    transition: none !important;
  }
}

/* Guide sticky side accounts for the fixed nav plus the on-page bar. */
.guide__stick { top: calc(var(--nav) + 48px + 16px); }

.lab .code pre, #tpl-out {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
