/* Workflow scenes (the messy-workflow pages). Markup: scripts/workflow-scenes.mjs. Playback: workflow-scenes.js.

   One Control Tower frame per customer film, drawing beat by beat what the customer says. The language is the one
   the story and implementation scenes already use: a product-window frame on a dotted stage; Horizon only for what
   Mach 1 handles; signal orange only for the problem; the plane glyph only for the agent.

   Six scene types share one frame:
     board   requests as strips: each arrives incomplete, is filled in, and lands Cleared or With your team
     lanes   bars on a track: a "before" value and the "now" value that replaces it
     router  inputs, the Mach 1 node, outputs, joined by wires
     sweep   a grid of requests that fills, then clears
     thread  a conversation
     steps   a rail of steps and what they add up to

   Sizes are in em from the frame's font size, which follows the frame's width, so a scene scales like a picture.
   A scene is written with every beat on (.is-b1 … .is-bN): that is its end state, and what shows without the
   script or with reduced motion. Only opacity, translate, scale, colour and stroke offsets change; nothing moves
   layout while a scene plays. */

.ws {
  container: ws / inline-size;
  position: relative;
  min-width: 0;
  color: var(--fg);
}
.ws *,
.ws *::before,
.ws *::after { box-sizing: border-box; }
.ws-frame {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* The same 16:9 box as the film beside it. A definite height (not aspect-ratio), so content can never stretch it. */
  height: calc(100cqw * 9 / 16);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-2);
  font: 400 clamp(10px, 2.3cqw, 13.5px) / 1.35 var(--font-sans);
}
.ws.is-fluid .ws-frame { height: auto; font-size: clamp(11px, 2.55cqw, 14px); }
.ws-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, var(--grid-dot) 1px, transparent 1.2px);
  background-size: 16px 16px;
  -webkit-mask-image: radial-gradient(ellipse 85% 80% at 50% 50%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 85% 80% at 50% 50%, #000 30%, transparent 100%);
}
.ws-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(62% 56% at 100% 0%, var(--horizon-soft), transparent 72%);
}

/* ---------- Bar, stage, caption ---------- */
.ws-bar {
  display: flex;
  align-items: center;
  gap: 0.7em;
  min-height: 3em;
  padding: 0.5em 1em;
  border-bottom: 1px solid var(--line);
}
.ws-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  min-width: 0;
  color: var(--fg-2);
  font: 500 0.8em / 1 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ws-plane { flex: none; width: 1.3em; height: 1.3em; fill: var(--horizon-2); }
