/* ══ TEST LINKS ══════════════════════════════════════════════════════════════
 * The owner's side of test links (test-links.js): the line under the test
 * panel's buttons, Agent Studio → Test links, the sheet that makes or edits a
 * link, and the call inspector's "Test link feedback" (inspector.js). Built
 * from the console's own parts — workspace cards, the modal, the chip and the
 * state capsule — so nothing here is a new idiom, only their arrangement. */

/* ── the test panel's way in ─────────────────────────────────────────────── */
.rail-share { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--ui-sep); }
.rail-share[hidden] { display: none; }
.rail-share-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0; font-size: 12px; }
.rail-share-btn svg { width: 14px; height: 14px; flex: none; }
/* The phone's dock holds the one button that starts or ends a call; the way
   to a test link is in Agent Studio → Test links there. */
.dock .rail-share { display: none; }

/* ── Agent Studio → Test links ───────────────────────────────────────────── */
.workspace-heading .tl-new { flex: none; margin: 0; min-height: 32px; padding: 7px 14px;
  border-radius: var(--ui-r-control); font: 600 12.5px/1 var(--sans); }
.tl-card { padding: 4px 0; }
.tl-list { display: flex; flex-direction: column; }
.tl-state { margin: 0; padding: 18px; font-size: 13px; line-height: 1.55; color: var(--c-ink-3); }
.tl-state-bad { color: var(--c-alarm-ink); }
.tl-state .linkbtn { padding: 0; font-size: 12.5px; }
.tl-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 22px 18px; }
.tl-empty strong { font: 600 14px/1.35 var(--sans); color: var(--c-ink); }
.tl-empty p { margin: 0 0 6px; max-width: 58ch; font-size: 13px; line-height: 1.55; color: var(--c-ink-3); }
.tl-empty button { margin: 0; }

.tl-link { padding: 14px 18px; border-top: 1px solid var(--ui-sep); }
.tl-link:first-child { border-top: 0; }
.tl-link[data-state=expired], .tl-link[data-state=revoked] { background: var(--ui-fill-2); }
.tl-link:first-child[data-state=expired], .tl-link:first-child[data-state=revoked] { border-radius: var(--ui-r-card) var(--ui-r-card) 0 0; }
.tl-link:last-child[data-state=expired], .tl-link:last-child[data-state=revoked] { border-radius: 0 0 var(--ui-r-card) var(--ui-r-card); }
.tl-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tl-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.tl-label { font: 600 14px/1.35 var(--sans); letter-spacing: -0.008em; color: var(--c-ink); overflow-wrap: anywhere; }
/* State is the Studio's capsule with a lamp: green open, amber paused,
   grey for a link that no longer works. */
.tl-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 7px; border-radius: 999px;
  background: var(--ui-fill-2); color: var(--c-ink-2); font: 500 11.5px/1.2 var(--sans); white-space: nowrap; }
.tl-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c-ink-4); }
.tl-status[data-state=active] { background: var(--accent-bg); color: var(--accent); }
.tl-status[data-state=active]::before { background: var(--accent); }
.tl-status[data-state=paused] { background: var(--c-open-bg); color: var(--c-open-ink); }
.tl-status[data-state=paused]::before { background: var(--c-open); }
.tl-acts { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; flex: none; }
.tl-acts button, .tl-acts .tl-act { margin: 0; min-height: 28px; padding: 6px 10px; font-size: 12px;
  border-radius: var(--ui-r-control); }
/* The WhatsApp link is an <a> (it opens wa.me), dressed as the Studio's
   quiet button beside it (agent-tools.css · .workspace-card button.ghost). */
.tl-acts .tl-act { display: inline-flex; align-items: center; border: 0; background: var(--ui-fill-2);
  color: var(--c-ink); font: 500 12.5px/1 var(--sans); text-decoration: none; }
