/* Interactive figures for the NVFP4 RL blog. Scoped under .nvfp4-viz. */

figure.nvfp4-viz {
  margin: 34px 0;
}

figure.nvfp4-viz.viz-active > img {
  display: none;
}

figure.nvfp4-viz .viz-card {
  border-top: 1px solid var(--line, #d8d0c4);
  padding-top: 12px;
}

figure.nvfp4-viz .viz-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 8px;
}

figure.nvfp4-viz .viz-kicker {
  font: 700 10.5px/1 "Inter", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent, #176b64);
}

figure.nvfp4-viz .viz-title {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 400;
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink, #161513);
}

figure.nvfp4-viz .viz-sub {
  font: 500 11px/1.5 "SF Mono", Menlo, ui-monospace, monospace;
  color: var(--muted, #6d6860);
}

figure.nvfp4-viz .viz-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted, #6d6860);
  opacity: 0.85;
  white-space: nowrap;
}

/* ---- legend ---- */
figure.nvfp4-viz .viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 14px;
  margin: 0 0 8px;
  padding: 0;
}

figure.nvfp4-viz .viz-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: none;
  font: 500 11px/1.6 "SF Mono", Menlo, ui-monospace, monospace;
  color: #44403a;
  padding: 2px 4px;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

figure.nvfp4-viz .viz-chip:hover {
  background: rgba(23, 107, 100, 0.07);
}

