/* Tools: the controls of the request editor. WHERE the list and the editor sit
 * in the Studio belongs to agent-workspace.css; this file only draws them. */
#agent-tools-panel { min-width: 0; }
.tools-help { margin: 4px 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--c-ink-3); overflow-wrap: anywhere; }
.tools-doc { white-space: nowrap; color: var(--c-ink-2); font-size: 12.5px; font-weight: 500; text-decoration: none; }
.tools-doc:hover { text-decoration: underline; text-underline-offset: 3px; }

/* The call phase is a scope bar: a tinted pill under the chosen phase and
 * nothing under the others. It is deliberately quieter than the Studio's
 * segmented control above it, so the two read as a hierarchy — the part of
 * the agent, then the moment within it — rather than as two of the same. */
.tools-phases { display: flex; gap: 2px; }
.tools-phase { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 5px 12px; border: 0; border-radius: var(--ui-r-control); background: transparent; color: var(--c-ink-2); font: 500 13px/1 var(--sans); letter-spacing: -0.006em; }
.tools-phase:hover { background: var(--ui-fill-2); color: var(--c-ink); }
.tools-phase:active { transform: none; background: var(--ui-fill-3); }
.tools-phase[aria-selected=true] { background: var(--ui-fill-3); color: var(--c-ink); }
.tools-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font: 600 11px/1 var(--sans); font-variant-numeric: tabular-nums; background: var(--ui-fill); color: var(--c-ink-3); }
.tools-count:empty { display: none; }
.tools-phase[aria-selected=true] .tools-count { background: var(--c-surface); color: var(--c-ink-2); }

.tools-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.tools-primary { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 6px 12px; border: 0; border-radius: var(--ui-r-control); background: var(--c-ink); color: var(--c-paper); font: 600 12.5px/1 var(--sans); }
.tools-primary:hover { background: var(--c-ink-2); }
.tools-toolbar > .tool-field { margin: 0; }
.tools-toolbar > .tool-field > .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tools-toolbar-caption { font-size: 12px; color: var(--c-ink-3); margin-left: auto; }

.tools-empty { padding: 44px 24px 40px; text-align: center; background: var(--c-surface); border-radius: var(--ui-r-card); box-shadow: var(--ui-card); }
.tools-empty-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 50%; background: var(--ui-fill-2); color: var(--c-ink-3); font-size: 19px; }
.tools-empty h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.012em; margin: 0 0 6px; }
.tools-empty .tools-help { max-width: 380px; margin: 0 auto 18px; font-size: 13px; }

/* ── the list ── A source list: rows on the canvas, the open one raised. */
.tools-list { display: flex; flex-direction: column; gap: 2px; }
.tool-card { min-width: 0; border-radius: 10px; background: transparent; transition: background-color 120ms ease, box-shadow 120ms ease; }
@media (hover: hover) and (pointer: fine) { .tool-card:not(.is-open):hover { background: var(--ui-fill-2); } }
.tool-card.is-open { background: var(--c-surface); box-shadow: var(--ui-raise); }
.tool-summary { display: block; }
.tool-open { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 8px; width: 100%; min-width: 0; margin: 0; padding: 10px 10px 6px; border: 0; border-radius: 10px; background: transparent; color: var(--c-ink); text-align: left; }
.tool-open:hover { background: transparent; }
.tool-open:active { transform: none; }
.tool-order { flex: 0 0 18px; padding-top: 2px; font: 500 11px/1.4 var(--mono); color: var(--c-ink-3); font-variant-numeric: tabular-nums; }
.tool-identity { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tool-identity strong { font-size: 13.5px; font-weight: 600; letter-spacing: -0.008em; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-url { color: var(--c-ink-3); font-size: 11.5px; line-height: 1.4; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tool-badge { flex: none; margin-top: 1px; padding: 3px 6px; border-radius: 5px; background: var(--ui-fill); color: var(--c-ink-2); font: 600 10px/1.2 var(--mono); letter-spacing: 0.02em; }
.tool-card.is-disabled .tool-identity { color: var(--c-ink-3); }
.tool-check { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.5; color: var(--c-ink-2); cursor: pointer; }
.tool-summary > .tool-check { margin: 0 10px 0 36px; padding: 0 0 10px; font-size: 11.5px; color: var(--c-ink-3); }
.tool-execution input { width: 15px; height: 15px; accent-color: var(--c-ink); flex-shrink: 0; }

/* A setting that is on or off is a switch, not a tick — the tool row's
 * Enabled, call analysis, and keeping an agent as a draft. The checkbox stays
 * a real <input type=checkbox> underneath: same events, same label. */
.tool-summary > .tool-check input, #analysis-enabled, .workspace-switch input {
  appearance: none; -webkit-appearance: none; position: relative; flex: none;
  width: 28px; height: 16px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--ui-fill-3); transition: background-color 180ms ease; }
.tool-summary > .tool-check input::before, #analysis-enabled::before, .workspace-switch input::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(27, 26, 22, 0.25);
  transition: transform 220ms var(--ui-spring); }
