/* agent-run.css — agent-run.html: the configuration panel and the step-through over the stage.
 * .ar-app is a tall scroll track (the script sets its height) with one pinned screen, .ar-pin.
 * .ar-app[data-phase] is "pick" or "run"; [data-renderer="static"] has no WebGL and shows text only. */
.ar-app {
  --ar-top: 64px;
  --ar-gutter: clamp(20px, 3.6vw, 56px);
  --ar-panel: min(540px, 41vw);
  --ar-violet: oklch(74% 0.15 292);
  --ar-red: oklch(68% 0.2 22);
  --ar-cool: oklch(80% 0.12 195);
  position: relative;
  height: calc(100svh - var(--ar-top));
  background: var(--bg-canvas);
  color: var(--text-primary);
  overflow-anchor: none;
}
.ar-pin { position: sticky; top: var(--ar-top); height: calc(100svh - var(--ar-top)); overflow: hidden; }
.ar-app[data-phase="run"] .ar-canvas { cursor: pointer; }
.ar-hint { font-size: 14px; color: var(--text-tertiary); }
.ar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ar-app[data-renderer="static"] .ar-canvas { display: none; }
.ar-scrim { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, var(--bg-canvas) 0, var(--bg-canvas) 40%, transparent 50%); }
.ar-fade { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: var(--bg-canvas); }
.ar-app[data-phase="pick"] .ar-run, .ar-app[data-phase="run"] .ar-pick { display: none; }

.ar-kicker { margin: 0; font: 400 13px/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--track-2); }
html[lang="zh-CN"] .ar-kicker { font-family: var(--font-sans); font-size: 15px; letter-spacing: .04em; text-transform: none; }

