/* =============================================================================
   panel-timeline.css — an agent@2 reply's tool calls (panel-timeline.js).
   =============================================================================

   A chain (thinking and calls between two runs of text) is a `.thought-line`
   and keeps panel-thoughtline.css; text runs are `.chat-prose` and keep
   panel.html's. What is new is what a chain opens onto, and the tool group:
   one quiet line per call, in the trace's own register, the app's mark first
   and the state last.

   EVERY ROW IS ONE LINE TALL IN EVERY STATE. The spinner, ✓ and ✕ share one
   fixed box, the words ellipsize rather than wrap, and the result summary sits
   under the row only once the reader opens it. A call finishing never moves
   anything, which is what keeps a 12-step turn free of layout shift.

   Colours are tokens only (test-theme.js): the ink ladder for state, and
   --danger-rgb for a call that failed.
   ============================================================================= */

.atl-tools {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
  margin: 2px 0 10px;
}
.atl-tools:last-child { margin-bottom: 0; }

.atl-tool { min-width: 0; }
.atl-tool-head {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; height: 26px;
  padding: 0 4px 0 2px;
  border-radius: var(--r-ctl-sm, 6px);
  font: 400 var(--fs-md)/26px var(--sans);
  color: var(--t-meta);
  cursor: default;
  outline: none;
}
.atl-tool[data-has-detail] .atl-tool-head { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.atl-tool[data-has-detail] .atl-tool-head:hover { color: var(--t-secondary); background: var(--s-quiet); }
.atl-tool-head:focus-visible { box-shadow: var(--lit-rim); }

.atl-tool-glyph {
  flex: none; display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  color: var(--t-faint);
}
.atl-tool-glyph svg { width: 14px; height: 14px; display: block; }
.atl-tool-glyph .cn-logo { width: 14px; height: 14px; }

.atl-tool-text {
  flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.atl-tool[data-state="running"] .atl-tool-text { color: var(--t-secondary); }

/* How long a call took (the server's count), right-aligned before the mark.
   Empty while it runs, so the row's height and the mark's box never move. */
.atl-tool-ms {
  flex: none; margin-left: auto;
  font: 400 var(--fs-xs)/26px var(--mono);
  color: var(--t-faint);
  font-variant-numeric: tabular-nums;
}
.atl-tool-ms:empty { display: none; }
.atl-tool-ms:empty + .atl-tool-mark { margin-left: auto; }

/* The state, in one fixed box so the row never changes width or height. */
.atl-tool-mark {
  flex: none; display: inline-grid; place-items: center;
  width: 14px; height: 14px;
  font: 600 var(--fs-sm)/1 var(--sans);
  color: var(--t-faint);
}
.atl-tool[data-state="failed"] .atl-tool-mark { color: rgba(var(--danger-rgb), .9); }
.atl-tool[data-state="failed"] .atl-tool-text { color: var(--t-faint); }
.atl-spin {
  display: block; width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--hair);
  border-top-color: var(--t-secondary);
  animation: atl-spin .8s linear infinite;
}
@keyframes atl-spin { to { transform: rotate(360deg); } }

.atl-tool-chev {
  flex: none; width: 10px; opacity: 0;
  transition: transform var(--dur-2) ease, opacity var(--dur-3) ease;
}
.atl-tool[data-has-detail] .atl-tool-chev { opacity: .55; }
.atl-tool[data-open] .atl-tool-chev { transform: rotate(90deg); }

/* What came back, under the row it came back to, once asked for. */
.atl-tool-detail {
  margin: 2px 0 6px 26px; padding: 6px 0 2px 10px;
  border-left: 1px solid var(--hair);
  font: 400 var(--fs-md)/1.55 var(--sans); color: var(--t-meta);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.atl-tool-detail[hidden] { display: none; }

/* ---- a chain: one line over a run of thinking and calls ------------------
   The line is PXThoughtLine's own; what it opens onto is this. The hairline
   is `.tl-steps`'s, so the chain reads as the same kind of trace. Thoughts are
   text, open as soon as the chain is: the summary is the content, and folding
   it a second time behind "Thought for 1.2s" would hide the only thing there. */
.atl-chain .tl-steps:empty { display: none; }
.atl-chain .tl-body {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
  margin: 0 0 4px 12px; padding: 4px 0 2px 10px;
  border-left: 1px solid var(--hair);
}
.atl-thought {
  font: 400 var(--fs-base)/1.55 var(--sans);
  color: var(--t-meta);
  white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 2px 4px 2px 2px;
}
.atl-thought[hidden] { display: none; }
.atl-chain .tl-body .atl-tools { margin: 0; }
/* A settled line with no clock: it names its last step, or "Done thinking". */
.thought-line.atl-chain[data-untimed] .tl-timer { display: none; }

/* Spoken, not shown: the message's live region and each row's state word. */
.atl-vh {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.atl-vh, .atl-tool-chev, .atl-tool-mark { -webkit-user-select: none; user-select: none; }

@media (prefers-reduced-motion: reduce) {
  /* A still mark where the spinner was: the words already say "running". */
  .atl-spin { animation: none; border-top-color: var(--hair); background: var(--t-faint); transform: scale(.5); }
  .atl-tool-chev { transition: none; }
}

/* ONE BOX PER STEP (2026-11-22). A multi-step turn is several bubbles, like a person
   sending several messages: the earlier steps sit close above the last, which keeps
   the sources, the actions and the bottom-left tail. */
.chat-bubble.assistant.atl-part { margin-bottom: 4px; }
.chat-bubble.assistant.atl-part + .chat-bubble.assistant { margin-top: 0; }
