/* F3: the one chat component (agents/chat-app.js), drawn from the base system's ChatApp
   (templates/console-app/ChatApp.dc.html). Tokens only: --rc-* colours and fonts, --ok / --warn / --bad for state,
   --sp-* spacing, --r-sm radius (console.css's, with the 6px the design draws as its fallback). The values, light
   and dark, come from assets/base.css; nothing here names a colour, so dark follows the host's data-theme.
   The chat fills a positioned, sized container: the console host's main body is one. */

.ca{position:absolute;inset:0;display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--rc-bg);color:var(--rc-ink);font-family:var(--rc-font-sans);font-size:14px;line-height:20px}
.ca [hidden]{display:none!important}
.ca *,.ca *::before,.ca *::after{box-sizing:border-box}
:where(.ca) button,:where(.ca) textarea{font:inherit;color:inherit}
.ca button:focus-visible,.ca .ca-log:focus-visible{outline:var(--rc-focus-outline,2px solid var(--rc-focus));outline-offset:var(--rc-focus-offset,2px);box-shadow:none}
/* SysIcons: 16 in controls, 1.5 stroke, square caps, mitred joins, colour from the text. chat-app.js draws its glyphs on a 24 grid, so the
   stroke is 1.5 x 24 / 16 = 2.25 here to land on 1.5px; the geometry is the old set's until chat-app.js moves to the 16 grid. */
.ca svg{width:16px;height:16px;stroke-width:2.25;stroke-linecap:square;stroke-linejoin:miter}

/* the conversation: a log, 680 wide, centred */
.ca-log{flex:1;min-height:0;overflow:auto;padding:var(--sp-4) var(--sp-5) var(--sp-5);scrollbar-width:thin;scrollbar-color:var(--rc-rule) transparent}
.ca-thread{max-width:680px;margin:0 auto;display:flex;flex-direction:column;gap:var(--sp-6);min-width:0}
.ca-turn{min-width:0}

/* empty state: the agent, large, with its role */
.ca-empty{display:flex;align-items:center;gap:var(--sp-4);padding:clamp(16px,8vh,96px) 0 0}
.ca-face{display:block;flex:none;object-fit:contain}
[data-theme="dark"] .ca-face[data-mark="runi"]{filter:invert(1)}
.ca-face-lg{width:56px;height:56px}
.ca-face-sm{width:20px;height:20px}
.ca-empty-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--sp-1)}
.ca-empty-name{font-family:var(--rc-font-b);font-size:24px;line-height:32px;font-weight:400;overflow-wrap:anywhere}
.ca-empty-role{font-size:16px;line-height:24px;color:var(--rc-line);text-wrap:pretty;overflow-wrap:anywhere}
.ca-empty-hint{font-size:14px;line-height:20px;color:var(--rc-line);text-wrap:pretty;overflow-wrap:anywhere}

/* the operator's turn: right, sunk, with what they attached above it */
.ca-turn.is-op{display:flex;flex-direction:column;align-items:flex-end;gap:var(--sp-2)}
.ca-bubble{max-width:80%;background:var(--rc-bg-sub);border-radius:var(--rc-radius);padding:var(--sp-3) var(--sp-4);font-size:14px;line-height:20px;white-space:pre-wrap;overflow-wrap:anywhere;text-wrap:pretty}
.ca-meta{font-family:var(--rc-font-mono);font-size:12px;line-height:16px;color:var(--rc-line)}
.ca-atts{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--sp-2);max-width:80%}
.ca-turn.is-agent .ca-atts{justify-content:flex-start}
.ca-att.is-image{display:block;width:120px;height:90px;object-fit:cover;border-radius:var(--rc-radius);box-shadow:inset 0 0 0 1px var(--rc-hair)}
.ca-att.is-file{display:inline-flex;align-items:center;gap:var(--sp-2);height:36px;padding:0 var(--sp-3);border-radius:var(--rc-radius);border:1px solid var(--rc-rule);background:transparent;font-size:12px;line-height:16px;max-width:100%}
.ca-att-name{font-weight:600;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ca-att-meta{color:var(--rc-line)}

/* the agent's turn: name and time, steps, answer, app card */
.ca-turn.is-agent{display:flex;flex-direction:column;gap:var(--sp-2)}
.ca-head{display:flex;align-items:center;gap:var(--sp-2);min-width:0}
.ca-author{font-weight:600;min-width:0;overflow-wrap:anywhere}
.ca-time{font-family:var(--rc-font-mono);font-size:12px;line-height:16px;color:var(--rc-line)}
.ca-pulse{display:inline-block;flex:none;width:8px;height:8px;border-radius:50%;background:var(--rc-accent);animation:ca-pulse 1.2s ease-in-out infinite}
@keyframes ca-pulse{0%,100%{opacity:1}50%{opacity:.35}}
.ca-typing{display:inline-flex;gap:3px;align-items:center;height:26px}
.ca-typing i{width:6px;height:6px;border-radius:50%;background:var(--rc-line);animation:ca-pulse 1.2s ease-in-out infinite}
.ca-typing i:nth-child(2){animation-delay:.2s}
.ca-typing i:nth-child(3){animation-delay:.4s}

.ca-stepsbox{display:flex;flex-direction:column;gap:var(--sp-1)}
.ca-steps-toggle{align-self:flex-start;display:inline-flex;align-items:center;gap:var(--sp-1);height:28px;padding:0 var(--sp-2);margin-left:calc(var(--sp-2) * -1);border:0;border-radius:var(--rc-radius);background:transparent;color:var(--rc-line);font-size:12px;line-height:16px;cursor:pointer}
.ca-steps-toggle:hover{background:var(--rc-hover);color:var(--rc-ink)}
.ca-steps{display:flex;flex-direction:column;padding:var(--sp-1) 0 var(--sp-1) var(--sp-3);border-left:1px solid var(--rc-rule);font-size:12px;line-height:16px;color:var(--rc-text-2)}
.ca-reasoning{padding:var(--sp-1) 0 var(--sp-2);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--rc-line)}
.ca-step{display:flex;align-items:center;gap:var(--sp-2);min-height:24px;min-width:0}
.ca-step svg{flex:none;color:var(--ok)}
.ca-step-name{font-family:var(--rc-font-mono);flex:none;color:var(--rc-text-2)}
.ca-step-args{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--rc-line)}
.ca-step-res{flex:none;color:var(--rc-line)}

