/* LMSysDojo project page: section 03, analysis RL (assets/js/rl.js). Everything is scoped under #rl. */

/* ------------------------------------------------------------------ shared bits */
/* the segmented control: the same look as gap's (#gap .g-seg), a thumb sliding under the pressed button */
#rl .rl-seg {
  position: relative; display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); isolation: isolate; max-width: 100%;
}
#rl .rl-seg button {
  position: relative; z-index: 1; border: 0; background: none; cursor: pointer;
  padding: 7px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 520; color: var(--ink-3);
  white-space: nowrap; transition: color .25s var(--ease);
}
#rl .rl-seg button:hover, #rl .rl-seg button[aria-pressed="true"] { color: var(--ink); }
#rl .rl-seg button:focus-visible { border-radius: 999px; outline-offset: 2px; }
#rl .rl-seg-thumb {
  position: absolute; z-index: 0; left: 0; top: 3px; bottom: 3px; width: 0; border-radius: 999px;
  background: var(--bg); box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 0 0 1px var(--line);
  transition: transform .5s var(--ease-out), width .5s var(--ease-out);
}
:root[data-theme="dark"] #rl .rl-seg-thumb { background: var(--panel-2); box-shadow: 0 0 0 1px var(--line-2); }

/* ------------------------------------------------------------------ rl-signal */
#rl .rls-legend { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 0 0 22px; padding: 0; list-style: none; font-size: 13.5px; color: var(--ink-3); }
#rl .rls-legend li { display: inline-flex; align-items: baseline; gap: 9px; }
#rl .rls-legend li i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; transform: translateY(1px); }
#rl .rls-legend b { color: var(--ink); font-weight: 600; }
#rl .rls-legend em { font-style: normal; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); padding-left: 4px; white-space: nowrap; }
/* both panels share one label column and one value gutter, so their 0-100% axes have the same scale */
#rl .rls { --rls-lw: 150px; --rls-cg: 18px; }
#rl .rls-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
#rl .rls-panel { background: var(--panel); border-radius: var(--rad-lg); padding: 24px 28px 22px; }
#rl .rls-k { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; font-size: 15px; font-weight: 600; color: var(--ink); }
#rl .rls-k i { font-style: italic; font-weight: 500; }
#rl .rls-row { display: grid; grid-template-columns: var(--rls-lw) minmax(0, 1fr); column-gap: var(--rls-cg); row-gap: 5px; align-items: center; margin-bottom: 16px; }
#rl .rls-l { grid-row: span 2; font-size: 14px; color: var(--ink-2); line-height: 1.3; }
#rl .rls-row:has(> .rls-bar:only-of-type) .rls-l { grid-row: auto; }
#rl .rls-bar { grid-column: 2; position: relative; height: 16px; }
#rl .rls-track { position: absolute; inset: 0 52px 0 0; display: block; }
#rl .rls-track::before { content: ""; position: absolute; left: 0; top: -3px; bottom: -3px; width: 1px; background: var(--line-2); }
#rl .rls-fill, #rl .rls-ext {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 3px 3px 0; background: var(--c);
  transform-origin: 0 50%; transform: scaleX(0); transition: transform 1.2s var(--ease-out);
}
#rl .rls-ext { background: color-mix(in srgb, var(--c) 32%, transparent); }
#rl .rls-v {
  position: absolute; top: 50%; left: calc((100% - 52px) * var(--x-n, 0)); transform: translate(8px, -50%);
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
  opacity: 0; transition: opacity .5s ease .7s;
}
#rl .rls-in .rls-fill, #rl .rls-in .rls-ext { transform: scaleX(1); }
#rl .rls-in .rls-v { opacity: 1; }
#rl .rls-axis { position: relative; margin: 6px 0 0 calc(var(--rls-lw) + var(--rls-cg)); padding-top: 4px; }
#rl .rls-ticks { position: relative; display: block; height: 16px; margin-right: 52px; border-top: 1px solid var(--line); }
#rl .rls-ticks i { position: absolute; top: 4px; transform: translateX(-50%); font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
#rl .rls-at { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
#rl .rls-note { margin: 16px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); max-width: 60ch; }

