/* ===== Agent Flow ============================================ */
/* Replaces the rect-grid for the agent → steps level. The shape is
   intentionally different from sibling levels because agent execution
   is a sequence, not a peer collection. */

.zc-agent-flow-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.af-root {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 32px;
  flex: 1;
  min-height: 0;
}

/* Outcome strip — what the agent ACCOMPLISHED */
.af-outcome {
  border: 1px solid var(--line);
  background: var(--rect-bg);
  padding: 18px 22px;
  position: relative;
}
.af-outcome::before {
  content: "OUTCOMES · 24h";
  position: absolute;
  top: -7px;
  left: 14px;
  font-family: var(--type-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  background: var(--bg);
  padding: 0 6px;
}
.af-outcome-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
}
.af-outcome-num {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.af-outcome-val {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1;
}
.af-outcome-lab {
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

/* Narrative */
.af-narrative {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 14px;
}
.af-narrative-eyebrow {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}
.af-narrative-text {
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.02em;
  flex: 1;
}
.af-toggle {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--ink-2);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  cursor: pointer;
  text-transform: lowercase;
}
.af-toggle:hover:not(:disabled) {
  border-color: var(--ink-2);
  color: var(--ink);
}
.af-toggle:disabled { opacity: 0.4; cursor: default; }
.af-toggle-on { border-style: solid; color: var(--ink); border-color: var(--ink-2); }

/* Flow row */
.af-flow-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
  padding-bottom: 8px;
}
.af-flow {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-height: 200px;
  padding: 12px 0;
}

/* Input/output bookends */
.af-flow-input,
.af-flow-output {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 16px 18px;
  min-width: 130px;
  border: 1px dashed var(--line);
  background: transparent;
}
.af-flow-input-eyebrow {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}
.af-flow-input-label {
  font-family: var(--type-mono);
  font-size: 13px;
  color: var(--ink);
}

/* Step nodes */
.af-step {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.af-step-frame {
  position: relative;
  width: 220px;
  min-height: 168px;
  padding: 14px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--rect-bg);
  border: 1px solid var(--line);
  transition: border-color 200ms, transform 200ms, opacity 200ms, box-shadow 200ms, background 200ms;
}
.af-step:hover .af-step-frame {
  transform: translateY(-1px);
}

/* ---------- Per-role static stratification ---------- */
.af-step-thinking .af-step-frame {
  border-color: var(--ink-2);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--rect-bg) inset, 2px 2px 0 var(--line);
}
.af-step-thinking .af-step-glyph { color: var(--accent); }
.af-step-thinking .af-step-label { font-weight: 600; font-size: 16px; }

.af-step-tool .af-step-frame { border-color: var(--ink-2); }
.af-step-io .af-step-frame { background: transparent; border-style: dashed; }
.af-step-io .af-step-label { color: var(--ink-2); }

.af-step-plumbing .af-step-frame {
  opacity: 0.55;
  border-style: dotted;
  width: 170px;
  min-height: 130px;
  padding: 10px 12px 22px;
}
.af-step-plumbing .af-step-label { font-size: 12px; }

/* ---------- Status: pending (waiting in line) ---------- */
.af-step-status-pending .af-step-frame {
  /* default border, no dim */
}

/* ---------- Status: running (currently executing) ---------- */
.af-step-status-running .af-step-frame {
  border-color: var(--accent);
  border-style: solid;
}
.af-step-status-running .af-corner { border-color: var(--accent); }
.af-step-status-running .af-step-status-dot {
  background: var(--accent);
  animation: af-blink 0.9s ease-in-out infinite;
}

/* ---------- Status: done (completed this pass) ---------- */
.af-step-status-done .af-step-frame {
  border-color: var(--status-healthy);
  border-style: solid;
}
.af-step-status-done .af-corner { border-color: var(--status-healthy); }
.af-step-status-done .af-step-status-dot {
  display: none;
}

/* ---------- Head row ---------- */
.af-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
}
.af-step-glyph {
  font-size: 14px;
  color: var(--ink-2);
}
.af-step-type { font-family: var(--type-mono); }
.af-step-status-dot {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  opacity: 0.6;
}
.af-step-status-pending .af-step-status-dot { background: var(--ink-3); opacity: 0.4; }

.af-step-label {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.2;
  text-wrap: balance;
}

/* ---------- Detail row (per-type richer info) ---------- */
.af-step-detail {
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.35;
  border-left: 1.5px solid var(--line);
  padding-left: 8px;
  margin: 2px 0;
}
.af-step-detail-prompt { font-style: italic; }
.af-step-detail-quote {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.af-step-detail-args {
  font-size: 10.5px;
  color: var(--ink-3);
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Meta chip row ---------- */
.af-step-meta {
  margin-top: auto;
  font-family: var(--type-mono);
  font-size: 9.5px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
}
.af-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}
.af-chip-k {
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.af-chip-v {
  color: var(--ink-2);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.af-step-status-running .af-chip { border-color: var(--ink-2); }

/* ---------- Running progress bar (bottom edge) ---------- */
.af-step-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--line-2);
  overflow: hidden;
}
.af-step-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  animation: af-fill 1.6s linear forwards;
  box-shadow: 0 0 8px var(--accent);
}

/* ---------- Animations ---------- */
@keyframes af-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}
@keyframes af-fill {
  0%   { width: 0%; }
  100% { width: 100%; }
}
@keyframes af-arrow-flow {
  0%   { background-position: 0 0; }
  100% { background-position: 14px 0; }
}

/* ---------- Arrow upgrades (state-aware) ---------- */
.af-arrow {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
}
.af-arrow-line {
  position: absolute;
  left: 4px;
  right: 10px;
  top: 50%;
  height: 1px;
  background: currentColor;
  transform: translateY(-0.5px);
}
.af-arrow-tip {
  position: absolute;
  right: 2px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
  transform: translateY(-50%);
  font-size: 0;
  color: inherit;
}
.af-arrow-tip::before { content: ""; }
.af-arrow-traversed { color: var(--accent); }
.af-arrow-traversed .af-arrow-line { height: 1.5px; }

/* ---------- Input/output active state ---------- */
.af-flow-input-active {
  border-style: solid !important;
  border-color: var(--accent) !important;
}
.af-flow-input-meta {
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Reuse cad corner ticks */
.af-corner {
  position: absolute;
  width: 6px;
  height: 6px;
  border-color: var(--ink-3);
  border-style: solid;
  border-width: 0;
}
.af-corner-tl { top: -1px; left: -1px;  border-top-width: 1px; border-left-width: 1px; }
.af-corner-tr { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
.af-corner-bl { bottom: -1px; left: -1px;  border-bottom-width: 1px; border-left-width: 1px; }
.af-corner-br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

@media (max-width: 1100px) {
  .af-outcome-row { grid-template-columns: repeat(2, 1fr); }
}
