/* life — one stylesheet. Mobile first; tokens on :root; dark mode by preference. No inline styles (CSP). */
:root {
  --bg: #f5f7f7;
  --surface: #ffffff;
  --surface-2: #eef2f2;
  --text: #13201f;
  --muted: #4a5a5c;
  --border: #c9d3d4;
  --accent: #0b6e69;
  --accent-text: #ffffff;
  --accent-soft: #dcefed;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --warn-bg: #fff4d6;
  --warn-text: #5c4300;
  --ok: #1e6b34;
  --focus: #1a5fd1;
  --radius: 12px;
  --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1416;
    --surface: #182024;
    --surface-2: #212b30;
    --text: #e6eef0;
    --muted: #a9b7ba;
    --border: #3a484d;
    --accent: #5fd0c6;
    --accent-text: #05211f;
    --accent-soft: #163a38;
    --danger: #ffb4ab;
    --danger-text: #410002;
    --warn-bg: #3d3000;
    --warn-text: #ffe08a;
    --ok: #8fd9a0;
    --focus: #8ab4ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: 100%; }
/* iOS Dynamic Type: the root size follows the user's text size setting; everything else is in rem */
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1rem; line-height: 1.5;
  min-height: 100vh; min-height: 100dvh;
}
img { max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: .75rem; border-radius: 8px; margin: .5rem 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus, h1:focus { outline: none; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--surface); padding: .75rem 1rem; }
.skip:focus { left: calc(8px + var(--safe-left)); top: calc(8px + var(--safe-top)); }

/* shell */
.appbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.5rem + var(--safe-top)) calc(1rem + var(--safe-right)) .5rem calc(1rem + var(--safe-left));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand img { border-radius: 7px; }
.offline-badge { background: var(--warn-bg); color: var(--warn-text); border-radius: 999px; padding: .15rem .6rem; font-size: .85rem; }
main {
  max-width: 760px; margin: 0 auto;
  padding: 1rem calc(1rem + var(--safe-right)) calc(5.5rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.tabs a {
  flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; color: var(--muted); text-decoration: none; font-size: .75rem;
}
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabs a > span:not(.ico):not(.count) { max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .tabs a { font-size: .6875rem; } }
/* a tab's long label in the sidebar, its short one in the bottom bar */
.tabs .tab-long { display: none; }
@media (min-width: 900px) { .tabs .tab-long { display: inline; } .tabs .tab-short { display: none; } }
.tabs .count {
  position: absolute; top: 4px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: var(--danger-text); font-size: .75rem; line-height: 20px; text-align: center;
}
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .shell:has(> .tabs[hidden]) { grid-template-columns: 1fr; }
  .shell:has(> .tabs[hidden]) main { margin: 0 auto; }
  .appbar { grid-column: 1 / -1; }
  .tabs { position: sticky; top: 61px; align-self: start; flex-direction: column; border: 0; border-right: 1px solid var(--border); height: calc(100vh - 61px); padding: 1rem .5rem; background: transparent; }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: .75rem; padding: 0 1rem; border-radius: 10px; font-size: 1rem; min-height: var(--tap); }
  .tabs a[aria-current="page"] { background: var(--accent-soft); }
  .tabs .count { position: static; }
  main { padding-bottom: 2rem; margin: 0; }
}