/* chart cards: base.css .chart-card (as in #dojo and #gap) with a 16px title, a 13.5px caption and an optional control */
#rl .rl-card { padding: 24px 24px 20px; min-width: 0; }
#rl .rl-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
#rl .rl-card-head h4 { margin: 0 0 2px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
#rl .rl-card-head .cap { margin: 0; font-size: 13.5px; line-height: 1.5; }

/* ------------------------------------------------------------------ rl-throughput */
#rl .rl-throughput { margin-top: 64px; }
#rl .rlt { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: stretch; }
#rl .rlt-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
#rl .rlt-legend li { display: inline-flex; align-items: center; gap: 7px; }
#rl .rlt-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
#rl .rlt-cap { margin: 8px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-3); max-width: 46ch; }
#rl .rlt-nodes { display: none; }
#rl .rlt-col:has(> .is-narrow) .rlt-nodes { display: block; }
#rl .rlm { position: relative; --lw: 212px; --vp: 48px; padding-bottom: 30px; }
#rl .rlm-grid { position: absolute; left: calc(var(--lw) + 14px); right: var(--vp); top: -4px; bottom: 0; pointer-events: none; }
#rl .rlm-grid i { position: absolute; top: 0; bottom: 26px; left: calc(var(--x) * 100%); width: 1px; background: var(--line); font-style: normal; }
#rl .rlm-grid i:first-child { background: var(--line-2); }
#rl .rlm-grid span { position: absolute; top: calc(100% + 8px); left: 0; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
#rl .rlm-row { position: relative; display: grid; grid-template-columns: var(--lw) minmax(0, 1fr); column-gap: 14px; align-items: center; min-height: 34px; }
#rl .rlm-row + .rlm-row { margin-top: 4px; }
#rl .rlm-l { display: flex; flex-direction: column; align-items: flex-end; text-align: right; line-height: 1.25; }
#rl .rlm-l b { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
#rl .rlm-l small { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
#rl .rlm-bar { position: relative; height: 14px; margin-right: var(--vp); }
#rl .rlm-bar i {
  position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--x) * 100%); border-radius: 0 3px 3px 0; background: var(--c);
  transform-origin: 0 50%; transform: scaleX(0); transition: transform 1.1s var(--ease-out);
}
#rl .rlm-bar em {
  position: absolute; top: 50%; left: calc(var(--x) * 100%); transform: translate(8px, -50%); font-style: normal;
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; opacity: 0; transition: opacity .5s ease .6s;
}
#rl .rlm-in .rlm-bar i { transform: scaleX(1); }
#rl .rlm-in .rlm-bar em { opacity: 1; }
#rl .rlm-row:nth-child(3) .rlm-bar i { transition-delay: .04s; } #rl .rlm-row:nth-child(4) .rlm-bar i { transition-delay: .08s; }
#rl .rlm-row:nth-child(5) .rlm-bar i { transition-delay: .12s; } #rl .rlm-row:nth-child(6) .rlm-bar i { transition-delay: .16s; }
#rl .rlm-row:nth-child(7) .rlm-bar i { transition-delay: .2s; } #rl .rlm-row:nth-child(8) .rlm-bar i { transition-delay: .24s; }
#rl .rlm-row:nth-child(9) .rlm-bar i { transition-delay: .28s; } #rl .rlm-row:nth-child(10) .rlm-bar i { transition-delay: .32s; }
#rl .rlm-row:nth-child(11) .rlm-bar i { transition-delay: .36s; } #rl .rlm-row:nth-child(12) .rlm-bar i { transition-delay: .4s; }
@media (max-width: 560px) {
  #rl .rl-card { padding: 18px 14px 14px; }   /* as #gap .gp-chart */
  #rl .rlm { --lw: 0px; }
  #rl .rlm-grid { left: 0; }
  #rl .rlm-grid i:not(:first-child) { display: none; }
  #rl .rlm { padding-bottom: 6px; }
  #rl .rlm-grid span { display: none; }
  #rl .rlm-row { grid-template-columns: minmax(0, 1fr); row-gap: 4px; min-height: 0; }
  #rl .rlm-row + .rlm-row { margin-top: 12px; }
  #rl .rlm-l { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0 8px; text-align: left; }
}