.ca-answer{font-family:var(--rc-font-b);font-size:16px;line-height:26px;text-wrap:pretty;overflow-wrap:anywhere;min-width:0}
.ca-answer>*{margin:0}
.ca-answer>*+*{margin-top:var(--sp-3)}
.ca-answer a{color:var(--rc-accent)}
.ca-code{font-family:var(--rc-font-mono);font-size:13px;background:var(--rc-bg-sub);padding:1px var(--sp-1);border-radius:var(--rc-radius)}
.ca-pre{margin:0;padding:var(--sp-3) var(--sp-4);background:var(--rc-bg-sub);border-radius:var(--rc-radius);overflow:auto;font-family:var(--rc-font-mono);font-size:13px;line-height:20px}
.ca-quote{padding-left:var(--sp-4);border-left:2px solid var(--rc-accent);font-style:italic;color:var(--rc-text-2)}
.ca-list{padding-left:var(--sp-5)}
.ca-h{font-family:var(--rc-font-sans);font-size:16px;line-height:24px;font-weight:600}
.ca-rule{border:0;border-top:1px solid var(--rc-hair)}
.ca-cursor{color:var(--rc-line)}

/* a table in a reply: label-caps head, a rule under it, hairline rows (SysData) */
.ca-table-wrap{overflow-x:auto;max-width:100%}
.ca-table{border-collapse:collapse;width:100%;font-family:var(--rc-font-sans);font-size:14px;line-height:20px}
.ca-table th{padding:0 var(--sp-4) var(--sp-2) 0;border-bottom:1px solid var(--rc-rule);font-size:12px;line-height:16px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--rc-line);text-align:left;white-space:nowrap}
.ca-table td{padding:var(--sp-3) var(--sp-4) var(--sp-3) 0;border-bottom:1px solid var(--rc-hair);color:var(--rc-text-2);text-align:left}
.ca-table td:first-child{font-weight:600;color:var(--rc-ink)}
.ca-table .is-right{text-align:right;font-family:var(--rc-font-mono)}
.ca-table .is-center{text-align:center}
.ca-table th:last-child,.ca-table td:last-child{padding-right:0}
.ca-table tbody tr:hover td{background:var(--rc-bg-sub)}

.ca-cites{display:flex;flex-direction:column;gap:var(--sp-1);font-size:12px;line-height:16px;color:var(--rc-line)}
.ca-cite{display:flex;gap:var(--sp-2)}
.ca-cite-n{font-family:var(--rc-font-mono)}

