/* Emberwick Energy: site styles, then the assistant's styles from the agentify-website templates. */
:root { --brand: #9a3412; --tint: #fdf1ea; --ink: #1f2328; --paper: #fbfaf8; --line: #d0d7de; --muted: #59636e; --surface: #ffffff; --surface-2: #f6f8fa; --brand-ink: #9a3412; --brand-solid: #9a3412; color-scheme: light; }
:root[data-theme="dark"] { --tint: #2b1a10; --ink: #e6edf3; --paper: #0d1117; --line: #30363d; --muted: #9da7b3; --surface: #161b22; --surface-2: #1c2330; --brand-ink: #fb923c; --brand-solid: #c2410c; color-scheme: dark; }
* { box-sizing: border-box; }
:root { --chat-h: clamp(720px, 88vh, 920px); }
body { margin: 0; font: 16px/1.55 system-ui, sans-serif; color: var(--ink); background: var(--paper); }
header { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; padding: 14px 24px; background: var(--brand); }
header a { color: #fff; text-decoration: none; }
header nav { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.95em; }
header nav a:hover, header nav a:focus-visible { text-decoration: underline; }
.brand { font-weight: 700; font-size: 1.25em; letter-spacing: 0.01em; }
.brand span { font-weight: 400; opacity: 0.9; }
main { max-width: 1040px; margin: 0 auto; padding: 8px 24px 48px; }
section { margin-top: 40px; }
h1 { font-size: clamp(1.6em, 4vw, 2.3em); line-height: 1.2; margin: 6px 0 12px; }
h2 { font-size: 1.4em; margin: 0 0 10px; }
h3 { font-size: 1.05em; margin: 18px 0 6px; }
.eyebrow { margin: 28px 0 0; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8em; color: var(--brand-ink); font-weight: 700; }
.note { background: var(--tint); border-left: 4px solid var(--brand-ink); padding: 10px 14px; border-radius: 4px; }
.summary { display: grid; grid-template-columns: fit-content(40%) 1fr; gap: 6px 18px; margin: 18px 0 0; }
.summary dt { font-weight: 600; }
.summary dd { margin: 0; }
.card-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--surface); }
.card.current { border-color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-ink); }
.card h3 { margin-top: 0; }
.card p { margin: 4px 0; font-size: 0.95em; }
.card .strong { font-weight: 700; }
.card .rule { color: var(--brand-ink); font-weight: 600; }
form { display: grid; gap: 10px; max-width: 560px; }
label { font-weight: 600; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; width: 100%; background: var(--surface); color: inherit; }
button { font: inherit; padding: 9px 16px; border: 0; border-radius: 6px; background: var(--brand-solid); color: #fff; cursor: pointer; margin-top: 8px; justify-self: start; }
button:hover, button:focus-visible { filter: brightness(1.15); }
.error { color: #b42318; font-weight: 600; margin: 0; min-height: 1.2em; }
.result { background: var(--tint); border-radius: 8px; padding: 12px 14px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; margin-top: 12px; }
.bars > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; font-size: 0.75em; color: var(--muted); }
.bars .bar { width: 100%; background: var(--brand-solid); border-radius: 4px 4px 0 0; min-height: 2px; }
ul { padding-left: 20px; }
a { color: var(--brand-ink); }
footer { border-top: 1px solid var(--line); padding: 18px 24px; font-size: 0.85em; color: var(--muted); text-align: center; }

/* Assistant layout. Append to the site's stylesheet and set the colors to the site's palette. */
.assistant { margin-top: 48px; }

/* The runtime reads these variables for its chat, settings and agent panels.
   The chat background below also uses --ns-bg. White text sits on --ns-primary (the
   visitor's messages, Send, and the chat form and settings buttons) and on --ns-accent
   (Send while a turn is steered), so give both at least 4.5:1 contrast with white.
   --ns-accent also underlines the chat header. */
#agent-app {
  --ns-font: system-ui, sans-serif;
  --ns-bg: var(--surface);
  --ns-fg: var(--ink);
  --ns-primary: var(--brand-solid);
  --ns-accent: var(--brand-solid);
  --ns-border: var(--line);
  --ns-panelbg: var(--surface);
  --ns-msgbg: var(--surface-2);
  --ns-muted: var(--muted);
}

.assistant-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  /* Wider than the text above, up to 1320px, so the chat list, the chat and the swarm
     fit side by side. On a narrow screen the side margins come to 0. */
  margin: 16px calc(50% - min(760px, 50vw - 24px)) 0;
}

