/* A lesson diagram is a stop for its arrow keys. Where it fits the screen under the header, the browser's focus
   scroll brings it there whole with its ring: 8px under the header, where the page keeps 72px for a stop (styles.css),
   and 8px over the screen's foot. Retries' schedule at 390 stood with its ring 18px past the foot (R9-03). A taller
   one the browser centres, which left Evolve's title under the header on a phone (R10-C3): as every figure does, it
   stands its top 8px under the header as the focus comes into it (holdFoot, timeline.mjs). */
.lesson-diagram {
  --scene-padding: 28px;
  scroll-margin-top: calc(8px - 72px);
}
/* A cell holds the old words while they fade out over the new ones (a .figure-ghost, stage.css). */
.lesson-diagram [data-cell] { position: relative; }
.lesson-diagram-scroll { overflow-x: auto; }
/* A scene that scrolls inside its card, as on a phone, fades at an edge past which there is more of it; a schedule's
   left edge holds its lanes' pinned names, so only its right edge fades. */
.lesson-diagram-scroll[data-more="right"],
.lesson-diagram-scroll:has(.diagram-schedule)[data-more="left right"] {
  mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
}
.lesson-diagram-scroll:not(:has(.diagram-schedule))[data-more="left"] {
  mask-image: linear-gradient(to left, black calc(100% - 28px), transparent);
}
.lesson-diagram-scroll:not(:has(.diagram-schedule))[data-more="left right"] {
  mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent);
}
.diagram-scene {
  position: relative;
  min-width: 600px;
  /* The sentence under the scene stands about 24 under its last row. */
  padding: 24px var(--scene-padding) 20px;
  isolation: isolate;
}
.diagram-name {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font: 600 var(--text-sm) / 1.3 var(--sans);
}
.diagram-name .part-mark { flex: none; }
.diagram-name:is([data-part="loop"], [data-part="multi"]) .part-mark { color: var(--fig-model); }
.diagram-name:is([data-part="session"], [data-part="context"]) .part-mark { color: var(--fig-store); }
.diagram-name[data-part="tools"] .part-mark { color: var(--fig-tool); }
.diagram-scene h3 { margin: 0; color: var(--ink); font: 600 var(--text-sm) / 1.3 var(--sans); }
.diagram-datum {
  --status-ink: var(--muted);
  --status-fill: var(--sunken);
  position: relative;
  min-width: 0;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 3px;
}
.diagram-datum[data-tone="idle"] .diagram-name { color: var(--faint); }
.diagram-datum[data-reveal][aria-hidden="true"] {
  visibility: hidden;
}
.diagram-datum[data-tone="active"] { --status-ink: var(--accent-ink); --status-fill: var(--accent-pale); }
.diagram-datum[data-tone="ok"] { --status-ink: var(--ok); --status-fill: var(--ok-pale); }
.diagram-datum[data-tone="bad"] { --status-ink: var(--danger); --status-fill: var(--danger-pale); }
.diagram-detail { color: var(--muted); font: 400 var(--text-sm) / 1.35 var(--sans); }
.diagram-detail:empty { display: none; }
/* A status is the AI elements' status pill (elements.css): a dot and the word on a pale fill of its tone, or outlined
   where it has none, so a schedule reads as a queue of tasks, each running, ready or queued. The dot is drawn here, so
   the word can change without the pill being drawn again. */
.diagram-datum { --pill-ink: var(--muted); --pill-fill: transparent; --pill-edge: var(--line-strong); }
.diagram-datum[data-tone="active"] { --pill-ink: var(--accent-ink); --pill-fill: var(--accent-pale); --pill-edge: transparent; }
.diagram-datum[data-tone="ok"] { --pill-ink: var(--ok); --pill-fill: var(--ok-pale); --pill-edge: transparent; }
.diagram-datum[data-tone="bad"] { --pill-ink: var(--danger); --pill-fill: var(--danger-pale); --pill-edge: transparent; }
.diagram-status { position: relative; display: block; min-height: 18px; }
.diagram-status > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  border: 1px solid var(--pill-edge);
  border-radius: var(--radius-sm);
  background: var(--pill-fill);
  color: var(--pill-ink);
  font: 400 var(--text-xs) / 16px var(--sans);
  white-space: nowrap;
}
.diagram-status > span::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.diagram-status > span:empty { visibility: hidden; }
/* A pill too wide for its bar gives up its dot (.is-tight), then its words (.is-dot), at the same height; the bar's
   title says the words. */
.diagram-status > span.is-tight { padding-inline: 3px; }
.diagram-status > span.is-tight::before { display: none; }
.diagram-status > span.is-dot { gap: 0; padding-inline: 4px; font-size: 0; }
@media (forced-colors: active) {
  .diagram-status > span { border-color: CanvasText; }
}