.tool-summary > .tool-check input:checked, #analysis-enabled:checked, .workspace-switch input:checked { background: var(--c-ink); }
.tool-summary > .tool-check input:checked::before, #analysis-enabled:checked::before, .workspace-switch input:checked::before { transform: translateX(12px); }

/* ── the editor ── */
.tool-editor { padding: 20px; }
.tool-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.tool-label { font: 500 12px/1.35 var(--sans); color: var(--c-ink-2); }
.tool-field input, .tool-field textarea, .tool-field select { box-sizing: border-box; width: 100%; min-width: 0; background: var(--c-surface); color: var(--c-ink); font: 400 13.5px/1.45 var(--sans); border: 1px solid var(--ui-edge); border-radius: var(--ui-r-control); padding: 8px 11px; transition: border-color 120ms ease, box-shadow 120ms ease; }
.tool-field textarea { resize: vertical; min-height: 76px; }
.tool-field input::placeholder, .tool-field textarea::placeholder { color: var(--c-ink-3); }
.tool-field input:hover, .tool-field textarea:hover, .tool-field select:hover { border-color: rgba(27, 26, 22, 0.24); }
.tool-field input:focus, .tool-field textarea:focus, .tool-field select:focus { outline: none; border-color: rgba(27, 26, 22, 0.34); box-shadow: var(--ui-ring); }
.tool-field input:disabled { background: var(--c-paper); color: var(--c-ink-3); }
.tool-field [aria-invalid=true] { border-color: var(--c-alarm); box-shadow: 0 0 0 3.5px rgba(171, 35, 23, 0.1); }
.tool-field .tools-help { margin: 0; font-weight: 400; }
.tool-field input.tool-code, .tool-field textarea.tool-code, .tool-code { font-family: var(--mono); font-size: 12.5px; line-height: 1.7; }
.tool-field > .variable-insert { align-self: flex-end; margin-top: -2px; }
/* Section tabs inside the editor: plain words over a 2px rule — the third and
 * lightest level under the Studio's control and the phase scope bar. */
.tool-editor-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--ui-sep); margin: 0 -20px 20px; padding: 0 20px; }
.tool-editor-tab { position: relative; flex: none; background: transparent; border: 0; border-radius: 0; color: var(--c-ink-3); font: 500 13px/1 var(--sans); padding: 11px 0 12px; }
.tool-editor-tab:hover { background: transparent; color: var(--c-ink); }
.tool-editor-tab:active { transform: none; }
.tool-editor-tab[aria-selected=true] { color: var(--c-ink); }
.tool-editor-tab[aria-selected=true]::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--c-ink); }
.tool-endpoint { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; }
/* Disclosure rows: a chevron that turns, a hairline between them. */
.tool-details { border-top: 1px solid var(--ui-sep); padding: 0; margin: 4px 0 0; }
.tool-details > summary { display: flex; align-items: center; gap: 10px; padding: 13px 0; list-style: none; cursor: pointer; font: 500 13px/1.3 var(--sans); color: var(--c-ink); }
.tool-details > summary::-webkit-details-marker { display: none; }
.tool-details > summary::before { content: ''; flex: none; width: 6px; height: 6px; margin: 0 2px 0 1px; border-right: 1.6px solid var(--c-ink-3); border-bottom: 1.6px solid var(--c-ink-3); transform: rotate(-45deg); transition: transform 200ms var(--ui-spring); }
.tool-details[open] > summary::before { transform: translate(1px, -2px) rotate(45deg); }
.tool-details-body { margin: 2px 0 14px; }
.tool-details-body > .tool-details { margin-left: 0; }
.tool-pair { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(130px, 1.6fr) 30px; align-items: end; gap: 8px; }
.tool-pair .tool-field { margin-bottom: 10px; }
.tool-icon-button { display: grid; place-items: center; width: 30px; height: 36px; margin: 0 0 10px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--c-ink-3); font-size: 18px; font-weight: 400; }
.tool-icon-button:hover { background: var(--ui-fill-2); color: var(--c-ink); }
/* The editor's own small verbs (＋ Add parameter, ＋ Add condition, Store
 * secret …) are tinted, not boxed: they act on the form, they are not it. */
