/* Figures in the article: a numbered figure with its caption, and the spec-code charts inside it */
.article-figure { margin: 24px 0 36px; }
.article-figure .spec-code { padding: 20px 22px 16px; border: 1px solid var(--rule); border-radius: 10px; }
.article-figure figcaption { margin-top: 12px; color: var(--muted); font-size: 16px; line-height: 1.55; }
.article-figure .figure-label { color: var(--text); font-weight: 600; }

.article-figure .figure-title { margin: 0 0 6px; font-size: 18px; font-weight: 500; color: var(--text); }
/* a title and its legend on one line, the legend at the right; the legend goes under the title when they do not fit */
.spec-code .figure-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 24px; margin: 0 0 8px; }
.article-figure .spec-code .figure-head > * { margin: 0; }
.spec-code .legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.spec-code .legend .item { display: inline-flex; align-items: center; white-space: nowrap; }
.spec-code .key { display: inline-block; width: 22px; margin-right: 6px; border-top: 2px solid; }
.spec-code .source-key { border-color: var(--ink); }
.spec-code .spec-key { border-color: var(--accent); }
.spec-code .shared-key { border-top: 2px dashed var(--muted); }
.spec-code .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; }
.spec-code .source-swatch { background: var(--ink); }
.spec-code .spec-swatch { background: var(--accent); }

.spec-code svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.spec-code svg text { fill: var(--text); font-size: 13px; letter-spacing: 0; }
.spec-code svg .muted { fill: var(--muted); }
.spec-code svg .accent { fill: var(--accent); }
.spec-code svg .ratio { fill: var(--text); font-size: 12px; font-weight: 500; }
/* the charts: larger text, read at the chart's full width */
.spec-code.bars svg text { font-size: 15px; }
.spec-code.lines svg text { font-size: 17px; }
/* phones: the narrow drawing, its text at its own size */
.spec-code svg.compact { display: none; }
@media (max-width: 640px) {
  .spec-code svg.wide { display: none; }
  .spec-code svg.compact { display: block; }
  .spec-code svg.compact text, .spec-code.bars svg.compact .ratio, .spec-code.bars svg.compact .xlabel { font-size: 14px; }
  .spec-code.bars .legend, .spec-code.lines .legend { font-size: 14px; }
}
.spec-code.bars .legend, .spec-code.lines .legend { font-size: 16px; }
.spec-code.bars svg .ratio { font-size: 14px; }
.spec-code.bars svg .xlabel { font-size: 14px; }
.spec-code svg .panel-title { font-size: 15px; font-weight: 500; }   /* a chart beside another, under one figure title */
.spec-code .grid { stroke: var(--rule); stroke-width: 1; }
.spec-code .shared { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.spec-code .source { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.spec-code .spec { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.spec-code .source-dot { fill: var(--ink); stroke: var(--bg); stroke-width: 2; }
.spec-code .spec-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.spec-code .source-bar { fill: var(--ink); }
.spec-code .spec-bar { fill: var(--accent); }
.spec-code .hit { fill: transparent; }

/* hover: one variant's growth (the segment into its node), or one operation's bars */
.spec-code .growth { fill: none; stroke-width: 5; stroke-linecap: round; opacity: 0; pointer-events: none; transition: opacity 120ms ease; }
.spec-code .source-growth { stroke: var(--ink); }
.spec-code .spec-growth { stroke: var(--accent); }
.spec-code .node { pointer-events: none; transition: r 120ms ease; }
.spec-code svg.dim .source, .spec-code svg.dim .spec { opacity: 0.35; }
.spec-code .growth.on { opacity: 1; }
.spec-code .node.on { r: 7; }

.figure-card {
  position: fixed;
  display: none;
  z-index: 40;
  min-width: 240px;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 10px 12px;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.10);
  font-size: 14px;
  line-height: 1.5;
}
.figure-card b { display: block; margin-bottom: 4px; font-size: 15px; font-weight: 500; }
.figure-card .row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: lining-nums tabular-nums; }
.figure-card .row span:first-child { color: var(--muted); }

/* composition: kernels on top of the shared library; a kernel lights the operations it uses, an operation its kernels */
.composition svg .band { fill: color-mix(in srgb, var(--accent) 6%, var(--bg)); stroke: var(--rule); }
.composition svg .band-title { font-size: 15px; font-weight: 500; }
.composition svg .card rect { fill: var(--bg); stroke: var(--text); stroke-width: 1.25; transition: stroke 120ms ease; }
.composition svg .chip rect { fill: var(--bg); stroke: var(--accent); stroke-width: 1.25; transition: fill 120ms ease; }
.composition svg .mono { font-family: var(--mono); font-size: 12.5px; }
.composition svg .card, .composition svg .chip { cursor: pointer; transition: opacity 120ms ease; }
.composition svg.dim .card:not(.on), .composition svg.dim .chip:not(.on) { opacity: 0.35; }
.composition svg .card.on rect { stroke: var(--accent); }
.composition svg .chip.on rect { fill: color-mix(in srgb, var(--accent) 16%, var(--bg)); }

/* shape of a kernel spec: the read-only input and the mutable tensors before the run on the left, the return output
   and the mutable tensors after it on the right, an arrow per dependency. HTML boxes (text at reading size), with
   the arrows in a fixed-size SVG between them. All light; hovering f_math or f_machine turns its three boxes and
   two arrows green, and nothing else changes. */
/* this figure stands on its own: no outer frame */
.article-figure .spec-code.shape { padding: 0; border: 0; }
.shape-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr); grid-template-rows: 64px 64px auto auto auto;
  row-gap: 14px; column-gap: 0; align-items: center; padding: 0 16px; }
.shape-links { grid-column: 2; grid-row: 1 / span 2; overflow: visible; }
.shape-links path { fill: none; stroke: var(--muted); stroke-opacity: 0.55; stroke-width: 1.5; transition: stroke 150ms ease, stroke-opacity 150ms ease; }
.shape-links .head { fill: var(--muted); fill-opacity: 0.55; stroke: none; transition: fill 150ms ease, fill-opacity 150ms ease; }
.shape-links .hit { stroke: transparent; stroke-width: 14; pointer-events: stroke; }
.shape-node { box-sizing: border-box; height: 64px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 0 14px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); font-size: 18px; line-height: 1.3;
  white-space: nowrap; transition: border-color 150ms ease, background-color 150ms ease; }
.shape-label { font-size: 14px; font-variant-caps: all-small-caps; letter-spacing: 0.05em; color: var(--muted); }
.shape-label code { font-family: var(--mono); font-size: 12px; font-variant-caps: normal; letter-spacing: 0; background: none; padding: 0; color: var(--text); }
/* a square root with its bar: the radicand's top border runs on from the top of the √ */
.sqrt, .shape-node .nobreak { white-space: nowrap; }
.sqrt .radicand { display: inline-block; line-height: 1; padding: 1px 1px 0 1px; margin-left: -0.08em; border-top: 1px solid currentColor; }
.shape-node sub, .shape-node sup { font-size: 0.65em; line-height: 0; }
/* constraints and layout: the precondition under the inputs, PTX memory along the bottom, and a dashed layout arrow
   from each tensor to its region of memory (drawn by figures.js from the boxes' positions) */