/* The bar sits on an actual time axis. A gap means the actor was idle. */
.diagram-schedule { --name-width: 142px; }
.diagram-axis, .diagram-lane {
  display: grid;
  grid-template-columns: var(--name-width) minmax(0, 1fr);
  align-items: center;
}
.diagram-axis > .diagram-name { font-size: var(--text-xs); color: var(--muted); }
.diagram-ticks {
  position: relative;
  height: 25px;
  border-bottom: 1px solid var(--line-strong);
  font: 400 var(--text-xs) / 1.4 var(--mono);
}
.diagram-ticks span {
  position: absolute;
  left: var(--at);
  transform: translateX(-50%);
  color: var(--muted);
}
.diagram-ticks .is-current { color: var(--accent-ink); }
.diagram-time-area { position: relative; display: grid; gap: 12px; padding-bottom: 4px; }
.diagram-time-guides { position: absolute; inset: 0 0 0 var(--name-width); pointer-events: none; }
.diagram-time-guides::before {
  position: absolute;
  inset: 0;
  content: "";
  background: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px calc(100% / var(--columns)));
  border-right: 1px solid var(--line);
}
/* The cursor stands over the grid and under the bars, which are opaque, so it never crosses a bar's words. */
.diagram-time-cursor {
  position: absolute;
  inset-block: 0;
  left: var(--time, 0%);
  width: 1px;
  background: var(--accent);
}
.diagram-lane { position: relative; min-height: 50px; }
.diagram-lane-bars {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  align-items: center;
  min-height: 48px;
}
.schedule-group {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.schedule-group > .diagram-name { width: var(--name-width); min-height: 22px; }
.schedule-group .diagram-lane > .diagram-name { padding-left: 14px; font-weight: 400; }
.schedule-bar {
  --bar-fill: var(--accent-pale);
  --bar-active: color-mix(in srgb, var(--bar-ink) 22%, var(--surface));
  --bar-ink: var(--accent);
  min-height: 42px;
  margin-inline: 2px;
  grid-row: 1;
  grid-column: var(--start) / span var(--span);
  grid-template-columns: minmax(0, 1fr);
  padding: 3px 5px 5px;
  isolation: isolate;
}
/* A bar's name and status stay inside it: the name ends in an ellipsis, and the player narrows a status too wide for
   the bar (.is-tight, then .is-dot). */
.schedule-bar > :is(.diagram-name, .diagram-status) { min-width: 0; max-width: 100%; }
/* A schedule keeps the width it has in a desktop's card, at which its bars hold their names and statuses: a narrower
   card scales the whole scene (stageZoom), so its words shrink together rather than each bar giving its words up. On
   a phone it scrolls instead, at its least width per unit of time (below). */
.lesson-diagram .diagram-scene:has(.diagram-schedule) { min-width: 1040px; }
.schedule-bar .diagram-label { min-width: 0; overflow: hidden; white-space: nowrap; }
/* A name the bar cannot hold whole is left out (lesson-diagrams.mjs, fit); the bar's title says it. */
.schedule-bar .diagram-label.is-unnamed { visibility: hidden; }
/* A bar wider than what the scene shows (`.is-wide`, lesson-diagrams.mjs), as Evolve's archive is on a phone, keeps its
   name and status just inside the view's left edge while the scene scrolls under them, so they show wherever the
   clock stands. */
.schedule-bar.is-wide > :is(.diagram-name, .diagram-status) { position: sticky; left: 5px; }
/* Under the fill stands the plan: the bar's whole length, opaque, in a hairline. The fill covers it as the clock goes. */
.schedule-bar::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  content: "";
  border-radius: 4px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
/* A bar still running when the axis ends (`open`) runs on past it: its plan fades out at the axis's end. */
.schedule-bar.is-open { margin-right: 0; }
.schedule-bar.is-open::before, .schedule-bar.is-open .schedule-elapsed {
  border-radius: 4px 0 0 4px; mask-image: linear-gradient(to right, black calc(100% - 40px), transparent);
}
/* A bar is its fill and its name. The part the clock has reached stands in a deeper fill while it runs. A bar in a
   part's pale fill runs in that part's fill in use, which the theme sets: on the dark surface the pale fill already
   holds a fifth of the colour, so a share mixed here would be lost against it. */
.schedule-elapsed {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: 4px;
  background: var(--bar-fill);
  clip-path: inset(0 calc((1 - var(--elapsed)) * 100%) 0 0);
}
.schedule-bar[data-tone="active"] .schedule-elapsed { background: var(--bar-active); }
/* Before the clock reaches a bar it stands as the plan: a hairline and its name, faint, so the figure shows the whole
   schedule at rest. The bar takes its fill when the clock reaches it; a reader of the page hears it only then. */
.schedule-bar[data-reveal][aria-hidden="true"] { visibility: visible; }
.schedule-bar[data-reveal][aria-hidden="true"] .diagram-name { color: var(--faint); }
.schedule-bar[data-reveal][aria-hidden="true"] .diagram-status > span { visibility: hidden; }
.schedule-bar .diagram-name { font-size: var(--text-xs); white-space: nowrap; }
.schedule-bar .diagram-status { min-height: 14px; }
.schedule-bar .diagram-status > span { white-space: nowrap; }
.schedule-bar[data-cell="request-2"] { padding-inline: 2px; }
.schedule-bar:is([data-cell="parent-wait"], [data-cell="serial-wait"]) { --bar-fill: var(--sunken); --bar-ink: var(--muted); }
[data-lesson-diagram="async"] .schedule-group .schedule-bar,
[data-lesson-diagram="subagents"] .schedule-bar:is([data-cell$="-a"], [data-cell$="-b"]) {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="async"] .schedule-group .schedule-bar[data-tone="active"] {
  --status-ink: var(--fig-tool-on-active);
}
[data-lesson-diagram="subagents"] .schedule-bar:is([data-cell$="-a"], [data-cell$="-b"])[data-tone="active"] {
  --status-ink: var(--fig-tool-on-active);
}
[data-lesson-diagram="async"] .diagram-lane { min-height: 45px; }
[data-lesson-diagram="async"] .diagram-lane-bars { min-height: 44px; }
[data-lesson-diagram="async"] .schedule-queue {
  --bar-fill: transparent;
  --bar-ink: var(--wire);
  margin-inline: 0;
  padding-left: 5px;
}
[data-lesson-diagram="async"] .schedule-queue .diagram-name {
  color: var(--muted);
  font-weight: 400;
}
/* A result that is done but not yet taken waits on a thin dashed line from where it finished to where the model
   takes it. Its plan is the same line in the wire's colour; its words stand on the surface, over the cursor. */
.schedule-queue::before,
.schedule-queue .schedule-elapsed {
  inset-block: auto 12px;
  height: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  border-top: 1px dashed var(--wire);
}
.schedule-queue > .diagram-name { background: var(--surface); }
.schedule-queue .diagram-status > span { background-color: var(--surface); background-image: linear-gradient(var(--pill-fill), var(--pill-fill)); }

[data-lesson-diagram="subagents"] .diagram-schedule { --name-width: 168px; }
.schedule-difference {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  height: 22px;
  margin-left: var(--name-width);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--motion-fade) ease-out, visibility 0s var(--motion-fade);
}
.schedule-difference > span {
  position: relative;
  grid-column: 6 / 8;
  padding-top: 5px;
  border-top: 1px solid var(--accent);
  color: var(--accent-ink);
  font: 600 var(--text-xs) / 1.3 var(--sans);
  text-align: center;
}
.schedule-difference > span::before, .schedule-difference > span::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 0;
  height: 5px;
  border-left: 1px solid var(--accent);
}
.schedule-difference > span::after { left: auto; right: 0; }
[data-lesson-diagram="subagents"] .diagram-scene[data-frame="7"][data-settled="true"] .schedule-difference {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--motion-fade) ease-out, visibility 0s;
}
/* Each stage's clock runs down its own group: One Child, Two Children, then Without Waiting. */
[data-lesson-diagram="subagents"] .diagram-scene[data-stage="0"] .diagram-time-cursor {
  bottom: auto;
  height: 141px;
}
[data-lesson-diagram="subagents"] .diagram-scene:is([data-stage="1"], [data-stage="2"]) .diagram-time-cursor {
  top: 153px;
  bottom: auto;
  height: 195px;
}
/* Keep Talking plays on the group under the saved units, with a clock of its own. */
[data-lesson-diagram="subagents"] .diagram-scene[data-stage="3"] .diagram-time-cursor { top: 394px; }
/* In a narrow column each lane's name stands over its bars, so each group starts lower. */
@container (max-width: 560px) {
  [data-lesson-diagram="subagents"] .diagram-scene[data-stage="0"] .diagram-time-cursor { height: 184px; }
  [data-lesson-diagram="subagents"] .diagram-scene:is([data-stage="1"], [data-stage="2"]) .diagram-time-cursor {
    top: 196px;
    height: 257px;
  }
  [data-lesson-diagram="subagents"] .diagram-scene[data-stage="3"] .diagram-time-cursor { top: 499px; }
}
[data-lesson-diagram="subagents"] .diagram-time-guides { bottom: 4px; }
[data-lesson-diagram="subagents"] .schedule-difference > span { background: var(--surface); }
/* The report waits on a thin dashed line, named in the plain weight, as a queued result is in Async tools. */
[data-lesson-diagram="subagents"] .schedule-queue {
  --bar-fill: transparent;
  --bar-ink: var(--wire);
  margin-inline: 0;
  padding-left: 5px;
}
[data-lesson-diagram="subagents"] .schedule-queue .diagram-name { color: var(--muted); font-weight: 400; }
[data-lesson-diagram="subagents"] [data-cell="serial-compare"][data-tone="ok"] .schedule-elapsed,
[data-lesson-diagram="subagents"] [data-cell="parallel-compare"][data-tone="ok"] .schedule-elapsed {
  border-right: 2px solid var(--bar-ink);
}

/* Agent Swarm: the clerks' bars are their reads, in the tools' colour as the children's are in Subagents. A clerk
   that failed is a bar like the others, in the colour of a failure. */
[data-lesson-diagram="swarm"] .diagram-schedule { --name-width: 132px; }
[data-lesson-diagram="swarm"] .schedule-group .schedule-bar {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="swarm"] .schedule-group .schedule-bar[data-tone="bad"] {
  --bar-fill: var(--danger-pale);
  --bar-ink: var(--danger);
}
[data-lesson-diagram="swarm"] [data-cell="parent-join"][data-tone="ok"] .schedule-elapsed {
  border-right: 2px solid var(--bar-ink);
}

/* Retries: the Loop waits on one request while the Model Client sleeps between attempts and the Model API answers
   each one. The client's sleeps are in its class's colour, as the home map draws the Model Client; an attempt is
   neutral until its answer, a failure's colour for an error and a success's for the reply. A line parts the lanes,
   and a bar keeps little room at its sides, since an attempt or a backoff is one second wide. */