/* icons: CSS masks over currentColor */
.ico { display: inline-block; width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ico-grid { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.ico-check { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M7.5 12.5l3 3 6-6.5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.ico-link { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico-user { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M4 21c1-4 4-6 8-6s7 2 8 6' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.ico-bell { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico-home { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 11l8-7 8 7M6 9.5V20h12V9.5M10 20v-5h4v5' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 .75rem; }
.card h2, .card h3 { margin-top: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead p { margin: .25rem 0 0; }
.back { display: inline-flex; align-items: center; min-height: var(--tap); text-decoration: none; }
.badge { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
.badge.write { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.badge.ok { color: var(--ok); }
.notice { border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; background: var(--accent-soft); }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.error { background: var(--danger); color: var(--danger-text); }
.empty { text-align: center; padding: 2rem 1rem; }
.loading { color: var(--muted); }

/* controls */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); min-width: var(--tap);
  padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger, .button.danger { background: var(--danger); color: var(--danger-text); border-color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: .5rem; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.saved, button.saved:disabled { position: relative; color: transparent; background: var(--ok); border-color: var(--ok); opacity: 1; }
button.saved::after {
  content: ""; position: absolute; inset: 0; background: var(--accent-text);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 1.4rem no-repeat;
}
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="password"], textarea, select {
  width: 100%; min-height: var(--tap); padding: .5rem .75rem; border-radius: 10px; border: 1px solid var(--muted);
  background: var(--surface); color: var(--text); font: inherit; font-size: max(16px, 1rem);
}
textarea { min-height: 5rem; resize: vertical; }
.copy { display: flex; gap: .5rem; }
.copy input { flex: 1; font-family: var(--mono); font-size: 14px; }

.wide { width: 100%; }
.highlight { border: 2px solid var(--accent); }
dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; align-items: baseline; margin: 0 0 .5rem; }
dd { margin: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
li.token { padding: .5rem 0; border-top: 1px solid var(--surface-2); }
li.token:first-child { border-top: 0; }
.row > .field { flex: 1 1 10rem; }
details.card > summary { margin: -.25rem 0; }

/* experience editor */
fieldset.domain { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; margin: 0 0 .75rem; background: var(--surface); }
fieldset.domain legend { padding: 0; margin: 0; width: 100%; float: left; }
.domain-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 1rem; border-bottom: 1px solid var(--border); }
.domain-head h3 { margin: 0; text-transform: capitalize; }
.domain-head .check { align-items: center; }
.domain-head .check input { margin: 0; }
.domain-head + * { clear: both; }
.ep { padding: .5rem 1rem; border-top: 1px solid var(--surface-2); clear: both; }
.ep:first-of-type { border-top: 0; }
.check { display: flex; gap: .75rem; align-items: flex-start; min-height: var(--tap); font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 10px 0 0; flex: none; accent-color: var(--accent); }
.check .title { display: block; font-weight: 600; }
.check .id { font-family: var(--mono); font-size: .8rem; color: var(--muted); word-break: break-all; }
.ep details { margin: 0 0 .25rem 2.25rem; }
summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--accent); font-weight: 600; }
.skill p:last-child, .skill ul:last-child { margin-bottom: 0; }
.skill { font-size: .9rem; background: var(--surface-2); border-radius: 8px; padding: .75rem; }
.savebar {
  position: sticky; bottom: calc(56px + var(--safe-bottom)); z-index: 5; display: flex; gap: .5rem; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; margin-top: 1rem;
}
@media (min-width: 900px) { .savebar { bottom: 1rem; } }

/* steps */
ol.steps { padding-left: 1.25rem; }
ol.steps li { margin-bottom: .75rem; }
ol.steps li::marker { font-weight: 700; color: var(--accent); }

/* dialog */
dialog { border: 0; border-radius: var(--radius); padding: 1.25rem; max-width: min(480px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
/* a long unbroken URL, title or agent-written text wraps inside a card or dialog instead of widening the page at phone width */
.card, dialog { overflow-wrap: anywhere; }

/* toasts */
.toast-area { position: fixed; left: 0; right: 0; bottom: calc(64px + var(--safe-bottom)); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; padding: 0 1rem; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; max-width: 520px; }
.toast.error { background: var(--danger); color: var(--danger-text); }

/* sign in and legal */
.center { max-width: 420px; margin: 2rem auto; }
.hero { text-align: center; margin-bottom: 1.5rem; }
.hero img { border-radius: 18px; }
.legal main, main.legal { padding-bottom: 2rem; }
.legal h2 { margin-top: 1.75rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; justify-content: center; margin-top: 1.5rem; }
.footer-links a { display: inline-flex; align-items: center; min-height: var(--tap); }
.noscript { padding: 1rem; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .2s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* studio: experiences, the experience page, agents, connectors, catalog health (js/views/studio.js) */
:root {
  --ok-bg: #e5f2e8;
  --bad: #a3261f;
  --bad-bg: #fbecec;
  --orange: #8a4600;
  --orange-bg: #fdf1e2;
  --meter-over: #c96a12;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ok-bg: #16301f;
    --bad: #ffb4ab;
    --bad-bg: #3d1916;
    --orange: #ffc58a;
    --orange-bg: #3a2810;
    --meter-over: #f0a050;
  }
}
main:has(> .studio) { max-width: 1180px; }
.studio { overflow-wrap: anywhere; }
body:not(.dev) .dev-only, body.dev .plain-only, .filtered-out { display: none !important; }
.studio button, .studio [tabindex="-1"] { scroll-margin-top: 5rem; }
.studio .pagehead .lead { font-size: 1.05rem; }
.studio .pagehead .actions { margin-top: 0; }
.studio pre.dev-only { font-size: .8rem; }

/* sub-nav and the developer-mode switch */
.studio-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 .75rem; border-bottom: 1px solid var(--border); margin: -.5rem 0 1rem; }
.studio-nav ul { display: flex; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.studio-nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .6rem; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; }
.studio-nav a:hover { color: var(--text); }
.studio-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
@media (max-width: 480px) { .studio-nav a { padding: 0 .4rem; font-size: .9rem; } }
.switch { gap: .6rem; padding: 0 .4rem; border: 0; background: none; font-weight: 600; color: var(--text); }
.switch.bare { padding: 0; flex: none; }
.switch .track { position: relative; flex: none; width: 42px; height: 24px; border-radius: 12px; background: var(--muted); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); }
.switch[aria-pressed="true"] .track { background: var(--accent); }
.switch[aria-pressed="true"] .knob { transform: translateX(18px); }
@media (prefers-reduced-motion: no-preference) { .switch .knob { transition: transform .15s ease-out; } }

/* status pills, chips, tags */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.unknown { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.pill-link, button.pill-link { display: inline-flex; align-items: center; min-height: var(--tap); min-width: 0; padding: 0; border: 0; background: none; font: inherit; text-decoration: none; cursor: pointer; }
.pill-link:hover .pill { text-decoration: underline; }
.chip { display: inline-flex; align-items: center; padding: .1rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chip.warn { background: var(--orange-bg); color: var(--orange); }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.tag { display: inline-flex; align-items: center; padding: .05rem .5rem; border-radius: 6px; border: 1px solid transparent; background: var(--surface-2); color: var(--text); font-size: .8rem; white-space: nowrap; }
.tag.agent { background: transparent; border-color: var(--muted); font-weight: 600; }
code.tag { font-family: var(--mono); font-size: .78rem; white-space: normal; word-break: break-all; }
.fingerprint { font-family: var(--mono); letter-spacing: .05em; word-break: break-all; }
a.tag { position: relative; text-decoration: none; }
a.tag::after { content: ''; position: absolute; inset: -11px -2px; }
a.tag:hover { text-decoration: underline; }
.tag.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.tag.agent.bad { border-color: var(--bad); }
.tag.risk, .tag.sev-medium { background: var(--orange-bg); color: var(--orange); border-color: transparent; }
.tag.sev-high { background: var(--bad-bg); color: var(--bad); border-color: transparent; font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tag.replaced { background: var(--accent-soft); border-color: transparent; }
/* mail triage (mail-triage.ts): the Email tile's links, and a category's examples; square corners, no pills */
a.tag.tag-link { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.examples > li.example { padding: .5rem 0; border-top: 1px solid var(--surface-2); }
.examples > li.example:first-child { border-top: 0; }
.examples .actions { margin-top: .25rem; }
.k { margin: .75rem 0 .25rem; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
span.k { display: block; margin: 0; }

/* icon buttons, the 50-tool note, the catalog banner */
.icon-btn, .info-btn { min-width: var(--tap); min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--text); }
.ico-copy { width: 20px; height: 20px; --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='9' y='9' width='12' height='12' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.icon-btn span[aria-hidden] { font-size: 1.5rem; line-height: 1; }
.info-btn span { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; font: italic 700 .8rem Georgia, serif; }
.info-btn[aria-expanded="true"] span { background: var(--text); color: var(--surface); border-color: var(--text); }
.note { background: var(--orange-bg); color: var(--orange); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1rem; min-height: var(--tap); padding: .6rem 1rem; margin: 0 0 1rem; border-radius: var(--radius); background: var(--orange-bg); color: var(--orange); text-decoration: none; }
.banner:hover span:last-child { text-decoration: underline; }

/* experience tiles (expandable, like agents and connectors) */
.acc-h { margin: 0; font-size: inherit; }
.agent-grid { display: grid; gap: .5rem; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.agent-btn { flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: .35rem .7rem; text-align: left; font-weight: 400; }
.agent-btn-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.tpl-list li { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; }
.tpl-list p { margin: 0; }

/* modal */
.studio-dialog { width: min(560px, calc(100vw - 2rem)); max-width: none; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.dialog-head h2 { margin: 0 0 .5rem; }
.kicker { margin: 0; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.health-line { justify-content: flex-start; gap: .25rem .6rem; }
dl.facts { display: block; margin: .5rem 0; }
.facts dt { font-size: .8rem; font-weight: 600; color: var(--muted); }
.facts dd { display: block; margin: 0 0 .75rem; }

/* experience page */
.studio-cols { display: grid; gap: 0 1.25rem; align-items: start; }
@media (min-width: 1100px) { .studio-cols { grid-template-columns: minmax(0, 1fr) 340px; } }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; margin: 1.5rem 0 .5rem; }
.sec-head h2 { margin: 0; }
.tcards { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.tcard { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); padding: .5rem .5rem .5rem 1rem; }
.tcard.on { background: var(--surface); border: 1px solid var(--text); }
.tcard p { margin: 0 0 .25rem; }
.tcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.tcard-head strong { display: inline-block; margin-top: .6rem; }
.tcard .row { justify-content: flex-start; gap: 0 1rem; }
.tcard .row a { display: inline-flex; align-items: center; min-height: var(--tap); }
.trows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.trow { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 0 .5rem 0 1rem; border-top: 1px solid var(--surface-2); }
.trow:first-child { border-top: 0; }
.trow-main { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .6rem; min-width: 0; }
.trow-main a { display: inline-flex; align-items: center; min-height: var(--tap); }
details.picker { margin-top: 1.5rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 .75rem; }
.panel h2 { margin: 0; font-size: 1.05rem; }
.panel > h2 { margin-bottom: .5rem; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem .5rem; margin-bottom: .25rem; }
.failing, .health-rows, .harness { list-style: none; margin: .5rem 0; padding: 0; }
.failing li { margin-bottom: .35rem; }
.health-rows li, .harness li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 2rem; border-top: 1px solid var(--surface-2); }
.harness li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.harness li > .small { text-align: right; }
.budget-total { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .4rem; margin: 0; }
.budget-total strong { font-size: 2rem; line-height: 1.1; }
.meter { position: relative; height: 12px; margin: .6rem 0 .25rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter-base, .meter-over { position: absolute; top: 0; bottom: 0; }
.meter-base { left: 0; background: var(--text); }
.meter-over { left: 50%; background: var(--meter-over); }
.meter-mark { position: absolute; top: 0; bottom: 0; left: calc(50% - 1px); width: 2px; background: var(--bad); }
.meter-scale { display: flex; justify-content: space-between; margin-bottom: .75rem; font-size: .75rem; color: var(--muted); }

/* expandable lists: agents, connectors, catalog groups */
.acc-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.bank-accounts { list-style: none; margin: .25rem 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.acc-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
/* a closed tile stays compact (about 80px): line 1 is one tap-height row, line 2 its tags; nothing has a flex-basis */
.acc-top { display: flex; flex-direction: column; gap: 2px; padding: 6px 1rem 10px .5rem; }
.acc-top > .tags { padding-left: 2rem; }
.acc-top > .tags:empty { display: none; }
.acc-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .6rem; cursor: pointer; }
.acc-count { display: inline-flex; align-items: center; gap: .25rem; margin-left: auto; }
button.acc { justify-content: flex-start; gap: .5rem; padding: 0 .5rem; border: 0; background: none; color: var(--text); font-size: 1.05rem; text-align: left; }
.chev::before { content: '▸'; display: inline-block; width: 1em; color: var(--muted); }
[aria-expanded="true"] > .chev::before { content: '▾'; }
.acc-body { padding: 0 1rem 1rem; border-top: 1px solid var(--border); }
.fold { border-top: 1px solid var(--surface-2); }
.fold:first-child { border-top: 0; }
.fold-head { margin: 0; font-size: 1rem; }
button.fold-btn { width: 100%; justify-content: space-between; padding: 0; border: 0; background: none; color: var(--text); text-align: left; }
.fold-body { padding-bottom: .75rem; }
.conn-health { display: inline-flex; align-items: center; gap: .3rem; margin-right: .5rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; margin-bottom: .75rem; }
.toolbar > input { flex: 1 1 14rem; width: auto; }
.add-conn { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.add-conn label { margin: 0; }
.add-conn select { width: auto; }

/* an agent's tools: a 4-column grid on wide screens, stacked cells with labels on phones */
.tool-grid { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: .5rem; }
.tool-row { display: grid; gap: .5rem; padding: .6rem .75rem; border-top: 1px solid var(--surface-2); }
.tool-head { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tool-cell { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; min-width: 0; overflow-wrap: anywhere; }
.tool-cell select { width: auto; max-width: 100%; }
.tool-cell p { margin: 0; }
.cell-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tool-group { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; padding: .25rem .75rem; background: var(--surface-2); }
.tool-group button.link { padding: .25rem .5rem; }
.tool-edit { padding: .75rem; background: var(--accent-soft); }
.tool-edit-grid { display: grid; gap: .75rem; }
@media (min-width: 760px) {
  .tool-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) minmax(0, .8fr) minmax(0, .9fr); }
  .tool-head { position: static !important; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; border-top: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
  .cell-label { display: none; }
  .tool-edit-grid { grid-template-columns: 1fr 1fr; }
}

/* connector tools and their descriptions */
.ep-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.ep-item { border-top: 1px solid var(--surface-2); padding: .25rem 0; }
.ep-item:first-child { border-top: 0; }
.ep-line { display: grid; gap: .25rem .75rem; align-items: center; }
@media (min-width: 760px) { .ep-line { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; } }
.ep-what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.ep-desc { margin: 0; }
.ep-edit { padding: .75rem; margin-bottom: .5rem; border-radius: 8px; background: var(--accent-soft); }
.seg { display: inline-flex; flex-wrap: wrap; margin-bottom: .75rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.ep-view:empty { display: none; }
.diff { margin-bottom: .75rem; padding: .5rem .75rem; border-radius: 8px; background: var(--surface); font-family: var(--mono); font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff .add { color: var(--ok); }
.diff .del { color: var(--bad); }

/* endpoints: a section per connector, a tile per endpoint */
.ep-conn > .sec-head .acc-count { margin-left: 0; }
.ep-about { margin: 0 0 .5rem; }
.ep-used { margin: 0 0 .75rem; }
.ep-used > .small { margin-right: .15rem; }
.ep-conn > p.small { margin-bottom: .75rem; }
.acc-top > .ep-when { margin: 0; padding-left: 2rem; color: var(--muted); }
.ep-inputs { list-style: none; margin: 0 0 .5rem; padding: 0; }
.ep-inputs li { border-top: 1px solid var(--surface-2); padding: .35rem 0; overflow-wrap: anywhere; }
.ep-inputs li:first-child { border-top: 0; }
.ep-inputs p { margin: .1rem 0 0; }

/* catalog health */
.counters { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.counter { min-width: 7rem; padding: .5rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.counter strong { display: block; font-size: 1.6rem; line-height: 1.2; }
.collide { display: grid; gap: 0 1rem; }
@media (min-width: 760px) { .collide, .before-after { grid-template-columns: 1fr 1fr; } }
.fixes { margin: 0 0 .5rem; padding-left: 1.25rem; }
.fixes li { margin-bottom: .35rem; }
.change { margin-bottom: .75rem; }
.before-after { display: grid; gap: .5rem; margin-top: .25rem; }
.before, .after { padding: .5rem .75rem; border-radius: 8px; background: var(--surface-2); }
.after { background: var(--accent-soft); }
.before p, .after p { margin: .25rem 0 0; white-space: pre-wrap; }
details.done > summary { margin: -.25rem 0; }

/* ==== chat and trace (js/views/chat*.js, js/views/trace*.js): admin-only chat, live trace tree, annotations ==== */
main:has(> .chat) { max-width: 1440px; }
.chat { overflow-wrap: anywhere; }
.ico-chat { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v11H10l-5 4v-4H4z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico-thumb { width: 20px; height: 20px; --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 11v9H3v-9zM7 11l4-8a2 2 0 0 1 2 2v4h5.5a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.3 20H7' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico-thumb.down { transform: rotate(180deg); }
.chat-switch { margin-bottom: 1rem; }
.chat-grid { display: grid; gap: 1rem; align-items: start; min-width: 0; }
.chat-pane { min-width: 0; }
.chat-pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem .75rem; margin: 0 0 .5rem; }
.chat-pane-head h2 { margin: 0; }
.chat-pane-head .actions { margin-top: 0; }
.chat-right, .chat-thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.field-error { color: var(--bad); font-weight: 600; margin: 0 0 .5rem; }

/* sessions and the new-chat form */
.chat-list { margin-bottom: .75rem; }
.chat-list .fold-head { border-bottom: 1px solid var(--border); }
.chat-session-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; max-height: 16rem; overflow-y: auto; }
button.chat-session { width: 100%; flex-direction: column; align-items: flex-start; gap: 0; padding: .35rem .75rem; font-weight: 400; text-align: left; }
button.chat-session[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.chat-session-name { font-weight: 600; }
.chat-session-list button:focus-visible, .trace-tree button:focus-visible { outline-offset: -3px; }
.chat-harnesses { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.chat-harnesses legend { font-weight: 600; padding: 0; margin-bottom: .25rem; }
.chat-harness .small { display: block; }
.chat-par input[type="number"], .chat-new input[type="number"] { width: 7rem; }

/* the conversation and composer */
.chat-thread h2 { margin: 0 0 .25rem; }
.chat-scroll { margin: .5rem 0; }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.msg { max-width: 92%; padding: .5rem .85rem; border-radius: var(--radius); background: var(--surface-2); }
.msg[data-role="user"] { align-self: flex-end; background: var(--accent-soft); }
.msg-who { display: block; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text:empty, .msg-activity:empty, .msg-foot:empty { display: none; }
.msg-activity { margin: .25rem 0 0; }
.msg-error { color: var(--bad); font-weight: 600; }
.chat-composer { border-top: 1px solid var(--border); padding-top: .5rem; background: var(--surface); }
.chat-composer .field { margin-bottom: .5rem; }
.chat-composer textarea { min-height: 3.5rem; }
.chat-composer-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem; }
.chat-composer-bar .actions { margin-top: 0; }
.chat-par label { font-size: .875rem; }

/* the trace tree: nested lists of disclosure buttons */
.trace-sum { margin: 0 0 .5rem; }
.trace-empty { margin: .5rem 0; }
.trace-tree, .tnode-kids { list-style: none; margin: 0; padding: 0; }
.tnode-kids { margin-left: .6rem; padding-left: .5rem; border-left: 2px solid var(--border); }
.tnode-row { border-radius: 8px; }
.tnode[data-kind="subagent"] > .tnode-row { border-left: 4px solid var(--accent); }
.tnode[data-status="error"] > .tnode-row { background: var(--bad-bg); }
button.tnode-btn { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: .2rem .45rem; padding: .3rem .5rem; border: 0; background: none; font-weight: 400; text-align: left; }
button.tnode-btn:hover { background: var(--surface-2); }
.tkind { padding: 0 .4rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.tnode[data-kind="subagent"] > .tnode-row .tkind { background: var(--accent-soft); border-color: transparent; }
.tname { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.tnode[data-kind="run"] > .tnode-row .tname, .tnode[data-kind="subagent"] > .tnode-row .tname { font-weight: 600; }
.tstatus { display: inline-flex; align-items: center; gap: .3rem; padding: 0 .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.tstatus::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tstatus.ok { background: var(--ok-bg); color: var(--ok); }
.tstatus.error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.tstatus.running { background: var(--accent-soft); color: var(--text); }
.tstatus.cancelled { background: var(--surface-2); color: var(--muted); }
.tdur, .tnotes { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.tnode-body { padding: 0 0 .25rem .5rem; }
.tnode-detail { padding: 0 .25rem; }
.tnode-detail:empty { display: none; }
.tfacts { margin: .25rem 0; }
.terror { margin: .25rem 0 .5rem; padding: .5rem .75rem; border-radius: 8px; background: var(--bad-bg); color: var(--bad); white-space: pre-wrap; overflow-wrap: anywhere; }
details.tblock { margin: 0 0 .25rem; }
details.tblock > summary { min-height: 2.75rem; list-style: none; gap: .35rem; font-size: .9rem; }
details.tblock > summary::-webkit-details-marker { display: none; }
details.tblock > summary::before { content: '▸'; width: 1em; color: var(--muted); }
details.tblock[open] > summary::before { content: '▾'; }
pre.tpre { max-height: 18rem; overflow: auto; margin: 0 0 .5rem; font-size: .8rem; }

/* annotations */
.tann { padding: 0 .25rem .25rem; }
.tann-list { list-style: none; margin: .25rem 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.tnote { padding: .4rem .6rem; border-radius: 8px; background: var(--surface-2); }
.tnote-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.tnote-why { margin: .2rem 0 0; }
.tann-note { margin: .25rem 0; }
button.tann-toggle { padding: .5rem 0; }
.tann-form { margin: .25rem 0 .5rem; padding: .75rem; border-radius: 8px; background: var(--accent-soft); }
.tthumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.tthumbs .k { width: 100%; margin: 0; }
button.tthumb[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .tstatus.running::before { animation: tpulse 1.2s ease-in-out infinite; }
  @keyframes tpulse { 50% { opacity: .25; } }
}
/* phones and tablets: one pane at a time. The composer stays in the page flow (not sticky), so it never covers a
   focused message or button (WCAG 2.4.11); sending scrolls the reply into view. */
@media (max-width: 1099.98px) {
  .chat-grid[data-pane="chat"] > .chat-right, .chat-grid[data-pane="trace"] > .chat-left { display: none; }
}
@media (max-width: 480px) { .tabs:has(> a:nth-of-type(7)) a { font-size: .625rem; } }
/* wide screens: conversation and trace side by side, each scrolling on its own */
@media (min-width: 1100px) {
  .chat-switch { display: none; }
  .chat-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.25rem; }
  .chat-scroll { max-height: calc(100dvh - 30rem); min-height: 12rem; overflow-y: auto; }
  .chat-right { position: sticky; top: calc(61px + 1rem); }
  .trace-scroll { max-height: calc(100dvh - 14rem); overflow-y: auto; }
}
/* viewers (anonymized: no message text, structure-only traces, aliases), an admin's Mine / All list, read-only chats */
.ico-eye-off { width: 18px; height: 18px; --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 12s3.5-6 9-6 9 6 9 6-3.5 6-9 6-9-6-9-6z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='12' r='3' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M4 4l16 16' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.badge.anon { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .7rem; font-size: .85rem; background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.trace-head { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.trace-head .badge.anon { padding: .1rem .55rem; font-size: .75rem; }
.trace-head .ico-eye-off { width: 16px; height: 16px; }
.chat-filter { margin: .5rem 0 .25rem; }
.chat-filter button { min-width: 4.5rem; }
.chat-session-who { font-size: .875rem; }
.chat-readonly { margin: .5rem 0; }
.tclass { font-weight: 600; }
.ttok { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.ttok:empty { display: none; }
/* assistant replies rendered as Markdown (js/markdown.js); the user's own text stays plain, pre-wrapped */
.msg[data-role="assistant"] .msg-text { white-space: normal; }
.msg-text > :last-child { margin-bottom: 0; }
.msg-text p, .msg-text ul, .msg-text ol, .msg-text blockquote, .msg-text pre { margin: 0 0 .6rem; }
.msg-text ul, .msg-text ol { padding-left: 1.25rem; }
.msg-text li + li { margin-top: .15rem; }
.msg-text h3, .msg-text h4, .msg-text h5, .msg-text h6 { margin: .75rem 0 .35rem; font-size: 1rem; }
.msg-text :not(pre) > code { padding: 0 .3rem; border-radius: 4px; background: var(--surface); }
.msg-text pre { background: var(--surface); font-size: .85rem; }
.msg-text blockquote { margin-left: 0; padding-left: .75rem; border-left: 3px solid var(--border); color: var(--muted); }
.msg-text hr { border: 0; border-top: 1px solid var(--border); }
/* ==== end chat and trace ==== */
/* Markdown replies: no gap above a leading heading or rule; code in a block keeps the block's size, not .9em of it */
.msg-text > :first-child { margin-top: 0; }
.msg-text pre code { font-size: inherit; }
