/* ── Knowledge ────────────────────────────────────────────────────────────────
 * Phone numbers' page shape (.agents-page / .agents-heading here, the inset
 * grouped list and the state pill from numbers.css), the Studio's cards
 * (agent-workspace.css) and the model pages' table (.stm-table). Only layout
 * lives here; every colour is an app.css token. */
[data-knowledge-nav][hidden], [data-agent-panel][hidden] { display: none !important; }
.kb-page [hidden] { display: none !important; }
.kb-page .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
                    clip-path: inset(50%); white-space: nowrap; border: 0; }

.kb-actions { display: flex; gap: 8px; flex-shrink: 0; margin: 0 0 4px; }
.kb-actions button { display: inline-flex; align-items: center; gap: 6px; margin: 0; min-height: 34px;
                     padding: 8px 14px 8px 11px; font-size: 13px; font-weight: 600; border-radius: var(--ui-r-control); }
.kb-actions svg { width: 15px; height: 15px; }

#kb-status { margin: 0 0 16px; font-size: 13px; color: var(--c-ink-3); }
#kb-status:empty { display: none; }
#kb-status.numbers-error { color: var(--c-alarm-ink); }
.kb-retry { display: none; margin: -4px 0 20px; min-height: 32px; font-size: 12.5px; }
.kb-page[data-state="error"] .kb-retry { display: inline-flex; }
.kb-page[data-state="loading"] #kb-list-view, .kb-page[data-state="error"] #kb-list-view { display: none; }
.kb-page[data-empty="true"] #kb-new { visibility: hidden; }

/* the list: each base is one row, the whole row the target */
.kb-row { width: 100%; margin: 0; border: 0; border-radius: 0; background-color: transparent; color: inherit;
          text-align: left; font: inherit; cursor: pointer; }
.kb-row:hover { background-color: var(--c-sunk); }
.kb-row:active { transform: none; }
.kb-row .number-meta, .kb-row .number-note { display: block; }
.kb-row-go { align-self: center; font-size: 20px; line-height: 1; color: var(--c-ink-3); }