[data-lesson-diagram="retries"] .diagram-schedule { --name-width: 132px; }
.diagram-name[data-part="client"] .part-mark { color: var(--fig-tool); }
[data-lesson-diagram="retries"] .diagram-lane + .diagram-lane { padding-top: 8px; border-top: 1px solid var(--line); }
[data-lesson-diagram="retries"] .schedule-bar { padding-inline: 3px; }
[data-lesson-diagram="retries"] .schedule-bar[data-cell^="wait-"] {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="retries"] .schedule-bar[data-cell^="attempt-"] { --bar-fill: var(--sunken); --bar-ink: var(--muted); }
/* On a phone a second is some 35px: a one-second bar holds "Wait" over "≤1 s", or "429", with a pixel or two left. */
@container (max-width: 560px) {
  [data-lesson-diagram="retries"] .schedule-bar { margin-inline: 1px; padding-inline: 2px; }
}
[data-lesson-diagram="retries"] .schedule-bar[data-tone="bad"] { --bar-fill: var(--danger-pale); --bar-ink: var(--danger); }
[data-lesson-diagram="retries"] .schedule-bar[data-tone="ok"] { --bar-fill: var(--ok-pale); --bar-ink: var(--ok); }
/* Steering: the model's requests in the accent, the tools' calls in their colour, as in Async tools. What you typed
   is its words over a thin dashed line in your colour, from when you typed it to the request that takes it. */
[data-lesson-diagram="steering"] .diagram-schedule { --name-width: 132px; }
.diagram-name[data-part="interface"] .part-mark { color: var(--fig-you); }
[data-lesson-diagram="steering"] .schedule-bar[data-cell^="read-"] {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="steering"] .schedule-bar[data-cell^="read-"][data-tone="active"] {
  --status-ink: var(--fig-tool-on-active);
}
[data-lesson-diagram="steering"] .schedule-queue {
  --bar-fill: transparent;
  --bar-ink: var(--fig-you);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-inline: 0;
  padding-left: 5px;
}
[data-lesson-diagram="steering"] .schedule-queue .diagram-name { font-weight: 400; }
/* Where a wait's words and status stand side by side, the words give way first and the status keeps its pill. */
.schedule-queue > .diagram-name { flex: 0 1 auto; }
.schedule-queue > .diagram-status { flex: none; }
[data-lesson-diagram="steering"] .schedule-queue:not([aria-hidden="true"]) .schedule-elapsed { border-top-color: var(--fig-you); }

/* Always-On Agents: the agent's turns in the accent and its sleep in the plain fill a wait has, the reader in the
   tools' colour as a child is in Subagents, and what wakes it in your colour, as what you typed is in Steering: a tick
   or an event is a short bar, and an event that waits for a turn is its name over a thin dashed line. */
[data-lesson-diagram="always-on"] .diagram-schedule { --name-width: 132px; }
[data-lesson-diagram="always-on"] .schedule-bar[data-cell^="asleep-"] { --bar-fill: var(--sunken); --bar-ink: var(--muted); }
[data-lesson-diagram="always-on"] .schedule-bar[data-cell="reader"] {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="always-on"] .schedule-bar[data-cell="reader"][data-tone="active"] { --status-ink: var(--fig-tool-on-active); }
[data-lesson-diagram="always-on"] .schedule-group .schedule-bar {
  --bar-fill: var(--fig-you-pale);
  --bar-active: var(--fig-you-active);
  --bar-ink: var(--fig-you);
  padding-inline: 3px;
}
[data-lesson-diagram="always-on"] .schedule-queue {
  --bar-fill: transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-inline: 0;
  padding-left: 5px;
}
[data-lesson-diagram="always-on"] .schedule-queue .diagram-name { font-weight: 400; }
@container (max-width: 560px) {
  [data-lesson-diagram="always-on"] .schedule-bar { margin-inline: 1px; padding-inline: 2px; }
}
[data-lesson-diagram="always-on"] .schedule-queue:not([aria-hidden="true"]) .schedule-elapsed { border-top-color: var(--fig-you); }


/* Agent Teams: three members side by side, each its status, mailbox and Session, the rows level across the three,
   and the Board's task list under them. Hidden rows keep their room, so nothing moves as rows appear. These are
   places, so no box stands round one: a hairline parts a member from the next and the Board from the members, and
   a member's or the Board's class colour fills only the band that names it. */
[data-lesson-diagram="teams"] .diagram-scene { min-width: 680px; }
.diagram-team { display: grid; gap: 14px; }
.team-members {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto auto;
  gap: 10px 0;
}
.team-member {
  display: grid;
  grid-row: 1 / span 3;
  grid-template-rows: subgrid;
  row-gap: 10px;
  padding: 0 14px;
}
.team-member:first-child { padding-left: 0; }
.team-member:last-child { padding-right: 0; }
.team-member + .team-member { border-left: 1px solid var(--line); }
.team-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 2px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--fig-model-pale);
}
.team-head .diagram-name { min-height: 24px; }
.team-head .diagram-status { grid-column: 2; grid-row: 1; }
/* What a member is doing is a tool call, in code; the line keeps its height when it is empty. */
.team-head .diagram-detail { grid-column: 1 / -1; min-height: 1.4em; font: 400 var(--text-xs) / 1.4 var(--mono); }
.team-head .diagram-detail:empty { display: block; }
.team-head[data-tone="idle"] .diagram-name { color: var(--faint); }
.team-head[data-tone="idle"] .diagram-detail { font-family: var(--sans); }
/* A member's and a task's status is the status pill of the diagrams, in its tone. */
.diagram-team [data-cell] { --pill-ink: var(--muted); --pill-fill: transparent; --pill-edge: var(--line-strong); }
.diagram-team [data-cell][data-tone="active"] { --pill-ink: var(--accent-ink); --pill-fill: var(--accent-pale); --pill-edge: transparent; }
.diagram-team [data-cell][data-tone="ok"] { --pill-ink: var(--ok); --pill-fill: var(--ok-pale); --pill-edge: transparent; }
.team-place { display: grid; align-content: start; gap: 4px; }
.team-place h4 { margin: 0; color: var(--muted); font: 400 var(--text-xs) / 1.3 var(--sans); }
.team-slot { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 4px; }
/* "Empty" holds the first row's place until a row arrives. */
.team-slot > .team-empty, .team-slot > :first-child { grid-area: 1 / 1; }
.team-empty { align-self: start; padding: 5px 2px; color: var(--muted); font: 400 var(--text-xs) / 1.4 var(--sans); }
.team-slot:has(> [aria-hidden="false"]) > .team-empty { visibility: hidden; }
.team-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 8px;
  row-gap: 1px;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--chip);
}
.team-row.is-mail { grid-template-columns: minmax(0, 1fr); }
/* The mailbox is one line: its name, then its one message or "Empty", so the Board stands close under the members. */
.team-place.is-mailbox { grid-template-columns: auto minmax(0, 1fr); align-items: start; column-gap: 10px; }
.team-place.is-mailbox > h4 { padding-top: 6px; }
/* The lane over the Board, along which mail goes from one member's column to another's; nothing stands in it. */
.team-lane { height: 30px; margin: -14px 0 -14px; }
.team-row[data-tone="active"] { background: var(--accent-pale); }
.team-row[data-tone="ok"] { background: var(--ok-pale); }
.team-row .player-chip { grid-row: 1 / span 2; align-self: start; }
.team-text { min-width: 0; color: var(--ink); font: 400 var(--text-xs) / 1.4 var(--mono); overflow-wrap: break-word; }
.team-row .diagram-detail { color: var(--ink); font: 400 var(--text-xs) / 1.4 var(--sans); }
/* What a person wrote is prose; a notice is message content, in code. */
.team-row.is-prose .team-text { font-family: var(--sans); }
.team-row .diagram-status { display: none; }
:is(.team-row, .team-task)[aria-hidden="true"] { visibility: hidden; }
.team-board { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.team-board-head { padding: 6px 10px; border-radius: 6px; background: var(--fig-store-pale); }
.team-board .diagram-name { min-height: 24px; }
/* A task is a row of the Board's list, parted from the next by a hairline. */
.team-task {
  display: grid;
  grid-template-columns: 32px minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 1fr) 92px;
  align-items: baseline;
  column-gap: 12px;
  min-height: 32px;
  padding: 6px 10px;
}
.team-task + .team-task { border-top: 1px solid var(--line); }
.team-task-more { display: contents; }
.team-task-id { font: 600 var(--text-xs) / 1.4 var(--mono); color: var(--ink); }
.team-task-what { font: 400 var(--text-sm) / 1.4 var(--sans); color: var(--ink); }
.team-needs { font: 400 var(--text-xs) / 1.4 var(--sans); color: var(--muted); }
.team-task .diagram-detail { font: 400 var(--text-xs) / 1.4 var(--sans); color: var(--muted); }
.team-task .diagram-status { text-align: right; }
/* Handoffs: three roles side by side, each its section of the system prompt and the tools a request offers while it is
   active, parted by hairlines as Agent Teams' members are; the active role's band and tools are lit, the others quiet.
   Under them, across the three, the runtime's places as rows of a list: what you wrote last, the extension's state,
   the next request and the reply, whose calls and answers share one cell, unseen until their frame, so nothing moves. */