.article-figure .shape-pre { grid-column: 1; grid-row: 3; margin: -4px 0 0; max-width: calc(100% - 40px); font-size: 16px; }
.shape-memory { grid-column: 1 / span 3; grid-row: 4; display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr); margin-top: 22px; }
.mem-seg { display: flex; justify-content: center; gap: 10px; padding: 7px 8px; border: 1px solid var(--rule); background: var(--surface); }
.mem-seg + .mem-seg { border-left: 0; }
.mem-seg:first-child { border-radius: 8px 0 0 8px; }
.mem-seg:last-child { border-radius: 0 8px 8px 0; }
.mem-seg code { font-family: var(--mono); font-size: 13px; background: none; padding: 0; }
.article-figure .shape-memory-label { grid-column: 1 / span 3; grid-row: 5; margin: -12px 0 0; text-align: center; line-height: 1; }
.shape-layout { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.shape-layout path.route { fill: none; stroke: var(--muted); stroke-opacity: 0.7; stroke-width: 1.25; stroke-dasharray: 4 3; transition: stroke 150ms ease; }
.shape-layout path.hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.shape-layout marker path { fill: var(--muted); fill-opacity: 0.7; stroke: none; }
.shape-layout marker path.on { fill: var(--accent); fill-opacity: 1; }
.shape-layout text { font-family: var(--mono); font-size: 12.5px; fill: var(--muted); pointer-events: auto; cursor: pointer; transition: fill 150ms ease; }
/* hover on layout: the regions, routes and tensors it maps turn green, like spec_math and spec_mut */
.shape-layout path.route.on { stroke: var(--accent); stroke-opacity: 1; }
.shape-layout text.on { fill: var(--accent); }
.mem-seg { cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease; }
.mem-seg.on { box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.shape-node.layout-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.shape-grid [data-fn] { cursor: pointer; }
.shape-grid[data-focus="math"] .shape-node[data-in~="math"],
.shape-grid[data-focus="machine"] .shape-node[data-in~="machine"] {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.shape-grid[data-focus="math"] .shape-links .math,
.shape-grid[data-focus="machine"] .shape-links .machine { stroke: var(--accent); stroke-opacity: 1; }
.shape-links .fn { font-family: var(--mono); font-size: 12.5px; fill: var(--muted); transition: fill 150ms ease; }
.shape-grid[data-focus="math"] .shape-links .math-fn,
.shape-grid[data-focus="machine"] .shape-links .machine-fn { fill: var(--accent); }
.shape-grid[data-focus="math"] .shape-links .math-head,
.shape-grid[data-focus="machine"] .shape-links .machine-head { fill: var(--accent); fill-opacity: 1; }
/* phones: a narrow middle column, its arrows drawn at its width, their names above and below it at reading size */
.shape-links.compact { display: none; }
@media (max-width: 640px) {
  .shape-grid { grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr); grid-template-rows: 76px 76px auto auto auto; padding-top: 22px; }
  .shape-memory { grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr); }
  .mem-seg { flex-wrap: wrap; gap: 0 6px; padding: 6px 4px; }
  .mem-seg code { font-size: 11px; }
  .shape-links.wide { display: none; }
  .shape-links.compact { display: block; }
  .shape-node { height: 76px; font-size: 15px; padding: 0 8px; white-space: normal; }
  .shape-links.compact .fn { font-size: 11px; }
  .article-figure .shape-pre { font-size: 15px; text-wrap: balance; }
}

/* paragraphs inside figures are scoped under .article-figure so the article's `.post-body p` margins do not reach them */
/* the correctness square: tensors on top (f), memory below (the kernel), the layout lowering one onto the other */
.article-figure .spec-code.square { padding: 0; border: 0; container-type: inline-size; }
.square-grid { display: grid; grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr) 160px; grid-template-rows: 64px 64px 64px auto; align-items: center; }
.article-figure .square-condition { grid-column: 1 / span 3; margin: 14px 0 0; text-align: center; font-size: 18px; }
.square-node { box-sizing: border-box; height: 64px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); font-size: 18px; line-height: 1.3; white-space: nowrap; }
.square-label { font-size: 14px; font-variant-caps: all-small-caps; letter-spacing: 0.05em; color: var(--muted); }
.square-h { display: flex; flex-direction: column; align-items: stretch; padding: 0 10px; }
.square-h-text { text-align: center; font-size: 17px; line-height: 1.2; }
.square-h-line { position: relative; height: 0; margin: 4px 6px 14px 0; border-top: 1.5px solid var(--text); }
.square-h-line::after { content: ""; position: absolute; right: -6px; top: -5.5px; border-left: 8px solid var(--text); border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; }
.square-v { position: relative; height: 100%; display: flex; justify-content: center; }
.square-v-line { position: relative; width: 0; margin: 6px 0 8px; border-left: 1.5px solid var(--accent); }
.square-v-line::after { content: ""; position: absolute; bottom: -6px; left: -5.5px; border-top: 8px solid var(--accent); border-left: 4.5px solid transparent; border-right: 4.5px solid transparent; }
.square-v-text { position: absolute; left: calc(50% + 10px); top: 50%; transform: translateY(-50%); font-size: 15px; line-height: 1.25; color: var(--accent); white-space: nowrap; }
/* the right arrow's label sits inside the square, clear of the notes column */
.square-v.inner-left .square-v-text { left: auto; right: calc(50% + 10px); text-align: right; }
/* a node's memory: one cell per tensor's bytes, then the rest of memory; the cell execution writes is lit */
.square-memory { display: flex; }
.square-memory > span { flex: 1; height: 24px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--rule); background: var(--bg); font-size: 16px; }
.square-memory > span + span { border-left: 0; }
.square-memory > span:first-child { border-radius: 5px 0 0 5px; }
.square-memory > span:last-child { border-radius: 0 5px 5px 0; color: var(--muted); }
.square-memory > span.written { box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.article-figure .square-note { margin: 0 0 0 16px; font-size: 14px; font-variant-caps: all-small-caps; letter-spacing: 0.05em; color: var(--muted); line-height: 1.3; }
/* the specification (the top arrow and the layout) in the accent color; the kernel's arrow stays plain */
.square-h.spec .square-h-text { color: var(--accent); }
.square-h.spec .square-h-line { border-top-color: var(--accent); }
.square-h.spec .square-h-line::after { border-left-color: var(--accent); }
.article-figure .square-brace { align-self: stretch; display: flex; align-items: center; margin: 6px 0 6px 10px; padding-left: 10px; border-left: 2px solid var(--rule);
  font-size: 17px; font-variant-caps: normal; letter-spacing: 0; font-weight: 600; color: var(--text); }
.square-h-text code, .square-v-text code { font-family: var(--mono); font-size: 14px; background: none; padding: 0; color: inherit; white-space: inherit; }
.article-figure .square-brace.spec { grid-column: 4; grid-row: 1 / span 2; border-left-color: var(--accent); color: var(--accent); }
/* where the brackets do not fit: a legend of the arrows' colors, the specification's and the kernel's */
.article-figure .square-legend { display: none; grid-column: 1 / -1; grid-row: 4; justify-content: center; flex-wrap: wrap; gap: 6px 28px;
  margin: 18px 0 0; font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--text); }
