/* AI agents, AI providers and the MCP server (screens-ai*.jsx). Same tokens and components as the rest of the cabinet. */

/* agent monogram: rounded square in the agent colour with a small bot mark */
.ai-mono { --ac: var(--st-3); position: relative; width: 44px; height: 44px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: color-mix(in oklch, var(--ac) 16%, var(--surface)); color: var(--ac); font-weight: 680; font-size: 15px; letter-spacing: 0.01em;
  border: 1px solid color-mix(in oklch, var(--ac) 30%, var(--surface)); }
.ai-mono.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 12px; }
.ai-mono.xs { width: 24px; height: 24px; border-radius: 8px; font-size: 10px; }
.ai-mono.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.ai-mono .ai-botmark { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--ac); border: 1px solid var(--line); }
.ai-mono.sm .ai-botmark, .ai-mono.xs .ai-botmark { display: none; }
.ai-mono.off { filter: grayscale(1); opacity: 0.6; }

/* agents list */
.ai-agentcard { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); cursor: pointer; text-align: left; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--r-3); box-shadow: var(--shadow-1); width: 100%; font: inherit; color: inherit; min-width: 0; }
.ai-agentcard:hover { border-color: var(--accent-line); }
.ai-agentcard.off { background: var(--surface-2); }
.ai-agentcard .ai-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); padding-top: var(--s-3); border-top: 1px dashed var(--line); }
.ai-agentcard .ai-figs b { display: block; font-size: var(--fs-m); font-variant-numeric: tabular-nums; }
.ai-chans { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ai-chan { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px 0 4px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.ai-chan .ico { width: 16px; height: 16px; display: grid; place-items: center; color: var(--muted); }

/* kill switch / paused banner */
.ai-kill { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-radius: var(--r-3); border: 1px solid color-mix(in oklch, var(--danger) 35%, var(--line));
  background: var(--danger-soft); }
.ai-kill .ico { color: var(--danger); flex: none; margin-top: 2px; }

/* three-state tool mode control */
.ai-mode { display: inline-grid; grid-template-columns: repeat(3, minmax(0, auto)); padding: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; }
.ai-mode button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font: 560 var(--fs-xs) var(--font-ui); cursor: pointer; white-space: nowrap; }
.ai-mode button.on.allowed { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--ok) 30%, transparent); }
.ai-mode button.on.approval { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--warn) 30%, transparent); }
.ai-mode button.on.forbidden { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--danger) 30%, transparent); }
.ai-toolrow { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.ai-toolrow:last-child { border-bottom: 0; }
.ai-toolrow .ai-mode { align-self: stretch; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ai-toolrow .ai-mode button { min-width: 0; min-height: 40px; padding: 2px 4px; white-space: normal; line-height: 1.15; text-align: center; flex-direction: column; gap: 2px; font-size: 11.5px; }

/* wizard */
.ai-wizhead { display: flex; flex-direction: column; gap: var(--s-2); }
.ai-wizbar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.ai-wizbar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.ai-wizfoot { position: sticky; bottom: 0; z-index: 5; display: flex; gap: var(--s-2); justify-content: space-between; align-items: center; padding: var(--s-3) var(--s-4);
  margin: 0 calc(-1 * var(--s-4)) calc(-1 * var(--s-4)); background: color-mix(in oklch, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.ai-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-swatch { width: 32px; height: 32px; border-radius: 10px; border: 2px solid transparent; background: var(--sw); cursor: pointer; padding: 0; }
.ai-swatch.on { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.ai-know { display: flex; align-items: center; gap: var(--s-3); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); min-width: 0; }
.ai-know .bld-pk { width: 32px; height: 32px; border-radius: 9px; }
.ai-hours { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.ai-hours .d { font-size: var(--fs-s); font-weight: 600; color: var(--text-2); }
.ai-hours .span { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: var(--fs-s); }
.ai-hours .span .input { width: 76px; min-height: 36px; text-align: center; font-variant-numeric: tabular-nums; }
.ai-bound { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border-radius: var(--r-3); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.ai-limit { display: flex; flex-direction: column; gap: 6px; }
.ai-limit .row .input { max-width: 160px; }

/* chat (test chat, record assistant) */
.ai-chat { display: flex; flex-direction: column; gap: 10px; padding: var(--s-3); border-radius: var(--r-3); background: var(--surface-2); border: 1px solid var(--line); min-height: 260px; }
.ai-bub { align-self: flex-start; max-width: 88%; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface);
  border: 1px solid var(--line); font-size: var(--fs-m); line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.ai-bub .txt { white-space: pre-line; }
.ai-bub.me { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: var(--accent-soft); border-color: var(--accent-line); }
.ai-bub .meta { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ai-call { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
  font: 12px/1.4 var(--font-mono); color: var(--text-2); }
.ai-call .ico { flex: none; }
.ai-call.ok .ico { color: var(--ok); }
.ai-call.denied .ico, .ai-call.forbidden .ico { color: var(--danger); }
.ai-call.pending { background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 30%, var(--line)); }
.ai-call.pending .ico { color: var(--warn); }
.ai-compose { display: flex; gap: 8px; align-items: flex-end; }
.ai-compose .textarea { min-height: 44px; resize: none; }
.ai-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.5; }
.ai-typing i:nth-child(2) { opacity: 0.75; }
.ai-typing i:nth-child(3) { opacity: 1; }

/* journal */
.ai-runrow .ico-trig { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.ai-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--s-3); padding-bottom: var(--s-4); position: relative; }
.ai-step::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 0; width: 2px; background: var(--line); }
.ai-step:last-child::before { display: none; }
.ai-step .dotk { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); }
.ai-step.llm .dotk { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.ai-step.tool .dotk { color: var(--st-2); }
.ai-step.bad .dotk { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 30%, var(--line)); }
.ai-step.wait .dotk { color: var(--warn); background: var(--warn-soft); }
.ai-step.note .dotk { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 30%, var(--line)); }
.ai-stepbody { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding-top: 4px; }
.ai-json { margin: 0; font: 12px/1.5 var(--font-mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-2); padding: 10px 12px;
  white-space: pre-wrap; word-break: break-word; color: var(--text-2); max-height: 280px; overflow: auto; }
.ai-figline { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.ai-figline span { display: inline-flex; align-items: center; gap: 4px; }

/* approvals */
.ai-appr { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
.ai-appr.pending { border-color: color-mix(in oklch, var(--warn) 40%, var(--line)); }
.ai-appr .what { display: flex; flex-direction: column; gap: 4px; padding: var(--s-3); border-radius: var(--r-2); background: var(--surface-2); border: 1px solid var(--line); }
.ai-appr .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-appr .btns .btn { flex: 1 1 140px; }

/* usage */
.ai-bars { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 6px; border-bottom: 1px solid var(--line); }
.ai-bars .b { flex: 1 1 0; height: 100%; display: flex; flex-direction: column-reverse; gap: 1px; min-width: 0; }
.ai-bars .b i { display: block; width: 100%; }
.ai-bars .b i:last-child { border-radius: 3px 3px 0 0; }
.ai-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--text-2); }
.ai-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ai-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ai-meter { display: flex; flex-direction: column; gap: 6px; }

/* settings: mode choice */
.ai-modecard { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-radius: var(--r-3); border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.ai-modecard.on { border-color: var(--accent); background: var(--accent-soft); }
.ai-modecard .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; margin-top: 2px; display: grid; place-items: center; }
.ai-modecard.on .radio { border-color: var(--accent); }
.ai-modecard.on .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.ai-model { display: flex; align-items: center; gap: var(--s-3); padding: 10px 12px; border-radius: var(--r-2); border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.ai-model.dim { opacity: 0.55; }
.ai-model .tier { font: 600 11px var(--font-mono); color: var(--muted); }

/* MCP */
.ai-copy { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: var(--r-2); border: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
.ai-copy code { flex: 1 1 auto; min-width: 0; font: 13px var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ai-cfg { margin: 0; font: 12px/1.55 var(--font-mono); background: oklch(0.22 0.012 275); color: oklch(0.92 0.01 275); border-radius: var(--r-2); padding: 12px 14px;
  white-space: pre; overflow: auto; max-height: 320px; }
.ai-cfg .k { color: oklch(0.8 0.12 250); }
.ai-cfg .s { color: oklch(0.82 0.12 150); }
.ai-steps { counter-reset: s; display: flex; flex-direction: column; gap: var(--s-3); }
.ai-steps li { list-style: none; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; }
.ai-steps li::before { counter-increment: s; content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft);
  color: var(--accent); font: 650 13px var(--font-ui); }
.ai-steps ol, ol.ai-steps { margin: 0; padding: 0; }
.ai-scope { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font: 11.5px var(--font-mono); color: var(--text-2); }

/* OAuth consent */
.ai-consent { display: flex; flex-direction: column; gap: var(--s-4); }
.ai-consent .pair { display: flex; align-items: center; justify-content: center; gap: var(--s-3); }
.ai-consent .pair .link { width: 36px; border-top: 2px dashed var(--line-strong); }
.ai-consent .applogo { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font: 700 18px var(--font-ui); color: var(--text); }
.ai-scoperow { display: flex; gap: var(--s-3); align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ai-scoperow:last-child { border-bottom: 0; }

/* record card assistant */
.ai-panel { display: flex; flex-direction: column; gap: var(--s-3); }
.ai-panel .head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.ai-panel .head .pick { flex: 1 1 180px; max-width: 240px; }

/* conversation banner (inbox) and process step */
.ai-convbar { display: flex; align-items: center; gap: var(--s-3); padding: 10px 12px; border-radius: var(--r-2); background: var(--accent-soft); border: 1px solid var(--accent-line); flex-wrap: wrap; }
.ai-convbar.human { background: var(--surface-2); border-color: var(--line); }
.ai-msgagent { align-self: flex-end; max-width: 80%; display: flex; flex-direction: column; gap: 4px; padding: 9px 12px; border-radius: 16px 16px 4px 16px; background: var(--accent-soft);
  border: 1px solid var(--accent-line); font-size: var(--fs-m); }
.ai-msgagent .by { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--accent); font-weight: 600; }

@container qapp (min-width: 720px) {
  .ai-toolrow { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--s-4); }
  .ai-toolrow .ai-mode { align-self: auto; grid-template-columns: repeat(3, minmax(0, auto)); flex: none; }
  .ai-toolrow .ai-mode button { min-height: 32px; padding: 0 10px; white-space: nowrap; flex-direction: row; gap: 5px; font-size: var(--fs-xs); }
  .ai-wizfoot { margin: 0; border-radius: var(--r-3); border: 1px solid var(--line); position: static; }
  .ai-appr .btns .btn { flex: 0 0 auto; }
}

/* AI in a conversation of the inbox: the agent bar under the header, the author line of agent messages */
.ib-aibar { padding-top: var(--s-3); }
.ib-aibar:empty { display: none; }
.ib-bub .ib-who.ai-by { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--accent); }

/* nested scroll areas keep the wheel/finger at their ends while they overflow (q-contain, packages/ui/src/styles/app.css) */
.ai-json { animation: q-contain-y linear both !important; animation-timeline: scroll(self block) !important; }
.ai-cfg { animation: q-contain-y linear both, q-contain-x linear both !important; animation-timeline: scroll(self block), scroll(self inline) !important; }