[data-lesson-diagram="handoffs"] .diagram-scene { min-width: 680px; }
.diagram-handoffs { display: grid; gap: 16px; }
.diagram-handoffs [data-cell] { --pill-ink: var(--muted); --pill-fill: transparent; --pill-edge: var(--line-strong); }
.diagram-handoffs [data-cell][data-tone="active"] { --pill-ink: var(--accent-ink); --pill-fill: var(--accent-pale); --pill-edge: transparent; }
.diagram-handoffs [data-cell][data-tone="ok"] { --pill-ink: var(--ok); --pill-fill: var(--ok-pale); --pill-edge: transparent; }
.hand-roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto auto auto; row-gap: 10px; }
.hand-role { display: grid; grid-row: 1 / span 3; grid-template-rows: subgrid; row-gap: 10px; padding: 0 14px; }
.hand-role:first-child { padding-left: 0; }
.hand-role:last-child { padding-right: 0; }
.hand-role + .hand-role { border-left: 1px solid var(--line); }
.hand-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  padding: 6px 10px; border-radius: 6px; background: var(--chip);
}
.hand-head[data-tone="active"] { background: var(--fig-model-pale); }
.hand-head .diagram-name { min-height: 24px; }
.hand-head[data-tone="quiet"] .diagram-name, .hand-head[data-tone="idle"] .diagram-name { color: var(--muted); }
.hand-head .diagram-detail { display: none; }
.hand-place { display: grid; align-content: start; gap: 4px; }
.hand-place h4 { margin: 0; color: var(--muted); font: 400 var(--text-xs) / 1.3 var(--sans); }
.hand-section { margin: 0; color: var(--ink); font: 400 var(--text-xs) / 1.45 var(--sans); }
.hand-tools { display: flex; flex-wrap: wrap; gap: 4px; }
/* A tool the next request offers is lit; one it does not offer stands as an outline. */
.hand-tool {
  padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: transparent;
  color: var(--muted); font: 400 var(--text-xs) / 1.4 var(--mono);
}
.hand-tool[data-tone="active"] { border-color: transparent; background: var(--fig-tool-pale); color: var(--ink); }
.hand-tool :is(.diagram-detail, .diagram-status) { display: none; }
.hand-runtime { display: grid; border-top: 1px solid var(--line); padding-top: 6px; }
.hand-row {
  display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px;
  min-height: 32px; padding: 6px 10px;
}
.hand-row + .hand-row { border-top: 1px solid var(--line); }
.hand-name { color: var(--muted); font: 400 var(--text-xs) / 1.4 var(--sans); }
.hand-row > .diagram-detail { display: block; min-height: 1.4em; color: var(--ink); font: 400 var(--text-xs) / 1.4 var(--sans); }
.hand-row[data-cell="you"] > .diagram-detail { font-size: var(--text-sm); }
.hand-row[data-cell="request"] > .diagram-detail, .hand-row[data-cell="state"] > .diagram-detail { color: var(--muted); }
.hand-row.is-reply { grid-template-columns: 132px minmax(0, 1fr); }
.hand-slot { display: grid; grid-template-columns: minmax(0, 1fr); }
.hand-slot > * { grid-area: 1 / 1; }
.hand-reply {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px;
}
.hand-reply[aria-hidden="true"] { visibility: hidden; }
.hand-call { min-width: 0; color: var(--ink); font: 400 var(--text-xs) / 1.4 var(--mono); overflow-wrap: break-word; }
.hand-reply.is-answer { grid-template-columns: minmax(0, 1fr) auto; }
.hand-reply.is-answer .hand-call { font: 400 var(--text-sm) / 1.4 var(--sans); }
.hand-reply.is-answer > .diagram-detail { display: none; }
.hand-reply > .diagram-detail { min-width: 0; color: var(--muted); font: 400 var(--text-xs) / 1.4 var(--mono); overflow-wrap: break-word; }
.hand-empty { align-self: start; color: var(--muted); font: 400 var(--text-xs) / 1.4 var(--sans); }
.hand-slot:has(> [aria-hidden="false"]) > .hand-empty { visibility: hidden; }

/* On a phone the team keeps its three columns side by side, as wide as a tablet draws them, and scrolls inside its
   card: stood one under another they made a figure three screens tall, with its sentence and controls far under what
   a step changed. The scene follows each step to the member it acts on (followCells in lesson-diagrams.mjs). Handoffs
   keeps its three roles so, under its places, in the same way. */
@media (max-width: 600px) {
  /* The Board does not scroll with the members: it is as wide as the card shows, and a pixel more, so followCells
     still reads a task as a row that always shows, and it is pinned at the card's left edge, whichever member is in
     view. Its negative margins let it reach the scene's edges, so the pin holds from the first member to the last.
     Its words keep clear of the faded edges, and each task is two lines: its id, name and status, then what it needs
     and who holds it at which revision, a line kept for them before they show. */
  :is([data-lesson-diagram="teams"], [data-lesson-diagram="handoffs"]) .lesson-diagram-scroll { container-type: inline-size; }
  /* Each member is as wide as the view between its faded edges, so its rows wrap no more than they must. A Session
     keeps the room of every row the run adds, so nothing moves as one arrives; at this width that room is what the
     run's rows take, and the members' heads, the sentence and Play stand on one screen. */
  [data-lesson-diagram="teams"] .diagram-scene { min-width: calc(3 * (100cqw - 56px) + 2 * var(--scene-padding)); }
  :is(.team-board, .hand-runtime) {
    position: sticky; left: 0; z-index: 1; justify-self: start; width: calc(100cqw + 1px);
    margin-inline: calc(-1 * var(--scene-padding));
  }
  .team-board-head { margin-inline: 30px; }
  /* The Board stands over the members, a hairline under it, and the lane under their mailboxes. Each member's column
     keeps the lead's six rows of room, so under the members the Board stood a screen below a member's head, as T3
     below the checker's: over them, the task a member claims stands just above its head, and the head, its Session's
     rows and the task fit the room the held foot leaves at 360x780 (ML8-04). */
  .team-board { order: -1; padding: 0 0 14px; border-top: 0; border-bottom: 1px solid var(--line); }
  /* A Session's rows sit closer than on a wider card, a line of a notice a little tighter, so the room the run's rows
     keep is as short as it can be: the lead's four rows reserve it from the first frame. */
  .team-slot { gap: 3px; }
  .team-row { min-height: 26px; padding: 3px 8px; column-gap: 6px; }
  .team-row :is(.team-text, .diagram-detail) { line-height: 1.3; }
  /* Handoffs' places stand over its roles, as the Board stands over the members, and each role's tools stand under
     its head, over its section: a change of role lights the heads, the tools and the state and names the reply's
     call, which under the roles stood 608px apart at 360x780, the heads under the header (ML9-04). */
  .hand-runtime { order: -1; padding: 0 0 6px; border-top: 0; border-bottom: 1px solid var(--line); }
  .hand-place:has(> .hand-tools) { order: 1; }
  .hand-place:has(> .hand-section) { order: 2; }
  /* Its places do as the Board's tasks do: each row its name over its words and status, clear of the edges,
     and each call or answer of the reply as wide as the row, the call and its status over what it returned. */
  .hand-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; padding: 6px 30px; }
  .hand-row > .hand-name { grid-column: 1 / -1; }
  .hand-row.is-reply { grid-template-columns: minmax(0, 1fr); padding-inline: 0; }
  .hand-row.is-reply > .hand-name, .hand-reply, .hand-empty { padding-inline: 30px; }
  .hand-reply, .hand-reply.is-answer { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .hand-reply > .diagram-detail { grid-column: 1 / -1; grid-row: 2; }
  .team-task {
    grid-template-columns: 22px minmax(0, 1fr) 92px; grid-template-rows: auto auto; row-gap: 2px; column-gap: 8px;
    padding: 6px 30px;
  }
  .team-task-what { font-size: var(--text-xs); }
  .team-task-more { grid-column: 2 / -1; grid-row: 2; display: flex; gap: 5px; min-height: 1.4em; }
  .team-task .diagram-status { grid-column: 3; grid-row: 1; }
  .team-needs:empty { display: none; }
  .team-needs:not(:empty) + .diagram-detail::before { content: "· "; }
}