/* one base */
.kb-back { margin: 0 0 10px; }
.kb-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 0 0 18px; }
.kb-detail-head h2 { margin: 0 0 6px; font: 700 24px/1.2 var(--sans); letter-spacing: -0.02em; color: var(--c-ink); overflow-wrap: anywhere; }
.kb-detail-head .number-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.kb-danger { color: var(--c-alarm-ink) !important; }
.kb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-sources-card > header { align-items: flex-start; }
.kb-sources-card > header > button { flex: none; margin: 0; min-height: 32px; }
.kb-live-data { max-width: 62ch; }
.kb-live-data .linkbtn { display: inline; min-height: 0; margin: 0; vertical-align: baseline; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.kb-sources td { vertical-align: top; }
.kb-sources th.r, .kb-sources td.r { padding-right: 18px; }
.kb-source-name strong { display: block; color: var(--c-ink); font-weight: 600; overflow-wrap: anywhere; }
.kb-kind-tag { display: block; margin-top: 2px; font-size: 11.5px; color: var(--c-ink-3); }
.kb-source-error { display: block; margin-top: 4px; font-size: 12px; line-height: 1.45; color: var(--c-alarm-ink); max-width: 48ch; }
.kb-source-acts { white-space: nowrap; text-align: right; }
.kb-source-acts button { margin: 0 0 0 4px; }
.kb-sources .number-state { white-space: nowrap; }

/* Ask it like a caller (the showcase), and passages anywhere.
 * One row: the caller's language, the question, Ask; all three one height.
 * The select is the console's field with a drawn chevron, so it reads as the
 * same control as the input beside it. */
.kb-try-form { display: flex; gap: 8px; }
.kb-try-lang { flex: none; display: flex; }
/* the Studio's field (agent-workspace.css · .workspace-field input) */
.kb-try-form input, .kb-try-form select { margin: 0; min-height: 38px; padding: 8px 11px; border: 1px solid var(--ui-edge);
                     border-radius: var(--ui-r-control); background-color: var(--c-surface); color: var(--c-ink);
                     font: 400 13.5px/1.45 var(--sans); }
.kb-try-form input { flex: 1; min-width: 0; }
.kb-try-form select { width: 196px; padding-right: 30px; cursor: pointer; appearance: none; -webkit-appearance: none;
                      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%236f6c65' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
                      background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; }
.kb-try-form input:focus, .kb-try-form select:focus { outline: none; border-color: rgba(27, 26, 22, 0.34); box-shadow: var(--ui-ring); }
.kb-try-form button { margin: 0; flex: none; min-height: 38px; padding: 8px 16px; font-size: 13px; border-radius: var(--ui-r-control); }
.kb-try-note { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--c-ink-3); }
.kb-try-status { margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.kb-try-status:empty { display: none; }
.kb-try-status strong { font-weight: 600; color: var(--c-ink); }

/* The trace: what the caller said, in their own script, and the question the
 * agent took from it. Labels in a fixed column so the two lines align. */
.kb-trace { display: grid; gap: 10px; margin: 14px 0 0; padding: 12px 14px; border-radius: var(--ui-r-control);
            background: var(--c-paper); box-shadow: inset 0 0 0 1px var(--ui-sep); }
.kb-trace-row { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 4px 16px; align-items: baseline; }
.kb-trace dt { font: 600 11px/1.4 var(--sans); letter-spacing: 0.04em; text-transform: uppercase; color: var(--c-ink-3); }
.kb-trace dt small { display: block; margin-top: 1px; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.kb-trace dd { margin: 0; font: 400 15px/1.55 var(--sans); color: var(--c-ink); overflow-wrap: anywhere; }
.kb-trace-row[data-step="understood"] dd { font-size: 14px; color: var(--c-ink-2); }

/* A new answer arrives: the trace, then the passages, each a short rise.
 * Occasional (one per question), so it earns a little motion; nothing moves
 * more than 4px and nothing waits on it. */
@keyframes kb-arrive { from { opacity: 0; transform: translateY(4px); } }
.kb-trace-row, #kb-try-hits > .kb-hit { animation: kb-arrive 220ms var(--ease-out) both; }
.kb-trace-row:nth-child(2) { animation-delay: 50ms; }
#kb-try-hits > .kb-hit:nth-child(1) { animation-delay: 60ms; }
#kb-try-hits > .kb-hit:nth-child(2) { animation-delay: 100ms; }
#kb-try-hits > .kb-hit:nth-child(3) { animation-delay: 140ms; }
#kb-try-hits > .kb-hit:nth-child(n+4) { animation-delay: 180ms; }
@media (prefers-reduced-motion: reduce) {
  @keyframes kb-arrive-still { from { opacity: 0; } }
  .kb-trace-row, #kb-try-hits > .kb-hit { animation: kb-arrive-still 160ms ease both; animation-delay: 0ms !important; }
}

@media (max-width: 640px) {
  .kb-try-form { flex-wrap: wrap; }
  .kb-try-lang { flex: 1 0 100%; }
  .kb-try-form select { width: 100%; }
  .kb-try-form input { flex: 1 1 0; width: auto; }
  .kb-try-form button { width: auto; }
  .kb-trace-row { grid-template-columns: minmax(0, 1fr); }
}
.kb-hits { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.kb-hit { padding: 10px 12px; border-radius: var(--ui-r-control); background: var(--c-sunk); }
.kb-hit-where { display: block; font-size: 11.5px; font-weight: 600; color: var(--c-ink-2); }
.kb-hit-text { margin: 4px 0 0; font-size: 13px; line-height: 1.5; color: var(--c-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.kb-hit-answer { color: var(--c-ink-2); }
.kb-hit-foot { display: block; margin-top: 6px; font-size: 11.5px; color: var(--c-ink-3); font-variant-numeric: tabular-nums; }

/* add a source */
.kb-kinds { margin: 0 0 16px; width: max-content; max-width: 100%; overflow-x: auto; }
.kb-drop { display: grid; gap: 4px; place-items: center; text-align: center; padding: 26px 16px; cursor: pointer;
           border: 1px dashed var(--c-line-strong); border-radius: var(--ui-r-card); background: var(--c-paper); }
.kb-drop strong { font-size: 14px; color: var(--c-ink); }
.kb-drop span { font-size: 12.5px; color: var(--c-ink-3); }
.kb-drop.on, .kb-drop:hover { border-color: var(--c-ink-3); background: var(--c-sunk); }
.kb-drop:focus-within { box-shadow: var(--ui-ring); }
.kb-file-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.kb-file { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px 10px;
           padding: 8px 10px; border-radius: var(--ui-r-control); background: var(--c-sunk); font-size: 13px; }
.kb-file strong { font-weight: 500; overflow-wrap: anywhere; }
.kb-file-size { color: var(--c-ink-3); font-variant-numeric: tabular-nums; }
.kb-file .kb-source-error, .kb-file-note { grid-column: 1 / -1; grid-row: 2; margin: 0; font-size: 12px; color: var(--c-ink-3); }
.kb-file .kb-source-error { color: var(--c-alarm-ink); }
.kb-file .workspace-remove { grid-column: 3; grid-row: 1; }
.kb-legend { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--c-ink-2); }
.kb-scope { margin: 0 0 14px; }
.kb-crawl { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.kb-crawl .modal-field:first-child { grid-column: 1 / -1; max-width: 220px; }
.kb-faq { display: grid; gap: 8px; margin: 0 0 8px; }
.kb-faq-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: 8px; align-items: start; }
.kb-faq-row textarea { min-height: 38px; resize: vertical; }

/* Agent Studio → Knowledge */
#agent-knowledge-settings .workspace-field { max-width: 180px; }
.kb-attach-list { display: grid; gap: 2px; }
.kb-attach { text-transform: none; letter-spacing: 0; font: 400 13px/1.45 var(--sans); display: flex; align-items: flex-start; gap: 10px; padding: 9px 8px; border-radius: var(--ui-r-control); cursor: pointer; }
.kb-attach:hover { background: var(--c-sunk); }
.kb-attach input { margin-top: 3px; }
.kb-attach-text { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; font-size: 13px; }
.kb-attach-text strong { font-weight: 600; color: var(--c-ink); overflow-wrap: anywhere; }
.kb-attach-text small { flex-basis: 100%; color: var(--c-ink-3); }

/* the citation under an agent line that answered from knowledge
 * (player.js · knowledgeChip): the transcript's own small type, a book mark
 * and the source's name. Ink, not a hue. */
.kb-cite { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 2px 7px 2px 6px;
           max-width: 100%; border-radius: 999px; background: var(--ui-fill, var(--c-sunk)); color: var(--c-ink-2);
           font: 500 11px/1.5 var(--sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-cite::before { content: ""; flex: none; width: 8px; height: 10px; border: 1.25px solid currentColor; border-radius: 1.5px; }
.msg .kb-cite, .pl-line .kb-cite { display: flex; width: max-content; }
.pl-line .kb-cite { grid-column: 2; }

@media (max-width: 720px) {
  .kb-detail-head { flex-direction: column; }
  .kb-crawl, .kb-faq-row { grid-template-columns: 1fr; }
  .kb-faq-row .workspace-remove { justify-self: end; }
  .kb-try-form { flex-direction: column; }
}

/* Logs: a knowledge search row (agent-logs.js · knowledgeRow), in ink tones. */
.logs-part-knowledge { color: var(--c-ink-2); background: var(--c-sunk); }
.use-r[data-knowledge-nav][hidden] { display: none !important; }