.ws-ill {
  padding: 0.32em 0.6em;
  border: 1px dashed var(--line-3);
  border-radius: 99em;
  color: var(--fg-3);
  font: 500 0.72em / 1 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ws-count {
  margin-left: auto;
  color: var(--fg-3);
  font: 500 0.8em / 1 var(--font-mono);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ws-stage {
  position: relative;
  display: grid;
  min-height: 0;
  padding: 1.1em 1.2em;
}
.ws-stage > * { min-width: 0; min-height: 0; }
.ws-capbar {
  display: grid;
  padding: 0.75em 1em 0;
  border-top: 1px solid var(--line);
  background: var(--bg-subtle);
}
.ws-capbar:not(:has(.ws-dot)) { padding-bottom: 0.75em; }
.ws-caps {
  display: grid;
  align-items: center;
  min-height: 2.7em;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ws-caps li {
  grid-area: 1 / 1;
  margin: 0;
  color: var(--fg);
  font-size: 1em;
  font-weight: 520;
  line-height: 1.35;
  letter-spacing: -0.005em;
  text-wrap: balance;
  opacity: 0;
}
.ws:not([data-beat]) .ws-caps li:last-child,
.ws[data-beat="1"] .ws-caps li[data-cap="1"],
.ws[data-beat="2"] .ws-caps li[data-cap="2"],
.ws[data-beat="3"] .ws-caps li[data-cap="3"],
.ws[data-beat="4"] .ws-caps li[data-cap="4"],
.ws[data-beat="5"] .ws-caps li[data-cap="5"],
.ws[data-beat="6"] .ws-caps li[data-cap="6"],
.ws.is-film[data-beat="0"] .ws-caps li[data-cap="0"] { opacity: 1; }
.ws-caps li[data-cap="0"] { color: var(--fg-3); font-weight: 450; }

/* The rail: one segment per beat (built by the script). */
.ws-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.35em;
}
.ws-dot {
  appearance: none;
  display: block;
  min-height: 24px;
  margin: 0;
  padding: 0.7em 0 0.85em;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ws-dot::before {
  content: "";
  display: block;
  height: 3px;
  border-radius: 3px;
  background: var(--line-2);
}
.ws-dot.is-done::before { background: var(--fg-4); }
.ws-dot[aria-current="true"]::before { background: linear-gradient(90deg, var(--horizon-1), var(--horizon-2) 55%, var(--horizon-3)); }
.ws-dot:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 6px; }
@media (hover: hover) {
  .ws-dot:hover::before { background: var(--fg-3); }
  .ws-dot[aria-current="true"]:hover::before { background: linear-gradient(90deg, var(--horizon-1), var(--horizon-2) 55%, var(--horizon-3)); }
}

/* Before the script has set a scene up, keep its stage out of sight (the script marks the document first). */
html.ws-js .ws:not([data-live]) .ws-stage,
html.ws-js .ws:not([data-live]) .ws-caps { visibility: hidden; }

/* ---------- Tones ---------- */
.ws .t-m1 { --t: var(--horizon-2); --t-ink: var(--horizon-ink); --t-soft: var(--horizon-soft); --t-line: var(--horizon-line); }
.ws .t-problem { --t: var(--accent); --t-ink: var(--accent-ink); --t-soft: var(--accent-soft); --t-line: var(--accent-line); }
.ws .t-plain { --t: var(--fg-3); --t-ink: var(--fg); --t-soft: var(--bg-sunken); --t-line: var(--line-2); }
.ws .t-team { --t: var(--fg); --t-ink: var(--fg); --t-soft: transparent; --t-line: var(--line-3); }
.ws-i { display: block; flex: none; width: 1.15em; height: 1.15em; }

.ws-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.4em 0.75em;
  border: 1px solid var(--t-line);
  border-radius: 99em;
  background: linear-gradient(var(--t-soft), var(--t-soft)), var(--bg-elev);
  color: var(--t-ink);
  font: 520 0.88em / 1.15 var(--font-sans);
  white-space: nowrap;
}
.ws-chip.is-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.ws-chip.is-solid { border-color: transparent; background: linear-gradient(100deg, var(--horizon-1), var(--horizon-2) 55%, var(--horizon-3)); color: #fff; }
.ws-chip.is-solid .ws-plane { fill: #fff; }
.ws-notes { display: flex; flex-wrap: wrap; gap: 0.45em; }
.ws-foot {
  margin: 0;
  color: var(--fg-2);
  font-size: 0.9em;
  line-height: 1.35;
  text-wrap: balance;
}

/* ---------- Beats ----------
   Off: an element whose beat has not arrived. On: a state that switches at a beat. */
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"]) { opacity: 0; translate: 0 0.7em; }
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"])[data-in="left"] { translate: -1.1em 0; }
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"])[data-in="right"] { translate: 1.1em 0; }
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"])[data-in="fade"] { translate: none; }
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"])[data-in="pop"] { translate: none; scale: 0.82; }
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"])[data-in="grow"] { opacity: 1; translate: none; scale: 0 1; }
:is(.ws:not(.is-b1) [data-at="1"], .ws:not(.is-b2) [data-at="2"], .ws:not(.is-b3) [data-at="3"], .ws:not(.is-b4) [data-at="4"], .ws:not(.is-b5) [data-at="5"], .ws:not(.is-b6) [data-at="6"])[data-in="draw"] { opacity: 1; translate: none; stroke-dashoffset: 1; }
:is(.ws.is-b1 [data-until="1"], .ws.is-b2 [data-until="2"], .ws.is-b3 [data-until="3"], .ws.is-b4 [data-until="4"], .ws.is-b5 [data-until="5"], .ws.is-b6 [data-until="6"]) { opacity: 0; scale: 0.92; }
:is(.ws.is-b1 [data-dim="1"], .ws.is-b2 [data-dim="2"], .ws.is-b3 [data-dim="3"], .ws.is-b4 [data-dim="4"], .ws.is-b5 [data-dim="5"], .ws.is-b6 [data-dim="6"]) { opacity: 0.4; }
:is(.ws.is-b1 [data-strike="1"], .ws.is-b2 [data-strike="2"], .ws.is-b3 [data-strike="3"], .ws.is-b4 [data-strike="4"], .ws.is-b5 [data-strike="5"], .ws.is-b6 [data-strike="6"]) { opacity: 0.5; }
:is(.ws.is-b1 [data-strike="1"], .ws.is-b2 [data-strike="2"], .ws.is-b3 [data-strike="3"], .ws.is-b4 [data-strike="4"], .ws.is-b5 [data-strike="5"], .ws.is-b6 [data-strike="6"]) > span { text-decoration: line-through; text-decoration-thickness: 1.5px; }

/* ---------- Pass: the tower sweep crossing a board or a grid ---------- */
.ws-pass {
  position: absolute;
  inset: -0.5em auto -0.5em 0;
  z-index: 3;
  width: 20%;
  border-radius: 0.5em;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--horizon-2) 16%, transparent) 55%, color-mix(in srgb, var(--horizon-3) 42%, transparent) 99%, var(--horizon-3) 100%);
}

