/* Assistant layout, from the agentify-website template, in the page's three colors.
   The runtime reads the --ns-* variables. It hard-codes white text on --ns-primary and a
   few light backgrounds; the overrides below use the palette instead (styles.css). */
#agent-app {
  --ns-font: var(--sans);
  --ns-bg: transparent;
  --ns-fg: var(--c2);
  /* The runtime also sets --ns-primary inline from the manifest's theme; the palette wins here. */
  --ns-primary: var(--c3) !important;
  --ns-accent: var(--c3);
  --ns-border: var(--line-2);
  --ns-panelbg: color-mix(in oklab, var(--c2) 3%, transparent);
  --ns-msgbg: color-mix(in oklab, var(--c2) 6%, transparent);
  --ns-muted: var(--muted);
  color: var(--ns-fg);
  margin-top: 14px;
}

/* Set the height once the runtime has mounted the chat, so a failed load leaves no empty box. */
#agent-app.ns-composed-app [data-ns-slot="chat"] { height: 520px; }
#agent-app .ns-chat { background: color-mix(in oklab, var(--well) 45%, transparent); border-radius: 16px; }

/* Header: the assistant's name, the model badge and the Developer switch. */
#agent-app .ns-header { flex-wrap: wrap; border-bottom: 1px solid var(--line-2); padding-bottom: 12px; }
#agent-app .ns-title { font-weight: 600; letter-spacing: -.02em; }

/* Buttons and bubbles that sit on the accent take the accent's text color. */
#agent-app .ns-msg.user,
#agent-app .ns-inputbar .ns-send,
#agent-app .ns-settings-body button:not(.ghost),
#agent-app .ns-consent-actions button:not(.ghost),
#agent-app .ns-w-btn:not(.ghost),
#agent-app .ns-linker-form button:not(.ghost) { background: var(--c3); color: var(--on-c3); border-color: transparent; }
#agent-app .ns-msg { overflow-wrap: break-word; }
#agent-app .ns-msg.bot { background: color-mix(in oklab, var(--c2) 6%, transparent); border: 1px solid var(--line); color: var(--ns-fg); }
#agent-app .ns-inputbar input,
#agent-app .ns-inputbar textarea,
#agent-app .ns-input { background: color-mix(in oklab, var(--well) 70%, transparent); color: var(--ns-fg); border: 1px solid var(--line-2); }
#agent-app .ns-inputbar button:not(.ns-send) { background: transparent; color: var(--ns-fg); border: 1px solid var(--line-2); }

/* Agents panel: one slim row above a full-width chat. */
#agent-app .assistant-panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 12px; }
#agent-app [data-ns-slot="agents"] { order: -1; }
#agent-app .ns-agents { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; min-height: 0; overflow: visible; border-radius: 14px;
  background: color-mix(in oklab, var(--c2) 3%, transparent); border-color: var(--line-2); }
#agent-app .ns-agents h3 { margin: 0; }
#agent-app #ns-anodes { display: flex; flex-wrap: wrap; gap: 8px; }
#agent-app .ns-anode { gap: 8px; padding: 4px 12px 4px 10px; border-radius: 999px; background: color-mix(in oklab, var(--c2) 4%, transparent); border-color: var(--line-2); color: var(--ns-fg); }
#agent-app .ns-anode .ns-aicon { display: none; }
#agent-app .ns-anode .ns-ameta { display: flex; align-items: baseline; gap: 6px; }
#agent-app .ns-anode .ns-aname { font-size: 13px; font-weight: 500; }
#agent-app .ns-anode .ns-arole { font-size: 12px; }
#agent-app .ns-anode .ns-adot { background: var(--faint); }
#agent-app .ns-anode.done .ns-adot { background: var(--ok); }
#agent-app .ns-agents .ns-status { margin-left: auto; }
#agent-app .ns-action-status { color: var(--muted); }

