#inference { scroll-margin-top: 22px; }
#inference-player { position: relative; max-width: 800px; margin: 22px auto; font-size: 15px; line-height: 1.4; color: var(--ink); }
#inference-player .stage { overflow: auto hidden; padding: 8px 0; }
#inference-player .seq { position: relative; display: inline-flex; align-items: flex-start; height: 280px; }

/* The model spans whatever part of the sequence currently exists. */
#inference-player .model { position: absolute; left: 0; right: 0; top: 76px; height: 76px; box-sizing: border-box; padding-left: 14px; border-radius: 16px; background: #e9edf1; display: flex; align-items: center; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; }

/* One column per piece of the sequence: output above the model, input below. */
#inference-player .col { position: relative; z-index: 1; width: 0; opacity: 0; overflow: hidden; transition: width .5s ease, opacity .35s ease; }
#inference-player .col.on { width: var(--w); opacity: 1; }
#inference-player .col > div { width: var(--w); padding: 0 6px; box-sizing: border-box; transition: width .5s ease; }
#inference-player .out { height: 68px; }
#inference-player .gap { height: 120px; }
#inference-player .in { height: 78px; }
#inference-player .box { height: 56px; box-sizing: border-box; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-weight: 500; line-height: 1.2; text-align: center; white-space: nowrap; transition: background .4s, color .4s; }
#inference-player .temp .box { background: #eceef0; color: #4a545e; }                 /* used for this decision only */
#inference-player .out .box { background: #fbe9c8; color: #7a5410; }
#inference-player .in .box { align-self: stretch; height: 40px; }

/* Inputs: a picture with its name underneath. Blue ones stay in the cache, grey ones are used once. */
#inference-player .item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; line-height: 1.2; text-align: center; white-space: nowrap; color: #4a545e; transition: color .4s; }
#inference-player .keep .item { color: #1d4f7c; }
#inference-player .pic { display: block; width: 50px; height: 40px; border-radius: 6px; background: #eceef0; fill: currentColor; fill-opacity: .5; transition: background .4s; }
#inference-player .keep .pic { background: #cfe1f2; }
#inference-player .glyphs { display: flex; align-items: center; gap: 5px; height: 40px; }
#inference-player .glyphs .pic { width: 36px; height: 29px; border-radius: 5px; }
#inference-player .say { display: block; width: 28px; height: 24px; margin-top: 5px; fill: #eceef0; }
#inference-player .say .ln { fill: none; stroke: currentColor; stroke-opacity: .5; stroke-width: 2; stroke-linecap: round; }
/* Past images are a film strip: one more frame each time an image joins. */
#inference-player .past > div { padding: 0 8px; }
#inference-player .film { align-self: stretch; height: 40px; border-radius: 3px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='40'%3E%3Crect width='28' height='40' fill='%234a86bd'/%3E%3Cg fill='%23eaf3fb'%3E%3Crect x='4.5' y='3.5' width='5' height='3.5' rx='1'/%3E%3Crect x='18.5' y='3.5' width='5' height='3.5' rx='1'/%3E%3Crect x='4.5' y='33' width='5' height='3.5' rx='1'/%3E%3Crect x='18.5' y='33' width='5' height='3.5' rx='1'/%3E%3C/g%3E%3Crect x='2' y='10' width='24' height='20' rx='2' fill='%23dbe9f6'/%3E%3C/svg%3E") 0 0 / 28px 40px repeat-x; }
/* A short arrow from each input up into the model. */
#inference-player .feed { display: block; position: relative; top: 88px; width: 10px; height: 22px; margin: 0 auto; color: #9aa4ad; transition: color .4s; }
#inference-player .keep .feed { color: #3f7fb8; }
#inference-player .feed::before { content: ""; position: absolute; left: 4px; top: 5px; bottom: 0; width: 2px; background: currentColor; }
#inference-player .feed::after { content: ""; position: absolute; left: 0; top: 0; border: 5px solid transparent; border-top: 0; border-bottom: 7px solid currentColor; }
#inference-player[data-step="2"] .n1 .item { color: #4a545e; }                                /* not cached yet */
#inference-player[data-step="2"] .n1 .pic { background: #eceef0; }
#inference-player[data-step="2"] .n1 .feed { color: #9aa4ad; }

