/* ==========================================================================
   agent-kit.css: styles for agent-kit.js (traces, graphs, context windows,
   call maps, memory boards, strips, run grids, swimlanes).
   Every color is a site token, so light/dark switch without a redraw.
   Role palette (shared by every widget):
     user/human  fg        thought  muted      tool call  blue
     result      amber     error    coral      checkpoint brand
   ========================================================================== */
.ak {
  --ak-human: var(--fg);
  --ak-thought: var(--muted);
  --ak-call: var(--sem-secondary);
  --ak-obs: var(--sem-amber);
  --ak-err: var(--sem-coral);
  --ak-ok: var(--sem-primary);
  --ak-stub: var(--line-strong);
  --ak-panel: var(--bg-deep);
  font-family: var(--font-mono);
  color: var(--reading);
}
.ak-ico { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ak-ico.solid { fill: currentColor; stroke: none; }

/* shared tone helpers */
.ak .t-brand, .ak .t-ok { color: var(--ak-ok); }
.ak .t-amber { color: var(--ak-obs); }
.ak .t-coral, .ak .t-bad { color: var(--ak-err); }
.ak .t-blue { color: var(--ak-call); }
.ak .t-muted { color: var(--muted); }

/* ---------- TracePlayer ---------- */
.ak-trace { display: flex; flex-direction: column; gap: 10px; }
.ak-trace-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ak-tbtn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 5px 10px;
  border: 1px solid var(--line-strong); border-radius: 3px;
  background: var(--card-2); color: var(--reading);
  font: 500 11.5px var(--font-mono); cursor: pointer;
}
.ak-tbtn:hover { border-color: var(--brand); color: var(--fg); }
.ak-tbtn[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }
.ak-trace-status { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ak-trace-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ak-trace-cols.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .ak-trace-cols.two { grid-template-columns: minmax(0, 1fr); }
  /* stacked side-by-side runs: drop the raw call line to keep each run short */
  .ak-trace-cols.two .ak-ev-detail { display: none; }
  .ak-trace-cols.two .ak-ev { padding: 3px 4px 3px 0; }
}
.ak-trace-col { background: var(--ak-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 6px; min-width: 0; }
.ak-trace-col.t-bad { border-color: color-mix(in srgb, var(--ak-err) 45%, var(--line)); }
.ak-trace-col.t-ok { border-color: color-mix(in srgb, var(--ak-ok) 45%, var(--line)); }
.ak-trace-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.ak-trace-head .ak-ico { align-self: center; color: var(--muted); }
.ak-trace-title { font-size: 12px; font-weight: 600; color: var(--fg); }
.ak-trace-sub { font-size: 11px; color: var(--muted); }
.ak-trace-list { list-style: none; margin: 0; padding: 0; }
.ak-ev {
  --c: var(--ak-thought);
  position: relative;
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; align-items: start;
  padding: 5px 4px 5px 0;
  transition: opacity 180ms ease, background-color 180ms ease;
}
/* the spine that joins events into one run */
.ak-ev::before { content: ""; position: absolute; left: 11.5px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.ak-ev:first-child::before { top: 14px; }
.ak-ev:last-child::before { bottom: calc(100% - 14px); }
.ak-ev-ico {
  position: relative; z-index: 1;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  background: color-mix(in srgb, var(--c) 12%, var(--card));
  color: var(--c);
}
.ak-ev-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; padding-top: 1px; }
.ak-ev-role { font-size: 11px; letter-spacing: 0.06em; color: var(--c); }
.ak-ev-title { font-family: var(--font-sans); font-size: 13px; line-height: 1.35; color: var(--fg); overflow-wrap: anywhere; }
.ak-ev-detail { font-family: var(--font-mono); font-size: 11px; color: var(--muted); overflow-wrap: anywhere; background: none; padding: 0; }
.ak-ev-badge {
  align-self: center; white-space: nowrap;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 2px;
  border: 1px solid currentColor; color: var(--muted);
}
.ak-ev-badge.t-bad { color: var(--ak-err); background: color-mix(in srgb, var(--ak-err) 12%, transparent); }
.ak-ev-badge.t-ok { color: var(--ak-ok); background: var(--brand-tint); }
.ak-ev-badge.t-blue { color: var(--ak-call); }
.ak-ev-badge.t-amber { color: var(--ak-obs); }
.ak-ev.r-human { --c: var(--ak-human); }
.ak-ev.r-call { --c: var(--ak-call); }
.ak-ev.r-obs { --c: var(--ak-obs); }
.ak-ev.r-error { --c: var(--ak-err); }
.ak-ev.r-checkpoint, .ak-ev.r-done { --c: var(--ak-ok); }
.ak-ev.r-retry { --c: var(--ak-obs); }
.ak-ev.r-dedup { --c: var(--ak-call); }
.ak-ev.r-history, .ak-ev.r-skip, .ak-ev.r-runtime { --c: var(--muted); }
.ak-ev.r-error .ak-ev-title { color: var(--ak-err); }
.ak-ev.r-skip .ak-ev-ico, .ak-ev.r-history .ak-ev-ico { border-style: dashed; background: transparent; }
.ak-ev.r-skip .ak-ev-title, .ak-ev.r-history .ak-ev-title { color: var(--muted); }
.ak-ev.t-bad .ak-ev-title { color: var(--ak-err); }
.ak-ev.is-future { opacity: 0.22; }
.ak-ev.is-cur { background: color-mix(in srgb, var(--c) 9%, transparent); border-radius: 3px; }
.ak-ev.is-cur .ak-ev-ico { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }

/* ---------- StateGraph ---------- */
.ak-graph { width: 100%; }
.ak-graph-svg { display: block; width: 100%; overflow: visible; }
.ak-edge { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.ak-edge.dashed { stroke-dasharray: 4 3; }
.ak-edge.on { stroke: var(--ak-ok); stroke-width: 2; }
.ak-arrow.off { fill: var(--line-strong); }
.ak-arrow.on { fill: var(--ak-ok); }
.ak-edge-label { font: 11px var(--font-mono); fill: var(--muted); }
.ak-edge-label.on { fill: var(--ak-ok); }
.ak-node rect, .ak-node polygon { fill: var(--card); stroke: var(--line-strong); stroke-width: 1.2; transition: stroke 160ms ease, fill 160ms ease; }
.ak-node text { font: 600 11.5px var(--font-mono); fill: var(--muted); }
.ak-node.visited rect, .ak-node.visited polygon { stroke: var(--ak-ok); stroke-width: 1.8; }
.ak-node.visited text { fill: var(--fg); }
.ak-node.active rect, .ak-node.active polygon { fill: var(--brand-tint); stroke-width: 2.4; }
.ak-node.failed rect, .ak-node.failed polygon { stroke: var(--ak-err); stroke-width: 2.2; fill: color-mix(in srgb, var(--ak-err) 10%, var(--card)); }
.ak-node.failed text { fill: var(--ak-err); }
.ak-crash { color: var(--ak-err); }
.ak-crash path { fill: var(--card); }
.ak-ckpt { color: var(--ak-ok); }
.ak-loop { fill: none; stroke: var(--ak-obs); stroke-width: 1.5; stroke-dasharray: 3 2; }
.ak-attempt.ok { fill: var(--ak-ok); }
.ak-attempt.fail { fill: var(--ak-err); }
.ak-note { font: 11px var(--font-mono); fill: var(--muted); }
.ak-note.t-ok { fill: var(--ak-ok); }
.ak-note.t-bad { fill: var(--ak-err); }
.ak-note.t-amber { fill: var(--ak-obs); }
.ak-token { fill: var(--fg); stroke: var(--card); stroke-width: 2; opacity: 0; }
.ak-token.live { opacity: 1; filter: drop-shadow(0 0 4px var(--brand-glow)); }

/* ---------- ContextWindow ---------- */
.ak-ctx { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 14px; align-items: start; }
@media (max-width: 640px) { .ak-ctx { grid-template-columns: minmax(0, 1fr); } }
.ak-ctx-stage { min-width: 0; }
.ak-ctx-svg { display: block; width: 100%; }
.ak-ctx-slot { fill: var(--ak-panel); }
.ak-ctx-overzone { fill: color-mix(in srgb, var(--ak-err) 7%, transparent); }
.ak-ctx-limit { fill: none; stroke: var(--fg); stroke-width: 1.4; opacity: 0.75; }
.ak-ctx-cap { font: 600 11px var(--font-mono); fill: var(--muted); }
.ak-ctx-cap.over { fill: var(--ak-err); }
.ak-ctx-foot { font: 11px var(--font-mono); fill: var(--muted); }
.ak-hatch { fill: var(--ak-err); opacity: 0.55; }
.ak-ctx-overhatch { pointer-events: none; }
.ak-blk { fill: var(--muted); }
.ak-blk.c-sys { fill: var(--muted); opacity: 0.75; }
.ak-blk.c-tool { fill: var(--ak-call); opacity: 0.85; }
.ak-blk.c-reason { fill: var(--ak-ok); opacity: 0.9; }
.ak-blk.c-obs { fill: var(--ak-obs); opacity: 0.85; }
.ak-blk.c-file { fill: color-mix(in srgb, var(--ak-obs) 35%, var(--card)); stroke: var(--ak-obs); stroke-width: 0.8; }
.ak-blk.c-report { fill: color-mix(in srgb, var(--ak-call) 35%, var(--card)); stroke: var(--ak-call); stroke-width: 0.8; }
.ak-blk.c-stub { fill: var(--fg); opacity: 0.72; }
.ak-blk.c-summary { fill: var(--card); stroke: var(--fg); stroke-width: 1; stroke-dasharray: 2 2; }
.ak-blk.c-pinned { fill: var(--brand-tint); stroke: var(--ak-ok); stroke-width: 1.4; }
.ak-blk.is-over { opacity: 0.5; }
.ak-blk.is-fresh { animation: ak-pop 520ms ease-out; }
@keyframes ak-pop { 0% { opacity: 0.15; } 40% { opacity: 1; } 100% { } }
.ak-ctx-side { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 640px) { .ak-ctx-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ak-side-item {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 8px; row-gap: 1px; align-items: center;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ak-panel);
  color: var(--muted);
}
.ak-side-item .ak-side-label { font-size: 11px; }
.ak-side-item .ak-side-val { grid-column: 2; font-size: 12px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
.ak-side-item.t-amber { color: var(--ak-obs); }
.ak-side-item.t-blue { color: var(--ak-call); }
.ak-side-item.t-ok { color: var(--ak-ok); }
.ak-side-item.t-bad { color: var(--ak-err); border-color: color-mix(in srgb, var(--ak-err) 40%, var(--line)); }
.ak-side-item.is-off { opacity: 0.45; }
.ak-side-item.is-off .ak-side-val { font-weight: 400; color: var(--muted); }

/* ---------- CallMap ---------- */
.ak-callmap-svg { display: block; width: 100%; }
.ak-call-bg { fill: var(--card); }
.ak-call-tools { fill: var(--ak-call); opacity: 0.7; }
.ak-call-line { fill: var(--muted); opacity: 0.55; }
.ak-call-fog { fill: var(--ak-err); }
.ak-call-frame { fill: none; stroke: var(--fg); stroke-width: 1.3; }
.ak-call-frame.t-bad { stroke: var(--ak-err); }
.ak-call-frame.t-ok { stroke: var(--ak-ok); }
.ak-call-frame.t-amber { stroke: var(--ak-obs); }
.ak-call-label { font: 600 11.5px var(--font-mono); fill: var(--fg); }
.ak-call-sub { font: 11px var(--font-mono); fill: var(--muted); }
.ak-call-sub.t-bad { fill: var(--ak-err); }
.ak-call-sub.t-ok { fill: var(--ak-ok); }
.ak-call-mini { font: 11px var(--font-mono); fill: var(--muted); }
.ak-call-edge { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.ak-call-bracket { fill: none; stroke: var(--muted); stroke-width: 1.2; }
.ak-doc { stroke-width: 1; }
.ak-doc.g0 { fill: color-mix(in srgb, var(--ak-ok) 55%, var(--card)); stroke: var(--ak-ok); }
.ak-doc.g1 { fill: color-mix(in srgb, var(--ak-ok) 22%, var(--card)); stroke: var(--ak-ok); }
.ak-doc.unread { fill: none; stroke: var(--line-strong); stroke-dasharray: 2 1.5; }

/* ---------- CardBoard ---------- */
.ak-board { display: grid; grid-template-columns: minmax(0, 1fr) 168px; gap: 14px; align-items: start; }
@media (max-width: 640px) { .ak-board { grid-template-columns: minmax(0, 1fr); } }
.ak-board-head, .ak-bin-title { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.ak-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 5px; }
@media (max-width: 480px) { .ak-slots { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ak-card {
  --c: var(--line-strong);
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 6px;
  min-height: 30px; padding: 4px 7px;
  border: 1px solid var(--c); border-radius: 3px; background: var(--card);
  font-size: 11.5px; color: var(--reading);
}
.ak-card .ak-ico { color: var(--muted); }
.ak-card-num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.4em; text-align: right; }
.ak-card-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ak-card-meta { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
/* dense board (many slots): small numbered tiles; the rule, pinned and summary cards keep their text */
.ak-board.is-dense .ak-slots { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.ak-board.is-dense .ak-card { grid-template-columns: auto auto; justify-content: center; min-height: 26px; padding: 2px 4px; gap: 3px; }
.ak-board.is-dense .ak-card:not(.t-rule):not(.t-pinned):not(.t-summary) .ak-card-text,
.ak-board.is-dense .ak-card:not(.t-rule):not(.t-pinned):not(.t-summary) .ak-card-meta {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.ak-board.is-dense .ak-card.t-rule, .ak-board.is-dense .ak-card.t-pinned { grid-column: span 4; grid-template-columns: auto auto minmax(0, 1fr); justify-content: stretch; }
.ak-card.t-rule { --c: var(--ak-ok); background: var(--brand-tint); color: var(--fg); }
.ak-card.t-rule .ak-ico { color: var(--ak-ok); }
.ak-card.t-pinned { --c: var(--ak-ok); border-width: 2px; background: var(--brand-tint); color: var(--fg); }
.ak-card.t-pinned .ak-ico { color: var(--ak-ok); }
.ak-card.t-delete { --c: color-mix(in srgb, var(--ak-obs) 60%, transparent); }
.ak-card.t-delete .ak-ico { color: var(--ak-obs); }
.ak-card.t-summary { --c: var(--muted); grid-template-columns: auto minmax(0, 1fr); border-style: dashed; color: var(--muted); grid-column: 1 / -1; }
.ak-card.t-summary b { color: var(--fg); font-weight: 600; }
.ak-card.t-summary .ak-card-text { white-space: normal; }
.ak-card.is-empty { border-style: dashed; border-color: var(--line); background: transparent; }
.ak-card.is-fresh { animation: ak-slide 420ms var(--ease-out-expo, ease-out); }
@keyframes ak-slide { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.ak-bin { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 8px 10px; background: var(--ak-panel); }
.ak-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.ak-chip { min-width: 24px; padding: 1px 5px; text-align: center; font-size: 11px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 2px; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.ak-chip.t-delete { color: var(--ak-obs); border-color: color-mix(in srgb, var(--ak-obs) 45%, transparent); }
.ak-chip.t-rule { color: var(--ak-err); border-color: var(--ak-err); background: color-mix(in srgb, var(--ak-err) 12%, transparent); font-weight: 700; }
.ak-bin-empty { margin: 0; font-size: 11px; color: var(--muted); }

/* ---------- StepStrip ---------- */
.ak-strip { position: relative; padding-bottom: 16px; user-select: none; }
.ak-strip-cells { display: flex; gap: 2px; height: 30px; cursor: pointer; touch-action: none; }
.ak-strip-cells.dense { gap: 0; }
.ak-cell {
  --c: var(--line-strong);
  position: relative; flex: 1 1 0; min-width: 0;
  background: color-mix(in srgb, var(--c) 35%, var(--ak-panel));
  border-radius: 1px;
}
.ak-strip-cells.dense .ak-cell { border-right: 1px solid var(--card); }
.ak-cell.t-ok { --c: var(--ak-ok); }
.ak-cell.t-bad { --c: var(--ak-err); }
.ak-cell.t-amber { --c: var(--ak-obs); }
.ak-cell.t-blue { --c: var(--ak-call); }
.ak-cell.t-muted { --c: var(--line-strong); }
.ak-cell.is-after { opacity: 0.4; }
.ak-cell::after { position: absolute; inset: 0; display: grid; place-items: center; font: 700 11px var(--font-mono); line-height: 1; }
.ak-cell.m-check::after { content: "✓"; color: var(--ak-ok); }
.ak-cell.m-cross::after { content: "✕"; color: var(--ak-err); }
.ak-cell.m-flag::after { content: "◆"; color: var(--fg); font-size: 8px; }
.ak-cell.m-dot::after { content: "•"; color: var(--fg); }
.ak-cell.m-tick { box-shadow: inset 0 3px 0 var(--ak-call); }
.ak-cell.b-ok { box-shadow: inset 0 -4px 0 var(--ak-ok); }
.ak-cell.b-bad { box-shadow: inset 0 -4px 0 var(--ak-err); }
.ak-cell.m-tick.b-ok { box-shadow: inset 0 3px 0 var(--ak-call), inset 0 -4px 0 var(--ak-ok); }
.ak-cell.is-cur { outline: 2px solid var(--fg); outline-offset: 1px; z-index: 1; opacity: 1; }
.ak-strip-ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; }
.ak-tick { position: absolute; transform: translateX(-50%); font-size: 11px; line-height: 14px; color: var(--muted); white-space: nowrap; }

/* ---------- RunGrid ---------- */
.ak-rungrid { border-radius: var(--radius); padding: 2px; }
.ak-rungrid:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.ak-rungrid-cells { display: grid; gap: 2px; cursor: pointer; }
.ak-run { position: relative; aspect-ratio: 1; border-radius: 2px; background: var(--line-strong); }
.ak-run.t-ok { background: color-mix(in srgb, var(--ak-ok) 80%, var(--card)); }
.ak-run.t-amber { background: color-mix(in srgb, var(--ak-obs) 80%, var(--card)); }
.ak-run.t-bad { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ak-err); }
.ak-run.t-bad::after { content: ""; position: absolute; inset: 28%; background: linear-gradient(45deg, transparent 42%, var(--ak-err) 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, var(--ak-err) 42% 58%, transparent 58%); }
.ak-run.t-muted { background: color-mix(in srgb, var(--muted) 30%, var(--card)); }
.ak-run.is-cur { outline: 2px solid var(--fg); outline-offset: 1px; z-index: 1; }
.ak-rungrid-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 11px; color: var(--reading); }
.ak-key { display: inline-flex; align-items: center; gap: 6px; }
.ak-key i { width: 9px; height: 9px; border-radius: 2px; background: var(--line-strong); }
.ak-key.t-ok i { background: var(--ak-ok); }
.ak-key.t-amber i { background: var(--ak-obs); }
.ak-key.t-bad i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ak-err); }
.ak-key.t-muted i { background: color-mix(in srgb, var(--muted) 45%, var(--card)); }

/* ---------- Swimlanes ---------- */
.ak-lanes { display: flex; flex-direction: column; gap: 4px; }
.ak-lane { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
.ak-lane:hover { border-color: var(--line); }
.ak-lane.is-active { border-color: color-mix(in srgb, var(--brand) 55%, transparent); background: var(--brand-tint); }
.ak-lane-head { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ak-lane-label { font-size: 11.5px; font-weight: 600; color: var(--fg); }
.ak-lane-sub { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ak-lane-sub.t-ok { color: var(--ak-ok); }
.ak-lane-sub.t-amber { color: var(--ak-obs); }
.ak-lane-sub.t-bad { color: var(--ak-err); }
.ak-lane-track { min-width: 0; }
.ak-lane-svg { display: block; width: 100%; }
@media (max-width: 560px) { .ak-lane { grid-template-columns: minmax(0, 1fr); gap: 4px; } .ak-lane-head { flex-direction: row; flex-wrap: wrap; gap: 2px 10px; } }
.ak-lane-rail { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.ak-lb.k-ok { fill: var(--ak-ok); opacity: 0.85; }
.ak-lb.k-redone { fill: var(--muted); opacity: 0.4; }
.ak-lb.k-ckpt { fill: var(--ak-ok); opacity: 0.35; }
.ak-lb.k-replay { fill: var(--ak-obs); opacity: 0.9; }
.ak-lb.k-wait { fill: color-mix(in srgb, var(--ak-call) 22%, var(--card)); stroke: var(--ak-call); stroke-width: 1; stroke-dasharray: 3 2; }
.ak-lb.k-held { fill: color-mix(in srgb, var(--ak-err) 15%, var(--card)); stroke: var(--ak-err); stroke-width: 1; stroke-dasharray: 3 2; }
.ak-lb-fail { fill: var(--ak-err); }
.ak-lb-text { font: 600 11px var(--font-mono); fill: var(--fg); }
.ak-lb-text.k-wait { fill: var(--ak-call); }
.ak-lb-text.k-held { fill: var(--ak-err); }
.ak-lane-end { font: 600 11px var(--font-mono); fill: var(--muted); }
.ak-lane-end.t-ok { fill: var(--ak-ok); }
.ak-lane-end.t-bad { fill: var(--ak-err); }
.ak-lane-axis { font-size: 11px; color: var(--muted); text-align: right; padding: 0 8px; }

/* ---------- generic: a compact legend row of role swatches ---------- */
.ak-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font: 11px var(--font-mono); color: var(--muted); margin: 8px 0 0; padding: 0; list-style: none; }
.ak-legend li { display: inline-flex; align-items: center; gap: 6px; }
.ak-sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.ak-sw.sys { background: var(--muted); }
.ak-sw.tool { background: var(--sem-secondary); }
.ak-sw.reason { background: var(--sem-primary); }
.ak-sw.obs { background: var(--sem-amber); }
.ak-sw.stub { background: var(--fg); opacity: 0.45; width: 3px; }
.ak-sw.file { background: color-mix(in srgb, var(--sem-amber) 35%, var(--card)); box-shadow: inset 0 0 0 1px var(--sem-amber); }
.ak-sw.report { background: color-mix(in srgb, var(--sem-secondary) 35%, var(--card)); box-shadow: inset 0 0 0 1px var(--sem-secondary); }
.ak-sw.summary { box-shadow: inset 0 0 0 1px var(--fg); }
.ak-sw.over { background: repeating-linear-gradient(45deg, var(--sem-coral) 0 2px, transparent 2px 4px); }

/* visually hidden text alternative */
.ak-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .ak-blk.is-fresh, .ak-card.is-fresh { animation: none; }
  .ak-ev { transition: none; }
}

/* framed stage for kit widgets (pairs with .canvas-wrap.framed) */
.canvas-wrap.framed.ak-frame { padding: 12px 14px; }
@media (max-width: 480px) { .canvas-wrap.framed.ak-frame { padding: 10px 8px; } }
.ak-sw.lane-ok { background: var(--sem-primary); opacity: 0.85; }
.ak-sw.lane-redone { background: var(--muted); opacity: 0.4; }
.ak-sw.lane-fail { background: var(--sem-coral); width: 3px; }
.ak-sw.lane-replay { background: var(--sem-amber); }
.ak-sw.lane-wait { background: color-mix(in srgb, var(--sem-secondary) 22%, var(--card)); box-shadow: inset 0 0 0 1px var(--sem-secondary); }
.ak-sw.lane-held { background: color-mix(in srgb, var(--sem-coral) 15%, var(--card)); box-shadow: inset 0 0 0 1px var(--sem-coral); }