/* ------------------------------------------------------------------ rl-results + rl-train */
#rl .rl-results-grid { align-items: stretch; }
#rl .rlr-stage { position: relative; }
#rl .rlr-chart { transition: opacity .4s var(--ease-out), transform .4s var(--ease-out); }
#rl .rlr-chart.rlr-enter { opacity: 0; transform: translateY(6px); }
#rl .rlr-chart.rlr-leave { position: absolute; inset: 0 0 auto 0; opacity: 0; pointer-events: none; }
#rl .rlr-note { margin: 6px 0 0; font-size: 14px; line-height: 1.55; color: var(--ink-3); }
#rl .rlr-note b { color: var(--blue-ink); font-weight: 620; }
/* the untrained 27B, the reference: hollow rings that circle the dots it shares with the trained 9B */
#rl .rlr-chart .series[data-key="q27"] circle.pt { fill: none !important; stroke: var(--ink-3); stroke-width: 1.5px; }
/* charts.js colours end labels with their series; small numbers need text contrast (blue: --blue-ink) */
#rl .rlr-chart .series[data-key="q9rl"] text.end, #rl .rltr .series text.end { fill: var(--blue-ink) !important; }
#rl .rlr-chart .series[data-key="q9"] text.end { fill: var(--ink-3) !important; }
#rl .rltr + .rltr { margin-top: 20px; }
#rl .rltr-k { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; margin: 0 0 6px; font-size: 14px; font-weight: 600; letter-spacing: -.005em; line-height: 1.4; color: var(--ink); }
#rl .rltr-k span { font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--ink-3); }
#rl .rltr-cap { margin: 10px 0 0; font-size: 14px; line-height: 1.55; color: var(--ink-3); }

/* ------------------------------------------------------------------ rl-pipeline: the live schematic */
#rl {
  /* analysis shade by weights version, newest first (the paper's Fig. rl-infra); waits, empty cells, buffer tiles */
  --rlp-v0: #0B4FA8; --rlp-v1: #007FFF; --rlp-v2: #6FB2FF; --rlp-v3: #B5D6FF;
  --rlp-wait: #D3D6DD; --rlp-cell: #E1E4EA; --rlp-tile: #FFFFFF;
  /* the fleet's roles, as the paper's Fig. "Fleet management and elastic nodes" */
  --rlp-serve: var(--blue); --rlp-train: var(--blue-2); --rlp-score: var(--violet); --rlp-probe: var(--violet-2);
  --rlp-fmt: var(--ink-3); --rlp-idle: var(--ink-4); --rlp-lent: var(--blue); --rlp-slot: var(--line-2); --rlp-lift: rgba(16, 24, 40, .20);
  /* rl-results: the untrained 9B, the quieter line next to the trained one's --blue */
  --rlr-q9: var(--blue-2);
}
:root[data-theme="dark"] #rl {
  --rlp-v0: #A9D3FF; --rlp-v1: #3B9AFF; --rlp-v2: #2A6CC0; --rlp-v3: #1D426F;
  --rlp-wait: #343B48; --rlp-cell: #2A303B; --rlp-tile: #0E1116; --rlp-lift: rgba(0, 0, 0, .6);
  --rlr-q9: #2A6CC0;   /* --blue-2 is lighter than --blue in dark mode and would outshine the trained line */
}
#rl .rlp { margin-top: 8px; }
#rl .rlp-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 12px; }
#rl .rlp-title { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
#rl .rlp-ctrl { display: flex; align-items: center; gap: 14px; }
/* the paper's measured throughput for the current setup */
#rl .rlp-ro { display: flex; align-items: center; gap: 10px; margin: 0; padding: 4px 14px 4px 12px; border-radius: 12px; background: var(--blue-bg); }
#rl .rlp-ro-n { font-size: 22px; font-weight: 600; line-height: 1.1; color: var(--blue-ink); font-variant-numeric: tabular-nums; }
#rl .rlp-ro-t { display: flex; flex-direction: column; font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
#rl .rlp-ro-t small { font-size: 11.5px; color: var(--ink-3); }
#rl .rlp-play {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2);
  display: inline-grid; place-items: center; cursor: pointer; transition: color .2s, border-color .2s;
}
#rl .rlp-play:hover { color: var(--ink); border-color: var(--line-2); }
#rl .rlp-play svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#rl .rlp-play .i-play { display: none; fill: currentColor; stroke-width: 1.2; }
#rl .rlp-play.is-paused .i-play { display: block; }
#rl .rlp-play.is-paused .i-pause { display: none; }