.tool-editor button.ghost.small, .workspace-panel button.ghost.small, .workspace-card button.ghost { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; margin: 0; padding: 5px 10px; border: 0; border-radius: 7px; background: var(--ui-fill-2); color: var(--c-ink); font: 500 12.5px/1 var(--sans); }
.tool-editor button.ghost.small:hover, .workspace-panel button.ghost.small:hover, .workspace-card button.ghost:hover { background: var(--ui-fill-3); }
.tool-execution { border: 0; padding: 0; margin: 20px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool-execution legend { margin-bottom: 10px; font-size: 12px; font-weight: 500; color: var(--c-ink-2); }
.tool-execution-choice { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border: 1px solid var(--ui-edge); border-radius: 10px; cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.tool-execution-choice:has(:checked) { border-color: var(--c-ink); box-shadow: 0 0 0 1px var(--c-ink); }
.tool-execution-choice strong { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.tool-execution-choice small { font-size: 12px; color: var(--c-ink-3); line-height: 1.5; display: block; }
.tool-condition-row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(100px, 1fr) minmax(75px, 1fr) 30px; gap: 8px; align-items: end; }
.tool-condition-row .tool-field { margin-bottom: 10px; }
.tool-condition-row .tool-icon-button { grid-column: 4; }
.tool-editor-foot { border-top: 1px solid var(--ui-sep); padding-top: 12px; margin-top: 20px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.tool-remove { color: var(--c-alarm-ink); background: transparent; border: 0; border-radius: 7px; font: 500 12.5px/1 var(--sans); padding: 8px; margin-left: -8px; }
.tool-remove:hover { background: var(--c-alarm-bg); }
.tool-reorder { display: flex; gap: 6px; }
.tool-reorder button { min-height: 28px; margin: 0; padding: 5px 10px; border: 0; border-radius: 7px; background: var(--ui-fill-2); color: var(--c-ink-2); font: 500 12px/1 var(--sans); }
.tool-reorder button:hover { background: var(--ui-fill-3); color: var(--c-ink); }
.tools-error { font-size: 12.5px; color: var(--c-alarm-ink); line-height: 1.5; overflow-wrap: anywhere; }
.tools-error:empty { display: none; }
.tools-response-empty { padding: 24px 0 6px; }
.tool-result { margin-top: 20px; border-radius: 10px; box-shadow: 0 0 0 1px var(--ui-sep); overflow: hidden; }
.tool-result-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--ui-fill-2); font-size: 12px; }
.tool-result > .tools-help, .tool-result > .tools-error { margin: 12px; }
.tool-result > .tool-details { margin: 0; padding: 0 12px; }
.tool-result pre { max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: 12px/1.6 var(--mono); }
.tool-response-table { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 12.5px; }
.tool-response-table th { text-align: left; color: var(--c-ink-3); font: 500 11.5px/1.3 var(--sans); letter-spacing: 0; text-transform: none; }
.tool-response-table th, .tool-response-table td { border-bottom: 1px solid var(--ui-sep); padding: 10px 12px; vertical-align: top; overflow-wrap: anywhere; }
.tool-response-table th:nth-child(2) { width: 90px; }
.tool-response-table .tool-check { font-size: 12px; }
.tool-value-type { color: var(--c-ink-3); }
.tool-argument { display: grid; grid-template-columns: 1fr 120px; gap: 0 12px; padding: 16px 0; border-bottom: 1px solid var(--ui-sep); margin-bottom: 14px; }
.tool-argument > .tool-field:nth-child(3) { grid-column: 1 / -1; }
.tool-argument > .tool-remove { text-align: right; justify-self: end; }
.tool-field, .tool-check, .tool-execution-choice { text-transform: none; letter-spacing: normal; font-weight: 400; }
.tool-field input, .tool-field textarea { font-weight: 400; }

@media (max-width: 760px) {
  .tools-phases { flex: 1; }
  .tools-phase { flex: 1; justify-content: center; padding: 5px 6px; font-size: 12.5px; }
  .tools-toolbar-caption { display: none; }
  .tool-editor { padding: 14px 14px 0; }
  .tool-editor-tabs { margin: 0 -14px 16px; padding: 0 14px; gap: 18px; overflow-x: auto; }
  .tool-execution { grid-template-columns: 1fr; }
  .tool-condition-row { grid-template-columns: 1fr 1fr 30px; padding-top: 10px; border-bottom: 1px solid var(--ui-sep); }
  .tool-condition-row .tool-field:first-child { grid-column: 1 / 3; grid-row: 1; }
  .tool-condition-row .tool-icon-button { grid-column: 3; grid-row: 1; }
  .tool-condition-row .tool-field { grid-row: 2; }
  .tool-pair { grid-template-columns: 1fr 30px; }
  .tool-pair .tool-field { grid-column: 1; }
  .tool-pair .tool-icon-button { grid-column: 2; grid-row: 1 / 3; }
  .tool-field input, .tool-field textarea, .tool-field select { font-size: 16px; }
  .tool-response-table th, .tool-response-table td { padding: 9px 7px; }
  .tool-response-table th:nth-child(2) { width: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .tool-summary > .tool-check input::before, #analysis-enabled::before, .workspace-switch input::before,
  .tool-details > summary::before { transition: none; }
}