/* The cache is a tray around the blue pictures. It stretches when an image is added. */
#inference-player .cache { position: absolute; left: 0; top: 180px; width: 156px; height: 84px; box-sizing: border-box; border: 2px solid #3f7fb8; border-radius: 14px; background: #eaf3fb; transition: width .5s ease; }
#inference-player .cache b { position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%); padding: 1px 10px; border-radius: 10px; background: #3f7fb8; color: #fff; font-size: 12px; letter-spacing: .06em; }
#inference-player[data-cycle="1"]:not([data-step="1"]):not([data-step="2"]) .cache { width: 240px; }
#inference-player[data-cycle="2"] .cache { width: 268px; }
#inference-player[data-cycle="3"] .cache { width: 296px; }
#inference-player .past { --w: 156px; }
#inference-player[data-cycle="2"] .past { --w: 184px; }
#inference-player[data-cycle="3"] .past { --w: 212px; }
/* Later images: the previous image joins the film strip, then the new one is added to the cache. */
#inference-player[data-step="9"] .cache { animation: lc-roll2 1.8s ease both; }
#inference-player[data-step="12"] .cache { animation: lc-roll3 1.8s ease both; }
#inference-player[data-step="9"] .n2 .item, #inference-player[data-step="12"] .n3 .item { animation: lc-join 1.8s ease both; }
#inference-player[data-step="9"] .n2 .pic, #inference-player[data-step="12"] .n3 .pic { animation: lc-join-bg 1.8s ease both; }
#inference-player[data-step="9"] .n2 .feed, #inference-player[data-step="12"] .n3 .feed { animation: lc-join-arrow 1.8s ease both; }
@keyframes lc-roll2 { 0% { width: 240px; } 30%, 62% { width: 184px; } 100% { width: 268px; } }
@keyframes lc-roll3 { 0% { width: 268px; } 30%, 62% { width: 212px; } 100% { width: 296px; } }
@keyframes lc-join { 0%, 62% { color: #4a545e; } 100% { color: #1d4f7c; } }
@keyframes lc-join-bg { 0%, 62% { background: #eceef0; } 100% { background: #cfe1f2; } }
@keyframes lc-join-arrow { 0%, 62% { color: #9aa4ad; } 100% { color: #3f7fb8; } }

/* Output tokens. Reasoning: all at once. Subtask: one by one. Actions: block by block, one bar per block. */
#inference-player .toks { display: flex; gap: 6px; }
#inference-player .grid { display: grid; grid-template-columns: repeat(5, 1fr); justify-items: center; width: 100%; }
#inference-player .grp { display: flex; }
#inference-player .toks.groups { gap: 6px; }
#inference-player .tok, #inference-player .slot { display: block; width: 14px; height: 7px; border-radius: 3px; box-sizing: border-box; }
#inference-player .slot { border: 1.5px solid #9aa4ad; }
#inference-player .tok { background: #d9a441; }
#inference-player .tok, #inference-player .grp { position: relative; opacity: 0; transform: scale(.3); transition: opacity .25s, transform .25s; }
#inference-player .grp .tok { width: 6px; border-radius: 0; opacity: 1; transform: none; transition: none; }
#inference-player .grp .tok:first-child { border-radius: 3px 0 0 3px; }
#inference-player .grp .tok:last-child { border-radius: 0 3px 3px 0; }
#inference-player .grp .tok:only-child { border-radius: 3px; }

/* Autoregressive: a small hop from each subtask token (or action group) to the next one. */
#inference-player .sub .box, #inference-player .act .box { padding-bottom: 7px; }
#inference-player .sub .tok + .tok::before, #inference-player .grp + .grp::before { content: ""; position: absolute; right: calc(50% - .75px); top: calc(100% + 4px); width: var(--hop, 21.5px); height: 7px; box-sizing: border-box; border: 1.5px solid #b98a2e; border-top: 0; border-radius: 0 0 50% 50% / 0 0 100% 100%; }
#inference-player .sub .tok + .tok::after, #inference-player .grp + .grp::after { content: ""; position: absolute; left: 50%; top: calc(100% + 1px); margin-left: -3.5px; border: 3.5px solid transparent; border-top: 0; border-bottom: 4.5px solid #b98a2e; }
#inference-player .col.on .tok, #inference-player .col.on .grp, #inference-player.throw .tok, #inference-player.throw .grp { opacity: 1; transform: none; }

/* One arrow per slot, all rising through the model together. */
#inference-player .arrow { position: relative; width: 10px; height: 112px; margin-top: 4px; opacity: 0; clip-path: inset(100% 0 0 0); transition: opacity .2s, clip-path 0s .2s; }
#inference-player .arrow::before { content: ""; position: absolute; left: 4px; top: 5px; bottom: 0; width: 2px; background: linear-gradient(to top, rgba(207, 154, 58, .3), #cf9a3a); }
#inference-player .arrow::after { content: ""; position: absolute; left: 0; top: 0; border: 5px solid transparent; border-top: 0; border-bottom: 7px solid #cf9a3a; }
#inference-player[data-step="5"] .arrow, #inference-player[data-step="10"] .arrow { opacity: 1; clip-path: inset(0); transition: clip-path .6s ease-out var(--d), opacity 0s var(--d); }
#inference-player[data-step="5"] { --d: .6s; }
#inference-player[data-step="10"] { --d: .9s; }

#inference-player[data-step="5"] .slots .tok { transition-delay: 1.2s; }
#inference-player[data-step="6"] .sub .tok:nth-child(1), #inference-player[data-step="7"] .grp:nth-child(1) { transition-delay: .6s; }
#inference-player[data-step="6"] .sub .tok:nth-child(2), #inference-player[data-step="7"] .grp:nth-child(2) { transition-delay: 1.0s; }
#inference-player[data-step="6"] .sub .tok:nth-child(3), #inference-player[data-step="7"] .grp:nth-child(3) { transition-delay: 1.4s; }
#inference-player[data-step="6"] .sub .tok:nth-child(4), #inference-player[data-step="7"] .grp:nth-child(4) { transition-delay: 1.8s; }
#inference-player[data-step="7"] .grp:nth-child(5) { transition-delay: 2.2s; }

/* Second decision: the same sequence, played quickly in one step. */
#inference-player[data-step="10"] .slots { transition-delay: .3s; }
#inference-player[data-step="10"] .slots .tok { transition-delay: 1.5s; }
#inference-player[data-step="10"] .sub { transition-delay: 1.8s; }
#inference-player[data-step="10"] .sub .tok:nth-child(1) { transition-delay: 2.2s; }
#inference-player[data-step="10"] .sub .tok:nth-child(2) { transition-delay: 2.4s; }
#inference-player[data-step="10"] .sub .tok:nth-child(3) { transition-delay: 2.6s; }
#inference-player[data-step="10"] .sub .tok:nth-child(4) { transition-delay: 2.8s; }
#inference-player[data-step="10"] .act { transition-delay: 3.0s; }
#inference-player[data-step="10"] .grp:nth-child(1) { transition-delay: 3.4s; }
#inference-player[data-step="10"] .grp:nth-child(2) { transition-delay: 3.6s; }
#inference-player[data-step="10"] .grp:nth-child(3) { transition-delay: 3.8s; }
#inference-player[data-step="10"] .grp:nth-child(4) { transition-delay: 4.0s; }
#inference-player[data-step="10"] .grp:nth-child(5) { transition-delay: 4.2s; }

/* Throwing away: a trash can pops up, the temporary blocks are sucked into it, then the model shrinks back. */
#inference-player.throw .temp { overflow: visible; transition: width .5s ease 1.9s, opacity .3s ease 1.6s; }
#inference-player.throw .temp .out .box, #inference-player.throw .temp .item { opacity: 0; transition: transform .7s cubic-bezier(.55, 0, .9, .45) var(--t), opacity .2s ease-in calc(var(--t) + .5s); }
#inference-player.throw .temp .item { transform: translate(var(--tx), 4px) scale(.08) rotate(25deg); }
#inference-player.throw .temp .out .box { transform: translate(var(--tx), 198px) scale(.08) rotate(-25deg); }
#inference-player.throw .temp .feed { opacity: 0; transition: opacity .2s var(--t); }
#inference-player .act .in { display: flex; align-items: center; justify-content: center; }
#inference-player .can { width: 40px; height: 46px; overflow: visible; fill: #fff; stroke: #5f6b76; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.5); transition: opacity .2s, transform .2s; }
#inference-player.throw .can { opacity: 1; transform: none; transition: opacity .2s, transform .3s cubic-bezier(.3, 1.6, .5, 1); }
#inference-player .lid { transform-box: fill-box; transform-origin: 100% 100%; }
#inference-player.throw .lid { animation: lc-lid 1.6s ease both; }
@keyframes lc-lid { 0%, 100% { transform: none; } 18%, 82% { transform: rotate(32deg); } }

/* Latency numbers, shown beside the cache on the last step. */
#inference-player .latency { position: absolute; left: 338px; top: 104px; width: 440px; opacity: 0; transition: opacity .3s; }
#inference-player[data-step="12"] .latency { opacity: 1; transition: opacity .6s 1.4s; }
#inference-player .latency p { margin: 0; font-size: 13px; color: var(--muted); }
#inference-player .latency dl { display: flex; gap: 36px; margin: 10px 0; }
#inference-player .latency dt { font-size: 24px; font-weight: 600; line-height: 1.2; }
#inference-player .latency dd { margin: 0; font-size: 13px; color: var(--muted); }
#inference-player .latency dd b { font-weight: 600; color: var(--ink); }
#inference-player .latency .note { font-size: 12px; color: #7d868e; }

/* The caption sits in the empty corner just above the model, next to where things happen. */
#inference-player .caption { position: absolute; left: 6px; top: 8px; height: 62px; max-width: min(360px, 100%); margin: 0; display: flex; align-items: flex-end; font-size: 19px; font-weight: 600; line-height: 1.25; text-wrap: balance; }
#inference-player .controls { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
#inference-player .controls button { height: 34px; min-width: 34px; border: 1px solid #cbd3d9; border-radius: 6px; background: #fff; color: inherit; font: inherit; cursor: pointer; }
#inference-player .controls .play { min-width: 68px; }
#inference-player .controls button svg { display: block; width: 20px; height: 20px; margin: auto; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#lc-paper #inference-player .controls .dl { margin-left: auto; font-size: 13px; color: var(--muted); }
#inference-player .dots { flex: 0 1 380px; display: flex; gap: 5px; }
#inference-player .dots button { flex: 1; min-width: 0; height: 6px; padding: 0; border: 0; border-radius: 3px; background: #dce0e5; }
#inference-player .dots button.now { background: var(--ink); }

/* On the page: the figure caption, and small screens. */
#lc-paper #inference-player figcaption { max-width: none; margin-top: 10px; }
#lc-paper #inference-player noscript p { margin-top: 10px; font-size: 14px; color: var(--muted); }
#inference-player.small .stage { overflow: hidden; height: calc(280px * var(--s) + 16px); }
#inference-player.small .seq { transform: scale(var(--s)); transform-origin: 0 0; }
#inference-player.small .caption { position: static; height: auto; min-height: 2.5em; max-width: none; font-size: 17px; }
@media (max-width: 580px) {
  #inference-player .controls { flex-wrap: wrap; }
  #inference-player .controls > button { height: 42px; min-width: 42px; }
  #inference-player .dots { flex: 1 1 0; }
  #lc-paper #inference-player .controls .dl { flex: 1 0 100%; margin-left: 0; text-align: center; }
}