/* Isolation Levels: four levels side by side under the page whose order they run. Each is its lines over the walls
   between it and the host's kernel, and the host's kernel runs along the foot under all four, with what a way out needs
   under it. The rows are level across the four. A line, an output and a way out keep their room unseen until their
   frame, and "Nothing run yet" holds the first line's place, so nothing moves as they appear. */
[data-lesson-diagram="isolation"] .diagram-scene { min-width: 0; }
.diagram-isolation { display: grid; gap: 14px; }
.diagram-isolation [data-cell] { --pill-ink: var(--muted); --pill-fill: transparent; --pill-edge: var(--line-strong); }
.diagram-isolation [data-cell][data-tone="active"] { --pill-ink: var(--accent-ink); --pill-fill: var(--accent-pale); --pill-edge: transparent; }
.diagram-isolation [data-cell][data-tone="ok"] { --pill-ink: var(--ok); --pill-fill: var(--ok-pale); --pill-edge: transparent; }
.diagram-isolation [data-cell][data-tone="bad"] { --pill-ink: var(--danger); --pill-fill: var(--danger-pale); --pill-edge: transparent; }
.diagram-isolation :is(.iso-page, .iso-line, .iso-out, .iso-way) .diagram-status { display: none; }
.diagram-isolation :is(.iso-head, .iso-wall, .iso-kernel) .diagram-detail { font-size: var(--text-xs); line-height: 1.4; }
.diagram-name[data-part="sandbox"] .part-mark { color: var(--fig-tool); }
/* The page is outside the host, a record of what it says: its address, what it is, and the order in its text. */
.iso-page {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--sunken);
}
.iso-what { color: var(--muted); font-size: var(--text-xs); }
.iso-page .diagram-detail { color: var(--ink); font: 400 var(--text-xs) / 1.45 var(--mono); overflow-wrap: anywhere; }
.iso-levels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(5, auto);
  column-gap: 10px;
}
.iso-level { display: grid; grid-column: var(--at); grid-row: 1 / span 5; grid-template-rows: subgrid; min-width: 0; }
.iso-box {
  display: grid;
  grid-row: 1 / span 3;
  grid-template-rows: subgrid;
  row-gap: 9px;
  min-width: 0;
  padding: 9px 8px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
/* A level's name and examples, and under them, level across the four, whether this runtime has it. */
.iso-head { display: grid; grid-template-rows: auto auto 1fr; gap: 2px; padding-inline: 2px; }
.iso-head .diagram-name { min-height: 24px; }
.iso-head .diagram-label { min-width: 0; overflow-wrap: anywhere; }
.iso-head .diagram-status { align-self: end; margin-top: 3px; }
/* The lines run as a terminal shows them: each command after its prompt, and what it printed under it. What a level
   this runtime lacks prints nothing; its line says what answered, in words. */
.iso-run {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  padding: 6px 8px 8px;
  border-radius: 6px;
  background: var(--sunken);
}
.iso-run > .iso-empty, .iso-run > :first-child { grid-area: 1 / 1; }
.iso-empty { color: var(--muted); font: 400 var(--text-xs) / 1.4 var(--sans); }
.iso-run:has(> [aria-hidden="false"]) > .iso-empty { visibility: hidden; }
:is(.iso-line, .iso-out, .iso-way)[aria-hidden="true"] { visibility: hidden; }
.iso-line { min-width: 0; }
.iso-line:not(:first-child) { margin-top: 6px; }
.iso-command { display: block; color: var(--ink); font: 400 var(--text-xs) / 1.4 var(--mono); overflow-wrap: anywhere; }
.iso-command::before { content: "$ "; color: var(--muted); }
.iso-out { min-width: 0; }
.iso-out .diagram-detail { display: block; color: var(--ink); font: 400 var(--text-xs) / 1.4 var(--mono); overflow-wrap: anywhere; }
.iso-out[data-tone="bad"] .diagram-detail { color: var(--danger); }
.iso-out.is-note .diagram-detail { color: var(--muted); font-family: var(--sans); }
/* A wall is a boundary the command stands inside, drawn in the sandbox's colour; it takes the colour of what it does
   with an attempt: answers it, or refuses it. */
.iso-walls { display: grid; align-content: end; gap: 8px; min-width: 0; }
.iso-wall {
  display: grid;
  gap: 2px;
  padding: 6px 10px 7px;
  border: 1px solid var(--fig-tool-line);
  border-radius: 6px;
  background: var(--fig-tool-pale);
}
.iso-wall .diagram-status, .iso-kernel .diagram-status { margin-top: 3px; }
.diagram-isolation .is-silent .diagram-status { display: none; }
.iso-wall[data-tone="active"], .iso-kernel[data-tone="active"] { border-color: var(--accent); }
.iso-wall[data-tone="bad"] { border-color: var(--danger); }
/* The host's kernel is one band under all four; each level meets it in its own column. */
.iso-host {
  grid-column: 1 / -1;
  grid-row: 4;
  margin-top: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--fig-outside-fill);
}
.iso-host span { display: block; padding: 7px 12px 0; color: var(--ink); font: 600 var(--text-sm) / 1.3 var(--sans); }
.iso-kernel {
  display: grid;
  grid-row: 4;
  align-content: start;
  gap: 2px;
  margin: 42px 8px 8px;
  padding: 6px 10px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}
.iso-kernel .diagram-name { display: none; }
.iso-way { display: grid; grid-row: 5; align-content: start; gap: 1px; padding: 9px 2px 0; }
.iso-way .diagram-name { color: var(--muted); font: 400 var(--text-xs) / 1.3 var(--sans); }
.iso-way .diagram-detail { color: var(--ink); font: 600 var(--text-sm) / 1.35 var(--sans); }
.diagram-scene:has(.diagram-isolation) .diagram-transfer { font: 400 var(--text-xs) / 1.4 var(--mono); }
/* Narrower, the levels stand two by two, the rows still level across each pair, and each meets the host's kernel in a
   box of its own. On a phone the four keep their columns at a fixed width and the figure scrolls sideways inside its
   card, as a flow figure does, so the levels can still be read across and an attempt still travels straight down. */
