.scene.drift {
  --drift-purple: #692568;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.drift-heading { display: block; margin-bottom: 0; }
#drift-title {
  display: grid;
  gap: .15em;
}
#drift-title span:last-child { color: var(--blue); }
.scene-tabs { overflow-x: auto; scrollbar-width: thin; }
.scene-tabs button { flex-shrink: 0; }
.drift-phases {
  display: flex;
  gap: 30px;
  border-bottom: 1px solid #dfe5ee;
}
.drift-phases button {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 0 14px;
  color: #727e8f;
  font-size: 13px;
  text-align: left;
}
.drift-phases button > span {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: #9aa4b1;
}
.drift-phases button::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: var(--drift-purple);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform calc(0.4s / var(--motivation-rate, 1)) var(--ease);
}
.drift-phases button[aria-pressed="true"] { color: var(--ink); }
.drift-phases button[aria-pressed="true"]::after { transform: scaleX(1); }
.drift-phases button:hover { color: var(--drift-purple); }
.drift-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #cbd4e2 transparent;
  border-radius: 18px;
  background: radial-gradient(ellipse at 80% 60%, #eaf0fa80, transparent 65%);
}
.drift-canvas {
  width: 100%;
  min-width: 760px;
  max-width: none;
  height: auto;
  max-height: 380px;
  overflow: visible;
}
.drift-canvas text { font: 400 15px Inter, sans-serif; fill: #627187; }
.drift-canvas .drift-small { font-size: 12px; fill: #7b8797; }
.drift-canvas .drift-hand { font: 400 25px TailHand, Inter, sans-serif; }
.drift-canvas .drift-math { font: 400 18px TailMath, serif; }
.drift-canvas .drift-ink { fill: var(--ink); }
.drift-canvas .drift-blue { fill: var(--blue); }
.drift-canvas .drift-purple { fill: var(--drift-purple); }
.drift-canvas .drift-orange { fill: var(--orange); }
.drift-canvas path, .drift-canvas line {
  stroke-linecap: round;
  stroke-linejoin: round;
}
.drift-controls {
  display: flex;
  align-items: center;
  gap: 1.125rem;
  padding-top: 1.0625rem;
  border-top: 1px solid #dfe5ee;
}
.drift-controls input {
  flex: 1;
  min-width: 0;
  height: 0.25rem;
  margin: 0;
  accent-color: var(--drift-purple);
  cursor: pointer;
}
.drift-progress {
  min-width: 7.25rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.drift-sources {
  align-self: flex-end;
  margin: 0;
  color: var(--muted);
  font: 400 0.76rem/1.5 Inter, sans-serif;
  text-align: right;
}
.drift-sources a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: #b9c8d9;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.drift-sources a:is(:hover, :focus-visible) { text-decoration-color: currentColor; }
@media (max-width: 850px) {
  .drift-phases { gap: 22px; }
}
@media (max-width: 600px) {
  .scene.drift { gap: 16px; }
  .scene-tabs button { flex: 0 0 auto; max-width: 190px; }
  .drift-chain-summary { visibility: hidden; }
  .drift-phases { gap: 15px; justify-content: space-between; }
  .drift-phases button { display: grid; gap: 6px; font-size: 12px; }
  .drift-canvas { min-width: 760px; }
  .drift-controls { gap: 10px; }
  .drift-progress { min-width: 96px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .drift *, .drift *::after { transition: none !important; }
}

#motivation { background: var(--chapter-light); }
.mot-story-head {
  --mot-tab-size: clamp(0.75rem, 0.9vw, 0.88rem);
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: start;
  gap: 0.45rem; padding-bottom: 0.8rem; border-bottom: 1px solid #d5dfe8;
}
#motivation #motivation-title {
  display: block; margin: clamp(1rem, 1.6vw, 1.45rem) 0 0; color: #1d3047;
  font: 600 calc(var(--mot-tab-size) + 0.22rem)/1.4 Inter, sans-serif;
  letter-spacing: -0.015em; text-wrap: pretty;
}
.mot-story-head .motivation-toolbar { align-items: center; margin: 0; gap: 1rem; }
.mot-story-head .scene-tabs { gap: 0.25rem; }
.mot-story-head .scene-tabs button {
  flex: none; padding: 0.49rem 0.75rem; border-radius: 2rem; white-space: nowrap;
  font: 500 var(--mot-tab-size)/1.35 Inter, sans-serif; color: #526576;
}
.mot-story-head .scene-tabs button.selected { background: #293f59; color: #fff; box-shadow: none; }
.mot-story-head .icon-button { width: 1.85rem; height: 1.85rem; margin: 0; }
#motivation .motivation-stage {
  min-height: 0; margin-top: clamp(1rem, 2vh, 1.65rem); border: 0; border-radius: 0;
  background: transparent; overflow: visible;
}
#motivation .scene { padding: 0; }
#motivation .drift-viewport { border-radius: 0; background: transparent; }
#motivation .drift-canvas { display: block; max-height: calc(30rem + 2 * var(--desktop-spacing)); }
#motivation .drift-phases {
  width: fit-content; max-width: 100%; flex-wrap: wrap; justify-content: flex-start;
  gap: 0.55rem 1.2rem; border: 0;
}
#motivation .drift-phases button {
  max-width: 100%; font-size: 0.77rem; line-height: 1.5; text-wrap: pretty; padding-bottom: 0.4rem;
}
#motivation .drift-controls, #motivation .scene-control { margin: 0.65rem 0 0; }
#motivation .frequency-caption {
  margin: 0 0 clamp(0.75rem, 1.7vh, 1.2rem); color: #3d5369;
  font: 400 clamp(0.83rem, 1.06vw, 0.98rem)/1.55 Inter, sans-serif;
}
#motivation .frequency-layout { align-items: center; }
#motivation .frequency-images img { height: auto; aspect-ratio: auto 1; border-radius: 0; }
#motivation .frequency-images .image-label, #motivation .curation-image-heading .image-label {
  font: 550 clamp(0.68rem, 0.82vw, 0.83rem)/1.4 Inter, sans-serif;
  text-transform: none; letter-spacing: 0; color: #455a70;
}
#motivation :is(.curation-image,.composite-target,.curation-pieces > *) { background: transparent; border-radius: 0; }
#motivation .scene-header { display: flex; align-items: center; justify-content: flex-end; margin: 0 0 0.65rem; }
#motivation .equation-line { display: flex; justify-content: center; }
#motivation #curation-equation {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; width: 100%;
  gap: 0.12em 0.24em; color: #304358;
  font: 400 clamp(0.62rem, 1.2vw, 1.075rem)/1.35 TailMath, Georgia, serif;
}
#curation-equation .equation-group { display: inline-flex; align-items: baseline; gap: 0.16em; }
#curation-equation .equation-operator { padding: 0; line-height: inherit; color: #53697d; }
#motivation #curation-equation .equation-term {
  padding: 0.12em 0.16em; min-height: 24px; align-content: center; font: inherit;
  transition: background calc(220ms / var(--motivation-rate, 1)) ease, color calc(220ms / var(--motivation-rate, 1)) ease;
}
.curation-flow[data-phase="preserve"] ~ .equation-line [data-curation-part="source"] { background: #e1efe4; }
.curation-flow[data-phase="edit"] ~ .equation-line [data-curation-part="edit"] { background: #e3ebf7; }
.curation-flow[data-phase="complete"] ~ .equation-line [data-curation-part="target"] { background: #e8edf4; }
#scene-terminal {
  --base-fill: #f1f4f7;
  --base-edge: #8091a3;
  --base-ink: #354a61;
  --tuned-fill: #315b93;
  --tuned-ink: #fff;
  max-width: 71rem;
  margin-inline: auto;
}
.terminal-protocol {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
  margin-bottom: clamp(0.9rem, 2.5vh, 1.8rem);
}
.terminal-train, .terminal-inference { min-width: 0; }
.terminal-panel-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 2.1rem;
  gap: 0.3rem 0.55rem;
}
.terminal-panel-heading h3 {
  margin-right: auto;
  color: #24384d;
  font: 600 0.96rem/1.35 Inter, sans-serif;
}
#terminal-target-link, .terminal-framework-link {
  color: #476480;
  font-size: 0.75rem;
}
#terminal-target-link { padding: 0.3rem 0.15rem; }
#terminal-target-link:hover, .terminal-framework-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
#terminal-replay { width: 1.75rem; height: 1.75rem; margin: 0; }
#scene-terminal .terminal-training-diagram {
  display: block;
  width: min(100%, 30rem);
  height: auto;
  margin: 0 auto;
}
.terminal-protocol svg {
  --early-fill: var(--base-fill);
  --early-edge: var(--base-edge);
  --early-ink: var(--base-ink);
  --late-fill: var(--base-fill);
  --late-edge: var(--base-edge);
  --late-ink: var(--base-ink);
}
.terminal-protocol .terminal-training-diagram,
.terminal-protocol [data-run="switch"],
.terminal-protocol [data-run="all"] {
  --late-fill: var(--tuned-fill);
  --late-edge: var(--tuned-fill);
  --late-ink: var(--tuned-ink);
}
.terminal-protocol [data-run="all"] {
  --early-fill: var(--tuned-fill);
  --early-edge: var(--tuned-fill);
  --early-ink: var(--tuned-ink);
}
.schedule-early rect { fill: var(--early-fill); stroke: var(--early-edge); }
.schedule-final rect { fill: var(--late-fill); stroke: var(--late-edge); }
.schedule-early text { fill: var(--early-ink); }
.schedule-final text { fill: var(--late-ink); }
.schedule-early circle { fill: var(--early-edge); }
.schedule-early rect, .schedule-final rect { stroke-width: 1.35; }
.schedule-early text, .schedule-final text {
  text-anchor: middle;
  font: 600 14px/1 Inter, sans-serif;
  font-variant-numeric: tabular-nums;
}
.schedule-connection { fill: none; stroke: #718298; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.term-note { font: 500 12px Inter, sans-serif; fill: #53667c; }
.term-math { font: 17px TailMath, Georgia, serif; fill: #334a61; }
.term-loss { font: 600 15px Inter, sans-serif; fill: #96532e; }
.terminal-weights { display: flex; align-items: center; gap: 0.9rem; color: #53667a; font: 400 0.73rem/1.35 Inter, sans-serif; }
.terminal-weights span { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.terminal-weights span::before { content: ""; width: 0.62rem; height: 0.62rem; box-sizing: border-box; border-radius: 2px; border: 1.3px solid var(--base-edge); background: var(--base-fill); }
.terminal-weights span:last-child::before { background: var(--tuned-fill); border-color: var(--tuned-fill); }
.terminal-runs { display: grid; gap: 0.35rem; margin: 0.25rem 0 0; }
.terminal-runs > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8.3rem, 47%);
  gap: 0.5rem;
  align-items: center;
}
.terminal-runs dt { color: #293c51; font: 500 clamp(0.79rem, 1.07vw, 0.95rem)/1.35 Inter, sans-serif; }
.terminal-runs dd { margin: 0; }
.terminal-runs svg { width: min(100%, 12.5rem); height: auto; margin-left: auto; }

.terminal-results {
  width: 100%; table-layout: fixed; border-spacing: 0;
  font: 500 clamp(0.74rem, 0.98vw, 0.9rem)/1.35 Inter, sans-serif;
}
.terminal-results .turn-column { width: clamp(2.35rem, 5vw, 4.25rem); }
.terminal-results th { font-weight: 550; color: #334a61; text-align: left; }
.terminal-results thead th {
  position: sticky; top: var(--header-height); z-index: 1;
  background: #f8fafc; box-shadow: inset 0 1px #d6e0e9;
  padding-block: 0.6rem;
}
.terminal-results tbody th { vertical-align: top; padding-top: 0.6rem; font-variant-numeric: tabular-nums; }
.terminal-results :is(th,td):not(:first-child) { padding-inline: clamp(0.16rem, 0.47vw, 0.45rem); }
.terminal-results :is(th,td):last-child { padding-right: 0; }
.terminal-results td { padding-block: 0.25rem clamp(0.3rem, 1vw, 0.8rem); vertical-align: top; }
.terminal-results img { display: block; width: 100%; height: auto; aspect-ratio: 347 / 217; }
.terminal-results img:not([src]) { visibility: hidden; }
#terminal-status:empty { display: none; }
#terminal-status button { color: var(--blue); padding-block: 0.6rem; }
.terminal-conclusion {
  display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap;
  gap: 0.45rem 2rem; margin-top: 0.65rem; padding-top: 0.9rem; border-top: 1px solid #d6e0e9;
}
.terminal-conclusion p {
  flex: 1 1 min(100%, 32rem); max-width: 76ch; margin: 0;
  color: #35485c; font: 400 clamp(0.88rem, 1.05vw, 1rem)/1.6 Inter, sans-serif;
}
.terminal-conclusion strong { font-weight: 600; color: var(--blue); }
.terminal-framework-link { display: inline-flex; align-items: baseline; gap: 0.35rem; padding-block: 0.25rem; white-space: nowrap; }
@media (max-width: 700px) {
  .terminal-protocol { grid-template-columns: minmax(0, 1fr); gap: 0.8rem; }
  .terminal-inference { border-top: 1px solid #dbe3ea; padding-top: 0.4rem; }
  .terminal-runs { gap: 0.25rem; }
  .terminal-results { font-size: clamp(0.67rem, 2.5vw, 0.83rem); }
  .terminal-results .turn-column { width: 2.1rem; }
}
@media (max-width: 800px) {
  .mot-story-head { grid-template-columns: minmax(0, 1fr); align-items: stretch; gap: 0.75rem; }
  .mot-story-head .motivation-toolbar { justify-content: space-between; }
  #motivation .drift-canvas { max-height: none; }
  .mot-story-head .scene-tabs { flex: 1; min-width: 0; }
  .mot-story-head .scene-tabs button { padding-inline: 0.58rem; }
}
@media (max-width: 520px) {
  .mot-story-head { padding-bottom: 0.75rem; }
  .mot-story-head .motivation-toolbar { gap: 0.25rem; }
  .mot-story-head .scene-tabs { flex-wrap: wrap; gap: 0.12rem; }
  .mot-story-head .scene-tabs button { padding-inline: 0.39rem; }

}
@media (prefers-reduced-motion: reduce) {
  #motivation .scene { animation: none; }
  #motivation .equation-term { transition: none; }
}