/* the three challenges, one problem | fix switch each: gray while the problem shows, pale blue for the fix (as the
   paper figure's panels) */
#rl .rlp-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 14px; }
#rl .rlp-ch { min-width: 0; padding: 12px 14px; border-radius: var(--rad); background: var(--panel); transition: background-color .35s var(--ease); }
#rl .rlp-ch.is-fix { background: var(--panel-blue); }
#rl .rlp-ch-h { display: flex; align-items: center; gap: 8px; margin: 0 0 9px; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ink); }
#rl .rlp-ch-h .nb { width: 20px; height: 20px; font-size: 11px; }
#rl .rlp-ch .rl-seg { background: color-mix(in srgb, var(--bg) 62%, transparent); border-color: color-mix(in srgb, var(--line-2) 70%, transparent); }
#rl .rlp-ch .rl-seg button { padding: 6px 13px; font-size: 13px; }
#rl .rlp-ch-t { margin: 9px 0 0; min-height: 2.9em; font-size: 13px; line-height: 1.45; color: var(--ink-2); text-wrap: pretty; }
#rl .rlp-ch-t b { color: var(--ink); font-weight: 620; }

/* stage: lanes | buffer | gate | trainers, then the return wire's strip, then the fleet across the full width */
#rl .rlp-stage {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 196px 58px 168px; grid-template-rows: auto 40px auto;
  column-gap: 14px; align-items: stretch; isolation: isolate;
}
#rl .rlp-canvas { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; }
#rl .rlp-lanes, #rl .rlp-buf, #rl .rlp-train, #rl .rlp-fleet { position: relative; background: var(--panel); border-radius: var(--rad-lg); }
#rl .rlp-lanes { padding: 12px 16px 12px; }
#rl .rlp-area { height: calc(12 * 26px + 24px); }
#rl .rlp-cap { margin: 8px 0 0; font-size: 13px; color: var(--ink-3); }
/* the canvas draws a scale bar at the caption's first line: keep that line, and only that line, clear of it */
#rl .rlp-cap::before { content: ""; float: right; width: calc((100% - 10px) * 20 / var(--rlp-window, 100) + 92px); height: 1.3em; }
#rl .rlp-lanes.is-narrow .rlp-cap::before { float: none; display: block; }
#rl .rlp-cap b { color: var(--ink); font-weight: 600; }
#rl .rlp-buf { padding: 14px 12px 12px; display: flex; flex-direction: column; container-type: inline-size; }
#rl .rlp-train { padding: 14px 14px 12px; display: flex; flex-direction: column; align-self: center; }
/* the paper's stacked "Trainers" sheet */
#rl .rlp-train::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  background: var(--panel-2); transform: translate(5px, -5px);
}
#rl .rlp-train::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 1.5px var(--blue), 0 0 22px -4px color-mix(in srgb, var(--blue) 55%, transparent); opacity: 0;
  transition: opacity .5s var(--ease);
}
#rl .rlp-train.busy::after { animation: rlp-pulse 2.4s var(--ease) infinite; }
#rl .is-still .rlp-train.busy::after { animation-play-state: paused; }
@keyframes rlp-pulse { 0%, 100% { opacity: .15; } 50% { opacity: .75; } }
#rl .rlp-h { display: flex; align-items: center; justify-content: space-between; margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
#rl .rlp-sub { margin: 2px 0 12px; font-size: 12.5px; line-height: 1.4; font-style: italic; color: var(--ink-3); }
#rl .rlp-grid { height: min(172px, calc((100cqi - 16px) * 5 / 6 + 42px)); }   /* four rows of slots, the "dropped" line and the tray */
/* the buffer's last groups, one pip each: blue kept, dashed filtered, gray dropped */
#rl .rlp-tally { margin: 12px 0 0; }
#rl .rlp-tally-k { display: block; margin: 0 0 5px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
#rl .rlp-pips { height: 19px; }
#rl .rlp-tally + .rlp-sub { margin: 10px 0 0; }
#rl .rlp-tarea { height: 26px; margin: 2px 0 10px; }
#rl .rlp-status { margin: 0 0 10px; min-height: 2.8em; font-size: 12.5px; line-height: 1.4; color: var(--ink-2); }
#rl .rlp-eq { display: block; padding: 7px 10px; border-radius: 10px; background: var(--rlp-tile); color: var(--blue-ink); font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; transition: opacity .35s; }
#rl .rlp-train.is-idle .rlp-eq { opacity: .5; }
#rl .rlp-gate {
  align-self: center; display: grid; place-items: center; padding: 10px 4px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-3);
  font-family: var(--mono); font-size: 11px; font-weight: 600; line-height: 1.3; text-align: center;
  transition: background-color .35s var(--ease-out), color .35s, border-color .35s;
}
#rl .rlp-gate.on { background: var(--blue-fill); border-color: var(--blue-fill); color: var(--on-blue); }
/* the return wire's note, in the strip under the lanes: rl.js sets --rlp-rail-r so it ends just left of the wire's turn */
#rl .rlp-rail {
  grid-column: 1 / -1; grid-row: 2; align-self: center; margin: 0; padding: 0 var(--rlp-rail-r, 50%) 0 16px;
  text-align: right; font-size: 12.5px; line-height: 1.3; font-style: italic; color: var(--blue-ink); text-wrap: balance;
}