/* 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: var(--chat-h); }
/* The runtime gives the chat no background of its own. Keep --ns-msgbg different from
   --ns-bg, or bot replies lose their bubble. */
#agent-app .ns-chat { background: var(--ns-bg); }

/* Site-wide form rules often stretch the runtime's own controls. Undo them here. */
#agent-app input[type="checkbox"],
#agent-app input[type="radio"] { width: auto; }
#agent-app .ns-header { flex-wrap: wrap; }
/* Site label rules add margins and bold text, and the inputs inside the labels inherit
   the weight. */
#agent-app .ns-settings-body label { margin: 4px 0; font-weight: 400; }
/* Chat forms label radio groups with a legend, so site legend fonts would reach them. */
#agent-app .ns-w-label { font-family: inherit; }
/* Site label rules add margins to chat form fields and make their options bold. */
#agent-app .ns-widget label { margin: 0; }
#agent-app .ns-w-radio label,
#agent-app .ns-w-multi label,
#agent-app .ns-w-toggle { font-weight: 400; }
/* The runtime sizes radio and multi-choice options but not the checkbox label. */
#agent-app .ns-w-toggle { font-size: 13px; }
/* The runtime spaces its buttons with gap. A site's button margin pushes Send below the input. */
#agent-app button { margin: 0; }
/* A site's button:hover background also reaches the runtime's plain buttons, behind
   their dark text. Keep the runtime's own backgrounds. */
#agent-app .ns-devtoggle:not(.on):hover,
#agent-app .ns-modal-close:hover { background: transparent; }
#agent-app .ns-w-choice:disabled:hover { background: var(--surface); }
/* The runtime paints its chat widgets (forms, choices, info, confirm) and the partner
   consent card in fixed light colours, which break the dark theme. Draw them with this
   site's own tokens instead, so they match its cards and form fields in both themes. */
#agent-app .ns-widget { background: var(--surface-2); color: var(--ink); border-color: var(--line); border-radius: var(--radius); accent-color: var(--brand-solid); }
#agent-app .ns-w-desc, #agent-app .ns-w-fdesc, #agent-app .ns-w-csub, #agent-app .ns-w-fk { color: var(--muted); }
#agent-app .ns-w-row :is(input[type=text], input[type=number], input[type=date], input[type=time], select, textarea) { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: min(var(--radius), 8px); }
#agent-app .ns-w-row :is(input, select, textarea):focus-visible { outline: none; border-color: var(--brand-ink); box-shadow: 0 0 0 3px var(--ring); }
#agent-app .ns-w-choice { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: min(var(--radius), 10px); }
#agent-app .ns-w-choice:hover:not(:disabled) { background: var(--tint); border-color: var(--brand-ink); }
#agent-app .ns-w-cmeta { color: var(--brand-ink); }
#agent-app .ns-w-field { border-bottom-color: var(--line); }
#agent-app .ns-w-btn.ghost { color: var(--muted); border-color: var(--line); }
#agent-app .ns-consent { --caution: #b45309; --done: #166534; --declined: #b42318; background: color-mix(in srgb, #f59e0b 10%, var(--surface)); border-color: color-mix(in srgb, #f59e0b 60%, var(--line)); color: var(--ink); }
:root[data-theme="dark"] #agent-app .ns-consent { --caution: #fbbf24; --done: #4ade80; --declined: #f87171; }
/* Every consent card, waiting or answered, is one width on every site, whatever its text. */
#agent-app .ns-msg.ns-consent { box-sizing: border-box; width: min(95%, 520px); max-width: 95%; }
#agent-app .ns-consent-req, #agent-app .ns-consent-sub { color: var(--muted); }
#agent-app .ns-consent-actions button.ghost { color: var(--caution); border-color: color-mix(in srgb, var(--caution) 70%, transparent); }
#agent-app .ns-consent-done { color: var(--done); }
/* site.js marks the card with the visitor's answer: a decline reads in red. */
#agent-app .ns-consent[data-decision="decline"] .ns-consent-done { color: var(--declined); }
/* The model badges and warning hints keep their status hue, mixed with this theme's ink
   so the text stays readable on light and dark. */
#agent-app .ns-llmbadge { --tone: #64748b; background: color-mix(in srgb, var(--tone) 14%, var(--surface)); border-color: color-mix(in srgb, var(--tone) 55%, var(--line)); color: color-mix(in srgb, var(--tone) 45%, var(--ink)); }
#agent-app .ns-llmbadge.mock { --tone: #d97706; }
#agent-app .ns-llmbadge.real { --tone: #16a34a; }
#agent-app .ns-llmbadge.pending { --tone: #0284c7; }
#agent-app .ns-llmbadge.error { --tone: #dc2626; }
#agent-app .ns-hint.warn { color: color-mix(in srgb, #d97706 50%, var(--ink)); }
/* The developer log and the runtime's detail window: the site's surfaces, with each log
   row keeping its coloured edge. */