/* ---- the configuration panel ---- */
.ar-pick { position: absolute; left: var(--ar-gutter); top: 0; bottom: 0; width: var(--ar-panel); padding-block: clamp(18px, 3.2svh, 36px); overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; }
.ar-pick h1 { margin: 10px 0 0; font-size: clamp(30px, 2.9vw, 44px); font-weight: 650; line-height: 1.08; letter-spacing: -.028em; }
.ar-pick h1 { text-wrap: wrap; }
.ar-pick h1 em { display: block; font-style: normal; color: var(--title-dim, var(--text-secondary)); }
html[lang="zh-CN"] .ar-pick h1 { letter-spacing: 0; line-height: 1.24; }
.ar-lead { margin: 12px 0 0; font-size: 17px; line-height: 1.5; color: var(--text-secondary); text-wrap: pretty; }
.ar-field { margin: clamp(12px, 2.2svh, 20px) 0 0; padding: 0; border: 0; min-width: 0; }
.ar-field legend { padding: 0; margin-bottom: 8px; font: 400 12px/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-tertiary); }
html[lang="zh-CN"] .ar-field legend { font-family: var(--font-sans); font-size: 14px; letter-spacing: .02em; text-transform: none; }
.ar-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ar-options--chips { display: flex; flex-wrap: wrap; }
.ar-option { position: relative; display: block; cursor: pointer; }
.ar-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ar-option-face { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-hairline, var(--line)); border-radius: 10px; background: color-mix(in oklab, var(--surface-1) 72%, transparent); font-size: 15px; font-weight: 550; line-height: 1.2; color: var(--text-secondary); transition: border-color .16s, background .16s, color .16s; }
.ar-option-face svg { width: 18px; height: 18px; flex: none; }
.ar-option:hover .ar-option-face { color: var(--text-primary); border-color: color-mix(in oklab, var(--text-primary) 34%, transparent); }
.ar-option input:checked + .ar-option-face { color: var(--text-primary); border-color: var(--track-2); background: color-mix(in oklab, var(--track-2) 14%, var(--surface-1)); }
.ar-option input:focus-visible + .ar-option-face { outline: 2px solid var(--track-1); outline-offset: 2px; }
.ar-status { margin-top: clamp(12px, 2.2svh, 20px); padding: 12px 14px; border: 1px solid color-mix(in oklab, var(--track-2) 45%, transparent); border-radius: 10px; background: color-mix(in oklab, var(--track-2) 8%, var(--surface-1)); }
.ar-status.is-recorded { border-color: color-mix(in oklab, var(--track-1) 45%, transparent); background: color-mix(in oklab, var(--track-1) 8%, var(--surface-1)); }
.ar-status b { display: block; font-size: 15px; font-weight: 620; }
.ar-status span { display: block; margin-top: 3px; font-size: 14.5px; line-height: 1.45; color: var(--text-secondary); text-wrap: pretty; }
.ar-pick-actions { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.ar-link { padding: 0; border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ar-link:hover { color: var(--text-primary); }
.ar-app[data-busy] .ar-pick-actions .button { opacity: .6; cursor: progress; }

/* ---- the run ---- */
.ar-run { position: absolute; inset: 0; pointer-events: none; }
.ar-run > * { pointer-events: auto; }
.ar-step { position: absolute; left: var(--ar-gutter); top: clamp(14px, 2.4svh, 26px); bottom: 104px; width: var(--ar-panel); display: flex; flex-direction: column; --a: var(--ar-violet); }
.ar-step[data-tone="fail"] { --a: var(--ar-red); }
.ar-step[data-tone="fix"] { --a: var(--ar-cool); }
.ar-step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font: 400 13px/1.4 var(--font-mono); color: var(--text-tertiary); }
.ar-tag { padding: 2px 8px; border: 1px solid color-mix(in oklab, var(--a) 55%, transparent); border-radius: 6px; color: var(--a); letter-spacing: .08em; text-transform: uppercase; }
html[lang="zh-CN"] .ar-step-head { font-family: var(--font-sans); font-size: 14px; }
html[lang="zh-CN"] .ar-tag { letter-spacing: .02em; text-transform: none; }
.ar-step-scroll { flex: 1; min-height: 0; margin-top: 12px; overflow-y: auto; scrollbar-width: thin; outline: 0; }
.ar-step h2 { margin: 0; font-size: clamp(26px, 2.3vw, 36px); font-weight: 650; line-height: 1.14; letter-spacing: -.024em; }
html[lang="zh-CN"] .ar-step h2 { letter-spacing: 0; line-height: 1.3; }
.ar-step-body { margin: 10px 0 0; font-size: 18px; line-height: 1.5; color: var(--text-secondary); text-wrap: pretty; }
.ar-say { margin: 12px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--a); }
.ar-say small { display: block; font: 400 12px/1.4 var(--font-mono); letter-spacing: .08em; color: var(--text-tertiary); }
.ar-say p { margin: 2px 0 0; font-size: 16px; line-height: 1.45; color: var(--text-primary); }
html[lang="zh-CN"] .ar-say small { font-family: var(--font-sans); font-size: 13px; letter-spacing: .02em; }
.ar-facts { display: grid; gap: 1px; margin-top: 14px; overflow: hidden; border: 1px solid var(--border-hairline, var(--line)); border-radius: 10px; background: var(--border-hairline, var(--line)); }
.ar-fact { padding: 10px 14px 11px; background: color-mix(in oklab, var(--surface-1) 90%, transparent); }
.ar-fact span { display: block; font-size: 13.5px; line-height: 1.35; color: var(--a); }
.ar-fact p, .ar-fact li { font-size: 16px; line-height: 1.42; color: var(--text-primary); font-variant-numeric: tabular-nums; text-wrap: pretty; }
.ar-fact p { margin: 3px 0 0; }
.ar-fact ul { display: grid; gap: 2px; margin: 4px 0 0; padding: 0; list-style: none; }
.ar-log { margin-top: 10px; }
.ar-log summary { width: fit-content; font-size: 14px; color: var(--text-tertiary); cursor: pointer; }
.ar-log summary:hover { color: var(--text-secondary); }
.ar-log summary:focus-visible { outline: 2px solid var(--track-1); outline-offset: 2px; border-radius: 3px; }
.ar-trace { display: grid; gap: 1px; margin-top: 8px; overflow: hidden; border: 1px solid var(--border-hairline, var(--line)); border-radius: 10px; background: var(--border-hairline, var(--line)); }
.ar-trace-row { padding: 9px 12px 10px; background: color-mix(in oklab, var(--surface-1) 90%, transparent); }
.ar-trace-row span { display: block; font: 400 11.5px/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--a); }
html[lang="zh-CN"] .ar-trace-row span { font-family: var(--font-sans); font-size: 13px; letter-spacing: .02em; text-transform: none; }
.ar-trace-row pre { margin: 4px 0 0; font: 400 13px/1.5 var(--font-mono); color: var(--text-primary); white-space: pre-wrap; overflow-wrap: anywhere; }
.ar-note { margin: 12px 0 0; font-size: 16px; line-height: 1.45; color: var(--text-primary); text-wrap: pretty; }
.ar-note::before { content: "∴ "; color: var(--a); }