.tl-acts .tl-act:hover { background: var(--ui-fill-3); }
.workspace-card .tl-acts button.ghost.tl-revoke:hover { color: var(--c-alarm-ink); background: var(--c-alarm-bg); }
.tl-meta, .tl-sub, .tl-feedback { margin: 5px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--c-ink-2);
  font-variant-numeric: tabular-nums; }
.tl-sub { color: var(--c-ink-3); }
.tl-feedback { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; }
.tl-dot { color: var(--c-ink-4); white-space: pre; }
.tl-fb-ok { color: var(--accent); }
.tl-quiet { color: var(--c-ink-3); }
.tl-paused { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 10px 0 0; padding: 9px 12px;
  border-radius: 10px; background: var(--c-open-bg); color: var(--c-open-ink); font-size: 12.5px; line-height: 1.5; }
.tl-paused button { margin: 0; min-height: 28px; padding: 6px 12px; font-size: 12px; border-radius: var(--ui-r-control); }
.tl-calls-toggle { margin: 8px 0 0; padding: 0; font-size: 12px; }

/* A link's calls: one row per call, the whole row opens it in the inspector.
   Rows carry data-h, the inspector's own mark for "a call lives here". */
.tl-calls { margin: 10px 0 0; border-radius: 10px; background: var(--c-paper); box-shadow: inset 0 0 0 1px var(--ui-sep); overflow: hidden; }
.tl-calls[hidden] { display: none; }
.tl-calls .tl-state { padding: 12px 14px; font-size: 12.5px; }
/* Each row is its own grid, so no column may size to its content: fixed
   tracks and fractions only, or the columns drift from row to row. */
.tl-call { display: grid; grid-template-columns: 116px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 64px 148px;
  gap: 10px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--ui-sep);
  font-size: 12.5px; line-height: 1.4; color: var(--c-ink-2); font-variant-numeric: tabular-nums; cursor: pointer; }
.tl-call > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-call:hover { background: var(--ui-fill-2); }
.tl-call:focus-visible { outline: 2px solid var(--c-ink); outline-offset: -2px; }
.tl-call.sel { background: var(--ui-fill); color: var(--c-ink); }
.tl-call-head { border-top: 0; padding-top: 8px; padding-bottom: 6px; font-size: 11.5px; color: var(--c-ink-3); cursor: default; }
.tl-call-head:hover { background: none; }
.tl-call-when { color: var(--c-ink); }
.tl-call-fb { display: flex; gap: 8px; }

/* ── the sheet ───────────────────────────────────────────────────────────── */
/* Several parts below set their own display; `hidden` still wins. */
.tl-sheet [hidden] { display: none !important; }
.tl-sheet .tl-opt { font-weight: 400; color: var(--c-ink-3); }
.tl-sheet .tl-lede { margin: -6px 0 12px; }
.tl-sheet .modal-section > h3 { margin-bottom: 10px; }
.tl-sheet .tl-none { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--ui-sep); }
.tl-sheet .tl-dirty { margin-bottom: 18px; }
.tl-tag { display: inline-block; padding: 2px 7px; border-radius: 999px; background: var(--ui-fill-2);
  color: var(--c-ink-3); font: 500 11px/1.3 var(--sans); white-space: nowrap; }

/* Versions: a check per version; a chosen one opens the name the tester sees. */
.tl-versions { display: flex; flex-direction: column; gap: 5px; }
.tl-version { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 7px 12px;
  border-radius: var(--ui-r-control); box-shadow: inset 0 0 0 1px var(--ui-edge); }
.tl-version.on { box-shadow: inset 0 0 0 1.5px var(--c-ink); }
.tl-version-pick { display: flex; align-items: center; gap: 10px; flex: 1 1 200px; min-width: 0; cursor: pointer; }
.tl-version-pick:has(:disabled) { opacity: 0.5; cursor: default; }
.tl-version-name { display: flex; flex-direction: column; min-width: 0; }
.tl-version-name strong { font: 600 13px/1.35 var(--sans); color: var(--c-ink); }
.tl-version-name small { font-size: 12px; line-height: 1.4; color: var(--c-ink-3); }
.tl-version-as { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; }
.tl-version-as > span { flex: none; font-size: 12px; color: var(--c-ink-3); }
.tl-sheet .tl-version-as input { min-height: 32px; padding: 6px 10px; }