#agent-app .ns-row { --tone: transparent; background: color-mix(in srgb, var(--tone) 8%, var(--surface-2)); color: var(--ink); }
#agent-app .ns-row.k-remote_call { --tone: #db2777; }
#agent-app .ns-row.k-mcp_call { --tone: #0d9488; }
#agent-app :is(.ns-row.k-error, .ns-row.status-error) { --tone: #dc2626; }
#agent-app .ns-row pre, #agent-app .ns-modal-card pre { background: var(--surface); color: var(--ink); border-color: var(--line); }
#agent-app .ns-pill { background: color-mix(in srgb, var(--brand-ink) 16%, var(--surface)); color: var(--ink); }
#agent-app .ns-toolbar input { background: var(--surface); color: var(--ink); border-color: var(--line); }
#agent-app .ns-modal-card { background: var(--surface); color: var(--ink); }
#agent-app .ns-mact { background: var(--surface-2); color: var(--ink); }
#agent-app .ns-modal-close { color: var(--muted); }
/* 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; }
/* Long links in a reply would run out of the bubble on a phone. "anywhere" would also
   let the consent card's buttons shrink and split their labels. */
#agent-app .ns-msg { overflow-wrap: break-word; }
/* On a phone the consent card is too narrow for its three buttons in one row, and
   "Always allow" breaks onto two lines. Keep each label whole and wrap the row. */
#agent-app .ns-consent-actions { flex-wrap: wrap; }
#agent-app .ns-consent-actions button { white-space: nowrap; }

/* Compact chat (issue #20). The runtime sets no font size on messages, so they took the
   page's 16px/1.55 body text, and rendered Markdown kept the browser's 1em paragraph and
   list margins inside each bubble. These rules only touch the chat, never the page. */
#agent-app .ns-msgs { gap: 8px; padding: 10px 12px; }
#agent-app .ns-msg { font-size: 14px; line-height: 1.45; padding: 7px 11px; max-width: 88%; }
/* An answer with figures (js/openui.js) gets the full width, for its charts. */
#agent-app .ns-msg:has(.ou-root) { max-width: 100%; width: 100%; }
#agent-app .ns-msg > :first-child { margin-top: 0; }
#agent-app .ns-msg > :last-child { margin-bottom: 0; }
#agent-app .ns-msg p { margin: 0 0 0.45em; }
#agent-app .ns-msg ul,
#agent-app .ns-msg ol { margin: 0.2em 0 0.45em; padding-left: 1.25em; }
#agent-app .ns-msg li { margin: 0.1em 0; }
#agent-app .ns-msg li > p { margin: 0; }
#agent-app .ns-msg h1,
#agent-app .ns-msg h2,
#agent-app .ns-msg h3,
#agent-app .ns-msg h4 { font-size: 1em; margin: 0.6em 0 0.2em; }
#agent-app .ns-msg table { border-collapse: collapse; font-size: 13px; margin: 0.3em 0 0.45em; }
#agent-app .ns-msg th,
#agent-app .ns-msg td { padding: 3px 10px 3px 0; border-bottom: 1px solid var(--ns-border); text-align: left; vertical-align: top; }
#agent-app .ns-input { font-size: 14px; }
/* Consent cards: tighter lines. Once answered, the result sits beside the title, and the
   partner's host and the request stay visible. */
#agent-app .ns-consent { font-size: 13px; }
#agent-app .ns-consent-sub { margin-bottom: 3px; }
#agent-app .ns-consent-req { margin-bottom: 6px; }
#agent-app .ns-consent:has(.ns-consent-done) { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
#agent-app .ns-consent:has(.ns-consent-done) > * { grid-column: 1 / -1; }
#agent-app .ns-consent:has(.ns-consent-done) > .ns-consent-title { grid-column: 1; grid-row: 1; }
#agent-app .ns-consent:has(.ns-consent-done) > .ns-consent-done { grid-column: 2; grid-row: 1; align-self: start; white-space: nowrap; }
#agent-app .ns-consent:has(.ns-consent-done) > .ns-consent-req { margin-bottom: 0; }
#agent-app .ns-consent-actions button { padding: 5px 12px; }
@media (max-width: 760px) {
  /* A phone's chat column is narrow, so let bubbles use more of it. */
  #agent-app .ns-msg { max-width: 94%; }
}