/* the provenance line and live counters, top right */
.ar-hud { position: absolute; right: var(--ar-gutter); top: clamp(14px, 2.4svh, 26px); display: grid; justify-items: end; gap: 8px; max-width: min(620px, 52vw); }
.ar-prov { margin: 0; text-align: right; font-size: 14px; line-height: 1.4; color: var(--text-secondary); }
.ar-prov b { color: var(--text-primary); font-weight: 600; }
.ar-prov--pick { color: var(--track-2); }
.ar-stats { display: flex; gap: clamp(12px, 1.6vw, 24px); margin: 0; padding: 8px 14px; border: 1px solid var(--border-hairline, var(--line)); border-radius: 10px; background: color-mix(in oklab, var(--surface-1) 76%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ar-stats div { display: grid; gap: 1px; }
.ar-stats dt { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.ar-stats dd { margin: 0; font: 400 17px/1.3 var(--font-mono); white-space: nowrap; }
.ar-stats dd small { font-size: 12px; color: var(--text-tertiary); }

/* the controls along the bottom */
.ar-bar { position: absolute; left: var(--ar-gutter); right: var(--ar-gutter); bottom: 18px; display: flex; align-items: flex-end; gap: clamp(16px, 2.4vw, 36px); }
.ar-rail { flex: 1; min-width: 0; display: flex; gap: 12px; }
.ar-rail-group { flex: 1 1 0; min-width: 0; display: grid; gap: 6px; }
.ar-rail-label { font-size: 13px; line-height: 1.2; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-rail-ticks { display: flex; gap: 3px; }
.ar-tick { flex: 1; height: 24px; padding: 10px 0; border: 0; background: none; cursor: pointer; }
.ar-tick::before { content: ""; display: block; height: 4px; border-radius: 2px; background: color-mix(in oklab, var(--text-primary) 18%, transparent); transition: background .16s; }
.ar-tick:hover::before { background: color-mix(in oklab, var(--text-primary) 42%, transparent); }
.ar-tick.is-done::before { background: color-mix(in oklab, var(--track-1) 70%, transparent); }
.ar-tick.is-on::before { background: var(--track-2); }
.ar-tick:focus-visible { outline: 2px solid var(--track-1); outline-offset: 1px; border-radius: 3px; }
.ar-controls { display: flex; align-items: center; gap: 10px; flex: none; }
.ar-controls .button[disabled] { opacity: .4; cursor: default; }
.ar-ending { display: flex; align-items: center; gap: 10px; }
.ar-ending[hidden], .ar-controls [hidden] { display: none; }
.ar-footnote { margin: 0; padding: 18px var(--ar-gutter, 24px); font-size: 14px; line-height: 1.55; color: var(--text-tertiary); border-top: 1px solid var(--border-hairline, var(--line)); }

/* ---- stacked: the picture on top, the panel below it, all inside the pinned screen ---- */
@media (max-width: 760px), (max-aspect-ratio: 11/10) {
  .ar-app { --ar-panel: 100%; }
  .ar-pin { display: flex; flex-direction: column; }
  .ar-canvas { position: relative; inset: auto; height: 30svh; flex: none; }
  .ar-scrim, .ar-fade { bottom: auto; height: 30svh; }
  .ar-scrim { background: linear-gradient(0deg, var(--bg-canvas) 0, transparent 22%); }
  .ar-app[data-renderer="static"] .ar-scrim { display: none; }
  .ar-pick { position: relative; inset: auto; width: auto; flex: 1; min-height: 0; padding: 8px var(--ar-gutter) 16px; }
  .ar-run { position: relative; inset: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 0 var(--ar-gutter); }
  .ar-app[data-phase="pick"] .ar-run, .ar-app[data-phase="run"] .ar-pick { display: none; }
  .ar-step { position: relative; left: auto; top: auto; bottom: auto; width: auto; flex: 1; min-height: 0; }
  .ar-hud { position: relative; right: auto; top: auto; max-width: none; justify-items: start; gap: 4px; }
  .ar-prov { text-align: left; font-size: 12.5px; }
  .ar-stats { width: 100%; justify-content: space-between; flex-wrap: nowrap; gap: 8px; padding: 5px 8px; }
  .ar-stats dt { font-size: 10px; }
  .ar-stats dd { font-size: 13px; }
  .ar-bar { position: relative; left: auto; right: auto; bottom: auto; flex-direction: column; align-items: stretch; gap: 4px; padding-bottom: 10px; }
  .ar-rail { gap: 6px; }
  .ar-rail-label { display: none; }
  .ar-tick { height: 14px; padding: 5px 0; }
  .ar-controls, .ar-ending { justify-content: flex-end; gap: 8px; }
  .ar-controls .ar-link { font-size: 13px; margin-right: auto; }
  .ar-controls .button { height: 40px; font-size: 14px; }
  .ar-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ar-options--chips { display: flex; }
}
@media (prefers-reduced-motion: reduce) { .ar-option-face, .ar-tick::before { transition: none; } }