/* the app the agent opened: a card that opens it */
.ca-toolcard{align-self:stretch;display:flex;align-items:center;gap:var(--sp-4);min-width:0;max-width:100%;padding:var(--sp-4) 0;border:0;border-top:1px solid var(--rc-rule);border-bottom:1px solid var(--rc-hair);border-radius:var(--rc-radius);background:transparent;color:var(--rc-ink);text-align:left;cursor:pointer}
.ca-toolcard:hover{background:var(--rc-hover)}
.ca-toolcard>svg{flex:none;color:var(--rc-line)}
.ca-appicon{flex:none;width:var(--sp-40);height:var(--sp-40);display:inline-flex;align-items:center;justify-content:center;border-radius:var(--rc-radius);background:var(--rc-bg-sub);font-weight:600}
.ca-toolcard-text{flex:1;min-width:0;display:flex;flex-direction:column}
.ca-toolcard-title{font-weight:600}
.ca-toolcard-desc{color:var(--rc-line);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* a note in the flow, an error with its retry, an approval gate */
.ca-turn.is-note{display:flex;align-items:center;gap:var(--sp-3);font-family:var(--rc-font-mono);font-size:12px;line-height:16px;color:var(--rc-line);margin-top:calc(var(--sp-4) * -1)}
.ca-turn.is-note::before,.ca-turn.is-note::after{content:"";flex:1;height:1px;background:var(--rc-hair)}
.ca-notice{display:flex;align-items:flex-start;gap:var(--sp-3);padding:var(--sp-3) 0 var(--sp-3) var(--sp-4);border-left:2px solid var(--bad)}
.ca-notice-text{flex:1;min-width:0;color:var(--rc-text-2);overflow-wrap:anywhere}
.ca-tbtn{display:inline-flex;align-items:center;gap:var(--sp-2);height:32px;padding:0 var(--sp-3);border:0;border-radius:var(--rc-radius);background:transparent;font-weight:600;cursor:pointer}
.ca-tbtn:hover{background:var(--rc-hover)}
.ca-tbtn-line{border:1px solid var(--rc-rule)}
.ca-tbtn-solid{background:var(--rc-accent);color:var(--rc-on-accent)}
.ca-tbtn-solid:hover{background:var(--rc-accent-hover)}
.ca-tbtn-solid:active,.ca-send:active:not(:disabled){background:var(--rc-accent-press)} /* rc.32 (2B) */
.ca-gate{display:flex;flex-direction:column;gap:var(--sp-2);padding:var(--sp-3) var(--sp-4);border:1px solid var(--rc-rule);border-left:2px solid var(--rc-accent);border-radius:var(--rc-radius);background:transparent}
.ca-gate-head{display:flex;align-items:center;gap:var(--sp-2);font-size:12px;line-height:16px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--rc-line)}
.ca-gate-title{font-weight:600}
.ca-gate-detail{color:var(--rc-text-2)}
.ca-gate-row{display:flex;flex-wrap:wrap;gap:var(--sp-2)}
.ca-gate-done{font-size:12px;line-height:16px;color:var(--rc-line)}

/* rows the activity feed adds (published turns, A2A transport) */
.ca-turn.is-transport{display:flex;flex-direction:column;gap:var(--sp-1);padding:var(--sp-3) var(--sp-4);border:1px solid var(--rc-hair);border-radius:var(--rc-radius);background:transparent;font-size:14px}
.ca-tr-party,.ca-tr-meta{font-size:12px;line-height:16px;color:var(--rc-line)}
.ca-tr-body{overflow-wrap:anywhere}
.ca-tr-body>*{margin:0}
.ca-turn.is-transport[data-state="failed"] .ca-tr-meta,.ca-turn.is-transport[data-state="rejected"] .ca-tr-meta{color:var(--bad);font-weight:600}

/* scroll to latest */
.ca-newbelow{align-self:center;margin:calc(var(--sp-6) * -1) 0 var(--sp-3);position:relative;z-index:2;display:inline-flex;align-items:center;gap:var(--sp-1);padding:6px var(--sp-4);border:1px solid var(--rc-rule);border-radius:var(--rc-radius);background:var(--rc-bg);box-shadow:var(--rc-shadow-float);color:var(--rc-ink);font-size:12px;line-height:16px;font-weight:600;cursor:pointer}