figure.nvfp4-viz .viz-chip:focus-visible {
  outline: 2px solid var(--accent, #176b64);
  outline-offset: 2px;
}

figure.nvfp4-viz .viz-chip.off {
  opacity: 0.4;
  text-decoration: line-through;
}

figure.nvfp4-viz .viz-chip .swatch {
  width: 20px;
  height: 0;
  border-top-style: solid;
  border-top-width: 2.5px;
  border-radius: 2px;
}

/* ---- plot ---- */
figure.nvfp4-viz .viz-plot {
  position: relative;
}

figure.nvfp4-viz svg.viz-svg {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: pan-y pinch-zoom;
}

figure.nvfp4-viz svg.viz-svg:focus-visible {
  outline: 2px solid var(--accent, #176b64);
  outline-offset: 2px;
}

figure.nvfp4-viz svg [role="link"]:focus-visible {
  outline: 2.5px solid var(--accent, #176b64);
  outline-offset: 3px;
}

figure.nvfp4-viz svg.viz-svg text {
  font-family: "Inter", system-ui, sans-serif;
}

figure.nvfp4-viz svg.viz-svg text.tick {
  font-size: 11px;
  fill: #8a847a;
  font-variant-numeric: tabular-nums;
}

figure.nvfp4-viz svg.viz-svg text.ax-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  fill: var(--muted, #6d6860);
}

figure.nvfp4-viz svg.viz-svg text.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  fill: #44403a;
}

figure.nvfp4-viz svg.viz-svg text.annot {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-size: 15px;
  fill: var(--ink, #161513);
}

/* ---- series lines: base weights, hover emphasis, legend isolate ---- */
figure.nvfp4-viz .viz-series path {
  transition: stroke-opacity 0.18s ease-out, stroke-width 0.18s ease-out;
}

figure.nvfp4-viz .viz-series path.main {
  stroke-width: 2.25;
  stroke-opacity: 0.95;
}

figure.nvfp4-viz .viz-series.wide path.main {
  stroke-width: 2.6;
}

figure.nvfp4-viz .viz-series.thin path.main {
  stroke-width: 1.4;
  stroke-opacity: 0.85;
}

figure.nvfp4-viz .viz-series path.raw {
  stroke-width: 1;
  stroke-opacity: 0.22;
}

/* replicate band: hidden until its run is hovered or legend-focused */
figure.nvfp4-viz .viz-series path.band {
  opacity: 0;
  transition: opacity 0.18s ease-out;
}

figure.nvfp4-viz .viz-series.hot path.band,
figure.nvfp4-viz .viz-series.focused path.band {
  opacity: 1;
}

figure.nvfp4-viz svg.has-hot .viz-series:not(.hot) path.band,
figure.nvfp4-viz .viz-series.faded path.band {
  opacity: 0;
}

figure.nvfp4-viz svg.has-hot .viz-series:not(.hot) path.main {
  stroke-opacity: 0.3;
}

figure.nvfp4-viz svg.has-hot .viz-series:not(.hot) path.raw {
  stroke-opacity: 0.08;
}

figure.nvfp4-viz .viz-series.hot path {
  transition-duration: 0.12s;
}

figure.nvfp4-viz .viz-series.hot path.main {
  stroke-width: 3.2;
  stroke-opacity: 1;
}

figure.nvfp4-viz .viz-series.wide.hot path.main {
  stroke-width: 3.4;
}

figure.nvfp4-viz .viz-series.thin.hot path.main {
  stroke-width: 2.2;
}

figure.nvfp4-viz .viz-series.faded.faded path.main,
figure.nvfp4-viz .viz-series.faded.faded path.raw {
  stroke-opacity: 0.14;
}

figure.nvfp4-viz .viz-crosshair {
  stroke: #b9b2a5;
  stroke-width: 1;
  stroke-opacity: 0.8;
}

figure.nvfp4-viz .viz-dot {
  fill-opacity: 0.65;
  stroke: none;
  pointer-events: none;
}

figure.nvfp4-viz .viz-dot.hot {
  fill-opacity: 1;
  stroke: #fffdf8;
  stroke-width: 1.6;
}

figure.nvfp4-viz .viz-zoom-rect {
  fill: rgba(23, 107, 100, 0.1);
  stroke: rgba(23, 107, 100, 0.45);
  stroke-width: 1;
}

/* ---- direct endpoint labels ---- */
figure.nvfp4-viz text.viz-endlabel {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

/* ---- caption + interaction note under the plot ---- */
figure.nvfp4-viz .viz-note {
  display: flex;
  align-items: baseline;
  gap: 6px 18px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted, #6d6860);
  flex-wrap: wrap;
}

figure.nvfp4-viz .viz-note .cap {
  flex: 1;
}

figure.nvfp4-viz .viz-note .how {
  margin-left: auto;
  white-space: nowrap;
  opacity: 0.75;
}

/* ---- tooltip: paper card ---- */
figure.nvfp4-viz .viz-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: var(--paper, #fffdf8);
  border: 1px solid var(--line, #d8d0c4);
  color: var(--ink, #161513);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.55;
  max-width: min(430px, calc(100% - 16px));
  box-shadow: 0 6px 24px rgba(32, 28, 20, 0.14);
  opacity: 0;
  transition: opacity 0.1s ease;
}

figure.nvfp4-viz .viz-tooltip.on {
  opacity: 1;
}

figure.nvfp4-viz .viz-tooltip .tt-x {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #6d6860);
  margin-bottom: 4px;
}

figure.nvfp4-viz .viz-tooltip .tt-row {
  display: grid;
  grid-template-columns: 14px fit-content(240px) 1fr auto;
  gap: 0 7px;
  align-items: center;
  white-space: nowrap;
  color: var(--muted, #6d6860);
}

figure.nvfp4-viz .viz-tooltip .tt-row.hot {
  color: var(--ink, #161513);
  font-weight: 600;
}

/* scatter/bar rows have no swatch column */
figure.nvfp4-viz .viz-tooltip .tt-row.tt-kv {
  grid-template-columns: max-content 1fr auto;
}

figure.nvfp4-viz .viz-tooltip .tt-row .sw {
  width: 14px;
  height: 0;
  border-top-style: solid;
  border-top-width: 2.5px;
  border-radius: 2px;
}

figure.nvfp4-viz .viz-tooltip .tt-row .name {
  font: 500 11px/1.6 "SF Mono", Menlo, ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(120px, 38vw, 220px);
}

figure.nvfp4-viz .viz-tooltip .tt-row .val {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

figure.nvfp4-viz .viz-tooltip .tt-row .delta {
  text-align: right;
  min-width: 40px;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted, #6d6860);
  font-variant-numeric: tabular-nums;
}

figure.nvfp4-viz .viz-tooltip .tt-row .mult {
  grid-column: 2 / -1;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--accent-strong, #a33e2d);
}

figure.nvfp4-viz .viz-tooltip .tt-note {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted, #6d6860);
}

/* ---- in-plot chrome: reset pill, ghost hint, sr-only ---- */
figure.nvfp4-viz .viz-reset {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  border: 1px solid var(--line, #d8d0c4);
  background: var(--paper, #fffdf8);
  color: var(--ink, #161513);
  border-radius: 999px;
  font: 500 11px/1 "Inter", system-ui, sans-serif;
  padding: 5px 10px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s;
}

figure.nvfp4-viz .viz-reset.on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

figure.nvfp4-viz .viz-reset:hover {
  background: rgba(23, 107, 100, 0.08);
}

figure.nvfp4-viz .viz-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- controls row (interactive concept widgets only) ---- */
figure.nvfp4-viz .viz-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #6d6860);
}

figure.nvfp4-viz .viz-controls label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

figure.nvfp4-viz input[type="range"] {
  accent-color: var(--accent, #176b64);
  width: 130px;
  height: 14px;
}

figure.nvfp4-viz .viz-btn {
  border: 1px solid var(--line, #d8d0c4);
  background: var(--paper, #fffdf8);
  color: var(--ink, #161513);
  border-radius: 8px;
  font: 500 12px/1 "Inter", system-ui, sans-serif;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

figure.nvfp4-viz .viz-btn:hover {
  background: rgba(23, 107, 100, 0.08);
}

figure.nvfp4-viz .viz-btn[aria-pressed="true"] {
  background: var(--accent, #176b64);
  border-color: var(--accent, #176b64);
  color: #fffdf8;
}

figure.nvfp4-viz figcaption {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted, #6d6860);
}

figure.nvfp4-viz figcaption p {
  margin: 0 0 8px;
}

figure.nvfp4-viz figcaption p:last-child {
  margin-bottom: 0;
}

figure.nvfp4-viz .prf-capfold {
  margin-top: 10px;
}

figure.nvfp4-viz .prf-capfold .prf-capfold {
  margin: 8px 0 2px 14px;
}
figure.nvfp4-viz .prf-capfold > summary {
  cursor: pointer;
  width: fit-content;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a847a;
  user-select: none;
}
figure.nvfp4-viz .prf-capfold > summary:hover {
  color: #55504a;
}
figure.nvfp4-viz .prf-capfold[open] > summary {
  margin-bottom: 2px;
}

@media (prefers-reduced-motion: reduce) {
  figure.nvfp4-viz .viz-series path,
  figure.nvfp4-viz .viz-tooltip,
  figure.nvfp4-viz text.viz-endlabel,
  figure.nvfp4-viz .viz-reset {
    transition: none !important;
  }
}

/* two figures side by side in the article */
.viz-row-2 {
  display: grid;
  /* minmax(0,...) so a wide legend or svg cannot blow the row past the column */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 28px;
  align-items: stretch;
}

@media (max-width: 820px) {
  .viz-row-2 {
    gap: 0 14px; /* stays two-up on small screens, just tighter */
  }
}

/* ---- multi-panel rows (auto-collapse when the container is narrow) ---- */
figure.nvfp4-viz .viz-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 14px;
}

/* ---- diagrams ---- */
figure.nvfp4-viz .viz-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

figure.nvfp4-viz .dg-node rect {
  transition: filter 0.15s ease;
}

figure.nvfp4-viz .dg-node {
  cursor: help;
}

figure.nvfp4-viz .dg-node.dim,
figure.nvfp4-viz .dg-edge.dim {
  opacity: 0.25;
  transition: opacity 0.15s ease;
}

figure.nvfp4-viz .dg-edge path.wire {
  fill: none;
  stroke: #55504a;
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

figure.nvfp4-viz .dg-edge path.wire.hot {
  stroke: var(--accent-strong, #a33e2d);
  stroke-width: 2.4;
}

figure.nvfp4-viz .dg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted, #6d6860);
}

figure.nvfp4-viz .dg-legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

figure.nvfp4-viz .dg-legend .key .box {
  width: 14px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

/* ---- NCU profiler recreation ---- */
figure.nvfp4-viz .ncu {
  background: #1d222a;
  border-radius: 10px;
  color: #d7dde8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow: hidden;
}

figure.nvfp4-viz .ncu .ncu-titlebar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 8px 12px;
  background: #262c36;
  color: #9aa7bd;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 12px;
}

figure.nvfp4-viz .ncu .ncu-body {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
}

@media (max-width: 760px) {
  figure.nvfp4-viz .ncu .ncu-body {
    grid-template-columns: 1fr;
  }
}

figure.nvfp4-viz .ncu .ncu-src {
  padding: 10px 0;
  overflow-x: auto;
  border-right: 1px solid #303845;
}

figure.nvfp4-viz .ncu .src-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1px 12px;
  white-space: pre;
  line-height: 1.55;
}

figure.nvfp4-viz .ncu .src-line:hover {
  background: #262e3b;
}

figure.nvfp4-viz .ncu .src-line.hot-line {
  background: rgba(163, 62, 45, 0.16);
}

figure.nvfp4-viz .ncu .src-line .ln {
  color: #5d6b82;
  width: 34px;
  flex: none;
  text-align: right;
}

figure.nvfp4-viz .ncu .src-line .pct {
  width: 52px;
  flex: none;
  text-align: right;
  color: #ffb054;
}

figure.nvfp4-viz .ncu .src-line .stallbar {
  width: 90px;
  flex: none;
  height: 9px;
  border-radius: 2px;
  background: #2c3440;
  overflow: hidden;
  display: flex;
}

figure.nvfp4-viz .ncu .code {
  color: #d7dde8;
}

figure.nvfp4-viz .ncu .kw { color: #6fb3ff; }
figure.nvfp4-viz .ncu .ty { color: #4ec9b0; }
figure.nvfp4-viz .ncu .fn { color: #dcdcaa; }
figure.nvfp4-viz .ncu .cm { color: #6a9955; }

figure.nvfp4-viz .ncu .ncu-panel {
  padding: 12px 14px;
}

figure.nvfp4-viz .ncu .ncu-panel h4 {
  margin: 0 0 8px;
  font: 600 12.5px "Inter", system-ui, sans-serif;
  color: #d7dde8;
}

figure.nvfp4-viz .ncu table.stalls {
  width: 100%;
  border-collapse: collapse;
}

figure.nvfp4-viz .ncu table.stalls td {
  padding: 3px 6px 3px 0;
  vertical-align: middle;
  font-size: 11.5px;
}

figure.nvfp4-viz .ncu table.stalls tr {
  cursor: help;
}

figure.nvfp4-viz .ncu table.stalls tr:hover td {
  background: #262e3b;
}

figure.nvfp4-viz .ncu .metric-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 7px;
}

figure.nvfp4-viz .ncu .bar-track {
  background: #2c3440;
  border-radius: 2px;
  height: 12px;
  width: 100%;
  overflow: hidden;
}

figure.nvfp4-viz .ncu .bar-fill {
  height: 100%;
  background: #4f8fe8;
}

figure.nvfp4-viz .ncu .ncu-note {
  padding: 8px 12px;
  color: #8b98ae;
}

/* ---- async RL timeline (header figure) ---- */
figure.nvfp4-viz .prf-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

figure.nvfp4-viz .prf-glabel {
  font: 600 10px/1 "Inter", system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #6d6860);
  margin-right: 3px;
}

figure.nvfp4-viz .prf-sliderval {
  font: 600 11.5px/1 "SF Mono", Menlo, ui-monospace, monospace;
  color: var(--ink, #161513);
  min-width: 3.6em;
}

figure.nvfp4-viz .prf-divider {
  border-top: 1px dashed var(--line, #d8d0c4);
  margin: 10px 0 8px;
}

figure.nvfp4-viz .prf-span {
  cursor: pointer;
  transition: stroke 0.1s ease;
}

figure.nvfp4-viz .prf-span:hover,
figure.nvfp4-viz .prf-span.hl {
  stroke: #161513;
  stroke-width: 1.2;
}

/* ---- two-level scaling widget ---- */
figure.nvfp4-viz .tl2-key {
  font: 500 11px/1.6 "SF Mono", Menlo, ui-monospace, monospace;
  color: var(--muted, #6d6860);
  margin: 4px 0 12px;
}

figure.nvfp4-viz .tl2-key b {
  color: var(--ink, #161513);
}

figure.nvfp4-viz .tl2-block {
  margin-bottom: 16px;
}

figure.nvfp4-viz .tl2-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  font: 500 11px/1.6 "SF Mono", Menlo, ui-monospace, monospace;
  color: var(--muted, #6d6860);
  margin-bottom: 6px;
}

figure.nvfp4-viz .tl2-head b {
  color: var(--ink, #161513);
}

figure.nvfp4-viz .tl2-chosen {
  color: var(--accent-strong, #a33e2d);
}

figure.nvfp4-viz .tl2-rowwrap {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

figure.nvfp4-viz .tl2-rowlabel {
  flex: none;
  width: 44px;
  text-align: right;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted, #6d6860);
  align-self: center;
}

figure.nvfp4-viz .tl2-rowlabel span {
  color: var(--accent-strong, #a33e2d);
  opacity: 0.75;
}

figure.nvfp4-viz .tl2-row {
  display: flex;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

figure.nvfp4-viz .tl2-tile {
  flex: 1 1 0;
  min-width: 0;
  cursor: pointer;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

figure.nvfp4-viz .tl2-tile:hover {
  outline: 1.5px solid rgba(22, 21, 19, 0.45);
  outline-offset: 1px;
}

figure.nvfp4-viz .tl2-mag {
  height: 26px;
}

figure.nvfp4-viz .tl2-err {
  height: 7px;
}

/* Hover footnotes: subtle superscript markers, note appears on hover/focus */
sup.fnref {
  position: relative;
  cursor: help;
  color: #48796f;
  font-size: 0.72em;
  font-weight: 500;
  padding: 0 1px;
}
sup.fnref .fnote {
  display: none;
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(320px, 76vw);
  background: #fffdf7;
  border: 1px solid #e0d9ca;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(22, 21, 19, 0.09);
  padding: 8px 11px;
  color: #55504a;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  z-index: 30;
}
sup.fnref:hover .fnote,
sup.fnref:focus .fnote,
sup.fnref:focus-within .fnote {
  display: block;
}

/* invisible strip below the card bridges the gap so the pointer can enter it */
sup.fnref .fnote::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 10px;
}

sup.fnref .fnote.fnote-wide {
  max-width: min(460px, 86vw);
}

.fnote .fntable {
  display: table;
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
}
.fnote .fntr {
  display: table-row;
}
.fnote .fnth,
.fnote .fntd {
  display: table-cell;
  padding: 4px 10px 4px 0;
  border-top: 1px solid #eee7d9;
}
.fnote .fnth {
  border-top: none;
  font-size: 12px;
  font-weight: 600;
  color: #3f3a33;
}
.fnote .fntd {
  font-variant-numeric: tabular-nums;
}

/* wide desktops: footnotes live in the right margin as translucent sidenotes,
   mirroring the ToC rail; they sharpen on hover of the note or its marker */
@media (min-width: 1460px) {
  /* width and offset shrink with the margin (210px from ~1740px wide down to
     ~150px at the 1460px breakpoint) so notes never spill past the viewport */
  sup.fnref .fnote,
  sup.fnref .fnote.fnote-wide {
    display: block;
    position: static;
    float: right;
    clear: right;
    width: min(210px, calc((100vw - 1120px) / 2 - 18px));
    max-width: none;
    margin: -0.2em max(-244px, calc(-6px - (100vw - 1120px) / 2)) 12px 0;
    transform: none;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #55504a;
    opacity: 0.55;
    transition: opacity 0.15s ease;
    z-index: auto;
  }

  /* the hover-bridge strip becomes the sidenote's number label */
  sup.fnref .fnote::before {
    content: attr(data-n) ". ";
    position: static;
    height: auto;
    font-weight: 600;
    color: #48796f;
  }

  sup.fnref:hover .fnote,
  sup.fnref:focus .fnote,
  sup.fnref .fnote:hover {
    display: block;
    opacity: 1;
  }
}

/* ---- NCU capture: crops to the source pane on phones ---- */
.ncu-wrap {
  position: relative;
  overflow: hidden;
}

.ncu-inner {
  position: relative;
  width: 100%;
}

.ncu-card {
  position: absolute;
  left: 70%;
  top: 44%;
  width: var(--cardw, 28.5%);
  filter: drop-shadow(0 10px 24px rgba(10, 12, 15, 0.6));
}

@media (max-width: 640px) {
  /* zoom to the code itself (gutter, line numbers, and the sampling pane
     crop away; the docked card's caption names the line and its stall share) */
  .ncu-inner {
    width: 233%;
    margin-left: -12.9%;
  }

  .ncu-card {
    position: static;
    width: var(--cardwm, 100%);
    margin: 10px auto 0;
  }
}

/* footnote cards become a bottom sheet on phones instead of clipping off-screen */
@media (max-width: 520px) {
  sup.fnref .fnote,
  sup.fnref .fnote.fnote-wide {
    position: fixed;
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 14px;
    width: auto;
    max-width: none;
    transform: none;
    z-index: 80;
  }

  figure.nvfp4-viz .viz-tooltip .tt-row {
    white-space: normal;
  }

  /* the interaction hint is wider than a paired figure's column on phones */
  figure.nvfp4-viz .viz-note .how {
    white-space: normal;
  }

  /* paired charts stack: two-up on a phone shrinks their labels to ~4px */
  .viz-row-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  /* the sim's run-stats readout is desktop detail */
  figure.nvfp4-viz .tl2-key {
    display: none;
  }

  /* tighter buttons so 'dequant bwd' and the bf16-layers cluster share a row */
  figure.nvfp4-viz .viz-btn {
    padding: 6px 8px;
  }

  figure.nvfp4-viz .viz-tooltip .tt-row .name {
    max-width: clamp(60px, 26vw, 220px);
  }
}

/* the judge scatter reads as a square; keep it that size when full-width */
figure[data-viz="online-nvfp4-judge-scatter"] .viz-plot {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