/* the fleet: 14 nodes of 8 GPUs in 17 slots, three jobs side by side */
#rl .rlp-fleet { grid-column: 1 / -1; grid-row: 3; padding: 13px 16px 14px; }
#rl .rlp-fh { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0 0 10px; }
#rl .rlp-fh .rlp-h { display: block; }
#rl .rlp-fsub { font-size: 12.5px; font-style: italic; color: var(--ink-3); }
/* the status gets its own line under the title, so a longer sentence never pushes the nodes down on wide screens */
#rl .rlp-fstat { flex: 1 1 100%; margin: 0; min-height: 1.4em; font-size: 12.5px; line-height: 1.4; color: var(--ink-2); text-wrap: balance; }
#rl .rlp-fstat b { color: var(--ink); font-weight: 620; }
#rl .rlp-fg { --slot-w: 146px; --rows: 3; position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 24px; padding-bottom: 8px; }
#rl .rlp-fr { min-width: 0; }
#rl .rlp-frh { display: flex; align-items: baseline; gap: 6px; margin: 0 0 7px; font-size: 12.5px; font-weight: 600; line-height: 18px; color: var(--ink-2); white-space: nowrap; }
#rl .rlp-frh i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c); flex: none; }
#rl .rlp-frh em { font-weight: 400; color: var(--ink-3); }
#rl .rlp-frq { font-weight: 500; color: var(--ink-2); }
#rl .rlp-frh.is-bn .rlp-frn { color: var(--ink); }
#rl .rlp-slots { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows), 17px); grid-auto-columns: var(--slot-w); gap: 5px 18px; }
#rl .rlp-fr[data-role="M"] .rlp-slots { column-gap: 8px; }
#rl .rlp-slot { display: flex; align-items: center; gap: 6px; height: 17px; }
#rl .rlp-sl { flex: none; width: 24px; text-align: right; font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--ink-3); transition: color .3s; }
#rl .rlp-slot.is-empty .rlp-sl { color: var(--ink-4); }
#rl .rlp-sb { flex: 1; height: 17px; }
/* the bottleneck: a raised card behind the job under most pressure; it glides when the bottleneck shifts */
#rl .rlp-bnc {
  position: absolute; left: 0; top: 0; z-index: 0; width: 0; height: 0; pointer-events: none; opacity: 0;
  border-radius: 14px; background: var(--bg); box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 0 0 1px var(--line);
  transition: transform .6s var(--ease-out), width .6s var(--ease-out), height .6s var(--ease-out), opacity .3s var(--ease);
}
:root[data-theme="dark"] #rl .rlp-bnc { background: var(--panel-2); box-shadow: 0 0 0 1px var(--line-2); }
#rl .rlp-bnc.on { opacity: 1; }
#rl .rlp-bnc-tab {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px;
  background: var(--block); color: var(--on-block); font-family: var(--mono); font-size: 9.5px; font-weight: 600; line-height: 12px;
  letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}