/* site.js and the runtime add their confirmation dialogs to <body>, outside #agent-app.
   Site h2 rules reach the heading, and the two buttons touch. A right margin keeps
   wrapped buttons lined up on the left. */
body > dialog h2 { margin: 0 0 12px; font: 700 1.25em system-ui, sans-serif; }
body > dialog button { margin-right: 8px; }
/* site.js's dialog: the details in two columns, and a plain decline button, so the two
   choices do not look the same. */
.assistant-review { max-width: 640px; width: 85%; max-height: 85vh; overflow: auto; border: 1px solid #888; border-radius: 12px; padding: 24px; font: 16px system-ui, sans-serif; }
.assistant-review dl { display: grid; grid-template-columns: fit-content(40%) 1fr; gap: 4px 16px; margin: 12px 0; }
.assistant-review dt { font-weight: 600; }
.assistant-review dd { margin: 0; overflow-wrap: anywhere; }
.assistant-review details { margin: 12px 0; }
.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) {
  .assistant-panels { grid-template-columns: 1fr; }
  /* On a phone, each detail goes under its label, so an email is not split. */
  .assistant-review dl { grid-template-columns: 1fr; gap: 0; }
  .assistant-review dd { margin-bottom: 8px; }
}

/* Voice input (js/voice-input.js): a small mic button inside the chat box's right edge.
   The box takes the room the old "Speak" button had. */
#agent-app .ns-inputwrap { position: relative; display: flex; flex: 1 1 220px; min-width: 0; }
#agent-app .ns-inputwrap input { flex: 1 1 auto; width: 100%; padding-right: 42px; }
#agent-app .ns-inputwrap input[hidden] { display: none; }
/* The growing chat box (js/chat-box.js): a textarea that starts one line high and grows
   upward as the request wraps, up to a limit, then scrolls. The bar is at the bottom of
   the chat, so its bottom edge stays put. */
#agent-app .ns-inputbar { align-items: flex-end; }
#agent-app .ns-inputwrap textarea { display: block; flex: 1 1 auto; width: 100%; height: 36px; min-height: 36px; margin: 0; padding: 7px 42px 7px 10px; border: 1px solid var(--ns-border); border-radius: 8px; font: 14px/1.4 system-ui, sans-serif; color: inherit; background: var(--surface); resize: none; overflow-y: hidden; }
#agent-app .ns-inputwrap textarea:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 0; }
#agent-app #ns-send { align-self: flex-end; min-height: 36px; }
/* The visitor's line breaks (Shift+Enter, pasted text) show in their message. */
#agent-app .ns-msg.user { white-space: pre-wrap; }
#agent-app .voice-button { position: absolute; right: 5px; bottom: 3px; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ns-muted); }
#agent-app .voice-button:hover, #agent-app .voice-button:focus-visible { background: var(--tint); color: var(--brand-ink); filter: none; }
#agent-app .voice-button:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 1px; }
/* While listening, the mic becomes a waveform of thin bars that rise and fall. */
#agent-app .voice-button[aria-pressed="true"] { width: 56px; border-radius: 15px; background: transparent; color: var(--brand-ink); }
#agent-app .ns-inputwrap:has(.voice-button[aria-pressed="true"]) :is(input, textarea) { padding-right: 68px; }
.voice-wave { display: flex; align-items: center; justify-content: center; gap: 2px; height: 20px; }
.voice-wave i { width: 2px; height: 5px; border-radius: 1px; background: currentColor; animation: voice-bar 0.9s ease-in-out infinite; animation-delay: calc(var(--bar) * -0.11s); }
.voice-wave i:nth-child(3n) { animation-duration: 0.7s; }
.voice-wave i:nth-child(4n + 1) { animation-duration: 1.1s; }
@keyframes voice-bar { 0%, 100% { height: 3px; } 50% { height: 18px; } }
@media (prefers-reduced-motion: reduce) {
  .voice-wave i { animation: none; }
  .voice-wave i:nth-child(odd) { height: 12px; }
  .voice-wave i:nth-child(even) { height: 6px; }
}
.voice-status { margin: 0; padding: 6px 10px; font-size: 0.9em; font-weight: 600; }
.voice-status:empty { display: none; }
/* The swarm at work (js/swarm-graph.js): the graph beside the chat. It takes the place
   of the runtime's own list of sites, which stays in the page but hidden. */