/* ---------- Board ---------- */
.ws-board { position: relative; display: grid; align-content: center; gap: 0.6em; }
.ws-strip {
  position: relative;
  display: grid;
  grid-template-columns: 4.4em minmax(0, 1fr) minmax(0, 1.2fr) 9.6em;
  align-items: center;
  gap: 0.9em;
  padding: 0.7em 0.9em 0.7em 1.2em;
  overflow: hidden;
  border-radius: 0.8em;
  background: var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
}
.ws-strip::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.3em;
  background: var(--accent);
}
:is(.ws.is-b1 [data-on="1"], .ws.is-b2 [data-on="2"], .ws.is-b3 [data-on="3"]).ws-strip::before { background: linear-gradient(180deg, var(--horizon-1), var(--horizon-3)); }
.ws-strip-id { color: var(--fg-3); font: 500 0.8em / 1 var(--font-mono); letter-spacing: 0.02em; white-space: nowrap; }
.ws-strip-title { overflow: hidden; font-weight: 560; letter-spacing: -0.005em; white-space: nowrap; text-overflow: ellipsis; }
.ws-strip-slot { display: grid; min-width: 0; }
.ws-strip-slot > * {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 0.45em;
  max-width: 100%;
  padding: 0.36em 0.75em 0.36em 0.6em;
  border-radius: 99em;
  font-size: 0.9em;
  font-weight: 520;
  line-height: 1.15;
  white-space: nowrap;
}
.ws-gap { border: 1px dashed var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); }
.ws-found { border: 1px solid var(--horizon-line); background: var(--horizon-soft); color: var(--horizon-ink); }
.ws-strip-status {
  display: inline-flex;
  justify-self: end;
  align-items: center;
  gap: 0.45em;
  padding: 0.45em 0.85em 0.45em 0.7em;
  border-radius: 99em;
  font-size: 0.9em;
  font-weight: 560;
  line-height: 1.15;
  white-space: nowrap;
}
.is-cleared > .ws-strip-status { background: linear-gradient(100deg, var(--horizon-1), var(--horizon-2) 55%, var(--horizon-3)); color: #fff; }
.is-cleared > .ws-strip-status .ws-plane { fill: #fff; }
.is-team > .ws-strip-status { box-shadow: inset 0 0 0 1px var(--line-3); background: var(--bg-elev); color: var(--fg); }

/* ---------- Lanes ---------- */
.ws-lanes { display: grid; align-content: center; gap: 1.1em; }
.ws-lane-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8em; min-height: 1.9em; margin-bottom: 0.45em; }
.ws-lane-label { color: var(--fg-3); font: 500 0.8em / 1.25 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.ws-flag {
  flex: none;
  padding: 0.42em 0.75em;
  border-radius: 99em;
  background: var(--fg);
  color: var(--bg);
  font: 560 0.82em / 1 var(--font-sans);
  white-space: nowrap;
}
.ws-track {
  position: relative;
  height: 2.8em;
  border-radius: 0.8em;
  background: linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 10% 100%, var(--bg-subtle);
  box-shadow: inset 0 0 0 1px var(--line);
}
.ws-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--size);
  min-width: 0.8em;
  border-radius: 0.8em;
  background: linear-gradient(var(--t-soft), var(--t-soft)), var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--t-line);
  transform-origin: left center;
}
.ws-fill.t-problem {
  background:
    repeating-linear-gradient(106deg, transparent 0 0.5em, color-mix(in srgb, var(--accent) 14%, transparent) 0.5em 0.62em),
    linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-elev);
}
.ws-fill.t-m1 {
  background: linear-gradient(100deg, var(--horizon-1), var(--horizon-2) 55%, var(--horizon-3));
  box-shadow: 0 0.4em 1.4em -0.4em var(--horizon-line);
}
.ws-fill-text {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0.9em;
  display: flex;
  align-items: center;
  color: var(--t-ink);
  font-weight: 560;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.ws-fill-text.is-end { right: 0.9em; left: auto; }
.ws-fill-text.is-out { left: calc(var(--size) + 0.8em); color: var(--fg); }
.ws-fill-text.t-m1:not(.is-out) { color: #fff; }

/* ---------- Router ---------- */
.ws-router-wrap { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 0.7em; }
.ws-router {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0 clamp(1.4em, 6cqw, 3.2em);
  min-height: 0;
}
.ws-wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ws-wires path {
  fill: none;
  stroke: var(--line-3);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.ws-wires path.t-m1 { stroke: var(--horizon-2); }
.ws-wires path.t-problem { stroke: var(--accent-line); }
.ws-col { position: relative; z-index: 1; display: grid; align-content: center; gap: 0.55em; min-width: 0; }
.ws-pill {
  min-width: 0;
  padding: 0.6em 0.85em;
  border: 1px solid var(--t-line);
  border-radius: 0.8em;
  background: linear-gradient(var(--t-soft), var(--t-soft)), var(--bg-elev);
}
.ws-pill > span { display: block; color: var(--t-ink); font-weight: 560; line-height: 1.25; letter-spacing: -0.005em; text-wrap: balance; }
.ws-pill > small { display: block; margin-top: 0.15em; color: var(--fg-3); font-size: 0.85em; line-height: 1.25; }
.ws-pill.t-team { border-style: dashed; }
.ws-hub { position: relative; z-index: 1; display: grid; justify-items: center; gap: 0.65em; width: 8em; text-align: center; }
.ws-node {
  position: relative;
  display: grid;
  place-items: center;
  width: 5.2em;
  height: 5.2em;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: 0 0 0 0.5em color-mix(in srgb, var(--fg) 3%, transparent), 0 0 0 1em color-mix(in srgb, var(--fg) 2%, transparent);
}
.ws-mark { position: relative; z-index: 1; width: 2.3em; height: 2.3em; fill: var(--fg-4); }
.ws-node-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  background: conic-gradient(from 0deg, transparent 0deg 236deg,
    color-mix(in srgb, var(--horizon-1) 14%, transparent) 300deg,
    color-mix(in srgb, var(--horizon-2) 30%, transparent) 344deg,
    color-mix(in srgb, var(--horizon-3) 58%, transparent) 359.5deg, transparent 360deg);
}
:is(.ws.is-b1 [data-on="1"], .ws.is-b2 [data-on="2"], .ws.is-b3 [data-on="3"], .ws.is-b4 [data-on="4"], .ws.is-b5 [data-on="5"], .ws.is-b6 [data-on="6"]).ws-node {
  border-color: var(--horizon-line);
  box-shadow: 0 0 0 0.5em var(--horizon-soft), 0 0 0 1em color-mix(in srgb, var(--horizon-2) 5%, transparent), 0 0.6em 2em -0.4em var(--horizon-line);
}
:is(.ws.is-b1 [data-on="1"], .ws.is-b2 [data-on="2"], .ws.is-b3 [data-on="3"], .ws.is-b4 [data-on="4"], .ws.is-b5 [data-on="5"], .ws.is-b6 [data-on="6"]).ws-node .ws-mark { fill: var(--fg); }
:is(.ws.is-b1 [data-on="1"], .ws.is-b2 [data-on="2"], .ws.is-b3 [data-on="3"], .ws.is-b4 [data-on="4"], .ws.is-b5 [data-on="5"], .ws.is-b6 [data-on="6"]).ws-node .ws-node-sweep { opacity: 1; }
.ws-hub-label { color: var(--fg-2); font-size: 0.82em; font-weight: 540; line-height: 1.25; text-wrap: balance; }

/* ---------- Sweep ---------- */
.ws-sweep { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0.8em; }
.ws-grid { position: relative; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); align-content: center; gap: 0.4em; }
.ws-tile {
  position: relative;
  aspect-ratio: 2.05 / 1;
  overflow: hidden;
  border-radius: 0.35em;
  background: var(--bg-sunken);
  box-shadow: inset 0 0 0 1px var(--line);
}
.ws-tile > b { position: absolute; inset: 0; border-radius: inherit; background: var(--t); }
.ws-tile > b.t-problem { background: color-mix(in srgb, var(--accent) 86%, var(--bg-elev)); }
.ws-tile > b.t-problem.is-miss {
  background:
    repeating-linear-gradient(106deg, transparent 0 0.34em, color-mix(in srgb, var(--accent) 34%, transparent) 0.34em 0.44em),
    var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.ws-tile > b.t-plain { background: var(--fg-3); }
.ws-tile > b.t-m1 { background: color-mix(in oklab, var(--horizon-1), var(--horizon-3) calc(var(--p, 0.5) * 100%)); }
.ws-tile > b.t-team { background: var(--bg-elev); box-shadow: inset 0 0 0 1.5px var(--fg-3); }
.ws-tile > b.t-team::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: var(--fg-2);
  translate: -50% -50%;
}
.ws-legend { display: flex; flex-wrap: wrap; gap: 0.35em 1.2em; }
.ws-key { display: inline-flex; align-items: center; gap: 0.5em; color: var(--fg-2); font-size: 0.88em; font-weight: 520; line-height: 1.25; }
.ws-key > i { flex: none; width: 0.9em; height: 0.9em; border-radius: 0.25em; background: var(--t); }
.ws-key.t-m1 > i { background: linear-gradient(100deg, var(--horizon-1), var(--horizon-3)); }
.ws-key.t-team > i { background: var(--bg-elev); box-shadow: inset 0 0 0 1.5px var(--fg-3); }

/* ---------- Thread ---------- */
.ws-thread { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 0.6em; }
.ws-thread-who {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  min-height: 2em;
  color: var(--fg-3);
  font: 500 0.78em / 1 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ws-thread-who > span:not(.ws-chip) { display: inline-flex; align-items: center; gap: 0.5em; }
.ws-thread-who > .ws-chip { font-family: var(--font-sans); font-size: 1.1em; letter-spacing: 0; text-transform: none; }
.ws-thread-body { display: flex; flex-direction: column; justify-content: flex-end; gap: 0.5em; min-height: 0; }
.ws-bub {
  max-width: 82%;
  padding: 0.62em 0.9em;
  border-radius: 1.05em;
  font-size: 0.98em;
  font-weight: 480;
  line-height: 1.32;
  text-wrap: pretty;
}
.ws-bub.is-left { align-self: flex-start; border-bottom-left-radius: 0.3em; background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--line); }
.ws-bub.is-right {
  align-self: flex-end;
  border-bottom-right-radius: 0.3em;
  background: linear-gradient(var(--horizon-soft), var(--horizon-soft)), var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--horizon-line);
}
.ws-tnote { display: flex; justify-content: center; }
.ws-tstatus { display: flex; align-items: center; justify-content: center; gap: 0.6em; color: var(--fg-3); }
.ws-skel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1em; }
.ws-skel > i { width: 82%; height: 1em; border-radius: 99em; background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--line); }
.ws-skel > i.is-right { justify-self: end; width: 70%; background: var(--horizon-soft); box-shadow: inset 0 0 0 1px var(--horizon-line); }