#rl .rlp-legend {
  display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 16px 0 0; padding: 14px 0 0; list-style: none; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
}
#rl .rlp-legend li { display: inline-flex; align-items: center; gap: 8px; }
#rl .rlp-legend i { display: inline-block; flex: none; }
#rl .rlp-legend .lg-break { flex-basis: 100%; height: 0; margin-top: -8px; }
/* the fleet's own legend, inside its panel as in the paper's figure */
#rl .rlp-flegend { margin: 14px 0 0; padding: 10px 0 0; border-top-color: var(--line-2); gap: 6px 18px; }
#rl .lg-ana { width: 30px; height: 7px; border-radius: 1px; background: linear-gradient(90deg, var(--rlp-v3) 0 25%, var(--rlp-v2) 25% 50%, var(--rlp-v1) 50% 75%, var(--rlp-v0) 75%); }
#rl .lg-build, #rl .lg-meas, #rl .lg-wait { width: 18px; height: 3.5px; border-radius: 1px; background: var(--block); }
#rl .lg-meas { background: var(--violet); }
#rl .lg-wait { background: var(--rlp-wait); }
#rl .lg-idle { width: 18px; height: 1px; background: repeating-linear-gradient(90deg, var(--ink-4) 0 1.5px, transparent 1.5px 5px); }
#rl .lg-dot, #rl .lg-ring { width: 8px; height: 8px; border-radius: 50%; background: var(--block); }
#rl .lg-ring { background: transparent; border: 1.3px solid var(--block); }
#rl .lg-cap { width: 2px; height: 11px; border-radius: 1px; background: var(--ink-2); }
#rl .lg-swap { width: 1px; height: 13px; background: repeating-linear-gradient(180deg, var(--ink-3) 0 3px, transparent 3px 6px); }
#rl .lg-cell { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
#rl .lg-cell.idle { background: transparent; border: 1px dashed var(--rlp-idle); }
#rl .lg-lent { width: 22px; height: 11px; border-radius: 3px; border: 1.3px dashed var(--rlp-lent); }

/* below the full width the three jobs' columns tighten and their subtitles go, so the pool never runs into the trainers */
@media (max-width: 1179px) {
  #rl .rlp-fg { --slot-w: 122px; gap: 16px; }
  #rl .rlp-slots { column-gap: 12px; }
  #rl .rlp-fr[data-role="M"] .rlp-slots { column-gap: 8px; }
  #rl .rlp-frh em { display: none; }
  /* the GPU legend in four even columns, so no item ends up alone on a line */
  #rl .rlp-flegend { display: grid; grid-template-columns: repeat(4, minmax(0, max-content)); }
}
/* the fleet switch sits in the fleet panel here (rl.js moves it), on white so it stands off the panel; the other two
   switches share the bar */