.square-legend .item { display: inline-flex; align-items: center; gap: 10px; }
.square-legend .item.spec { color: var(--accent); }
.square-legend .swatch { position: relative; width: 24px; height: 0; border-top: 1.5px solid currentColor; }
.square-legend .swatch::after { content: ""; position: absolute; right: -2px; top: -5.5px; border-left: 8px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; }
/* a narrow figure (the sidebar's range, phones): the brackets give way to the legend */
@container (max-width: 680px) {
  .square-grid { grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr); }
  .square-node { font-size: 16px; padding: 0 10px; }
  .square-v-text { white-space: normal; width: 70px; }
  .article-figure .square-brace { display: none; }
  .article-figure .square-legend { display: flex; }
}
@container (max-width: 440px) {
  .square-grid { grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr); }
  .square-node { font-size: 13px; padding: 0 6px; }
  .square-label { font-size: 12.5px; }
  .square-memory > span { height: 22px; font-size: 14px; }
  .square-v-text { font-size: 13px; width: 64px; }
  .square-h { padding: 0; }
  .square-h-text { font-size: 12.5px; }
  .square-h-text code, .square-v-text code { font-size: 11px; }
  .article-figure .square-legend { font-size: 15px; gap: 20px; }
}
@container (max-width: 340px) {
  .square-node { font-size: 12px; padding: 0 5px; }
}

/* the proof pipeline: what the user gives (amber), what TensorLean generates (gray), what is proven (green)
   and what is trusted (blue). The kernel's side runs along the bottom row, the spec's comes down the right,
   and the two meet below in the proof; across the body and the right column, one column on narrow screens */