/* Ends: the Studio's chip, one of them chosen. */
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--ui-edge);
  border-radius: 999px; cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.tl-sheet .tl-chip { font-size: 12.5px; color: var(--c-ink-2); }
.tl-sheet .tl-chip input { width: 13px; height: 13px; margin: 0; }
.tl-chip:has(:checked) { border-color: var(--c-ink); box-shadow: 0 0 0 1px var(--c-ink); }
.tl-sheet .tl-chip:has(:checked) { color: var(--c-ink); }
.tl-chip:has(:focus-visible) { outline: 2px solid var(--c-ink); outline-offset: 2px; }
.tl-custom { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
.tl-sheet .tl-custom input { width: 96px; }
#tl-ends-line { margin-top: 8px; }
.tl-estimate { margin: 0; }

/* Variables: name, how it's set, then the value or the tester's label. */
.tl-vars { display: flex; flex-direction: column; gap: 8px; }
.tl-var { display: grid; grid-template-columns: minmax(110px, 0.9fr) 150px minmax(0, 2fr); gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--ui-sep); }
.tl-var:first-child { border-top: 0; padding-top: 0; }
.tl-var-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
.tl-var-name code, .tl-scen-val code { font: 500 12px/1.4 var(--mono); color: var(--c-ink); overflow-wrap: anywhere; }
.tl-var-body { display: flex; gap: 8px; min-width: 0; }
.tl-var-body > * { flex: 1 1 0; min-width: 0; }
.tl-var-body .modal-help { align-self: center; }
.tl-mini { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tl-sheet .tl-mini > span { font-size: 11.5px; font-weight: 400; color: var(--c-ink-3); }
.tl-var[data-mode=tester] { align-items: end; }
.tl-var[data-mode=tester] > .tl-var-name, .tl-var[data-mode=tester] > .tl-var-mode { margin-bottom: 0; align-self: end; }

/* Scenarios: small cards, numbered, each with its own values. */
.tl-scenarios { display: flex; flex-direction: column; gap: 10px; margin: 0 0 10px; }
.tl-scen { padding: 12px; border-radius: var(--ui-r-card); background: var(--c-sunk); }
.tl-scen-head { display: flex; align-items: center; gap: 10px; }
.tl-scen-n { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-surface); box-shadow: var(--ui-raise); font: 600 11.5px/1 var(--sans); color: var(--c-ink-2); }
.tl-scen-head .tl-scen-title { flex: 1 1 auto; }
.tl-scen-x { flex: none; padding: 0; font-size: 12px; }
.tl-scen-vals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 10px 0 0 32px; }
.tl-scen-val { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl-add { margin: 0; }

/* Tools: a check, the owner's own name for it, when it runs, one line of what it does. */
.tl-tools { display: flex; flex-direction: column; }
.tl-tool { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--ui-sep); cursor: pointer; }
.tl-tool:first-child { border-top: 0; padding-top: 2px; }
.tl-tool-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tl-tool-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.tl-tool-name { font: 600 12.5px/1.4 var(--mono); color: var(--c-ink); overflow-wrap: anywhere; }
.tl-sheet .tl-tool-desc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 400; color: var(--c-ink-3); }

/* What the tester sees: switches in two columns. */
.tl-toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; }
.tl-sheet .tl-toggle { margin: 4px 0 8px; }
.tl-sub-h { margin: 14px 0 6px; font: 600 12px/1.4 var(--sans); color: var(--c-ink-2); }