@container (min-width: 481px) and (max-width: 780px) {
  .iso-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(10, auto); }
  .iso-level:nth-of-type(odd) { grid-column: 1; }
  .iso-level:nth-of-type(even) { grid-column: 2; }
  .iso-level:nth-of-type(n+3) { grid-row: 6 / span 5; }
  .iso-level:nth-of-type(n+3) > .iso-box { margin-top: 20px; }
  .iso-host { display: none; }
  .iso-kernel { margin: 8px 0 0; background: var(--sunken); }
  .iso-kernel .diagram-name { display: flex; }
}
@container (max-width: 480px) {
  [data-lesson-diagram="isolation"] .diagram-scene { min-width: 860px; }
}

/* This is a graph: two independent inputs converge on the one comparison. */
.diagram-plan {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 64px;
}
.plan-inputs > .diagram-name { padding-bottom: 7px; }
.plan-inputs > .plan-source {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  min-height: 100px;
  padding: 7px 12px;
  border-top: 1px solid var(--line-strong);
}
.plan-source .diagram-status { grid-column: 2; grid-row: 1; text-align: right; }
.plan-source .diagram-detail { grid-column: 1 / -1; }
.plan-coverage { display: grid; gap: 3px; grid-column: 1 / -1; width: 100%; padding-top: 2px; }
.plan-months, .plan-coverage-track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plan-months { color: var(--muted); font: 400 var(--text-xs) / 1.1 var(--sans); }
.plan-months span { padding-inline-start: 3px; }
.plan-source[data-tone="bad"] .plan-months span:last-child { color: var(--danger); }
.plan-coverage-track { position: relative; height: 8px; background: var(--sunken); }
.plan-coverage-track > span { z-index: 1; border-right: 2px solid var(--surface); }
.plan-coverage-track > span:last-child { border-right: 1px solid var(--line-strong); }
.plan-coverage-fill {
  position: absolute;
  inset: 0;
  transform: scaleX(var(--coverage, var(--initial-coverage, 0)));
  transform-origin: left;
  background: var(--accent);
}
/* The comparison is a step of the plan, as the reads are: the same neutral surface, outlined, not an outside system. */
.plan-comparison {
  min-height: 136px;
  padding: 16px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
.plan-comparison .diagram-detail { color: var(--status-ink); font-size: var(--text-lg); }
/* A refusal is the runtime's own error, so it is set as code, at the size of the figure's other words. */
.plan-comparison[data-tone="bad"] .diagram-detail { font: 400 var(--text-sm) / 1.4 var(--mono); }

/* Programmatic Tools: two ways to one total, each a Tools box over a Context box, the boxes level across the two.
   Hidden rows keep their room, so nothing moves while rows appear. Both ways stand in their places from the first
   frame: while the first plays, the second waits faded, empty and at no requests, and then only fills. */
.diagram-program {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto auto;
  gap: 8px 20px;
}
.program-way { display: grid; grid-row: 1 / span 3; grid-template-rows: subgrid; row-gap: 12px; }
.program-way h3 { align-self: end; }
.diagram-scene[data-stage="0"] .program-way[data-way="r"] { opacity: 0.45; }
.program-way { transition: opacity var(--motion-fade) ease-out; }
.program-part {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 3px;
  padding: 7px 10px 9px;
  border: 1px solid;
  border-radius: 8px;
}
.program-tools { border-color: var(--fig-tool-line); background: var(--fig-tool-pale); }
.program-context { border-color: var(--fig-store-line); background: var(--fig-store-pale); }
.program-part .diagram-name { min-height: 24px; }
.program-part-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* "Nothing called yet" holds the first item's place until a call arrives. */
.program-empty, .program-tools > .program-call:first-of-type { grid-area: 2 / 1; }
.program-empty { align-self: start; padding: 4px 2px; color: var(--muted); font-size: var(--text-xs); }
.program-tools:has(.program-call[aria-hidden="false"]) .program-empty { visibility: hidden; }
.program-row, .program-call {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--surface);
}
:is(.program-row, .program-call)[aria-hidden="true"] { visibility: hidden; }
.program-row .player-chip { flex: 0 0 76px; text-align: center; }
/* Code in a row breaks at its spaces, and inside a name only where the name alone is wider than the row. */
.program-text { min-width: 0; font: 400 var(--text-xs) / 1.45 var(--mono); overflow-wrap: break-word; }
.program-row.is-prose .program-text { font: 400 var(--text-sm) / 1.4 var(--sans); }
.program-call .diagram-detail { margin-left: auto; color: var(--muted); font: 400 var(--text-xs) / 1.45 var(--mono); }
.program-call.is-program { flex-wrap: wrap; row-gap: 5px; padding-block: 5px 7px; }
.program-source {
  flex: 1 0 100%;
  margin: 0;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--sunken);
  font: 400 var(--text-xs) / 1.38 var(--mono);
  white-space: pre;
}
/* Each line of the program wraps under its own start (hangingLines), so a long line stays inside its box on a phone. */
.diagram-program .program-source code { display: block; font: inherit; }
.program-inner { color: var(--muted); font-size: var(--text-xs); }
.program-inner span { color: var(--ink); font-family: var(--mono); }
.program-count .diagram-detail { color: var(--muted); font-size: var(--text-xs); }
.program-count[data-tone="active"] .diagram-detail { color: var(--accent-ink); font-weight: 600; }
.program-count .diagram-status { display: none; }
:is(.program-row, .program-call) .diagram-status { display: none; }

