/* Agent canvas, the run graph. Uses the host page's design tokens throughout
   so it inherits light/dark without a second palette to keep in sync. */

.ac {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  margin: 0 0 18px;
  overflow: hidden;
}

.ac-head {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-hover);
}
.ac-title { font-size: 13px; font-weight: 650; color: var(--text); letter-spacing: -0.01em; }
.ac-legend {
  margin-left: auto; display: flex; align-items: center; gap: 12px;
  font-size: 11px; color: var(--text-3);
}
.ac-k { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.ac-k.running { background: var(--accent); }
.ac-k.done    { background: var(--green); }
.ac-k.failed  { background: var(--red); }
.ac-k.skipped { background: var(--text-3); opacity: 0.5; }

/* The graph can be wider than the panel; it scrolls in its own box so the page
   body never scrolls sideways. */
.ac-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.ac-stage { position: relative; }

.ac-wires { position: absolute; inset: 0; pointer-events: none; }
.ac-edge {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
  transition: stroke 0.3s ease;
}
.ac-edge.live { stroke: var(--accent); opacity: 0.55; }
.ac-edge.flow {
  stroke-dasharray: 5 7;
  animation: ac-flow 0.9s linear infinite;
}
@keyframes ac-flow { to { stroke-dashoffset: -12; } }

/* ── nodes ─────────────────────────────────────────────────────────────── */
.ac-node {
  position: absolute;
  width: 208px; min-height: 60px;
  display: flex; flex-direction: column; gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius:8px;
  background: var(--bg-card);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}
.ac-node[data-nodata] { cursor: default; }
.ac-node:hover  { border-color: var(--accent-border); transform: translateY(-1px); }
.ac-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-node.sel    { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.ac-node.queued  { opacity: 0.52; }
.ac-node.done    { border-color: var(--green-border); background: var(--green-bg); }
.ac-node.failed  { border-color: var(--red-border);   background: var(--red-bg); }
.ac-node.skipped { opacity: 0.45; border-style: dashed; }
.ac-node.running {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ac-node-top { display: flex; align-items: center; gap: 7px; }
.ac-kind { font-size: 11px; color: var(--text-3); flex: none; }
.ac-node-label {
  font-size:13px; font-weight: 600; color: var(--text);
  line-height: 1.3; flex: 1; min-width: 0;
}

/* State is carried by shape and position as well as color, so the graph stays
   readable without relying on hue alone. */
.ac-state { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.ac-node.done .ac-state    { background: var(--green); }
.ac-node.failed .ac-state  { background: var(--red); }
.ac-node.skipped .ac-state { background: transparent; border: 1.5px dashed var(--text-3); }
.ac-node.running .ac-state {
  background: var(--accent);
  animation: ac-pulse 1.1s ease-in-out infinite;
}
@keyframes ac-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 0 0 5px transparent; }
}

.ac-note { font-size: 11px; color: var(--text-3); line-height: 1.35; }
.ac-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; font-size:11px;
}
.ac-ms { color: var(--text-3); font-variant-numeric: tabular-nums; }
.ac-peek { color: var(--accent); font-weight: 600; }

/* ── inspector ─────────────────────────────────────────────────────────── */
.ac-inspect {
  border-top: 1px solid var(--border-light);
  background: var(--bg-hover);
  padding: 13px 16px 15px;
}
.ac-i-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.ac-i-head strong { font-size: 13px; color: var(--text); }
.ac-i-meta { font-size: 11px; color: var(--text-3); }
.ac-i-x {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  color: var(--text-3); font-size:18px; line-height: 1; padding: 0 2px;
}
.ac-i-x:hover { color: var(--text); }

.ac-kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 7px 16px; margin: 0; }
.ac-kv dt { font-size:12px; color: var(--text-3); }
.ac-kv dd {
  margin: 0; font-size:13px; color: var(--text);
  font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; gap: 5px;
}
.ac-i-empty { margin: 0; font-size:13px; color: var(--text-3); }

.ac-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size:12px;
}
.ac-chip-s { font-style: normal; font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em; }
.ac-chip-s.cited       { color: var(--green); }
.ac-chip-s.not-cited   { color: var(--text-3); }
.ac-chip-s.unavailable { color: var(--yellow); }

@media (prefers-reduced-motion: reduce) {
  .ac-edge.flow { animation: none; stroke-dasharray: none; }
  .ac-node.running .ac-state { animation: none; }
  .ac-node { transition: none; }
  .ac-node:hover { transform: none; }
}

@media (max-width: 640px) {
  .ac-legend { display: none; }
}

/* ── time by phase ────────────────────────────────────────────────────────
   A progress bar says the run took 40s. This says which phase took 30 of
   them, which is the only version of that fact anyone can act on. */
.ac-timeline {
  border-top: 1px solid var(--border-light);
  background: var(--bg-card);
  padding: 12px 16px 14px;
}
.ac-tl-head {
  display: flex; align-items: baseline; gap: 10px;
  font-size:12px; font-weight: 650; color: var(--text-2);
  margin-bottom: 9px;
}
.ac-tl-total { margin-left: auto; font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; }

.ac-tl-bars { display: flex; flex-direction: column; gap: 4px; }
.ac-tl-row {
  display: grid; grid-template-columns: minmax(96px, 150px) 1fr auto;
  align-items: center; gap: 10px;
  width: 100%; padding: 3px 5px;
  border: 1px solid transparent; border-radius: 6px;
  background: none; font: inherit; text-align: left; cursor: pointer;
}
.ac-tl-row:hover { background: var(--bg-hover); }
.ac-tl-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ac-tl-row.sel { border-color: var(--accent-border); background: var(--accent-glow); }

.ac-tl-label {
  font-size:12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ac-tl-track { height: 7px; border-radius: 4px; background: var(--bg-active); overflow: hidden; }
.ac-tl-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.ac-tl-fill.done   { background: var(--green); }
.ac-tl-fill.failed { background: var(--red); }
.ac-tl-fill.skipped { background: var(--text-3); opacity: .4; }
/* The slowest phase is the one worth looking at, so it is the one that stands out. */
.ac-tl-fill.slow { background: var(--yellow); }
.ac-tl-ms { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }

.ac-i-copy {
  border: 1px solid var(--border); background: var(--bg-hover);
  color: var(--text-2); font: inherit; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius:4px; cursor: pointer; margin-left: auto;
}
.ac-i-copy:hover { color: var(--text); border-color: var(--accent-border); }
.ac-i-head .ac-i-x { margin-left: 6px; }

@media (max-width: 560px) {
  .ac-tl-row { grid-template-columns: 1fr auto; }
  .ac-tl-track { grid-column: 1 / -1; }
}