@media (max-width: 900px) {
  #rl .rlp-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #rl .rlp-fleet > .rlp-ch { margin: 0 0 14px; background: var(--bg); }
  #rl .rlp-fleet > .rlp-ch.is-fix { background: var(--panel-blue); }
}
@media (max-width: 820px) {
  #rl .rlp-fstat { min-height: 2.8em; }
}
@media (max-width: 1080px) {
  /* room for the rail note on two lines when the lanes get narrow */
  #rl .rlp-stage { grid-template-columns: minmax(0, 1fr) 176px 52px 150px; grid-template-rows: auto 50px auto; column-gap: 12px; }
  /* stacked panels keep the same label column, so the two 0-100% axes still share a scale */
  #rl .rls-grid { grid-template-columns: minmax(0, 1fr); }
}
/* the recipe cards: two columns and a full-width third until base.css stacks .grid3 at 760px */
@media (min-width: 761px) and (max-width: 1080px) {
  #rl .rl-recipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #rl .rl-recipe > :last-child { grid-column: 1 / -1; }
}
@media (min-width: 761px) and (max-width: 900px) {
  #rl .rlp-fg { --rows: 4; }
}
@media (max-width: 860px) {
  #rl .rlt { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  #rl .rlp-top { flex-wrap: wrap; align-items: flex-start; }
  #rl .rlp-title { min-width: 0; flex-wrap: wrap; row-gap: 6px; }
  #rl .rlp-ctrl { flex: 1 1 100%; justify-content: space-between; }
  #rl .rlp-ro { flex: 1; }
  /* the rollout legend sits right under the lanes (rl.js moves it) */
  #rl .rlp-stage > .rlp-legend { grid-column: 1 / -1; margin: -2px 0 0; padding: 0 4px; border-top: 0; }
  #rl .rlp-bar { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  #rl .rlp-ch-t { min-height: 0; }
  #rl .rlp-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: none; gap: 12px; }
  #rl .rlp-lanes { grid-column: 1 / -1; padding: 10px 12px; }
  #rl .rlp-gate { display: none; }
  /* lanes, the rollout legend, then the buffer beside the trainer card, with the rail note in the space under it */
  #rl .rlp-lanes { grid-row: 1; }
  #rl .rlp-stage > .rlp-legend { grid-row: 2; }
  #rl .rlp-buf { grid-column: 1; grid-row: 3; }
  #rl .rlp-train { grid-column: 2; grid-row: 3; align-self: start; }
  #rl .rlp-train::before { display: none; }
  #rl .rlp-rail { grid-column: 2; grid-row: 3; align-self: end; text-align: left; margin: 0; padding: 0 6px 8px 14px; }
  #rl .rlp-fleet { grid-row: 4; }
  /* the fleet: servers beside trainers, the pool in two columns below them */
  #rl .rlp-fleet { padding: 12px; }
  #rl .rlp-fg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "s t" "m m"; gap: 22px 12px; }
  #rl .rlp-fr[data-role="S"] { grid-area: s; }
  #rl .rlp-fr[data-role="T"] { grid-area: t; }
  #rl .rlp-fr[data-role="M"] { grid-area: m; }
  #rl .rlp-slots { grid-auto-flow: row; grid-template-rows: none; grid-auto-rows: 17px; grid-template-columns: minmax(0, 1fr); column-gap: 12px; }
  #rl .rlp-fr[data-role="M"] .rlp-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #rl .rlp-flegend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #rl .rls-panel { padding: 20px 18px 18px; }
  #rl .rls { --rls-lw: 112px; --rls-cg: 12px; }
  #rl .rls-l { font-size: 13px; }
}
@media (min-width: 560px) and (max-width: 760px) {
  #rl .rlp-fr[data-role="M"] .rlp-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 400px) {
  #rl .rlp-fstat { min-height: 4.2em; }
}

/* print: entrance states print finished */
@media print {
  #rl .rls-fill, #rl .rls-ext, #rl .rlm-bar i, #rl .chart .bar-anim { transform: none !important; transition: none !important; }
  #rl .rls-v, #rl .rlm-bar em, #rl .chart .pt, #rl .chart .end, #rl .chart .val-anim { opacity: 1 !important; transition: none !important; }
  #rl .chart path.line { stroke-dashoffset: 0 !important; opacity: 1 !important; transition: none !important; }
  #rl .rlr-chart.rlr-leave { display: none; }
}