.diagram-paths, .diagram-motions {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.diagram-paths [data-link] {
  stroke: var(--wire);
  stroke-width: 1.2;
  stroke-linejoin: round;
  fill: none;
  transition: stroke var(--motion-fade) ease-out;
}
.diagram-paths [data-link].is-current { stroke: var(--accent); stroke-width: 2; }
[data-lesson-diagram="planning"] [data-frame="2"][data-settled="false"] [data-link="1"] {
  stroke: var(--wire);
  stroke-width: 1.2;
  marker-end: url(#lesson-diagram-planning-rest);
}
.diagram-tip.rest { fill: var(--wire); }
.diagram-tip.active { fill: var(--accent); }
.diagram-motions { z-index: 3; overflow: hidden; }
.diagram-transfer {
  position: absolute;
  width: max-content;
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  background: var(--accent-pale);
  color: var(--accent-ink);
  font: 600 var(--text-xs) / 1.4 var(--sans);
}

.lesson-diagram .flow-timeline { border-top: 1px solid var(--line); }
.lesson-run-trace { margin-top: 24px; }
.lesson-run-trace [data-player="eval"] .player-panel { gap: 9px; }
.lesson-run-trace [data-player="eval"] .player-code pre { padding-block: 3px; }

@media (max-width: 760px) {
  .lesson-diagram { --scene-padding: 16px; }
  [data-lesson-diagram="async"] .diagram-schedule { --name-width: 104px; }
  .lesson-diagram .flow-timeline { flex-direction: column; gap: 8px; }
  .lesson-diagram .flow-scrubber { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .lesson-diagram :is(.diagram-status > span, [data-link], .program-way, .schedule-difference) { transition: none; }
}
/* What travels in Programmatic Tools is a call or its data, set as code is. */
.diagram-scene:has(.diagram-program) .diagram-transfer { font: 400 var(--text-xs) / 1.4 var(--mono); }

/* On a phone a schedule keeps a least width for each unit of its time and scrolls inside its card: the width at which
   every bar holds its name and its widest status whole and every time on the axis stands clear of the next
   (`--unit-min`, which lesson-diagrams.mjs measures). A lane's name stands over its bars, on the surface over the
   cursor, and stays 12px in from the card's left edge while the axis scrolls under it, its surface reaching to the
   edge; at rest it stands where it does. Once the axis has scrolled, a bar or a time passing under that edge fades
   out over 24px under the names (`data-more`, lesson-diagrams.mjs), so no word shows cut there; a bar wider than the
   view keeps its words clear of the fade. Placed last, and under the lesson's own figure, to outrank each figure's
   name width. */
@container (max-width: 560px) {
  .lesson-diagram[data-lesson-diagram] .diagram-scene:has(.diagram-schedule) {
    min-width: calc(var(--columns, 1) * var(--unit-min, 0px) + 2 * var(--scene-padding));
  }
  [data-lesson-diagram] .diagram-scene .diagram-schedule { --name-width: 0px; }
  .diagram-schedule :is(.diagram-axis, .diagram-lane) { grid-template-columns: minmax(0, 1fr); }
  .diagram-schedule :is(.diagram-axis, .diagram-lane) > .diagram-name,
  .diagram-schedule .schedule-group > .diagram-name {
    position: sticky; left: 12px; z-index: 3; width: max-content; padding-right: 6px; background: var(--surface);
    box-shadow: -12px 0 var(--surface);
  }
  .diagram-schedule .schedule-group .diagram-lane > .diagram-name { padding-left: 0; }
  .diagram-schedule :is(.diagram-ticks, .diagram-lane-bars)::before {
    content: ""; position: sticky; left: 0; z-index: 2; display: block; width: 24px; height: 100%;
    grid-row: 1; grid-column: 1 / -1; justify-self: start; align-self: stretch; pointer-events: none;
    visibility: hidden; background: linear-gradient(to right, var(--surface), transparent);
  }
  .diagram-schedule .diagram-ticks > span { top: 0; }
  .lesson-diagram-scroll[data-more~="left"] .diagram-schedule :is(.diagram-ticks, .diagram-lane-bars)::before {
    visibility: visible;
  }
  .schedule-bar.is-wide > :is(.diagram-name, .diagram-status) { left: 28px; }
  /* Once the axis has scrolled, any bar that starts under the left fade, not only one wider than the view, keeps its
     name and status just past it: Retries' last frame read "uest 1" and "ly" at 360 (R7-08). A queued input, whose
     words and status stand side by side, keeps them where they are, since pinned apart the words would slide over
     the status. A bar keeps them so only while what shows of it holds them (`data-pinned`, lesson-diagrams.mjs);
     one that shows less lets them go under the fade with it, so no word is cut there ("ady · queued", R8-02). */
  .lesson-diagram-scroll[data-more~="left"] .schedule-bar[data-pinned]:not(.schedule-queue) > :is(.diagram-name,
    .diagram-status) {
    position: sticky; left: 28px;
  }
  /* The first time on the axis starts at the axis's edge, inside the card, and the last ends at its other edge, so
     the view's ring, as the scene has the focus scrolled to its end, never runs through it (Always-On's "10:10"). */
  .diagram-schedule [data-diagram-tick="0"] { transform: none; }
  .diagram-schedule [data-diagram-tick].is-end { transform: translateX(-100%); }
  /* A bar's status keeps its fill and gives up its dot, so a unit of time needs less room. */
  .schedule-bar .diagram-status > span:not(.is-dot) { padding-inline: 3px; }
  .schedule-bar .diagram-status > span:not(.is-dot)::before { display: none; }
}

/* Agent Swarm's knob: the same six items on one time axis, with max_running picked from one to six. Six slot lanes
   always stand, so the figure keeps its height whatever is picked; a lane past the number is an unused hairline. A
   bar moves to its slot and time when the number changes, and the axis takes the pick's span: one slot's whole run,
   or the shorter run two to six share. The four numbers are registered, so the axis, the ticks and the bars glide
   together and nothing jumps. The bars are drawn as the lesson's diagram draws them: the clerks' reads in the tools'
   colour, a failure in a failure's, the parent's answer in the Loop's, and the wait as a dashed outline. */
@property --ss-span { syntax: "<number>"; inherits: true; initial-value: 20; }
@property --ss-from { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --ss-to { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --ss-slot { syntax: "<number>"; inherits: false; initial-value: 0; }
.swarm-slots {
  --name-width: 112px; --lane: 44px; --glide: 0.35s cubic-bezier(0.3, 0.7, 0.2, 1);
  transition: --ss-span var(--glide);
}
.swarm-slots .tw-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
/* The title wraps within the head, and on a small phone (360px) the knob's name stands over its numbers, so neither
   runs past the card. */
.swarm-slots .tw-head > * { max-width: 100%; }
.ss-knob { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.ss-knob > code { color: var(--muted); font: 400 var(--text-xs) / 1 var(--mono); }
.ss-knob button { min-width: 36px; font-variant-numeric: tabular-nums; }
/* The knob is a radio group, so the chosen number says aria-checked; it is raised as a chosen tab is. */
.ss-knob .player-segmented button[aria-checked="true"] {
  background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--stage-edge), var(--shadow-xs);
}
.ss-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px 22px 4px;
}
.ss-metric { display: grid; gap: 2px; }
.ss-metric > span { color: var(--muted); font: 400 var(--text-xs) / 1.3 var(--sans); }
.ss-metric > strong { color: var(--ink); font: 600 var(--text-lg) / 1.2 var(--sans); font-variant-numeric: tabular-nums; }
/* A tick past the axis stands beyond its end, unseen, so the chart clips it. */
.ss-chart { display: grid; gap: 6px; padding: 10px 22px 16px; overflow: hidden; }
.ss-axis, .ss-lane { display: grid; grid-template-columns: var(--name-width) minmax(0, 1fr); align-items: center; }
.ss-name { color: var(--muted); font: 400 var(--text-xs) / 1.3 var(--sans); }
.ss-lane.is-parent .ss-name { color: var(--ink); font-weight: 600; }
.ss-ticks {
  position: relative; height: 22px; border-bottom: 1px solid var(--line-strong); font: 400 var(--text-xs) / 1.4 var(--mono);
}
.ss-ticks span {
  position: absolute; left: calc(var(--tick) / var(--ss-span) * 100%); transform: translateX(-50%); color: var(--muted);
  transition: opacity 0.2s ease-out;
}
.ss-ticks span.is-past { opacity: 0; }
.ss-track {
  position: relative; height: var(--lane);
  background: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px calc(100% / var(--ss-span) * 2));
}
.ss-slots { position: relative; display: grid; }
.ss-lane.is-unused .ss-name { color: var(--faint); }
.ss-lane.is-unused .ss-track { background: linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat; }
.ss-lane.is-unused .ss-track::after {
  content: "unused"; position: absolute; top: 50%; left: 8px; padding: 0 6px; transform: translateY(-50%);
  background: var(--surface); color: var(--faint); font: 400 var(--text-xs) / 1.3 var(--sans);
}
.ss-bars { position: absolute; inset: 0 0 0 var(--name-width); pointer-events: none; }
.ss-bar {
  position: absolute; box-sizing: border-box; display: grid; align-content: center; gap: 1px; overflow: hidden;
  left: calc(var(--ss-from) / var(--ss-span) * 100%); width: calc((var(--ss-to) - var(--ss-from)) / var(--ss-span) * 100% - 3px);
  top: calc(var(--ss-slot, 0) * var(--lane) + 4px); height: calc(var(--lane) - 8px); margin-left: 1.5px; padding: 0 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--fig-tool-pale); color: var(--ink);
  transition: --ss-from var(--glide), --ss-to var(--glide), --ss-slot var(--glide);
}
.ss-bar > b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 var(--text-xs) / 1.25 var(--sans); }
/* A bar's row is a status pill, as the diagram above draws it when the table is complete: a total in `ok`, the failed
   clerk's in `danger`. It shows whole, or not at all where the bar cannot hold it (the bar's title says it). */
.ss-bar > span {
  justify-self: start; display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; border-radius: var(--radius-sm);
  background: var(--ok-pale); color: var(--ok); font: 400 var(--text-xs) / 16px var(--sans); white-space: nowrap;
}
.ss-bar > span::before, .ss-pill::before {
  content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.ss-bar.is-tight > span { visibility: hidden; }
.ss-bar.is-error { background: var(--danger-pale); color: var(--danger); }
.ss-bar.is-error > span { background: var(--danger-pale); color: var(--danger); }
.ss-lane.is-parent .ss-bar { top: 4px; }
.ss-bar.is-wait { background: var(--sunken); color: var(--muted); }
.ss-bar.is-answer { background: var(--accent-pale); color: var(--accent-ink); }
@media (forced-colors: active) { .ss-bar { border-color: CanvasText; } .ss-bar > span { border: 1px solid CanvasText; } }
.swarm-slots .flow-foot { padding: 12px 22px 18px; }
@media (prefers-reduced-motion: reduce) { .swarm-slots, .ss-bar, .ss-ticks span { transition: none; } }
/* The table run_swarm returns, in words, stands under the chart only on a phone, where a bar shows no amount. */
.ss-table { display: none; }
.ss-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; border-radius: var(--radius-sm);
  background: var(--ok-pale); color: var(--ok); font: 400 var(--text-xs) / 16px var(--sans); white-space: nowrap;
}
.ss-table .is-error .ss-pill { background: var(--danger-pale); color: var(--danger); }
@media (forced-colors: active) { .ss-pill { border: 1px solid CanvasText; } }
/* On a phone a unit of the knob's time keeps the least width at which every bar holds its name whole (`--unit-min`,
   which swarm-slots.mjs measures), so the chart scrolls inside its card, the lanes' names pinned at its left edge; a
   bar shows no amount there, and no title can be read on a phone, so the table under the chart says each row's total,
   the failed clerk's word and the parent's answer, two to a line, a pill under its name where the line is short. */
@media (max-width: 600px) {
  .swarm-slots { --name-width: 72px; --lane: 40px; }
  .ss-table { display: grid; gap: 6px; padding: 0 16px 14px; }
  .ss-table > p { margin: 0; color: var(--muted); font: 400 var(--text-xs) / 1.3 var(--sans); }
  .ss-table ul {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; padding: 0; list-style: none;
  }
  .ss-table li {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; min-width: 0;
    color: var(--ink); font: 600 var(--text-xs) / 1.3 var(--sans);
  }
  .ss-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-inline: 16px; }
  .ss-chart { overflow-x: auto; padding-inline: 16px; }
  .ss-chart > :is(.ss-axis, .ss-lane, .ss-slots) { min-width: calc(var(--name-width) + var(--ss-span) * var(--unit-min, 0px)); }
  .ss-ticks span.is-past { display: none; }
  /* A pinned name stands where it does at rest, 16px in from the card's edge (a sticky box keeps to its scroller's
     padding), its surface reaching to the edge, so nothing scrolls past it there. Once the chart has scrolled, it
     fades into the time passing under it, so a bar scrolled under it fades out at its edge; at rest nothing is under
     it, and the axis's first time and every bar's start show whole. */
  .ss-name {
    position: sticky; left: 0; z-index: 2; align-self: stretch; display: flex; align-items: center;
    background: var(--surface); box-shadow: -16px 0 var(--surface);
  }
  .ss-chart[data-more~="left"] .ss-name::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 100%; width: 16px; pointer-events: none;
    background: linear-gradient(to right, var(--surface), transparent);
  }
  .ss-ticks span:first-child { transform: none; }
  .ss-bar { padding: 0 4px; }
  .ss-bar > span { display: none; }
}