/* --u: one pixel of the figure drawn 1280 wide; the whole figure scales with its width, text included */
.flow, .flow-controls { --u: calc(100cqi / 1280); }
.flow { --user: #c4c4bf; --user-tint: var(--surface); --auto: #b7832c; --auto-tint: #fbf2e1; --trusted: #3a72b5; --trusted-tint: #eaf1fa;
  --code-keyword: #d73a49; --code-name: #6f42c1; --code-number: #005cc5; --code-comment: #6a737d;
  --gap: calc(60 * var(--u)); --arrow: calc(88 * var(--u)); display: grid; grid-template-columns: minmax(0, 1fr) var(--arrow) minmax(0, 1fr) var(--arrow) minmax(0, 1fr) var(--gap) minmax(0, 1fr);
  grid-template-areas:
    "src legend legend legend legend legend spec"
    "compile . . . . . lower"
    "ptx a1 hb a2 mem . lowered"
    ". . . . tee tee tee"
    ". . . . proof proof proof";
  grid-template-rows: auto calc(48 * var(--u)) auto auto auto; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .flow { --user: #55565b; --auto: #d8a54e; --auto-tint: #2d261a; --trusted: #74a6e2; --trusted-tint: #1b2431;
    --code-keyword: #f97583; --code-name: #b392f0; --code-number: #79b8ff; --code-comment: #8b949e; }
}
:root[data-theme="dark"] .flow { --user: #55565b; --auto: #d8a54e; --auto-tint: #2d261a; --trusted: #74a6e2; --trusted-tint: #1b2431;
  --code-keyword: #f97583; --code-name: #b392f0; --code-number: #79b8ff; --code-comment: #8b949e; }
.article-figure .flow-legend { grid-area: legend; align-self: center; justify-self: center; display: flex; flex-wrap: wrap; justify-content: center; gap: calc(6 * var(--u)) calc(20 * var(--u)); margin: 0; padding: calc(11 * var(--u)) calc(16 * var(--u)); border: calc(1.5 * var(--u)) solid color-mix(in srgb, var(--text) 30%, var(--bg)); border-radius: calc(10 * var(--u)); background: var(--surface); font-size: calc(18 * var(--u)); color: var(--text); }
.flow-legend .item { display: inline-flex; align-items: center; gap: calc(7 * var(--u)); }
.flow-legend .swatch { width: calc(18 * var(--u)); height: calc(18 * var(--u)); border-radius: calc(3 * var(--u)); border: calc(1.5 * var(--u)) solid var(--c); background: var(--t); }
.flow-legend .user { --c: var(--user); --t: var(--user-tint); }
.flow-legend .auto { --c: var(--auto); --t: var(--auto-tint); }
.flow-legend .proven { --c: var(--accent); --t: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.flow-legend .trusted { --c: var(--trusted); --t: var(--trusted-tint); }

.flow-box { --c: var(--auto); --t: var(--auto-tint); display: flex; flex-direction: column; min-width: 0; border: calc(1.5 * var(--u)) solid var(--c); border-radius: calc(10 * var(--u)); background: var(--bg); overflow: hidden; }
.flow-box.user { --c: var(--user); --t: var(--user-tint); }
.flow-box.proven { --c: var(--accent); --t: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
/* "1." before the title, the subtitle under the title's text */
.article-figure .flow-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: calc(6 * var(--u)); margin: 0; padding: calc(10 * var(--u)) calc(12 * var(--u)) calc(9 * var(--u)); background: var(--t); border-bottom: calc(1 * var(--u)) solid var(--c); line-height: 1.25; }
.flow-head b { font-size: calc(18 * var(--u)); font-weight: 600; white-space: nowrap; }
.flow-head > span:last-child { grid-column: 2; margin-top: calc(3 * var(--u)); font-size: calc(15 * var(--u)); color: var(--muted); white-space: nowrap; }
.flow-num { font-size: calc(18 * var(--u)); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.article-figure .flow-code { margin: 0; padding: calc(11 * var(--u)) calc(12 * var(--u)); background: none; border: 0; border-radius: 0; font-family: var(--mono); font-size: calc(16 * var(--u)); line-height: 1.6; white-space: pre; overflow: hidden; color: var(--text); }
.flow-code sub { font-size: 0.75em; line-height: 0; }
/* a long line that may break before its last term: the break hangs two spaces in, under the line */
.flow-code .flow-hang { display: block; padding-left: 3ch; text-indent: -2ch; white-space: pre-wrap; }
.flow-code .k { color: var(--code-keyword); }
.flow-code .f { color: var(--code-name); }
.flow-code .n { color: var(--code-number); }
.flow-code .c { color: var(--code-comment); }
.flow-body { padding: calc(8 * var(--u)) calc(12 * var(--u)) calc(11 * var(--u)); }
.article-figure .flow-checks { margin: calc(4 * var(--u)) 0 0; font-size: calc(16 * var(--u)); line-height: 1.45; }
.flow-checks span { display: block; }
.flow-checks span::first-letter { color: var(--accent); }
/* the proof as wide as every other box, centered under the T */
.flow-box.proof { justify-self: center; width: calc((100% - var(--gap)) / 2); }
/* what the PTX box rests on: the semantics, trusted, along its foot */
.article-figure .flow-trusted { display: flex; flex-direction: column; margin: auto 0 0; padding: calc(8 * var(--u)) calc(12 * var(--u)); background: var(--trusted-tint); border-top: calc(1.5 * var(--u)) solid var(--trusted); line-height: 1.3; }
.flow-trusted b { font-size: calc(16 * var(--u)); font-weight: 600; }
.flow-trusted span { font-size: calc(15 * var(--u)); color: var(--muted); }
.article-figure .flow-result + .flow-trusted { margin-top: 0; }
.article-figure .flow-result { margin: auto 0 0; padding: calc(9 * var(--u)) calc(12 * var(--u)); background: var(--t); border-top: calc(1.5 * var(--u)) solid var(--accent); color: var(--accent); font-size: calc(16 * var(--u)); font-weight: 600; text-align: center; }

.flow-graph { display: block; width: 100%; max-width: calc(260 * var(--u)); height: auto; margin: 0 auto; }
.flow-graph .lane { font: 13px var(--mono); fill: var(--muted); text-anchor: middle; }
.flow-graph .node { fill: var(--surface); stroke: var(--rule); stroke-width: 1; }
.flow-graph .node.on { stroke: var(--accent); stroke-width: 1.3; }
.flow-graph .node-text { font: 14.5px var(--mono); fill: var(--text); text-anchor: middle; }
.flow-graph .edge { fill: none; stroke: var(--muted); stroke-width: 1.3; }
.flow-graph .edge.on { stroke: var(--accent); stroke-width: 1.7; }
.flow-graph .tip { fill: var(--muted); }
.flow-graph .tip-on { fill: var(--accent); }

.flow-arrow { display: flex; flex-direction: column; justify-content: center; min-width: 0; color: var(--muted); }
.flow-arrow-text { font-size: calc(14 * var(--u)); line-height: 1.25; text-align: center; }
.flow-arrow-line { position: relative; flex: none; height: 0; margin: calc(5 * var(--u)) calc(6 * var(--u)); border-top: calc(1.5 * var(--u)) solid var(--muted); }
/* a horizontal arrow's line at the row's middle, its label just above it, so every arrow is level */
.flow-arrow.right { position: relative; }
.flow-arrow.right .flow-arrow-line { position: absolute; top: 50%; left: calc(6 * var(--u)); right: calc(8 * var(--u)); margin: 0; }
.flow-arrow.right .flow-arrow-text { position: absolute; left: 0; right: 0; bottom: calc(50% + calc(7 * var(--u))); }
.flow-arrow.right .flow-arrow-line::after { content: ""; position: absolute; top: calc(-5.25 * var(--u)); right: calc(-2 * var(--u)); border-left: calc(8 * var(--u)) solid var(--muted); border-top: calc(4.5 * var(--u)) solid transparent; border-bottom: calc(4.5 * var(--u)) solid transparent; }
.flow-arrow.down { flex-direction: row; justify-content: center; align-items: stretch; gap: calc(8 * var(--u)); }
.flow-arrow.down .flow-arrow-line { width: 0; height: auto; margin: calc(4 * var(--u)) 0 calc(6 * var(--u)); border-top: 0; border-left: calc(1.5 * var(--u)) solid var(--muted); }
.flow-arrow.down .flow-arrow-line::after { content: ""; position: absolute; bottom: calc(-6 * var(--u)); left: calc(-5.25 * var(--u)); border-top: calc(8 * var(--u)) solid var(--muted); border-left: calc(4.5 * var(--u)) solid transparent; border-right: calc(4.5 * var(--u)) solid transparent; }
.flow-arrow.down .flow-arrow-text { align-self: center; }
.flow-arrow.stack-only { display: none; }

/* the T: from the middles of the memory's box and the lowered spec's, down into the proof */
.flow-tee { position: relative; height: calc(54 * var(--u)); }
.flow-tee-arms { position: absolute; top: 0; height: 50%; left: calc((100% - var(--gap)) / 4); right: calc((100% - var(--gap)) / 4); border: calc(1.5 * var(--u)) solid var(--muted); border-top: 0; border-radius: 0 0 calc(8 * var(--u)) calc(8 * var(--u)); }
.flow-tee-stem { position: absolute; top: 50%; bottom: calc(6 * var(--u)); left: 50%; border-left: calc(1.5 * var(--u)) solid var(--muted); }
.flow-tee-stem::after { content: ""; position: absolute; bottom: calc(-6 * var(--u)); left: calc(-5.25 * var(--u)); border-top: calc(8 * var(--u)) solid var(--muted); border-left: calc(4.5 * var(--u)) solid transparent; border-right: calc(4.5 * var(--u)) solid transparent; }

/* wide: centered on the body, out to the chapter list and the right column (56px either side), and never narrower
   than keeps four boxes in a row; the chapter list fades while it is beside the figure */
@media (min-width: 1081px) { .article-figure.wide { width: max(100% + 112px, 920px); margin-left: calc(50% - max(50% + 56px, 460px)); margin-right: calc(50% - max(50% + 56px, 460px)); } }
.article-figure.wide { container-type: inline-size; }
@container (max-width: 900px) {
  /* two columns: the kernel's line down the left, the spec's down the right, meeting below in the proof; sizes
     in pixels, set per width below */
  .flow-controls { --u: 1px; }
  .flow-head > span:last-child, .flow-head b { white-space: normal; }
  .flow { --u: 1px; --gap: 14px; grid-template-columns: minmax(0, 1fr) var(--gap) minmax(0, 1fr); grid-template-rows: none;
    grid-template-areas:
      "legend legend legend"
      "src . spec"
      "compile . lower"
      "ptx . lower"
      "a1 . lower"
      "hb . lower"
      "a2 . lower"
      "mem . lowered"
      "tee tee tee"
      "proof proof proof"; }
  .article-figure .flow-legend { justify-self: stretch; margin-bottom: 66px; font-size: 15px; gap: 6px 14px; padding: 9px 12px; }
  /* the code as large as a column's widest line (24 characters) allows */
  .article-figure .flow-code { font-size: clamp(10px, calc(3.55cqi - 1.7px), 14px); padding: 9px 9px; }
  .flow-head > span:last-child, .flow-head b, .flow-trusted span { text-wrap: balance; }
  .flow-nobreak { white-space: nowrap; }
  .flow-graph { max-width: 230px; }
  .article-figure .flow-head { padding: 8px 9px 7px; column-gap: 5px; }
  .flow-num, .flow-head b { font-size: 16px; }
  .flow-head > span:last-child { font-size: 13.5px; }
  .flow-trusted b { font-size: 15px; } .flow-trusted span { font-size: 13.5px; }
  .article-figure .flow-result { font-size: 15px; }
  /* every arrow points down the middle of its column, its name beside it */
  .flow .flow-arrow { flex-direction: row; justify-content: flex-start; align-items: stretch; gap: 7px; height: 46px; padding-left: calc(50% - 0.75px); }
  .flow .flow-arrow.lower-arrow { height: auto; }
  .flow .flow-arrow .flow-arrow-line { position: relative; top: auto; left: auto; right: auto; width: 0; height: auto; margin: 4px 0 6px; border-top: 0; border-left: 1.5px solid var(--muted); }
  .flow .flow-arrow .flow-arrow-line::after { content: ""; position: absolute; left: -5.25px; right: auto; top: auto; bottom: -6px; border: 0; border-top: 8px solid var(--muted); border-left: 4.5px solid transparent; border-right: 4.5px solid transparent; }
  .flow .flow-arrow .flow-arrow-text { position: static; order: 2; align-self: center; text-align: left; font-size: 13px; }
}
@container (max-width: 480px) {
  .article-figure .flow-legend { font-size: 14px; }
  .article-figure .flow-code { padding: 8px 7px; }
  .article-figure .flow-head { padding: 7px 7px 6px; }
  .flow-num, .flow-head b { font-size: 14px; }
  .flow-head > span:last-child { font-size: 12px; }
  .flow-trusted b { font-size: 13px; } .flow-trusted span { font-size: 12px; }
  .article-figure .flow-trusted { padding: 6px 7px; }
  .article-figure .flow-result { font-size: 13.5px; padding: 7px; }
  .article-figure .flow-checks { font-size: 13px; }
  .flow-graph .node-text { font-size: 15px; } .flow-graph .lane { font-size: 14px; }
  .flow .flow-arrow .flow-arrow-text { font-size: 11.5px; }
}
/* no pause button under the legend when the figure does not play */
@media (prefers-reduced-motion: reduce) { @container (max-width: 900px) { .article-figure .flow-legend { margin-bottom: 18px; } } }

/* the pipeline, played (figures.js): a part shows when its turn comes, an arrow draws itself; the graph's
   checks light their nodes and edges; the proof is checked by a wave of light down its lines, then turns
   green. Without the script, or with reduced motion, the figure stays as drawn. */
.flow { position: relative; }
.flow [data-part], .flow [data-check] { transition: opacity 300ms ease, transform 300ms ease; }
.flow.playing [data-part]:not(.in), .flow.playing [data-check]:not(.in) { opacity: 0; transform: translateY(calc(8 * var(--u))); }
/* an arrow grows from its start to its tip: its origin holds while it shows, not only while hidden */
.flow-arrow-line { transition: transform 350ms ease; }
.flow-arrow.right .flow-arrow-line { transform-origin: left center; }
.flow-arrow.down .flow-arrow-line { transform-origin: top center; }
.flow.playing .flow-arrow.right[data-part]:not(.in) .flow-arrow-line { transform: scaleX(0); }
.flow.playing .flow-arrow.down[data-part]:not(.in) .flow-arrow-line { transform: scaleY(0); }
.flow-graph .node, .flow-graph .edge { transition: stroke 150ms ease, stroke-width 150ms ease; }
.flow.playing .flow-graph .node.on:not(.lit) { stroke: var(--rule); stroke-width: 1; }
.flow.playing .flow-graph .edge.on:not(.lit) { stroke: var(--muted); stroke-width: 1.3; marker-end: url(#flow-tip); }
.flow-graph .node.pair { stroke: var(--auto); stroke-width: 2.4; }
.flow-graph .node.scan, .flow-graph .edge.scan { stroke: var(--text); stroke-width: 2.4; }
.flow-code .ln { display: block; border-radius: calc(3 * var(--u)); transition: background-color 100ms ease; }
.flow-code .ln.lit { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.flow-code .untyped, .flow.playing .flow-code .hole .untyped { color: transparent; }   /* not yet typed: in place, so the box keeps its size */
/* boxes 5 to 7 are templates: while playing, a blank shows as a light green slot, and what fills it in green */
.flow.playing .flow-code .hole { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: calc(3 * var(--u)); }
.flow.playing .flow-code .hole, .flow.playing .flow-code .hole :not(.untyped) { color: var(--accent); }
.flow.playing .flow-code .hole.note, .flow.playing .flow-code .hole.note :not(.untyped) { background: none; color: inherit; }   /* a comment typed in its own color */
.flow-graph.source .node.on, .flow-graph.source .edge.on { stroke: var(--accent); stroke-width: 2.4; }   /* the graph box 5 is composed from */
.flow-ghost { position: absolute; z-index: 5; pointer-events: none; white-space: pre; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border-radius: calc(3 * var(--u)); }
.flow-ghost * { color: inherit; }   /* a blank's value on its way from box 2 */
/* the graph built as symbolic execution runs: an event, its edges and its warp's name hidden until their line runs */
.flow-graph [data-b] { transition: opacity 220ms ease; }
.flow.playing .flow-graph [data-b]:not(.in) { opacity: 0; }   /* not yet typed: in place, so the box keeps its size */
.flow-box, .article-figure .flow-head { transition: border-color 600ms ease, background-color 600ms ease; }
.article-figure .flow-result { max-height: 4em; overflow: hidden; transition: max-height 500ms ease, padding 500ms ease, opacity 500ms ease, border-width 500ms ease; }
.flow.playing .proof:not(.done) { --c: var(--auto); --t: var(--auto-tint); }
.flow.playing .proof:not(.done) .flow-result { max-height: 0; padding-top: 0; padding-bottom: 0; border-top-width: 0; opacity: 0; }
/* pause and replay, beside the figure (an image to assistive technology), under the legend: placed by the script */
.article-figure.wide { position: relative; }
/* the reader's controls (figures.js places them under the legend): one pill, back | play or pause | forward */
.flow-controls { position: absolute; display: inline-flex; align-items: stretch; border: calc(1.5 * var(--u)) solid color-mix(in srgb, var(--text) 30%, var(--bg));
                 border-radius: 999px; background: var(--bg); overflow: hidden; }
.flow-controls button { display: flex; align-items: center; margin: 0; padding: calc(8 * var(--u)) calc(14 * var(--u)); border: 0; background: none;
                        color: var(--text); font: calc(17 * var(--u)) var(--serif); cursor: pointer; }
.flow-controls button + button { border-left: calc(1 * var(--u)) solid color-mix(in srgb, var(--text) 18%, var(--bg)); }
.flow-controls button:hover { background: var(--surface); }
.flow-controls svg { width: calc(14 * var(--u)); height: calc(14 * var(--u)); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* a box's number plays the step that makes the box; the step playing has its number in green */
.flow-head.steppable { cursor: pointer; }
.flow-head.steppable:hover .flow-num, .flow-num.current { color: var(--accent); }
.flow.jump, .flow.jump * { transition: none !important; }   /* a jump to a step: its end state at once */
.flow:focus-visible { outline: calc(2 * var(--u)) solid var(--accent); outline-offset: calc(6 * var(--u)); border-radius: calc(8 * var(--u)); }
@container (max-width: 900px) {
  .flow .flow-arrow .flow-arrow-line { transform-origin: top center; }
  .flow.playing .flow-arrow[data-part]:not(.in) .flow-arrow-line { transform: scaleY(0); }
}

/* the tolerance split as a triangle: spec_math, kernel_Real and kernel_Float its corners, the algebraic error and
   the round-off error two sides, the kernel's deviation from spec_math the third; a narrow drawing for phones */
.tri { --round: #b7832c; margin: 4px 0 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tri { --round: #d8a54e; } }
:root[data-theme="dark"] .tri { --round: #d8a54e; }
.tri svg { display: block; width: 100%; height: auto; overflow: visible; }
.tri svg.compact { display: none; }
@media (max-width: 640px) { .tri svg.wide { display: none; } .tri svg.compact { display: block; } }
.tri line { stroke-width: 3; stroke-linecap: round; }
.tri .side-alg { stroke: var(--accent); }
.tri .side-round { stroke: var(--round); }
.tri .side-goal { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 7 6; }
.tri .pt { fill: var(--text); }
.tri text { font-family: var(--serif); font-size: 17px; fill: var(--text); }
.tri svg.compact text { font-size: 15px; }
.tri text.code { font-family: var(--mono); font-size: 15px; }
.tri svg.compact text.code { font-size: 13px; }
.tri .sub { font-size: 0.7em; }
.tri text.note { font-size: 14px; } .tri svg.compact text.note { font-size: 12.5px; }
.tri text.alg { fill: var(--accent); } .tri text.round { fill: var(--round); } .tri text.goal { fill: var(--muted); }


/* the loop-invariant figure (content/figures/loop-invariant.html): on the left one row of scores S and a cursor at kB,
   the keys seen behind it, the invariant at k hanging from it; on the right the kernel's loop as pseudocode, its
   running line lit. figures.js plays both together */
.loopinv { --code-keyword: #d73a49; --code-comment: #6a737d;
           display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 28px; align-items: start;
           padding: 20px 22px 18px; border: 1px solid var(--rule); border-radius: 10px; font-family: var(--serif); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .loopinv { --code-keyword: #f97583; --code-comment: #8b949e; } }
:root[data-theme="dark"] .loopinv { --code-keyword: #f97583; --code-comment: #8b949e; }
.loopinv p { margin: 0; }
.loopinv .li-label { margin-bottom: 12px; font-size: 17px; font-weight: 500; }
.loopinv .li-left { position: relative; min-width: 0; }
.loopinv .li-row { display: block; width: 100%; height: auto; overflow: visible; }
.loopinv .li-name { font: italic 20px var(--serif); fill: var(--text); }
.loopinv .li-tile { fill: color-mix(in srgb, var(--surface) 94%, var(--ink)); transition: fill 250ms ease; }   /* a key not yet seen: the hero's gray */
.loopinv .li-tile.seen { fill: color-mix(in srgb, var(--accent) 50%, var(--bg)); }
.loopinv .li-tile.now { fill: var(--accent); }
.loopinv .li-masked { fill: url(#li-hatch); stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 2; }
.loopinv .li-hatch { stroke: var(--muted); stroke-width: 1.2; }
.loopinv .li-cursor { transition: transform 500ms ease; }
.loopinv .li-cursor line { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.loopinv .li-cursor text { font: italic 15px var(--serif); fill: var(--accent); text-anchor: middle; }
/* the invariant at k, hanging from the cursor: its notch under the cursor, the box kept within the column */
.loopinv .li-inv { position: relative; width: min(100%, 350px); margin-top: 4px; padding: 10px 14px; border: 1.5px solid var(--accent); border-radius: 8px;
                   background: color-mix(in srgb, var(--accent) 6%, var(--bg)); transition: transform 500ms ease; }
.loopinv .li-inv::before { content: ""; position: absolute; top: -7.5px; left: calc(var(--notch, 24px) - 6px); width: 12px; height: 12px; transform: rotate(45deg);
                           border-left: 1.5px solid var(--accent); border-top: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }
.loopinv .li-inv p { font-size: 15px; line-height: 1.65; }
.loopinv .li-inv .li-inv-head { margin-bottom: 2px; color: var(--accent); font-size: 15px; }
.loopinv .li-inv .li-inv-note { color: var(--muted); font-size: 14px; }
/* under the invariant, the step of the iteration from k: its lines show as the loop's lines run */
.loopinv .li-step { margin-top: 6px; padding-top: 6px; border-top: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--bg)); }
.loopinv .li-step p { transition: opacity 250ms ease; }
.loopinv.playing .li-step [data-show]:not(.in) { opacity: 0; }
.loopinv .li-why { margin-left: 8px; color: var(--muted); font-size: 13.5px; }
.loopinv p.li-why { margin-left: 0; }
.loopinv .li-code { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--surface); font: 14px/1.75 var(--mono); white-space: pre; overflow-x: auto; }
.loopinv .li-ln { display: block; margin: 0 -6px; padding: 0 6px; border-radius: 3px; transition: background-color 150ms ease; }
.loopinv .li-ln.lit { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.loopinv .li-code .k { color: var(--code-keyword); }
.loopinv .li-code .c { color: var(--code-comment); }
.loopinv .li-tag { margin-left: 12px; padding: 1px 8px; border-radius: 999px; font: 13px var(--serif); color: var(--accent);
                   background: color-mix(in srgb, var(--accent) 14%, var(--bg)); opacity: 0; transition: opacity 250ms ease; }
.loopinv .li-tag.on { opacity: 1; }
.loopinv .li-replay { grid-column: 1 / -1; justify-self: center; padding: 6px 18px; border: 1.5px solid color-mix(in srgb, var(--text) 30%, var(--bg)); border-radius: 999px;
                      background: var(--bg); color: var(--text); font: 16px var(--serif); cursor: pointer; }
@media (max-width: 640px) {
  .loopinv { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .loopinv .li-code { font-size: 12.5px; }
}

/* the group-runs figure (content/figures/group-runs.html), horizontal: a CTA's threads folded by role into two
   symbolic runs, each a timeline left to right; an arrive pushes its run's writes, and the wait it completes, reached,
   unfolds to show what it pulls. figures.js plays it and draws the arrows */
.groupruns { display: grid; gap: 12px; padding: 18px 22px 16px; border: 1px solid var(--rule); border-radius: 10px; font-family: var(--serif); }
.groupruns p { margin: 0; }
.groupruns .gr-time { position: relative; display: grid; grid-template-columns: 158px repeat(7, minmax(0, 1fr)); grid-template-rows: 44px auto 50px auto 44px;
                      column-gap: 4px; align-items: center; }
.groupruns .gr-who { display: flex; align-items: center; gap: 10px; }
.groupruns .gr-who b { display: block; font-size: 15px; font-weight: 600; }
.groupruns .gr-who span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.groupruns .gr-cluster { flex: none; width: 32px; height: auto; }
.groupruns .gr-cluster circle { fill: color-mix(in srgb, var(--surface) 70%, var(--ink)); transition: opacity 500ms ease; }
.groupruns .gr-cluster.p circle { fill: var(--accent); }
.groupruns.folded .gr-cluster circle { opacity: 0.3; }
.groupruns .gr-line { align-self: center; height: 0; border-top: 1.5px solid color-mix(in srgb, var(--surface) 70%, var(--ink)); }
.groupruns .gr-line.p { border-top-color: color-mix(in srgb, var(--accent) 55%, var(--bg)); }
.groupruns .gr-ev { position: relative; z-index: 1; justify-self: center; }
.groupruns .gr-ev code { display: flex; flex-direction: column; align-items: center; padding: 3px 8px; border: 1.5px solid color-mix(in srgb, var(--surface) 70%, var(--ink));
                         border-radius: 6px; background: var(--bg); font: 12.5px/1.35 var(--mono); white-space: nowrap; }
.groupruns .gr-ev.p code { border-color: var(--accent); }
.groupruns .gr-ev code b { font-weight: 600; }
/* a wait's pull, unfolding from it away from the other lane; the read's value under it */
.groupruns .gr-open { position: relative; z-index: 1; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 13px; line-height: 1.3; white-space: nowrap; text-align: center;
                      transition: transform 350ms ease, opacity 300ms ease; }
.groupruns .gr-open.c { transform-origin: center top; }
.groupruns .gr-open.p { transform-origin: center bottom; align-self: end; }
.groupruns .gr-open.c { align-self: start; }
.groupruns .gr-open.note { transform-origin: center top; align-self: start; padding-top: 2px; }
.groupruns .gr-open span { color: var(--muted); font-size: 12.5px; }
.groupruns .gr-open.pull span { color: var(--accent); }
/* a value: plain in a write or a read, green where a wait pulls it */
.groupruns .gr-open code { padding: 1px 6px; border-radius: 4px; background: var(--surface); color: var(--text); font: 12.5px var(--mono); transition: background-color 250ms ease; }
.groupruns .gr-open.pull code { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); color: var(--accent); }
.groupruns .gr-open code.flash { background: color-mix(in srgb, var(--accent) 35%, var(--bg)); }
.groupruns .gr-open em { color: var(--muted); font-size: 12.5px; font-style: normal; }
.groupruns .gr-arrows { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.groupruns .gr-arrows marker path { fill: var(--accent); }
.groupruns .gr-sync { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.groupruns .gr-sync-label { font: 13px var(--serif); fill: var(--accent); }
.groupruns .gr-end { font-size: 15px; color: var(--muted); }
.groupruns [data-step] { transition: opacity 300ms ease; }
.groupruns.playing [data-step]:not(.in) { opacity: 0; }
.groupruns.playing .gr-open:not(.in) { transform: scaleY(0); }
.groupruns .gr-replay { justify-self: center; padding: 5px 16px; border: 1.5px solid color-mix(in srgb, var(--text) 30%, var(--bg)); border-radius: 999px;
                        background: var(--bg); color: var(--text); font: 15px var(--serif); cursor: pointer; }
/* phones: the timelines keep their width and scroll sideways */
@media (max-width: 640px) {
  .groupruns { padding: 14px; overflow-x: auto; }
  .groupruns .gr-time { min-width: 700px; }
}

/* hero:begin */
/* hero: the attention computation, TensorLean, and the four generations on their GPUs (content/figures/hero.html) */
/* each column's anchor sits at its vertical middle, so align-items: center puts them on one line */
.hx { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) 262px minmax(0, 1fr); align-items: center;
      gap: 0 20px; padding: 8px 0; font-family: var(--serif); color: var(--text);
      --m: 16px; --s: 12px;   /* the figure's two type sizes (the logo and the = are drawings) */
      font-variant-numeric: lining-nums; }
.hx > * { min-width: 0; }

/* left: the drawing's middle is the highlighted row; the formula hangs below it */
.hx .hx-tensor { position: relative; }   /* the drawing fills its column: its edges are the figure's and 20px from the middle */
.hx .hx-attn { display: block; }
.hx .hx-attn .ink { fill: var(--ink); } .hx-attn .accent { fill: var(--accent); }
.hx .hx-attn .mid { fill: color-mix(in srgb, var(--surface) 94%, var(--text)); }   /* the cards' gray, a shade deeper: small tiles look lighter than large cards */
.hx .hx-attn .lab { font-family: var(--serif); font-style: italic; font-size: 12.49px; fill: var(--text); }
.hx .hx-attn .lab .t { font-style: normal; font-size: 0.6em; }
.hx .hx-attn .soft { font-family: var(--serif); font-size: 12.49px; fill: var(--accent); }
.hx .hx-attn .arrow { stroke: var(--accent); stroke-width: 1; } .hx-attn .head { fill: var(--accent); }
.hx .hx-formula { position: absolute; left: 0; right: 0; top: calc(50% + 82px); height: 34px; box-sizing: border-box; margin: 0;
              display: flex; align-items: center; justify-content: center;
              font-size: var(--m); white-space: nowrap; }   /* bottom 116px under the middle, as the last card's */
.hx .hx-formula sup { font-size: 0.6em; }

/* middle: the equals sign is the column; TensorLean above it, the proof below it */
.hx .hx-bridge { position: relative; }
.hx .hx-eq { display: flex; align-items: center; gap: 12px; }
.hx .hx-eq .line { flex: 1; border-top: 1.5px solid var(--accent); }
.hx .hx-eq .sign { display: flex; flex-direction: column; gap: 7px; padding: 12px 0; }   /* drawn: two bars, centred on the line */
.hx .hx-eq .sign span { width: 30px; height: 4px; border-radius: 2px; background: var(--accent); }
.hx .hx-brand { position: absolute; bottom: calc(100% + 10px); left: 0; right: 0; margin: 0;
            display: flex; align-items: center; justify-content: center; gap: 10px; }
.hx .hx-logo { width: 58px; height: 58px; flex: none; }
.hx .hx-logo .ink { fill: var(--ink); } .hx-logo .accent { fill: var(--accent); }
.hx .hx-word { font-size: 34px;   /* the logo, not text: outside the three sizes, like the = */ font-weight: 500; font-variant-caps: small-caps; color: var(--text); }
.hx .hx-word .lean { color: var(--accent); }
.hx .hx-proof { position: absolute; top: calc(50% + 32px); left: 0; right: 0; height: 84px; box-sizing: border-box; margin: 0;
            display: flex; flex-direction: column; justify-content: center; padding: 0 12px;   /* bottom 116px under the middle */
            font-family: var(--mono); font-size: var(--s); line-height: 1.6; color: var(--text);
            background: color-mix(in srgb, var(--accent) 10%, var(--bg)); border: 0; border-radius: 6px; white-space: pre; overflow: hidden; }   /* the proof: TensorLean's green */
.hx .hx-proof code { font: inherit; background: none; padding: 0; }   /* the whole proof one flex item */
.hx .hx-proof .kw { color: var(--accent); }

/* right: each generation, a wire, and its GPU; the rows are equal, so the stack's middle falls between the 2nd and 3rd */
.hx .hx-machine { position: relative; }
.hx .hx-rows { display: grid; grid-template-columns: minmax(0, 1fr) 12px auto; align-items: center; row-gap: 8px; }
.hx .hx-card { min-width: 0; height: 52px; box-sizing: border-box; padding: 0 12px; background: var(--surface); border-radius: 6px;
           display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.hx .hx-head { margin: 0; line-height: 1.2; font-size: var(--m); font-weight: 600; white-space: nowrap; }
.hx .hx-head { display: flex; justify-content: space-between; gap: 8px; }
.hx .hx-head span { font-weight: 400; color: var(--muted); }   /* the year, at the line's end */
.hx .hx-ptx { margin: 0; line-height: 1.2; font-family: var(--mono); font-size: var(--s); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hx .hx-wire { border-top: 1px solid var(--text); }
.hx .hx-gpu { width: 54px; height: 52px; box-sizing: border-box; background: var(--surface); border-radius: 6px;
          display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.hx .hx-gpu b { font-size: var(--m); font-weight: 600; }
.hx .hx-more { position: absolute; top: calc(100% + 2px); left: 0; right: 0; margin: 0; padding-right: 102px;
           text-align: center; font-size: var(--m); line-height: 1; color: var(--muted); }
.hx .hx-more { padding-right: 66px; }
/* drawn at 840px, zoomed to its figure's width (figures.js sets --hero-k), so it is always exactly as wide as the text */
figure > .hx { width: 840px; zoom: var(--hero-k, 1); }
/* hero:end */

/* bugs by category (content/figures/bug-categories.html): a series a library, in a fixed order; six earthy hues
   (2026-11-20, the user's pick): teal, ochre, slate, brick, olive, plum, FlashAttention's teal near the page's accent;
   each theme its own steps (the dark one a darker ochre and a lighter plum), validated on its background (the dataviz
   validator: lightness band, chroma, color-blind and normal-vision separation of neighbours, contrast); no counts
   inside the segments, the hover card gives them */
:root { --bug-1: #00968f; --bug-2: #d39b2a; --bug-3: #4a6eaf; --bug-4: #b4492f; --bug-5: #8a9a2b; --bug-6: #8e4d7f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bug-1: #00968f; --bug-2: #bd8a1c; --bug-3: #4a6eaf; --bug-4: #b4492f; --bug-5: #8a9a2b; --bug-6: #a0598f; }
}
:root[data-theme="dark"] { --bug-1: #00968f; --bug-2: #bd8a1c; --bug-3: #4a6eaf; --bug-4: #b4492f; --bug-5: #8a9a2b; --bug-6: #a0598f; }
.bug-cats .bug-s1 { fill: var(--bug-1); } .bug-cats .bug-swatch-1 { background: var(--bug-1); }
.bug-cats .bug-s2 { fill: var(--bug-2); } .bug-cats .bug-swatch-2 { background: var(--bug-2); }
.bug-cats .bug-s3 { fill: var(--bug-3); } .bug-cats .bug-swatch-3 { background: var(--bug-3); }
.bug-cats .bug-s4 { fill: var(--bug-4); } .bug-cats .bug-swatch-4 { background: var(--bug-4); }
.bug-cats .bug-s5 { fill: var(--bug-5); } .bug-cats .bug-swatch-5 { background: var(--bug-5); }
.bug-cats .bug-s6 { fill: var(--bug-6); } .bug-cats .bug-swatch-6 { background: var(--bug-6); }
.bug-cats .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; }
.bug-cats svg .xlabel { font-size: 14px; }
/* verification time by kernel: the four properties in teal, ochre, brick, slate (the bugs' first four colors with
   the last two swapped, validated as neighbours in this order in both themes) */
.verif-time .vt-s1 { fill: var(--bug-1); } .verif-time .vt-swatch-1 { background: var(--bug-1); }
.verif-time .vt-s2 { fill: var(--bug-2); } .verif-time .vt-swatch-2 { background: var(--bug-2); }
.verif-time .vt-s3 { fill: var(--bug-4); } .verif-time .vt-swatch-3 { background: var(--bug-4); }
.verif-time .vt-s4 { fill: var(--bug-3); } .verif-time .vt-swatch-4 { background: var(--bug-3); }
/* a row (its name, its bar) opens the kernel's card (figures.js), in the bugs' card's look: one line, the kernel's
   source name and its file */
.verif-time { position: relative; }
.verif-time .vt-row { cursor: pointer; }
.verif-time .vt-row:hover path { opacity: 0.85; }
.vt-card { width: max-content; max-width: calc(100% - 16px); padding: 8px 12px; }
.vt-card code { font-family: var(--mono); }
/* the bugs' card: a segment's or a category's bugs, each its links, its library where the card spans several, its
   description; inside the figure, under what opened it, scrolling when long */
.bug-cats { position: relative; }
.bug-cats svg [data-cat] { cursor: pointer; }
.bug-card { position: absolute; z-index: 20; width: min(440px, calc(100% - 16px)); max-height: 340px; overflow-y: auto;
  padding: 10px 14px 4px; background: var(--bg); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12); font-size: 14px; line-height: 1.45; color: var(--text); text-align: left; }
.bug-card[hidden] { display: none; }
.bug-card-head { margin: 0 0 6px; font-weight: 500; }
.bug-card-head span { margin-left: 8px; color: var(--muted); font-weight: 400; font-variant-numeric: lining-nums; }
.bug-card ul { list-style: none; margin: 0; padding: 0; }
.bug-card li { padding: 7px 0; border-top: 1px solid var(--rule); }
.bug-card-links a { font-variant-numeric: lining-nums; }
.bug-card-lib { margin-left: 8px; color: var(--muted); font-size: 13px; }
.bug-card-desc { display: block; margin-top: 2px; color: var(--muted); }
.bug-card code { font-size: 0.88em; }

/* the scheduler's tasks (content/figures/cta-tasks.html, ~/TensorLean/.preview/cta_tasks_figure.py), read without
   the text: left, each query's KV blocks four to a task, a task in the color of the CTA that runs it (the site's
   categorical order); right, each CTA's tasks in its loop's order, and CTA 2's loop at one task with the assertions'
   values. The CTA the panel follows in full color, the others faint */
.ctatasks { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px 30px; align-items: start;
            padding: 18px 22px 18px; border: 1px solid var(--rule); border-radius: 10px; font-family: var(--serif); }
.ctatasks p { margin: 0; }
.ctatasks code { padding: 0; background: none; font-size: 13px; white-space: nowrap; }
.ctatasks .ct-sub { margin-bottom: 10px; font-size: 15.5px; font-weight: 500; }
.ctatasks .ct-sub code { font-size: 13px; font-weight: 400; }
.ctatasks .ct-grid { display: block; width: 100%; height: auto; overflow: visible; }
.ctatasks .ct-grid.compact { display: none; }
.ctatasks .ct-c0 { --ct: var(--bug-1); } .ctatasks .ct-c1 { --ct: var(--bug-2); }
.ctatasks .ct-c2 { --ct: var(--bug-3); } .ctatasks .ct-c3 { --ct: var(--bug-4); }
.ctatasks .ct-outline { fill: var(--ct); }
.ctatasks .ct-blk { fill: color-mix(in srgb, var(--bg) 30%, transparent); }
.ctatasks .ct-task-tile { cursor: pointer; transition: opacity 200ms ease; }
.ctatasks .ct-task-tile.ct-dim { opacity: 0.3; }
.ctatasks .ct-cursor { transition: x 250ms ease, y 250ms ease, width 250ms ease; }
.ctatasks .ct-axis { font: 13px var(--serif); fill: var(--muted); }
.ctatasks .ct-axis.ct-var { font: 13px var(--mono); fill: var(--text); }
.ctatasks .ct-row { font: 14px var(--mono); fill: var(--text); }
.ctatasks .ct-count { font: 14px var(--serif); fill: var(--muted); }
.ctatasks .ct-cursor { fill: none; stroke: var(--text); stroke-width: 2.5; }
/* the key under the tasks: one block, one task */
.ctatasks .ct-key { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 14.5px; color: var(--muted); }
.ctatasks .ct-key > span { display: inline-flex; align-items: center; gap: 7px; }
.ctatasks .ct-key-blk, .ctatasks .ct-key-task i { display: inline-block; width: 11px; height: 13px; border-radius: 2px;
                                                  border: 1.2px solid var(--muted); background: var(--bg); }
.ctatasks .ct-key-task { display: inline-flex; gap: 3px; padding: 2px 3px; border-radius: 4px; border: 1.2px solid var(--muted); }
/* each CTA's lane: its tasks in order, the first marked meta[k] */
.ctatasks .ct-lane { display: flex; align-items: center; gap: 6px; margin-top: 22px; }
.ctatasks .ct-lane.ct-dim { opacity: 0.4; }
.ctatasks .ct-lane-name { flex: 0 0 52px; font-size: 15px; }
.ctatasks .ct-task { position: relative; padding: 2px 7px; border-radius: 5px; font: 13px var(--mono); color: var(--text); cursor: pointer;
                     background: color-mix(in srgb, var(--ct) 22%, var(--bg)); border: 1.5px solid var(--ct); }
.ctatasks .ct-lane { transition: opacity 200ms ease; }
.ctatasks .ct-task.ct-now { outline: 2.5px solid var(--text); outline-offset: 2px; }
.ctatasks .ct-task[data-meta]::before { content: attr(data-meta); position: absolute; left: 0; bottom: calc(100% + 2px);
                                        font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
/* the panel: the variables, one line; the invariants at the ringed task, each with its values */
.ctatasks .ct-panel { grid-column: 1 / -1; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); }
/* the variables, first: each name and what it is */
.ctatasks .ct-vars { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 24px; padding-bottom: 12px;
                     border-bottom: 1px solid var(--rule); font-size: 14.5px; color: var(--muted); }
.ctatasks .ct-vars > span > code { color: var(--text); }
.ctatasks .ct-inv-head { margin-bottom: 6px; font-size: 15px; font-weight: 500; }
/* the three invariants share one grid: their names, their claims and their values each a left-aligned column */
.ctatasks .ct-invs { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: baseline; gap: 5px 18px; font-size: 15px; }
.ctatasks .ct-inv { display: contents; }
.ctatasks .ct-inv > code { justify-self: start; }
.ctatasks .ct-inv-name { color: var(--muted); }
.ctatasks .ct-inst { display: inline-flex; align-items: baseline; gap: 8px; color: var(--muted); }
.ctatasks .ct-ok { color: var(--accent); font-weight: 600; }
@media (max-width: 640px) {
  .ctatasks { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .ctatasks .ct-grid.wide { display: none; }
  .ctatasks .ct-grid.compact { display: block; }
  .ctatasks .ct-invs { grid-template-columns: minmax(0, 1fr); row-gap: 3px; }
  .ctatasks .ct-invs code { white-space: normal; font-size: 12px; }
  .ctatasks .ct-inst { margin-bottom: 8px; }
}