.assistant-panels:has(> .swarm-map[hidden]) { grid-template-columns: 1fr; }
#agent-app .ns-agents { display: none; }
.swarm-map { align-self: start; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.swarm-map[hidden] { display: none; }
.swarm-map h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.swarm-turns { display: flex; flex-wrap: wrap; gap: 4px; }
.swarm-turns[hidden] { display: none; }
#agent-app .swarm-turn { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); font-size: 12px; line-height: 1; }
#agent-app .swarm-turn[aria-pressed="true"] { background: var(--brand-solid); border-color: var(--brand-solid); color: #fff; }
#agent-app .swarm-turn[data-status="error"] { border-color: #a40e26; }
#agent-app .swarm-turn:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
.swarm-caption { margin: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swarm-counts { margin: 0; font-size: 12px; line-height: 1.3; color: var(--muted); }
.swarm-key { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0; font-size: 11px; color: var(--muted); }
.swarm-key-used::before { content: "\25CF  "; color: var(--brand-ink); }
.swarm-key-idle::before { content: "\25CB  "; }
.swarm-key-partner::before { content: "\2504  "; }
.swarm-key-a2a::before { content: "\2508  "; }
/* The drawing: a dark panel, so the lit agents and calls stand out. */
.swarm-stage { position: relative; padding: 6px; border-radius: 10px; background: radial-gradient(120% 70% at 50% 0%, #1a2742 0%, #0b1220 75%); perspective: 800px; }
.swarm-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: system-ui, sans-serif; transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)); transition: transform 0.25s ease-out; }
.swarm-grid-dot { fill: #2b3a55; }
.swarm-site rect { fill: color-mix(in srgb, var(--site) 6%, transparent); stroke: color-mix(in srgb, var(--site) 30%, transparent); transition: fill 0.3s, stroke 0.3s; }
.swarm-site[data-active="true"] rect { fill: color-mix(in srgb, var(--site) 13%, transparent); stroke: color-mix(in srgb, var(--site) 80%, transparent); }
.swarm-site-name, .swarm-site-status, .swarm-node-label { paint-order: stroke; stroke: #0b1220; stroke-width: 3px; stroke-linejoin: round; }
.swarm-site-name { font-size: 11.5px; font-weight: 700; fill: #e5ecf5; }
.swarm-site-status { font-size: 10px; fill: #93a4bb; }
.swarm-site-label[data-active="true"] .swarm-site-status { fill: var(--site); }
.swarm-edge-line { fill: none; stroke: #4b5b74; stroke-width: 1.1; transition: stroke 0.3s; }
.swarm-partner .swarm-edge-line { stroke-dasharray: 3 3; }
.swarm-a2a .swarm-edge-line { stroke-dasharray: 1 4; stroke-linecap: round; }
.swarm-edge.swarm-a2a:is([data-state="ok"], [data-state="running"]) .swarm-edge-line { stroke-dasharray: 1 3; stroke-linecap: round; }
.swarm-edge-arrow { fill: #4b5b74; }
.swarm-edge-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; }
.swarm-spark { display: none; fill: #fff; }
.swarm-edge:is([data-state="ok"], [data-state="running"]) .swarm-edge-line { stroke: var(--site); stroke-width: 1.8; stroke-dasharray: none; filter: drop-shadow(0 0 3px var(--site)); }
.swarm-edge:is([data-state="ok"], [data-state="running"]) .swarm-edge-arrow { fill: var(--site); }
.swarm-edge[data-state="asking"] .swarm-edge-line { stroke: #fbbf24; stroke-width: 1.6; }
.swarm-map[data-live="yes"] .swarm-edge[data-state="asking"] .swarm-edge-line { animation: swarm-pulse 1.1s ease-in-out infinite; }
.swarm-edge[data-state="asking"] .swarm-edge-arrow { fill: #fbbf24; }
.swarm-edge[data-state="refused"] .swarm-edge-line { stroke: #fbbf24; stroke-width: 1.8; stroke-dasharray: 2 4; }
.swarm-edge[data-state="refused"] .swarm-edge-arrow { fill: #fbbf24; }
.swarm-edge[data-state="error"] .swarm-edge-line { stroke: #f87171; stroke-width: 1.8; }
.swarm-edge[data-state="error"] .swarm-edge-arrow { fill: #f87171; }
.swarm-edge:hover .swarm-edge-line { stroke-width: 2.6; }
.swarm-node { cursor: pointer; outline: none; }
.swarm-node-halo { fill: transparent; stroke: transparent; stroke-width: 1.5; }
.swarm-node:hover .swarm-node-halo, .swarm-node:focus-visible .swarm-node-halo { stroke: #e5ecf5; }
.swarm-node-ring { fill: none; stroke: var(--site); stroke-width: 1.3; stroke-dasharray: 6 4; opacity: 0; transform-box: fill-box; transform-origin: center; }
.swarm-node-dot { stroke: #64748b; stroke-width: 1; }
.swarm-node-lit { opacity: 0; transition: opacity 0.3s; }
.swarm-node:is([data-state="ok"], [data-state="running"]) .swarm-node-lit { opacity: 1; filter: drop-shadow(0 0 5px var(--site)); }
.swarm-node[data-state="running"] .swarm-node-ring { opacity: 1; }
/* Only while the answer on show is being made does anything move. */
.swarm-map[data-live="yes"] .swarm-node[data-state="running"] .swarm-node-ring { animation: swarm-spin 2.4s linear infinite; }
.swarm-map[data-live="yes"] .swarm-node[data-state="running"] .swarm-node-lit { animation: swarm-pulse 1.1s ease-in-out infinite; }
.swarm-node[data-state="refused"] .swarm-node-dot { stroke: #fbbf24; stroke-width: 2; stroke-dasharray: 3 2; }
.swarm-node[data-state="error"] .swarm-node-dot { stroke: #f87171; stroke-width: 2.5; }
.swarm-node-label { font-size: 10.5px; fill: #b6c2d4; }
.swarm-node:is([data-state="ok"], [data-state="running"]) .swarm-node-label { fill: #fff; font-weight: 600; }
.swarm-node-count { font-size: 9.5px; font-weight: 700; fill: #fff; }
/* Once an answer is on show, what took no part steps back. */
.swarm-map[data-turn="yes"] .swarm-node[data-state="idle"] { opacity: 0.55; }
.swarm-map[data-turn="yes"] .swarm-edge[data-state="idle"] { opacity: 0.5; }
@keyframes swarm-spin { to { transform: rotate(360deg); } }
@keyframes swarm-pulse { 50% { opacity: 0.55; } }
@keyframes swarm-flow { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@supports (offset-path: path("M0,0 L1,1")) {
  .swarm-map[data-live="yes"] .swarm-edge:is([data-state="ok"], [data-state="running"]) .swarm-spark { display: block; animation: swarm-flow 2.8s linear infinite; }
  .swarm-edge[data-state="ok"] .swarm-spark-late { animation-delay: -1.4s; }
  .swarm-edge[data-state="running"] .swarm-spark { animation-duration: 1s; }
  .swarm-edge[data-state="running"] .swarm-spark-late { animation-delay: -0.5s; }
}
@media (prefers-reduced-motion: reduce) {
  .swarm-svg { transition: none; }
  .swarm-spark { display: none !important; }
  .swarm-node-ring, .swarm-node-lit, .swarm-edge-line { animation: none !important; }
}
/* What an agent or a call did: shown on hover and focus, kept open by a click or tap. */
.swarm-tip { position: absolute; left: 6px; right: 6px; z-index: 5; max-height: 240px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); font-size: 12px; line-height: 1.4; pointer-events: none; }
.swarm-tip[hidden] { display: none; }
.swarm-tip[data-pinned="true"] { pointer-events: auto; border-color: var(--brand-ink); box-shadow: 0 0 0 1px var(--brand-ink), 0 8px 24px rgba(0, 0, 0, 0.35); }
.swarm-tip p { margin: 0 0 3px; overflow-wrap: anywhere; }
.swarm-tip-head strong { font-family: ui-monospace, monospace; }
.swarm-tip-head span, .swarm-tip-quiet { color: var(--muted); }
.swarm-tip-label { font-weight: 600; }
.swarm-tip-bad { color: #a40e26; }
@media (max-width: 760px) {
  .swarm-map { width: 100%; max-width: 440px; justify-self: center; }
}

/* Developer log (the runtime's ⚙ Developer, with js/dev-log.js): a fixed-height panel
   under the chat that scrolls inside itself. It shows the answer on show in the graph,
   one line per event, and by default only the steps. The runtime's own agent tree is
   hidden: the graph above shows the same. */
#agent-app [data-ns-slot="agents"] { display: none; }
#agent-app[data-dev="true"] [data-ns-slot="agents"] { display: block; height: 260px; margin-top: 12px; }
#agent-app .ns-graph { display: none; }
#agent-app .ns-log { background: var(--surface); padding-top: 0; }
#agent-app .ns-log .ns-toolbar { position: sticky; top: 0; z-index: 1; margin: 0; padding: 8px 0 6px; background: var(--surface); }
#agent-app .ns-row { margin: 2px 0; padding: 2px 8px; }
#agent-app .ns-row .ns-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#agent-app .ns-row pre { max-height: 160px; }
#agent-app .dev-log-filters { position: sticky; top: 36px; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 6px; background: var(--surface); }
#agent-app .dev-log-filters button { padding: 2px 10px; border: 1px solid var(--ns-border); border-radius: 10px; background: transparent; color: var(--ns-muted); font-size: 11px; }
#agent-app .dev-log-filters button[aria-pressed="true"] { background: #1e293b; border-color: #1e293b; color: #fff; }
#agent-app .dev-log-filters .dev-log-scope { margin-left: auto; }
#ns-rows[data-scope="answer"] .ns-row.dev-log-other,
#ns-rows[data-show="steps"] .ns-row:not(.k-run, .k-agent, .k-tool, .k-mcp_call, .k-remote_fetch, .k-remote_call, .k-consent, .k-composition_skip, .k-composition_limit, .status-error),
#ns-rows[data-show="model"] .ns-row:not(.k-model_call),
#ns-rows[data-show="errors"] .ns-row:not(.status-error) { display: none; }

/* Suggested requests (js/prompt-hints.js): a line under the chat box. The line, the voice
   status and the partner menu sit in a band of fixed height under the input bar, so
   showing or hiding the hint never moves the bar: its bottom stays put while the box grows
   upward. */
#agent-app .ns-chat { position: relative; }
#agent-app .ns-inputbar { margin-bottom: 24px; }
#agent-app .ns-chat > .prompt-hint, #agent-app .ns-chat > .voice-status { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; height: 24px; margin: 0; padding: 0 10px; overflow: hidden; line-height: 24px; white-space: nowrap; text-overflow: ellipsis; }
#agent-app .ns-chat:has(> .partner-approval:not([hidden])) > .prompt-hint, #agent-app .ns-chat:has(> .partner-approval:not([hidden])) > .voice-status { bottom: 33px; }
#agent-app .ns-chat > .voice-status { background: var(--surface); }
/* The voice status takes the hint's place while it has a message, so the two never overlap. */
#agent-app .ns-chat:has(> .voice-status:not(:empty)) > .prompt-hint { visibility: hidden; }
#agent-app .ns-chat > .partner-approval { box-sizing: border-box; height: 33px; padding-top: 0; padding-bottom: 0; }
.prompt-hint { display: block; margin: 0; padding: 4px 10px; background: none; border: 0; font: inherit; font-size: 0.85em; opacity: 0.75; text-align: left; cursor: pointer; }
.prompt-hint[hidden] { display: none; }
.prompt-hint:hover, .prompt-hint:focus-visible { opacity: 1; text-decoration: underline; }

/* Live progress in the chat (js/live-chat.js): the steps, and the answer as it arrives. */
#agent-app .ns-turn-status { display: none; }
#agent-app .ns-live { white-space: pre-wrap; }
.ns-steps { margin: 6px 0; padding: 6px 10px; border: 1px solid rgba(128, 128, 128, 0.35); border-radius: 10px; font-size: 0.88em; opacity: 0.9; }
.ns-steps summary { cursor: pointer; }
.ns-steps ul { margin: 6px 0 2px; padding-left: 4px; list-style: none; }
.ns-steps li { margin: 2px 0; }
.ns-steps[data-running="true"] summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: currentColor; animation: ns-steps-pulse 1s ease-in-out infinite; }
@keyframes ns-steps-pulse { 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .ns-steps[data-running="true"] summary::after { animation: none; } }

/* Chats (js/chat-sessions.js): a column to the left of the chat. It is shown once the
   assistant has loaded. */
.assistant-panels:has(> .chat-side:not([hidden])) { grid-template-columns: 176px minmax(0, 1fr) 360px; }
.assistant-panels:has(> .chat-side:not([hidden])):has(> .swarm-map[hidden]) { grid-template-columns: 200px minmax(0, 1fr); }
.chat-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; align-self: start; max-height: var(--chat-h); }
.chat-side[hidden] { display: none; }
.chat-list { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.chat-list[hidden] { display: none; }
.chat-list h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
#agent-app .chat-new { width: 100%; margin: 0; padding: 8px 10px; font-size: 13px; font-weight: 600; justify-self: stretch; }
#agent-app .chat-new:disabled { opacity: 0.5; cursor: default; }
.chat-items { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; overflow-y: auto; }
#agent-app .chat-pick { display: block; width: 100%; margin: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; line-height: 1.3; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#agent-app .chat-pick[aria-current="true"] { background: var(--tint); border-color: var(--brand-ink); box-shadow: inset 3px 0 0 var(--brand-ink); font-weight: 600; }
#agent-app .chat-pick:disabled { opacity: 0.55; cursor: default; filter: none; }
#agent-app .chat-pick:focus-visible, #agent-app .chat-new:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
.chat-note { margin: 0; font-size: 11px; line-height: 1.35; color: var(--muted); }
/* Partner approval (js/partner-approval.js): one small menu under the chat box. */
#agent-app .partner-approval { display: flex; align-items: center; gap: 6px; padding: 4px 10px 8px; border-top: 1px solid var(--ns-border); font-size: 12px; color: var(--muted); }
#agent-app .partner-approval[hidden] { display: none; }
#agent-app .partner-approval label { margin: 0; font-weight: 400; }
#agent-app .partner-approval select { width: auto; max-width: 100%; padding: 2px 6px; border-radius: 6px; font-size: 12px; }
/* The runtime's own New chat button: the list's button does that now. */
#agent-app #ns-newchat { display: none; }
/* A partner contacted without a card, because the visitor chose automatic approval. */
#agent-app .ns-auto-approved { background: #f0fdf4; border: 1px solid #86efac; font-size: 13px; }
.ns-auto-approved-title { font-weight: 700; color: #166534; }
.ns-auto-approved-origin { font: 12px ui-monospace, monospace; color: var(--ns-muted, #59636e); }
.ns-auto-approved-request { margin-top: 3px; font-size: 12px; font-style: italic; color: var(--muted); }
@media (max-width: 1100px) {
  /* Less room: the list and the choice go above the chat, side by side. */
  .assistant-panels:has(> .chat-side:not([hidden])) { grid-template-columns: minmax(0, 1fr) 360px; }
  .assistant-panels:has(> .chat-side:not([hidden])):has(> .swarm-map[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .chat-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: stretch; max-height: none; }
  .chat-list { flex: 2 1 320px; }
  .chat-items { flex-direction: row; flex-wrap: wrap; max-height: 112px; }
  #agent-app .chat-new { width: auto; align-self: flex-start; }
  #agent-app .chat-pick { width: auto; max-width: 240px; }
}
@media (max-width: 760px) {
  .assistant-panels:has(> .chat-side:not([hidden])),
  .assistant-panels:has(> .chat-side:not([hidden])):has(> .swarm-map[hidden]) { grid-template-columns: minmax(0, 1fr); }
}

/* Themes. The page is dark by default (data-theme="dark" on <html>); js/theme.js adds the
   switch in the header and remembers the choice. The light values are the original ones. */
/* The runtime sets --ns-primary on the chat from the manifest, so this must be firm. */
:root[data-theme="dark"] #agent-app {
  --ns-primary: var(--brand-solid) !important;
  --ns-accent: var(--brand-solid) !important;
}
:root[data-theme="dark"] #agent-app a { color: var(--brand-ink); }
:root[data-theme="dark"] .error { color: #f87171; }
:root[data-theme="dark"] #agent-app .ns-consent { background: #2a2410; }
:root[data-theme="dark"] #agent-app .ns-consent-actions button.ghost { color: #fbbf24; border-color: #f59e0b; }
:root[data-theme="dark"] #agent-app .ns-auto-approved { background: #10281a; border-color: #1f6b3a; }
:root[data-theme="dark"] .ns-auto-approved-title { color: #4ade80; }
:root[data-theme="dark"] .ns-auto-approved-request { color: var(--muted); }
:root[data-theme="dark"] .swarm-tip-bad { color: #f87171; }
:root[data-theme="dark"] #agent-app .dev-log-filters button[aria-pressed="true"] { background: #334155; border-color: #334155; }
:root[data-theme="dark"] img.brand-icon { filter: none; }
.theme-switch { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 4px 10px 4px 6px; border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 999px; background: transparent; color: #fff; font-size: 0.85em; cursor: pointer; justify-self: auto; }
.theme-switch:hover, .theme-switch:focus-visible { background: rgba(255, 255, 255, 0.16); }
.theme-switch:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.theme-track { position: relative; width: 34px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.35); transition: background 0.2s; flex: none; }
.theme-knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.theme-switch[aria-checked="true"] .theme-track { background: rgba(255, 255, 255, 0.85); }
.theme-switch[aria-checked="true"] .theme-knob { transform: translateX(16px); background: #9a3412; }
@media (prefers-reduced-motion: reduce) { .theme-track, .theme-knob { transition: none; } }

/* The phone layout (js/mobile.js, mobile.css): its bars are only for phones. */
.m-tabs, .m-toolbar, .m-backdrop { display: none; }