/* Done: the link, and the three ways to send it. */
.tl-done-lede { margin: 0 0 14px; font-size: 13.5px; line-height: 1.55; color: var(--c-ink-2); }
.tl-done-lede strong { color: var(--c-ink); }
.tl-share { margin-bottom: 10px; }
.tl-share-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.tl-share-acts a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px;
  border: 1px solid var(--c-line-strong); border-radius: var(--ui-r-control); background: var(--c-surface);
  color: var(--c-ink-2); font: 500 13px/1 var(--sans); text-decoration: none; }
.tl-share-acts a:hover { color: var(--c-ink); border-color: var(--c-ink-4); }

/* ── the call inspector: a test link's feedback ──────────────────────────── */
.itf-who { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--c-ink-2); }
.itf-rating { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--c-ink); }
.itf-rating[data-rating=down] { color: var(--c-alarm-ink); }
.itf-rating[data-rating=none] { font-weight: 400; color: var(--c-ink-3); }
.itf-comment { margin: 8px 0 0; padding: 8px 12px; border-left: 2px solid var(--c-line-strong);
  font-size: 12.5px; line-height: 1.55; color: var(--c-ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.itf-flags { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.itf-flags li { padding: 8px 10px; border: 1px solid var(--c-line); border-radius: var(--r-sm); background: var(--c-surface); }
.itf-line { display: block; font-size: 12.5px; line-height: 1.5; color: var(--c-ink); overflow-wrap: anywhere; }
.itf-note { margin: 4px 0 0; font-size: 12px; line-height: 1.5; color: var(--c-ink-2); overflow-wrap: anywhere; }
.itf-note > span { color: var(--c-ink-3); }
.itf-approved { margin: 10px 0 0; padding: 8px 10px; border-radius: var(--r-sm); background: var(--accent-bg); }
.itf-approved > p:first-child { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--accent); }

/* ── narrower ────────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .tl-call { grid-template-columns: 104px minmax(0, 1fr) minmax(0, 1fr) 56px 136px; }
  .tl-call > span:nth-child(4) { display: none; }
}
@media (max-width: 760px) {
  .tl-link { padding: 12px 14px; }
  .tl-top { flex-direction: column; gap: 8px; }
  .tl-acts { justify-content: flex-start; }
  .tl-acts button, .tl-acts .tl-act { min-height: 34px; }
  .workspace-heading .tl-new { width: 100%; min-height: 40px; }
  /* A call is a small card: when and who on top, the rest under it. */
  .tl-call, .tl-call:not(.tl-call-head) { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 12px; }
  .tl-call-head { display: none; }
  .tl-call > span:nth-child(4) { display: block; }
  .tl-call > span:nth-child(1) { grid-column: 1; grid-row: 1; }
  .tl-call > span:nth-child(2) { grid-column: 1; grid-row: 2; }
  .tl-call > span:nth-child(n+3) { grid-column: 1 / -1; color: var(--c-ink-3); font-size: 12px; }
  .tl-call > span:nth-child(n+3)::before { content: attr(data-label) ": "; }
  .tl-call > span.tl-call-fb { grid-column: 2; grid-row: 1 / 3; align-self: start; display: flex; flex-direction: column;
    align-items: flex-end; gap: 2px; color: var(--c-ink-2); }
  .tl-call > span.tl-call-fb::before { content: none; }
}
@media (max-width: 640px) {
  .tl-var { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tl-var-body { grid-column: 1 / -1; flex-direction: column; }
  .tl-scen-vals { grid-template-columns: minmax(0, 1fr); margin-left: 0; }
  .tl-toggles { grid-template-columns: minmax(0, 1fr); }
  .tl-version-as { flex-basis: 100%; }
  .tl-share { flex-wrap: wrap; }
  .tl-share input { flex-basis: 100%; }
  .tl-share button { flex: 1 1 auto; min-height: 42px; }
  .tl-share-acts a { flex: 1 1 auto; justify-content: center; min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) { .tl-chip { transition: none; } }
