/* CodecMem page: interactive Summary figure (summary.js). Everything is scoped under .cms.
   Colours follow the page's :root variables; codec tokens use the internal-release hero colours:
   codec memory rgb(118,186,0), dense tokens rgb(74,143,227), on #101010. */
.cms {
  --cms-ours: var(--accent, #76b900);
  --cms-ours-hi: var(--accent-light, #9bdc2a);
  --cms-tok-dense: rgb(74, 143, 227);
  --cms-tok-codec: rgb(118, 186, 0);
  --cms-tok-bg: #101010;
  --cms-panel: var(--bg-subtle, #0b0b0b);
  --cms-line: var(--line, rgba(255, 255, 255, .14));
  --cms-ink: var(--ink, #f7f7f7);
  --cms-ink-soft: var(--ink-soft, #d6d6d6);
  --cms-ink-muted: var(--ink-muted, #a7a7a7);
  --cms-dot: #8f8f8f;
  --cms-bar: #5f5f5f;
  --cms-ring: #cfcfcf;
}

/* ---------- layout ---------- */
.cms-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr); }
.cms-panel {
  background: var(--cms-panel); border: 1px solid var(--cms-line); border-radius: 6px; display: flex;
  flex-direction: column; min-width: 0; padding: 18px 18px 16px; position: relative;
}
.cms-panel--bench { grid-column: 1 / -1; padding-bottom: 12px; }
.cms-head { align-items: center; display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
/* text levels: panel titles 22 px, axis titles 15 px (the small panels' subtitles are their axis titles),
   ticks 13 px, notes and descriptions in the muted caption grey */
.cms-title {
  align-items: center; color: #fff; display: flex; font-size: 25px; font-weight: 800; gap: 12px;
  letter-spacing: -.015em; line-height: 1.15;
}
.cms-title::before { background: var(--cms-ours); border-radius: 2px; content: ""; flex: none; height: .92em; width: 5px; }
.cms-sub { color: var(--cms-ink-soft); font-size: 15px; font-weight: 600; line-height: 1.4; margin-top: 9px; }
/* the four descriptions share one grid cell, so that switching between them never moves the chart */
.cms .cms-desc { color: var(--cms-ink-muted); display: grid; font-size: 13.5px; line-height: 1.55; margin: 12px 0 0; max-width: 880px; }
.cms .cms-desc > span { grid-area: 1 / 1; }
.cms .cms-desc > span[hidden] { display: block; visibility: hidden; }
.cms-desc b { color: var(--cms-ink); font-weight: 700; }
.cms .cms-note { color: var(--cms-ink-muted); font-size: 12.5px; line-height: 1.5; margin: auto 0 0; padding-top: 12px; }
.cms-fail { display: none; }
.cms.is-failed .cms-layout, .cms-js-failed .cms .cms-layout { display: none; }
.cms.is-failed .cms-fail, .cms-js-failed .cms .cms-fail { color: var(--cms-ink-muted); display: block; font-size: 14px; margin: 0; }

/* ---------- metric buttons (the page's .tabs look, under its own names) ---------- */
.cms-tabs {
  background: var(--bg-muted, #171717); border: 1px solid var(--cms-line); border-radius: 4px;
  display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px;
}
.cms-tab {
  appearance: none; background: transparent; border: 0; border-radius: 3px; color: var(--cms-ink-soft);
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 800; min-height: 34px; padding: 0 15px;
  transition: background-color .15s, color .15s; white-space: nowrap;
}
.cms-tab:hover { color: #fff; }
.cms-tab[aria-pressed="true"] { background: var(--cms-ours); color: #000; }
.cms-tab:focus-visible { outline: 2px solid var(--cms-ours-hi); outline-offset: 2px; }

/* ---------- over the plot: the y-axis title, and the legend (above it when they do not fit on one line) ---------- */
.cms-phead { align-items: baseline; display: flex; flex-wrap: wrap-reverse; gap: 8px 24px; justify-content: space-between; margin: 16px 0 6px; }
.cms-ytitle { align-items: baseline; color: var(--cms-ink); display: inline-flex; font-size: 15px; font-weight: 700; gap: 12px; line-height: 1.4; }
.cms-ytitle b { color: var(--cms-ink-soft); font-size: 13px; font-weight: 700; order: 2; }
.cms-ytitle span { order: 1; transition: opacity .17s ease; }
.cms-legend { color: var(--cms-ink-soft); display: flex; flex-wrap: wrap; font-size: 13px; gap: 4px 18px; line-height: 1.4; }
.cms-legend > span { align-items: center; display: inline-flex; gap: 7px; }
.cms-key { border-radius: 50%; box-sizing: border-box; display: inline-block; flex: none; height: 11px; width: 11px; }
.cms-key--ours { background: var(--cms-ours); box-shadow: 0 0 0 3px rgba(118, 185, 0, .22), 0 0 10px rgba(118, 185, 0, .55); }
.cms-key--base { background: var(--cms-dot); }
.cms-key--ref { border: 1.75px solid var(--cms-ring); }

/* ---------- SVG charts ---------- */
.cms-plot { min-height: 376px; position: relative; }
.cms-chart { min-height: 150px; position: relative; }
.cms-chart.cms-toks { min-height: 0; }
.cms-svg { display: block; font-family: var(--font-sans, Arial, Helvetica, sans-serif); height: auto; max-width: 100%; overflow: visible; }
.cms-svg text { font-family: inherit; }
.cms-gl { shape-rendering: crispEdges; stroke: rgba(255, 255, 255, .09); stroke-width: 1; }
.cms-gl--v { stroke: rgba(255, 255, 255, .055); }
.cms-axis { shape-rendering: crispEdges; stroke: rgba(255, 255, 255, .4); stroke-width: 1; }
.cms-axis--minor { stroke: rgba(255, 255, 255, .25); }
.cms-break { fill: none; stroke: var(--cms-ink-muted); stroke-linecap: round; stroke-width: 1.2; }
.cms-tick { fill: var(--cms-ink-soft); font-size: 13px; }
.cms-axis-title { fill: var(--cms-ink); font-size: 15px; font-weight: 700; }
.cms-dir { fill: var(--cms-ink-soft); font-size: 13px; }
.cms-axt-more { fill: var(--cms-ink-muted); font-weight: 400; }
.cms-y { transition: opacity .35s ease; }

/* points */
.cms-pt__in, .cms-glowlayer { transition: opacity .18s ease; }
.cms-sc.has-active .cms-pt:not(.is-active) .cms-pt__in { opacity: .32; }
.cms-sc.has-active:not(.is-ours-active) .cms-glowlayer { opacity: .3; }
.cms-pt__dot { fill: var(--cms-dot); stroke: var(--cms-panel); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; transition: transform .15s ease, fill .15s ease; }
.cms-pt--ref .cms-pt__dot { fill: var(--cms-panel); stroke: var(--cms-ring); stroke-width: 1.75; }
.cms-pt--ours .cms-pt__dot { fill: var(--cms-ours); stroke: #0b0b0b; stroke-width: 2; }
.cms-pt.is-active .cms-pt__dot { transform: scale(1.3); }
.cms-pt--base.is-active .cms-pt__dot { fill: #f1f1f1; }
.cms-pt--ref.is-active .cms-pt__dot { stroke: #fff; }
.cms-pt__glow { pointer-events: none; }
.cms-pt__pulse { fill: none; opacity: 0; pointer-events: none; stroke: var(--cms-ours-hi); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; }
.cms-pt__pulse.is-on { animation: cms-pulse 1.7s cubic-bezier(.2, .6, .3, 1) 2; }
@keyframes cms-pulse { 0% { opacity: .85; transform: scale(1); } 100% { opacity: 0; transform: scale(3.6); } }
.cms-pt__lab {
  fill: var(--cms-ink-muted); font-size: 12.5px; paint-order: stroke; pointer-events: none;
  stroke: var(--cms-panel); stroke-linejoin: round; stroke-width: 4px; transition: opacity .28s ease;
}
.cms-pt--ref .cms-pt__lab { fill: var(--cms-ink-soft); font-style: italic; }
.cms-pt--ours .cms-pt__lab { font-size: 14px; font-weight: 800; }
.cms-pt__name { fill: var(--cms-ours-hi); }
.cms-pt__val { fill: #fff; }
.cms-pt.is-active .cms-pt__lab { fill: #fff; }
.cms-pt__lab.is-hidden { opacity: 0; }
.cms-sc.is-moving .cms-pt__lab { opacity: 0; transition-duration: .12s; }

/* dense attention -> CodecMem; in the rank view, where the full-memory references sit on the cost axis, it rises from it */
.cms-conn { opacity: 0; pointer-events: none; transition: opacity .35s ease; }
.cms-sc.is-shown .cms-conn.is-on { opacity: 1; }
.cms-sc.is-shown.has-active .cms-conn.is-on { opacity: .3; }
.cms-sc.is-shown.is-moving .cms-conn.is-on { opacity: 0; transition-duration: .12s; }
.cms-conn__line { fill: none; stroke: rgba(155, 220, 42, .6); stroke-dasharray: 4 4; stroke-width: 1.25; }
.cms-conn__bg { fill: var(--cms-panel); transition: opacity .28s ease; }
.cms-conn__lab { fill: var(--cms-ours-hi); font-size: 12px; font-weight: 700; transition: opacity .28s ease; }

/* hover guides */
.cms-guide { stroke: rgba(255, 255, 255, .32); stroke-dasharray: 2 3; stroke-width: 1; }
.cms-chip rect { fill: #1c1c1c; stroke: rgba(255, 255, 255, .28); }
.cms-chip text { fill: #fff; font-size: 11.5px; font-weight: 700; }
.cms-chip--ours rect { fill: #142003; stroke: rgba(118, 185, 0, .75); }
.cms-chip--ours text { fill: var(--cms-ours-hi); }

/* keyboard targets over the points */
.cms-hits { inset: 0; pointer-events: none; position: absolute; }
.cms-hit {
  appearance: none; background: transparent; border: 0; border-radius: 50%; height: 28px; left: -14px;
  margin: 0; padding: 0; pointer-events: none; position: absolute; top: -14px; width: 28px;
}
.cms-hit:focus { outline: none; }
.cms-hit:focus-visible { box-shadow: 0 0 0 2px var(--cms-ours-hi); }

/* details card: beside the point, or docked under a narrow plot */
.cms-tip {
  background: rgba(16, 16, 16, .97); border: 1px solid var(--line-strong, rgba(255, 255, 255, .3)); border-radius: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .6); color: var(--cms-ink-soft); font-size: 12.5px; left: 0;
  line-height: 1.45; max-width: calc(100% - 4px); opacity: 0; padding: 10px 12px 10px; pointer-events: none;
  position: absolute; top: 0; transition: opacity .12s ease; width: 300px; z-index: 4;
}
.cms-tip.is-on { opacity: 1; }
.cms-tip.is-docked { box-shadow: none; display: none; margin-top: 10px; max-width: none; position: static; width: auto; }
.cms-tip.is-docked.is-on { display: block; }
.cms-tip.is-ours { border-color: rgba(118, 185, 0, .65); }
.cms-tip__name { color: #fff; font-size: 14px; font-weight: 800; }
.cms-tip__name em { color: var(--cms-ink-muted); font-size: 12px; font-style: normal; font-weight: 700; margin-left: 6px; }
.cms-tip.is-ours .cms-tip__name { color: var(--cms-ours-hi); }
.cms-tip__fam { color: var(--cms-ink-muted); font-size: 12px; }
.cms-tip__grid { border-top: 1px solid var(--cms-line); display: grid; gap: 3px 12px; grid-template-columns: auto minmax(0, 1fr); margin: 8px 0 0; padding-top: 8px; }
.cms-tip__grid dt { color: var(--cms-ink-muted); white-space: nowrap; }
.cms-tip__grid dd { color: var(--cms-ink); margin: 0; }
.cms-tip__grid dd span { color: var(--cms-ink-muted); margin-left: 6px; }
.cms-tip__grid .is-cur { color: #fff; font-weight: 700; }
.cms-tip.is-ours .cms-tip__grid dd.is-cur { color: var(--cms-ours-hi); }
.cms-tip__grid sup { font-size: 10px; margin-left: 1px; }
.cms-tip__note { border-top: 1px solid var(--cms-line); color: var(--cms-ink-muted); font-size: 12px; line-height: 1.4; margin-top: 8px; padding-top: 6px; }
.cms-pod {
  background: rgba(255, 255, 255, .09); border-radius: 3px; color: var(--cms-ink-soft); display: inline-block;
  font-size: 10.5px; font-style: normal; font-weight: 800; line-height: 1; margin-left: 6px; padding: 2px 5px 2px; vertical-align: 1px;
}
.cms-pod--1 { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- horizontal bars (the page's .bars look) ---------- */
.cms-hb__name { fill: var(--cms-ink); font-size: 14px; font-weight: 700; }
.cms-hb__sub { fill: var(--cms-ink-muted); font-size: 11.5px; }
.cms-hb__row.is-ours .cms-hb__name { fill: var(--cms-ours-hi); }
.cms-hb__val { fill: var(--cms-ink-muted); font-size: 11.5px; }
.cms-hb__row.is-ours .cms-hb__val { fill: var(--cms-ink); font-size: 13px; font-weight: 800; }
.cms-bar { fill: var(--cms-bar); transform-box: fill-box; transform-origin: 0 50%; }
.cms-hb__row.is-ours .cms-bar { fill: var(--cms-ours); }
.cms-hb__row:hover .cms-bar { opacity: .82; }
.cms-panel .cms-bar { transform: scaleX(0); transition: transform .95s cubic-bezier(.2, .75, .25, 1); }
.cms-panel .cms-hb__val { opacity: 0; transition: opacity .45s ease; }
.cms-panel.is-in .cms-bar { transform: none; }
.cms-panel.is-in .cms-hb__val { opacity: 1; }

/* ---------- context tokens, drawn to scale ---------- */
.cms-toks { display: grid; gap: 16px 26px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); margin-top: 12px; }
.cms-tok__head { align-items: baseline; color: var(--cms-ink-muted); display: flex; flex-wrap: wrap; font-size: 12.5px; gap: 2px 12px; justify-content: space-between; margin-bottom: 7px; }
.cms-tok__head b { color: var(--cms-ink); font-size: 13.5px; }
.cms-tok__head .cms-tok__fps { font-size: 12px; }
.cms-tok__head .cms-tok__fps b { color: var(--cms-ink-soft); font-size: 12px; font-weight: 800; }
.cms-tok__bars { background: var(--cms-tok-bg); border-radius: 4px; display: grid; gap: 8px; padding: 10px 11px; }
.cms-tok__row { align-items: center; display: grid; gap: 10px; grid-template-columns: 102px minmax(0, 1fr); }
.cms-tok__lab { color: var(--cms-ink-soft); font-size: 12px; font-weight: 700; white-space: nowrap; }
.cms-tok__lab--ours { color: var(--cms-ours-hi); }
.cms-tok__track { align-items: stretch; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); height: 12px; }
.cms-tok__track i { background: var(--cms-tok-dense); box-shadow: inset -1px 0 0 rgba(16, 16, 16, .85); display: block; }
.cms-tok__track i:first-child { border-radius: 2px 0 0 2px; }
.cms-tok__track i:last-child { border-radius: 0 2px 2px 0; box-shadow: none; }
.cms-tok__track i.cms-tok__ours { background: var(--cms-tok-codec); border-radius: 2px; box-shadow: 0 0 9px rgba(118, 186, 0, .6); }
.cms-tok__x { align-self: center; color: #fff; font-size: 12px; font-weight: 800; grid-column: 2 / -1; line-height: 12px; padding-left: 8px; white-space: nowrap; }
.cms-panel .cms-tok__track i { transform: scaleX(0); transform-origin: 0 50%; transition: transform .28s ease calc(var(--i, 0) * 26ms); }
.cms-panel .cms-tok__x { opacity: 0; transition: opacity .4s ease .75s; }
.cms-panel.is-in .cms-tok__track i { transform: none; }
.cms-panel.is-in .cms-tok__x { opacity: 1; }

/* ---------- numbers as a table ---------- */
.cms-table { color: var(--cms-ink-muted); font-size: 13px; margin-top: 10px; }
.cms-table summary { cursor: pointer; }
.cms-table__scroll { margin-top: 10px; max-width: 100%; overflow-x: auto; }
.cms-table table { border-collapse: collapse; }
.cms-table caption { caption-side: top; color: var(--cms-ink-soft); padding: 2px 0 6px; text-align: left; }
.cms-table th, .cms-table td { border-bottom: 1px solid var(--cms-line); padding: 5px 10px; text-align: right; white-space: nowrap; }
.cms-table th:first-child { text-align: left; }
.cms-table thead th { color: var(--cms-ink-soft); font-weight: 700; text-align: center; }
.cms-table thead th:first-child { text-align: left; }
.cms-table__band th { color: var(--cms-ink-soft); font-style: italic; font-weight: 400; padding-top: 9px; text-align: left; }
.cms-table tr.is-ours th, .cms-table tr.is-ours td { color: var(--cms-ours-hi); font-weight: 700; }
.cms-table sup { font-size: 10px; }
.cms .cms-table__notes { color: var(--cms-ink-muted); font-size: 12px; margin: 6px 0 4px; }

/* ---------- motion and widths ---------- */
.cms.is-still *, .cms.is-still *::before, .cms.is-still *::after { animation: none !important; transition: none !important; }
.cms.is-still .cms-bar, .cms.is-still .cms-tok__track i { transform: none !important; }
.cms.is-still .cms-hb__val, .cms.is-still .cms-tok__x { opacity: 1 !important; }
@media (prefers-reduced-motion: reduce) {
  .cms *, .cms *::before, .cms *::after { animation: none !important; transition: none !important; }
  .cms .cms-bar, .cms .cms-tok__track i { transform: none !important; }
  .cms .cms-hb__val, .cms .cms-tok__x { opacity: 1 !important; }
}
@media (min-width: 670px) {
  .cms-plot { min-height: 412px; }
}
@media (max-width: 900px) {
  .cms-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cms-panel--tokens { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .cms-layout { grid-template-columns: minmax(0, 1fr); }
  .cms-panel { padding: 14px 12px 12px; }
  .cms-panel--bench { padding-bottom: 8px; }
  .cms-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .cms-tab { padding: 0 8px; }
  .cms .cms-desc__more, .cms .cms-wide { display: none; }
  .cms-phead { margin-top: 14px; }
  .cms-title { font-size: 21px; gap: 10px; }
  .cms-sub, .cms-ytitle { font-size: 14px; }
}