/* Evolve a Program: the model's diffs, the sandbox's two runs of each child and the harness's archive and held-out
   check, on one axis of steps. A run in the sandbox is in the tools' colour, as Agent Swarm draws its clerks' reads;
   a refused run is a failure's. A bar is one step wide, so the scene keeps its room and scrolls on a phone. */

[data-lesson-diagram="evolve"] .diagram-schedule { --name-width: 132px; }
[data-lesson-diagram="evolve"] .schedule-bar { padding-inline: 4px; }
[data-lesson-diagram="evolve"] .schedule-bar:is([data-cell^="smoke-"], [data-cell^="search-"], [data-cell="held"]) {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="evolve"] .schedule-bar[data-tone="bad"] { --bar-fill: var(--danger-pale); --bar-ink: var(--danger); }
/* The archive's best so far is a record, in the muted fill a figure stands on: the sunken shade in light, a step over
   the card in dark, where the sunken one would read as a hole. */
[data-lesson-diagram="evolve"] [data-cell="best"] { --bar-fill: var(--stage); --bar-ink: var(--muted); }

/* An Agent That Edits Itself: the archive as a tree, a column for each diff from the seed and a row for each line of
   descent. Each version holds its place from the start, unseen until its frame. A line runs from a version's right
   edge to its child's left; a refused version, and the line to it, take a failure's colour. */
[data-lesson-diagram="self-edit"] .diagram-scene { min-width: 720px; }
/* On a phone, where the tree scrolls inside its card and follows each new version, a column keeps room for a
   version's name beside a Refused pill. */
@media (max-width: 600px) {
  [data-lesson-diagram="self-edit"] .diagram-scene { min-width: 860px; }
}
[data-lesson-diagram="self-edit"] .diagram-scene > .diagram-name { margin-bottom: 14px; }
.tree-depths {
  display: grid;
  grid-template-columns: repeat(var(--depths), minmax(0, 1fr));
  gap: 0 44px;
  margin-bottom: 8px;
  color: var(--muted);
  font: 400 var(--text-xs) / 1.4 var(--sans);
}
.diagram-tree {
  display: grid;
  grid-template-columns: repeat(var(--depths), minmax(0, 1fr));
  grid-auto-rows: minmax(62px, auto);
  align-items: center;
  gap: 14px 44px;
}
.tree-version {
  --pill-ink: var(--muted);
  --pill-fill: transparent;
  --pill-edge: var(--line-strong);
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.tree-version[data-tone="ok"] { --pill-ink: var(--ok); --pill-fill: var(--ok-pale); --pill-edge: transparent; }
.tree-version[data-tone="bad"] {
  --pill-ink: var(--danger);
  --pill-fill: var(--surface);
  --pill-edge: transparent;
  border-color: var(--danger);
  background: var(--danger-pale);
}
.tree-version[data-reveal][aria-hidden="true"] { visibility: hidden; }
.tree-id { color: var(--ink); font: 600 var(--text-sm) / 1.3 var(--sans); }
.tree-version .diagram-status { grid-column: 2; grid-row: 1; justify-self: end; }
.tree-version .diagram-detail { grid-column: 1 / -1; font-size: var(--text-xs); }
.diagram-paths [data-link].is-unseen { visibility: hidden; }
.diagram-paths [data-link].is-refused:not(.is-current) { stroke: var(--danger); }

/* Resolved: the task's own checks, the agent's patch, the two graders and the audit, on one axis of steps. A run of
   the tests in the sandbox is in the tools' colour, as Evolve a Program draws its runs; a verdict that fails is a
   failure's. Twelve one-step columns keep the figure's width, scaled to a narrower card; on a phone it scrolls. */
[data-lesson-diagram="resolved"] .diagram-schedule { --name-width: 140px; }
[data-lesson-diagram="resolved"] .schedule-bar { padding-inline: 4px; }
[data-lesson-diagram="resolved"] .schedule-bar:is([data-cell^="draft-"], [data-cell^="gold-"], [data-cell^="naive-"],
  [data-cell^="clean-"]) {
  --bar-fill: var(--fig-tool-pale);
  --bar-active: var(--fig-tool-active);
  --bar-ink: var(--fig-tool);
}
[data-lesson-diagram="resolved"] .schedule-bar[data-tone="bad"] { --bar-fill: var(--danger-pale); --bar-ink: var(--danger); }
