/* CodecMem "Overview" figure (cmv-). Uses the page's CSS variables, with the same values as fallbacks. */
.cmv {
  --cmv-green: rgb(118, 186, 0);
  --cmv-blue: rgb(74, 143, 227);
  --cmv-violet: rgb(167, 139, 250);
  --cmv-amber: rgb(240, 180, 41);
  --cmv-line: var(--line, rgba(255, 255, 255, 0.14));
  --cmv-line-strong: var(--line-strong, rgba(255, 255, 255, 0.3));
  margin: 0 0 30px;
}
.cmv-panel {
  background: var(--bg-subtle, #0b0b0b); border: 1px solid var(--cmv-line); border-radius: 6px;
  color: var(--ink, #f7f7f7); padding: 20px 20px 20px; position: relative;
}
.cmv-panel:focus { outline: none; }
.cmv-panel:focus-visible { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }

/* ---- the result in one sentence, computed from the data */
.cmv .cmv-headline { color: var(--ink-soft, #d6d6d6); font-size: 16px; line-height: 1.45; margin: 0 0 16px; }
.cmv-headline b {
  color: #fff; font-size: 24px; font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -.01em;
  line-height: 1;
}

/* ---- control bar */
.cmv-bar { align-items: center; display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; }
.cmv-play {
  align-items: center; appearance: none; background: transparent; border: 1px solid var(--cmv-line-strong);
  border-radius: 999px; color: #fff; cursor: pointer; display: inline-flex; flex: none; height: 34px;
  justify-content: center; padding: 0; transition: background-color .15s, border-color .15s, opacity .15s; width: 34px;
}
.cmv-play:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.62); }
.cmv-play:disabled { cursor: default; opacity: .35; }
.cmv.is-waiting .cmv-play { opacity: .55; }
.cmv-play:focus-visible, .cmv-seg button:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.6); outline-offset: 2px; }
.cmv-play svg { display: block; fill: currentColor; height: 13px; width: 13px; }
.cmv-play .cmv-i-pause, .cmv.is-playing .cmv-play .cmv-i-play { display: none; }
.cmv.is-playing .cmv-play .cmv-i-pause { display: inline; }
.cmv-clock { color: var(--ink-faint, #707070); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmv-clock b { color: var(--ink, #f7f7f7); font-weight: 700; }
.cmv-where { color: var(--ink-muted, #a7a7a7); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmv-seg {
  background: var(--bg-muted, #171717); border: 1px solid var(--cmv-line); border-radius: 4px; display: inline-flex;
  gap: 3px; margin-left: auto; padding: 3px;
}
.cmv-seg button {
  appearance: none; background: transparent; border: 0; border-radius: 3px; color: var(--ink-muted, #a7a7a7);
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; min-height: 30px; padding: 0 13px;
  transition: background-color .15s, color .15s; white-space: nowrap;
}
.cmv-seg button:hover { color: #fff; }
.cmv-seg button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* ---- layout: stage, steps, timeline and totals on the left; what the model reads on the right */
.cmv-main {
  display: grid; gap: 18px 32px;
  grid-template-areas: "stage ctx" "steps ctx" "tl ctx" "cum ctx";
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr;
}
.cmv-label {
  color: var(--ink-muted, #a7a7a7); display: block; font-size: 12.5px; font-weight: 800; letter-spacing: .12em;
  line-height: 1.3; text-transform: uppercase;
}

.cmv-stage {
  aspect-ratio: 640 / 540; background: #000; border-radius: 4px; grid-area: stage; overflow: hidden; position: relative;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.cmv-stage video, .cmv-ov { display: block; height: 100%; left: 0; position: absolute; top: 0; width: 100%; }
.cmv-stage video { object-fit: fill; }
.cmv-ov { cursor: pointer; }

/* ---- what the codec does in each window: three steps, each one wrapping inside its own column */
.cmv-steps { grid-area: steps; min-width: 0; }
.cmv-steps .cmv-label { margin-bottom: 9px; }
.cmv-steps ol {
  display: grid; gap: 8px 30px; grid-template-columns: repeat(3, auto); justify-content: start; list-style: none;
  margin: 0; padding: 0;
}
.cmv-steps li {
  align-items: center; color: var(--ink-soft, #d6d6d6); display: flex; font-size: 13px; gap: 8px; line-height: 1.35;
  position: relative;
}
.cmv-steps li:not(:last-child)::after {
  color: var(--ink-faint, #707070); content: "\2192"; position: absolute; right: -21px; top: 50%; transform: translateY(-50%);
}
.cmv-steps li b { color: var(--ink, #f7f7f7); font-weight: 700; white-space: nowrap; }
.cmv-steps svg { fill: none; flex: none; height: 15px; stroke: var(--ink-muted, #a7a7a7); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.4; width: 15px; }
.cmv-box { background: rgba(118, 186, 0, 0.22); border: 2px solid rgba(77, 176, 36, 0.98); border-radius: 1px; display: inline-block; flex: none; height: 14px; width: 14px; }

/* ---- timeline */
.cmv-tl { grid-area: tl; min-width: 0; }
.cmv-tlhead { align-items: center; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; }
.cmv-tlhead .cmv-label { margin-right: auto; }
.cmv-key { align-items: center; color: var(--ink-soft, #d6d6d6); display: inline-flex; font-size: 13px; gap: 6px; white-space: nowrap; }
.cmv-key i { border-radius: 2px; display: inline-block; height: 10px; width: 10px; }
.cmv-k-codec { background: var(--cmv-green); }
.cmv-k-recent { background: rgba(74, 143, 227, 0.4); box-shadow: inset 0 0 0 1px rgba(74, 143, 227, 0.6); }
.cmv-tlbox { height: 156px; position: relative; }
.cmv-tlcv { cursor: pointer; display: block; height: 100%; left: 0; position: absolute; top: 0; touch-action: pan-y; width: 100%; }
.cmv-tlcv:focus { outline: none; }
.cmv-tlcv:focus-visible { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); border-radius: 2px; }

/* ---- totals for the episode so far */
.cmv-cum { grid-area: cum; min-width: 0; }
.cmv-cumrows {
  align-items: center; display: grid; gap: 10px 14px; grid-template-columns: max-content minmax(0, 1fr) max-content;
  margin-top: 10px;
}
.cmv-cumname { color: var(--ink-soft, #d6d6d6); font-size: 13.5px; white-space: nowrap; }
.cmv-track { background: rgba(255, 255, 255, 0.06); border-radius: 2px; display: flex; height: 10px; overflow: hidden; }
.cmv-track i { display: block; flex: none; height: 100%; transition: width .2s linear; width: 0; }
.cmv-b-dense, .cmv-b-sink { background: var(--cmv-blue); }
.cmv-b-tub { background: var(--cmv-green); }
.cmv-cumval { color: var(--ink-muted, #a7a7a7); font-size: 13.5px; font-variant-numeric: tabular-nums; min-width: 12.5em; white-space: nowrap; }
.cmv-cumval b { color: var(--ink, #f7f7f7); font-size: 15px; font-weight: 700; }
.cmv-cumval em { color: #fff; font-size: 15px; font-style: normal; font-weight: 800; }

/* ---- what the model reads: inputs, then the DiT, then what it generates, as one centred flow */
.cmv-ctx { display: flex; flex-direction: column; grid-area: ctx; min-height: 0; min-width: 0; }
.cmv-ctx > .cmv-label { margin: 0 0 14px; }
.cmv-inputs { display: flex; flex: 1 1 auto; flex-direction: column; gap: 18px; min-height: 0; }
.cmv-grp { min-width: 0; }
.cmv-row { align-items: center; display: flex; gap: 10px; min-width: 0; }
.cmv-gh { align-items: baseline; display: flex; gap: 8px; margin-bottom: 8px; min-width: 0; }
.cmv-name { color: var(--ink, #f7f7f7); font-size: 14px; font-weight: 800; white-space: nowrap; }
.cmv-sub { color: var(--ink-muted, #a7a7a7); font-size: 12.5px; }
.cmv-gh .cmv-sub { display: block; margin-top: 1px; }
.cmv-stack { display: flex; flex-direction: column; gap: 1px; line-height: 1.35; min-width: 0; }
.cmv-ico { align-items: center; display: inline-flex; flex: none; justify-content: center; width: 54px; }
.cmv-cnt { color: var(--ink-muted, #a7a7a7); flex: none; font-size: 12.5px; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
.cmv-cnt b { color: var(--ink, #f7f7f7); font-size: 14px; font-weight: 800; }
.cmv img.cmv-sinkimg {             /* beats the page's ".figure img" (white paper-figure box) */
  background: #000; border-radius: 3px; box-shadow: 0 0 0 1.5px var(--cmv-blue); display: block; flex: none;
  height: 44px; margin: 1px; object-fit: fill; padding: 0; width: 52px;
}
.cmv-grp--mem { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.cmv-wallbox { flex: 1 1 0; min-height: 170px; position: relative; }
/* once the grid is laid out, the wall keeps the height of the grid (set by the script) */
.cmv-fit .cmv-inputs, .cmv-fit .cmv-grp--mem, .cmv-fit .cmv-wallbox { flex: none; }
.cmv-fit .cmv-wallbox { min-height: 0; }
.cmv-wall { display: block; height: 100%; left: 0; position: absolute; top: 0; width: 100%; }
.cmv-legend {
  align-items: center; color: var(--ink-muted, #a7a7a7); display: flex; flex-wrap: wrap; font-size: 12.5px;
  gap: 4px 11px; margin: -1px 0 11px;
}
.cmv-legend span { align-items: center; display: inline-flex; gap: 5px; white-space: nowrap; }
.cmv-legend i { border: 2px solid currentColor; border-radius: 2px; display: inline-block; height: 11px; width: 11px; }
.cmv-legend .cmv-pend i { background: none; border: 1px solid rgba(255, 255, 255, 0.42); }
.cmv-stripbox { height: 40px; position: relative; }
.cmv-strip { display: block; height: 100%; left: 0; position: absolute; top: 0; width: 100%; }

.cmv-toks { display: inline-flex; flex: none; gap: 3px; }
.cmv-toks i { border: 1.5px solid; border-radius: 3px; display: inline-block; height: 12px; width: 12px; }
.cmv-toks--text i { background: rgba(167, 139, 250, 0.2); border-color: var(--cmv-violet); }
.cmv-toks--vid i { background: rgba(74, 143, 227, 0.22); border-color: var(--cmv-blue); }
.cmv-toks--act i { background: rgba(240, 180, 41, 0.2); border-color: var(--cmv-amber); }

.cmv-down { color: rgba(255, 255, 255, 0.45); display: block; flex: none; height: 20px; margin: 10px auto; width: 10px; }
.cmv-dit {
  align-items: baseline; background: var(--bg-muted, #171717); border: 1px solid var(--cmv-line); border-radius: 6px;
  display: flex; flex-wrap: wrap; gap: 2px 8px; justify-content: center; padding: 9px 14px;
}
.cmv-dit b { color: #fff; font-size: 14.5px; font-weight: 800; }
.cmv-dit span { color: var(--ink-muted, #a7a7a7); font-size: 12.5px; }
.cmv-out {
  align-items: center; color: var(--ink-soft, #d6d6d6); display: flex; flex-wrap: wrap; font-size: 13.5px; gap: 8px 24px;
  justify-content: center;
}
.cmv-out > span { align-items: center; display: inline-flex; gap: 8px; white-space: nowrap; }
.cmv-out .cmv-sub { font-variant-numeric: tabular-nums; }

/* ---- tooltip */
.cmv-tip {
  background: rgba(16, 16, 16, 0.97); border: 1px solid var(--cmv-line-strong); border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55); color: var(--ink-soft, #d6d6d6); font-size: 12.5px; left: 0;
  line-height: 1.5; padding: 8px 10px; pointer-events: none; position: absolute; top: 0; white-space: nowrap; z-index: 5;
}
.cmv-tip[hidden] { display: none; }
.cmv-tip b { color: #fff; }
.cmv-tip .cmv-dim { color: var(--ink-muted, #a7a7a7); }
.cmv-tip canvas { border-radius: 3px; display: block; margin-bottom: 7px; }

/* ---- caption: position words follow the layout */
.cmv figcaption { max-width: none; }
.cmv-narrow { display: none; }

/* ---- errors */
.cmv-error .cmv-main { opacity: 0.35; }
.cmv-error .cmv-headline { display: none; }
.cmv .cmv-errmsg { color: var(--ink-soft, #d6d6d6); font-size: 15px; margin: 0 0 16px; }
.cmv-errmsg[hidden] { display: none; }

@media (max-width: 1000px) {
  .cmv-panel { padding: 14px 14px 16px; }
  .cmv-main { gap: 16px; grid-template-areas: "stage" "steps" "tl" "cum" "ctx"; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .cmv-stage { justify-self: center; max-width: calc(70vh * 640 / 540); width: 100%; }   /* never taller than the screen */
  .cmv-steps { margin-top: 2px; }
  .cmv-ctx { border-top: 1px solid var(--cmv-line); margin-top: 8px; padding-top: 18px; }
  .cmv-wallbox { flex: none; height: 300px; min-height: 0; }
  .cmv-wide { display: none; }
  .cmv-narrow { display: inline; }
}
@media (max-width: 640px) {
  .cmv .cmv-headline { font-size: 15px; }
  .cmv-headline b { font-size: 21px; }
  .cmv-seg { margin-left: 0; width: 100%; }
  .cmv-seg button { flex: 1 1 0; padding: 0 8px; }
}
@media (max-width: 520px) {
  .cmv-where { display: none; }
  .cmv-steps ol { grid-template-columns: minmax(0, 1fr); }
  .cmv-steps li:not(:last-child)::after { content: none; }
  .cmv-cumrows { gap: 4px 10px; grid-template-columns: max-content minmax(0, 1fr); }
  .cmv-cumval { grid-column: 2; margin-bottom: 6px; min-width: 0; }
  .cmv-tlbox { height: 132px; }
}
@media (prefers-reduced-motion: reduce) {
  .cmv-track i, .cmv-play, .cmv-seg button { transition: none; }
}

/* ---- the simple version on the page (.cmv-lite, 2026-12-01): the video with its tubelets, the headline and the
   running token count. The step list, the per-window chart, the context column and the view switch are hidden; the
   script still looks them up, so they stay in the markup. */
.cmv-lite .cmv-steps, .cmv-lite .cmv-tl, .cmv-lite .cmv-ctx, .cmv-lite .cmv-seg, .cmv-lite .cmv-where { display: none !important; }
.cmv-lite .cmv-headline { font-size: 19px; }
.cmv-lite .cmv-main {
  align-items: center; grid-template-areas: "stage cum"; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-rows: auto;
}
.cmv-lite .cmv-cum { align-self: center; }
.cmv-lite .cmv-cumrows { gap: 8px 12px; grid-auto-flow: row dense; grid-template-columns: minmax(0, 1fr) auto; margin-top: 14px; }
.cmv-lite .cmv-cumname { color: #fff; font-size: 16px; font-weight: 700; grid-column: 1; }
.cmv-lite .cmv-cumname--ours { color: var(--cmv-green); }
.cmv-lite .cmv-track { grid-column: 1 / -1; height: 16px; margin-bottom: 14px; }
.cmv-lite .cmv-cumval { font-size: 15px; grid-column: 2; min-width: 0; text-align: right; }
.cmv-lite .cmv-cumval b, .cmv-lite .cmv-cumval em { font-size: 17px; }
@media (max-width: 1000px) {
  .cmv-lite .cmv-main { grid-template-areas: "stage" "cum"; grid-template-columns: minmax(0, 1fr); }
}