/* Badges and toggles */
#agent-app .ns-llmbadge.mock, #agent-app .ns-llmbadge.pending,
#agent-app .ns-llmbadge.error { background: color-mix(in oklab, var(--c3) 12%, transparent); color: var(--c3); border-color: color-mix(in oklab, var(--c3) 45%, transparent); }
#agent-app .ns-llmbadge.real { background: color-mix(in oklab, var(--ok) 12%, transparent); color: var(--ok); border-color: color-mix(in oklab, var(--ok) 45%, transparent); }
#agent-app .ns-devtoggle { background: transparent; color: var(--ns-fg); border-color: var(--line-2); }
#agent-app .ns-devtoggle.on { background: var(--c2); color: var(--c1); border-color: var(--c2); }
#agent-app .ns-pill { background: color-mix(in oklab, var(--c2) 8%, transparent); color: var(--ink-2); }

/* Consent card */
#agent-app .ns-consent { background: color-mix(in oklab, var(--c3) 9%, transparent); border: 1px solid color-mix(in oklab, var(--c3) 50%, transparent); color: var(--ns-fg); }
#agent-app .ns-consent-sub { color: var(--c3); }
#agent-app .ns-consent-req { color: var(--ink-2); }
#agent-app .ns-consent-actions button.ghost { background: transparent; color: var(--c3); border-color: color-mix(in oklab, var(--c3) 55%, transparent); }
#agent-app .ns-consent-done { color: var(--ok); }
#agent-app .ns-linker { background: color-mix(in oklab, var(--c2) 5%, transparent); border-color: var(--line-2); }
/* While a consent card waits, the status line above it already says "Contacting", though
   nothing has been sent. Hide it until the visitor answers. */
#agent-app .ns-msgs:has(.ns-consent-actions) > .ns-turn-status { display: none; }
#agent-app .ns-consent-actions { flex-wrap: wrap; }
#agent-app .ns-consent-actions button { white-space: nowrap; }

/* Chat widgets */
#agent-app .ns-widget { background: color-mix(in oklab, var(--c2) 4%, transparent); border-color: var(--line-2); color: var(--ns-fg); }
#agent-app .ns-w-row input, #agent-app .ns-w-row select, #agent-app .ns-w-row textarea { background: color-mix(in oklab, var(--well) 70%, transparent); color: var(--ns-fg); border-color: var(--line-2); }
#agent-app .ns-w-choice { background: color-mix(in oklab, var(--c2) 5%, transparent); color: var(--ns-fg); border-color: var(--line-2); }
#agent-app .ns-w-choice:hover:not(:disabled) { border-color: var(--c3); }
#agent-app .ns-w-btn.ghost { background: transparent; color: var(--ns-fg); border-color: var(--line-2); }
#agent-app .ns-rich pre, #agent-app .ns-rich code { background: color-mix(in oklab, var(--well) 75%, transparent); color: var(--ink-2); }
#agent-app .ns-rich table th, #agent-app .ns-rich table td { border-color: var(--line-2); }

/* Settings: the runtime's own AI model settings, where the visitor adds a key. */
#agent-app [data-ns-slot="settings"] { margin-top: 12px; }
#agent-app .ns-settings { background: color-mix(in oklab, var(--c2) 3%, transparent); border-color: var(--line-2); border-radius: 14px; }
#agent-app .ns-settings-body input[type=text],
#agent-app .ns-settings-body input[type=password],
#agent-app .ns-settings-body input:not([type]),
#agent-app .ns-settings-body select { background: color-mix(in oklab, var(--well) 70%, transparent); color: var(--ns-fg); border-color: var(--line-2); }
#agent-app .ns-settings-body button.ghost { background: transparent; color: var(--ns-fg); border-color: var(--line-2); }
#agent-app .ns-key-help { background: color-mix(in oklab, var(--c2) 5%, transparent); border-color: var(--line-2); color: var(--ink-2); }
#agent-app .ns-key-help > a, #agent-app .ns-key-providers a { color: var(--c3); }
#agent-app .ns-key-providers a { background: transparent; border-color: var(--line-2); }
#agent-app .ns-key-providers small { color: var(--muted); }
#agent-app .ns-hint.warn { color: var(--c3); }
#agent-app select option { background: var(--c1); color: var(--c2); }