/* the foot: one status line, then the composer */
.ca-foot{flex:none;padding:0 var(--sp-5) var(--sp-4);width:100%;max-width:calc(680px + var(--sp-5) * 2);margin:0 auto;display:flex;flex-direction:column;gap:var(--sp-2)}
.ca-status{display:flex;align-items:center;gap:var(--sp-2);min-height:24px;font-family:var(--rc-font-mono);font-size:12px;line-height:16px;color:var(--rc-line)}
.ca-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--ok)}
/* Working is navy (SysFeedback; Runi, 30 Sep: the Working status is a dot), paper in dark where navy is the ground. */
.ca-dot[data-tone="work"]{background:var(--rc-navy);animation:ca-pulse 1.2s ease-in-out infinite}
[data-theme="dark"] .ca-dot[data-tone="work"]{background:var(--rc-ink)}
.ca-dot[data-tone="off"]{background:var(--rc-line)}
.ca-dot[data-tone="down"]{background:var(--bad)}
.ca-status-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;font-weight:400;color:var(--rc-text-2);white-space:nowrap}
.ca-dot[data-tone="down"]+.ca-status-label{color:var(--bad)}
.ca-status-activity{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ca-elapsed{margin-left:auto;font-family:var(--rc-font-mono);color:var(--rc-text-2)}

.ca-composer{position:relative;display:flex;flex-direction:column;background:transparent;border:1px solid var(--rc-line);border-radius:var(--rc-radius);padding:var(--sp-4) var(--sp-3) var(--sp-3) var(--sp-4)}
.ca-composer:focus-within{border-color:var(--rc-ink)} /* rc.32 (3A): rests on the line colour, as the fields */
.ca-file,.ca-cam{display:none}
.ca-input{display:block;width:100%;border:0;outline:none;resize:none;background:transparent;font-size:16px;line-height:24px;color:var(--rc-ink);padding:0;max-height:160px}
.ca-input::placeholder{color:var(--rc-line)}
.ca-drafts{display:flex;flex-wrap:wrap;gap:var(--sp-2);margin:0 0 var(--sp-3) calc(var(--sp-1) * -1)}
.ca-draft-att{display:inline-flex;align-items:center;gap:var(--sp-2);height:var(--sp-40);padding:0 var(--sp-1);border-radius:var(--rc-radius);border:1px solid var(--rc-rule);background:transparent;font-size:12px;line-height:16px;max-width:100%}
.ca-thumb{width:32px;height:32px;object-fit:cover;border-radius:var(--rc-radius);flex:none}
.ca-thumb.is-glyph{display:inline-flex;align-items:center;justify-content:center;background:var(--rc-bg-sub)}
.ca-att-text{display:flex;flex-direction:column;min-width:0}
.ca-att-remove{width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--rc-radius);background:transparent;color:var(--rc-line);cursor:pointer;padding:0}
.ca-att-remove:hover{background:var(--rc-hover);color:var(--rc-ink)}
.ca-bar{display:flex;align-items:center;gap:var(--sp-1);margin-top:var(--sp-4)}
.ca-bar-left,.ca-bar-right{display:flex;align-items:center;gap:var(--sp-1)}
.ca-bar-right{margin-left:auto}
.ca-ibtn{width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--rc-radius);background:transparent;color:var(--rc-text-2);cursor:pointer;padding:0}
.ca-bar-left .ca-ibtn:first-child{margin-left:calc(var(--sp-2) * -1)}
.ca-ibtn-lg{width:32px;height:32px}
.ca-ibtn:hover{background:var(--rc-hover);color:var(--rc-ink)}
.ca-send,.ca-stop{flex:none;width:var(--sp-40);height:var(--sp-40);display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--rc-radius);padding:0;cursor:pointer}
.ca-send{background:var(--rc-accent);color:var(--rc-on-accent)}
.ca-send:hover{background:var(--rc-accent-hover)}
/* Disabled text is --rc-text-disabled (Runi, 30 Sep), on the same sunk fill as the console's send (.cmp-send:disabled); it was a transparent ring.
   The restyle is Design (WB), provisional. */
.ca-send:disabled{background:var(--rc-bg-sub);box-shadow:none;color:var(--rc-text-disabled);cursor:not-allowed}
.ca-stop{background:var(--rc-ink);color:var(--rc-bg)}
.ca-listening{display:flex;align-items:center;gap:var(--sp-3);height:48px}
.ca-listening-label{font-weight:600}
.ca-rec-time{font-family:var(--rc-font-mono);color:var(--rc-text-2)}
.ca-wave{flex:1;display:flex;align-items:center;gap:3px;height:24px;overflow:hidden}
.ca-wave i{width:3px;flex:none;height:12px;border-radius:2px;background:var(--rc-line);animation:ca-pulse 1s ease-in-out infinite}
.ca-wave i:nth-child(3n){height:6px;animation-delay:.2s}
.ca-wave i:nth-child(3n+1){height:18px;animation-delay:.4s}

/* the one polite region: read by assistive tech, never seen */
.ca-announce{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}

@media (max-width:640px){
  .ca-log{padding:var(--sp-4) var(--sp-4) var(--sp-4)}
  .ca-foot{padding:0 var(--sp-4) var(--sp-3)}
  .ca-empty-name{font-size:24px;line-height:32px}
}
@media (prefers-reduced-motion:reduce){
  .ca *{animation:none!important;transition:none!important}
}