/* ---------- Steps ---------- */
.ws-flow { display: grid; align-content: center; gap: 1.2em; }
.ws-steps { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.ws-step { position: relative; display: grid; align-content: start; justify-items: center; gap: 0.6em; margin: 0; padding: 0 0.35em; text-align: center; }
.ws-step-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.8em;
  height: 2.8em;
  border-radius: 50%;
  background: linear-gradient(var(--t-soft), var(--t-soft)), var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--t-line);
  color: var(--t-ink);
}
.ws-step.t-m1 .ws-step-dot { box-shadow: inset 0 0 0 1px var(--t-line), 0 0.4em 1.2em -0.4em var(--horizon-line); }
.ws-step-dot .ws-i { width: 1.25em; height: 1.25em; }
.ws-step-link {
  position: absolute;
  top: 1.4em;
  right: 50%;
  width: 100%;
  height: 1.5px;
  margin-top: -0.75px;
  background: linear-gradient(90deg, var(--horizon-1), var(--horizon-3));
  transform-origin: left center;
}
.ws-step-text { display: grid; gap: 0.2em; min-width: 0; }
.ws-step-title { font-size: 0.92em; font-weight: 560; line-height: 1.22; letter-spacing: -0.005em; text-wrap: balance; }
.ws-step-val { color: var(--fg-3); font-size: 0.82em; line-height: 1.2; }
.ws-results { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6em; }
.ws-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1em 0.65em;
  padding: 0.55em 0.95em;
  border-radius: 0.85em;
  background: var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--horizon-line), 0 0.5em 1.4em -0.6em var(--horizon-line);
}
.ws-result > strong {
  padding-right: 0.06em;
  background: linear-gradient(100deg, var(--horizon-1), var(--horizon-2) 55%, var(--horizon-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.22em;
  font-weight: 620;
  line-height: 1.2;
  white-space: nowrap;
}
.ws-result > span { color: var(--fg-2); font-size: 0.86em; line-height: 1.25; }

/* ---------- Narrow frames (phones): taller picture, stacked layouts ---------- */
@container ws (max-width: 440px) {
  .ws-frame { height: calc(100cqw * 3.3 / 4); }
  .ws.is-fluid .ws-frame { height: auto; }
  .ws-stage { padding: 0.95em 1em; }
  .ws-ill { display: none; }
  .ws-strip { grid-template-columns: minmax(0, 1fr) auto; gap: 0.45em 0.7em; padding: 0.65em 0.8em 0.65em 1.1em; }
  .ws-strip-status { align-self: center; }
  .ws-strip-id { display: none; }
  .ws-strip-title { grid-area: 1 / 1; }
  .ws-strip-slot { grid-area: 2 / 1; }
  .ws-strip-status { grid-area: 1 / 2 / 3 / 3; }
  .ws-router { gap: 0 1.1em; }
  .ws-hub { width: 5.6em; }
  .ws-node { width: 4em; height: 4em; }
  .ws-mark { width: 1.8em; height: 1.8em; }
  .ws-pill { padding: 0.5em 0.65em; }
  .ws-col { gap: 0.4em; }
  .ws-col:has(> :nth-child(3)) small { display: none; }
  .ws-hub-label { font-size: 0.78em; }
  .ws-lane-head { min-height: 1.6em; margin-bottom: 0.35em; }
  .ws-track { height: 2.5em; }
  .ws-lanes { gap: 0.7em; }
  .ws-tile { aspect-ratio: 1.5 / 1; }
  .ws-flow { gap: 0.8em; }
  .ws-steps { grid-template-columns: minmax(0, 1fr); gap: 0.4em; }
  .ws-step { grid-template-columns: auto minmax(0, 1fr); align-items: center; justify-items: start; gap: 0.7em; padding: 0; text-align: left; }
  .ws-step-dot { width: 1.9em; height: 1.9em; }
  .ws-step-dot .ws-i { width: 1em; height: 1em; }
  .ws-step-link { display: none; }
  .ws-step-text { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0.7em; width: 100%; }
  .ws-step-val { text-align: right; }
  .ws-results { gap: 0.4em; }
  .ws-result { padding: 0.4em 0.75em; }
  .ws-result > strong { font-size: 1.08em; }
}

/* The smallest phones (320 to 340 wide): a square frame, so four outputs or five steps still fit. */
@container ws (max-width: 310px) {
  .ws-frame { height: calc(100cqw * 3.95 / 4); }
  .ws.is-fluid .ws-frame { height: auto; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .ws [data-at],
  .ws [data-until],
  .ws [data-dim],
  .ws [data-strike],
  .ws [data-on],
  .ws [data-on]::before,
  .ws-mark,
  .ws-node-sweep,
  .ws-caps li {
    transition:
      opacity 520ms var(--ease) var(--d, 0ms),
      translate 640ms var(--ease-out) var(--d, 0ms),
      scale 760ms var(--ease-out) var(--d, 0ms),
      background 420ms var(--ease) var(--d, 0ms),
      border-color 420ms var(--ease),
      box-shadow 520ms var(--ease),
      fill 420ms var(--ease);
  }
  .ws [data-in="grow"] { transition-duration: 520ms, 640ms, 900ms, 420ms, 420ms, 520ms, 420ms; }
  .ws [data-in="pop"] { transition-timing-function: var(--ease), var(--ease-out), var(--ease-spring), var(--ease), var(--ease), var(--ease), var(--ease); }
  .ws-wires path { transition: stroke-dashoffset 760ms var(--ease-out), opacity 420ms var(--ease); }
  .ws-caps li { transition: opacity 320ms var(--ease); }
  .ws-dot::before { transition: background 240ms var(--ease); }
  :is(.ws.is-b1 [data-at="1"], .ws.is-b2 [data-at="2"], .ws.is-b3 [data-at="3"], .ws.is-b4 [data-at="4"], .ws.is-b5 [data-at="5"], .ws.is-b6 [data-at="6"])[data-in="pass"] { animation: ws-pass 1150ms var(--ease-in-out) both; }
  :is(.ws.is-b1 [data-on="1"], .ws.is-b2 [data-on="2"], .ws.is-b3 [data-on="3"], .ws.is-b4 [data-on="4"], .ws.is-b5 [data-on="5"], .ws.is-b6 [data-on="6"]).ws-node .ws-node-sweep { animation: ws-spin 5.4s linear infinite; }
}
@keyframes ws-pass {
  from { opacity: 0; translate: -100% 0; }
  18%, 82% { opacity: 1; }
  to { opacity: 0; translate: 500% 0; }
}
@keyframes ws-spin { to { rotate: 360deg; } }
@keyframes ws-listen { 50% { opacity: 0.45; } }