/* Developer trace */
#agent-app .ns-row { background: color-mix(in oklab, var(--c2) 3%, transparent); color: var(--ink-2); }
#agent-app .ns-row.k-remote_call, #agent-app .ns-row.k-mcp_call { background: color-mix(in oklab, var(--c2) 5%, transparent); }
#agent-app .ns-row.status-error { background: color-mix(in oklab, var(--bad) 9%, transparent); }
#agent-app .ns-row pre { background: color-mix(in oklab, var(--well) 75%, transparent); border-color: var(--line-2); color: var(--ink-2); }
#agent-app .ns-graph, #agent-app .ns-log { background: var(--surface); border-color: var(--line-2); color: var(--ns-fg); }
#agent-app .ns-node { background: color-mix(in oklab, var(--c2) 5%, transparent); border-color: var(--line-2); color: var(--ns-fg); }
#agent-app .ns-node.origin { background: color-mix(in oklab, var(--c3) 10%, transparent); border-color: color-mix(in oklab, var(--c3) 45%, transparent); }
#agent-app .ns-node.active { background: var(--c3); border-color: var(--c3); color: var(--on-c3); }
#agent-app .ns-tbox { background: color-mix(in oklab, var(--c2) 6%, var(--surface)); border-color: var(--line-2); color: var(--ns-fg); }
#agent-app .ns-tbox.root { border-color: var(--c3); }
#agent-app .ns-tbox.leaf { background: transparent; color: var(--muted); }
#agent-app .ns-tbox.active { background: color-mix(in oklab, var(--c3) 14%, var(--surface)); border-color: var(--c3); }
#agent-app .ns-tbox .ns-tdot { background: var(--faint); }
#agent-app .ns-tbox.active .ns-tdot { background: var(--c3); }
#agent-app .ns-tchildren { border-left-color: var(--line-2); }
#agent-app .ns-tchildren > li::before { background: var(--line-2); }
#agent-app .ns-tchildren > li:last-child::after { background: var(--surface); }
#agent-app .ns-toolbar input { background: color-mix(in oklab, var(--well) 70%, transparent); color: var(--ns-fg); border-color: var(--line-2); }

/* Site-wide rules that must not reach the runtime's own controls. */
#agent-app input[type="checkbox"], #agent-app input[type="radio"] { width: auto; accent-color: var(--c3); }
#agent-app .ns-settings-body label { margin: 4px 0; font-weight: 400; color: var(--ns-fg); }
#agent-app .ns-widget label { margin: 0; color: var(--ns-fg); }
#agent-app button { margin: 0; }
#agent-app .ns-devtoggle:not(.on):hover, #agent-app .ns-modal-close:hover { background: transparent; }
#agent-app .ns-agents h3, #agent-app .ns-graph h3, #agent-app .ns-log h3 { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; }

/* The runtime's modal (agent details) opens over the whole page. */
.ns-modal { background: color-mix(in oklab, var(--c1) 65%, transparent) !important; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.ns-modal-card { background: color-mix(in oklab, var(--c1) 94%, var(--c2)) !important; color: var(--c2); border: 1px solid var(--line-2); }
.ns-modal-card pre, .ns-mact { background: color-mix(in oklab, var(--well) 75%, transparent) !important; color: var(--ink-2); }
.ns-modal-close { color: var(--muted) !important; }

/* Dialogs from site.js, the runtime and the guard are added to <body>, outside #agent-app. */
body > dialog { background: color-mix(in oklab, var(--c1) 94%, var(--c2)); color: var(--c2); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
body > dialog::backdrop { background: color-mix(in oklab, var(--c1) 65%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
body > dialog h2 { margin: 0 0 12px; font: 600 1.25em var(--sans); letter-spacing: -.02em; }
.assistant-review { max-width: 640px; width: 85%; max-height: 85vh; overflow: auto; padding: 24px; font: 16px var(--sans); }
.assistant-review pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-review .assistant-decline { background: transparent; color: inherit; border: 1px solid currentColor; }

@media (max-width: 760px) {
  #agent-app.ns-composed-app [data-ns-slot="chat"] { height: 560px; }
}
