/* ===========================================================
   indie.chat — design system
   Swiss/editorial · terracotta accent · mono labels
   =========================================================== */

:root {
  /* canvas + surface */
  --canvas:      #e7e7e8;
  --surface:     #ffffff;
  --surface-2:   #f3f3f4;
  --surface-3:   #eaeaec;

  /* ink */
  --ink:         #18181a;
  --ink-2:       #4d4d51;
  --ink-3:       #88888d;
  --ink-4:       #b0b0b6;

  /* lines */
  --line:        #dbdbde;
  --line-2:      #c8c8cd;
  --line-strong: #18181a;

  /* brand */
  --terra:       #c2562d;
  --terra-ink:   #a8441f;
  --terra-wash:  #efe2db;
  --terra-line:  #ddc0b1;

  --green:       #4f7a5b;
  --green-wash:  #e4eae5;
  --green-line:  #c2d0c4;

  --maroon:      #8c3526;
  --gold:        #7c7c82;

  /* type */
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* metrics */
  --rad:   3px;
  --rad-lg: 4px;
  --col:   42rem;   /* message column width */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ONE scrollbar everywhere: the thin pill the sidebar's list always had. Only
   that list and the transcript were styled, so the apps list and every menu,
   modal and panel showed the browser's own beside it, arrows and all.
   Chrome and Safari draw it from the ::-webkit-scrollbar rules. Firefox has
   none of those and gets the standard properties instead, ONLY Firefox:
   Chrome drops the ::-webkit-scrollbar styling once scrollbar-color is set. */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
*::-webkit-scrollbar-button { display: none; }
@supports (-moz-appearance: none) {
  * { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; }
::selection { background: var(--terra-wash); }

/* mono label utility */
.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ====================== app shell ====================== */
.app {
  display: grid;
  grid-template-columns: var(--side-w, 264px) 1fr;
  height: 100%;
  overflow: hidden;
}

.scrim { display: none; }

/* ====================== sidebar ====================== */
.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;        /* anchors the drag handle on its right edge */
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
}
.logo {
  width: 30px; height: 30px;
  background: var(--logo-img, url(/icons/logo.png)) center / contain no-repeat;
  flex: none;
}
.brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-name b, .bd { color: var(--terra); font-weight: 800; }
.brand-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-top: 1px;
}

.new-chat {
  margin: 2px 14px 14px;
  padding: 11px 14px;
  background: var(--terra);
  color: #fff;
  border: none;
  border-radius: var(--rad);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background .14s ease;
}
.new-chat:hover { background: var(--terra-ink); }
.new-chat .plus { font-size: 14px; line-height: 1; display: inline-flex; }
.new-chat .plus svg { width: 15px; height: 15px; }

.conv-head {
  padding: 4px 18px 8px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 12px;
}

.conv {
  position: relative;
  padding: 9px 11px 9px 12px;
  border-radius: var(--rad);
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.conv:hover { background: var(--surface-3); }
.conv.active {
  background: var(--surface);
  border-color: var(--line);
}
.conv.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--terra);
}
.conv-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 18px;
}
.conv-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  text-transform: uppercase;
}
/* what an agent is for, one line under its name */
.conv-desc {
  font-size: 11.5px; line-height: 1.35; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 18px;
}
.conv-del {
  position: absolute;
  top: 7px; right: 6px;
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: var(--ink-4);
  border-radius: var(--rad);
  display: none;
  align-items: center; justify-content: center;
  font-size: 14px;
}
.conv:hover .conv-del { display: flex; }
.conv-del:hover { background: var(--terra-wash); color: var(--maroon); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  flex: none;
}
.dot.off { background: var(--maroon); }
.foot-txt { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--ink-3); text-transform: uppercase; }
.foot-txt b { color: var(--ink); font-weight: 600; }
/* footer links — one consistent full-width row each (stacked) */
.install-link, .foot-link {
  width: 100%; box-sizing: border-box; margin: 0;
  display: inline-flex; align-items: center; gap: 7px; justify-content: flex-start;
  white-space: nowrap;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--rad); padding: 7px 10px;
  background: transparent; color: var(--ink-3);
}
.foot-link:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface); }
.install-link svg, .foot-link svg { width: 13px; height: 13px; flex: none; }
/* the install CTA keeps the terracotta accent */
.install-link { color: var(--terra-ink); border-color: var(--terra-line); background: var(--terra-wash); }
.install-link:hover { border-color: var(--terra); }

/* ====================== main ====================== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas);
}

/* Sits ABOVE the transcript, so its dropdowns open over the conversation
   instead of behind it. backdrop-filter makes this a stacking context, which
   traps the menu's own z-index inside — the topbar itself has to outrank the
   scroller, and the scroller became a positioned element when it gained the
   jump-to-end button. Kept under the canvas (30), scrim (55) and modals. */
.topbar {
  height: 56px;
  flex: none;
  position: relative;
  z-index: 25;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 86%, #fff);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
/* The kind label ("AGENT", "APP", "CHAT") is fixed width and the NAME is what
   truncates. Ellipsising the whole block instead left "A…" in a narrow pane —
   the label eating the space it was meant to caption. */
.topbar-title {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
}
.topbar-title .tt-kind {
  flex: none;
  color: var(--ink-4); font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.topbar-title .tt-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* model selector */
.model-sel { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 7px 11px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap;        /* never wrap the label onto multiple lines */
  min-width: 0;
}
.model-btn .sel-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 170px;
}
.model-btn:hover { border-color: var(--line-2); }
.model-btn .sq { width: 8px; height: 8px; background: var(--terra); flex: none; }
.model-btn .chev { color: var(--ink-4); font-size: 9px; margin-left: 2px; }
.model-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.28);
  min-width: 248px;
  padding: 5px;
  z-index: 40;
  /* every engine's models in one list can be long */
  max-height: min(70vh, 560px); overflow-y: auto;
}
.model-opt {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none; background: transparent;
  border-radius: var(--rad);
  text-align: left;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--ink);
}
.model-opt:hover { background: var(--surface-3); }
.model-opt .sq { width: 8px; height: 8px; background: var(--ink-4); flex: none; }
.model-opt.sel .sq { background: var(--terra); }
.model-opt .desc { display:block; font-family: var(--sans); font-size: 11px; letter-spacing: 0; color: var(--ink-3); text-transform: none; margin-top: 2px; }
.model-opt .label { flex: 1; }
/* "in memory": the model is loaded and answers immediately. Absence means we
   were not told, never that the model is cold, so it stays a quiet marker
   rather than a status anyone reads as authoritative. */
/* Box busy: is the model working, and is it for somebody else? A self-hosted
   deployment has one model server, so another person's turn is why yours waits
   — quiet grey when the work is your own, accented when it is not. */
.box-busy {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 100px;
  color: var(--ink-4); background: var(--surface); white-space: nowrap; cursor: default;
}
.box-busy .bb-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--ink-4); animation: bb-pulse 1.6s ease-in-out infinite;
}
.box-busy.others { border-color: var(--terra-line); background: var(--terra-wash); color: var(--terra-ink); }
.box-busy.others .bb-dot { background: var(--terra); }
@keyframes bb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .box-busy .bb-dot { animation: none; } }

/* Scope control: personal vs shared. The panel states both consequences in
   full because neither is visible at the moment of clicking, and one of them
   hands somebody's saved data to everyone. */
.app-scope { position: relative; }
.app-scope-btn {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); color: var(--ink-3); cursor: pointer; white-space: nowrap;
}
.app-scope-btn:hover { color: var(--ink); border-color: var(--line-2); }
.app-scope-btn.on { border-color: var(--green-line); background: var(--green-wash); color: var(--green); }
.app-scope-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  width: 320px; padding: 10px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad);
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.28);
  font-size: 12.5px; color: var(--ink-2); text-align: left; white-space: normal;
}
.app-scope-panel p { margin: 2px 0 8px; color: var(--ink); }
.app-scope-panel ul { margin: 0 0 10px; padding-left: 16px; }
.app-scope-panel li { margin: 4px 0; line-height: 1.45; }
.app-scope-panel.done { border-color: var(--terra-line); }
.app-scope-actions { display: flex; gap: 8px; justify-content: flex-end; }
.app-scope-actions .act-btn.primary { border-color: var(--terra); color: var(--terra-ink); background: var(--terra-wash); }

/* Context gauge: how full the window is after the last turn. A bar plus the
   numbers, because "72%" and "94k/131k" answer different questions. */
.ctx-gauge {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  color: var(--ink-3); white-space: nowrap;
}
.ctx-bar {
  display: inline-block; width: 46px; height: 4px;
  background: var(--surface-3); border-radius: 2px; overflow: hidden;
}
.ctx-fill { display: block; height: 100%; background: var(--ink-4); }
.ctx-gauge.warm { color: var(--ink-2); }
.ctx-gauge.warm .ctx-fill { background: var(--terra); }
.ctx-gauge.hot { color: var(--maroon); }
.ctx-gauge.hot .ctx-fill { background: var(--maroon); }

.model-warm {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 5px;
  border: 1px solid var(--green);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  vertical-align: 1px;
}
.model-opt .check { color: var(--terra); font-size: 12px; }

/* caption row inside dropdown menus */
.menu-cap {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-4); padding: 4px 10px 6px;
}
/* an engine's name over its models, in the one engine-and-model menu */
.model-menu .menu-cap.group { margin-top: 4px; padding-top: 9px; border-top: 1px solid var(--line); }

/* provider selector — live status dot (green = the chosen provider is the
   one that actually served the last response) */
.prov-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); flex: none; }
.prov-dot.on { background: var(--green); }
.prov-sel .model-btn .chev { margin-left: 2px; }

/* ====================== scroll / messages ====================== */
/* Wrapper exists only to anchor the floating "jump to end" button; it must
   pass the flex sizing straight through so the scroller behaves as before. */
.scroll-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Shown only while the newest turn is out of sight. In a long conversation
   that is the difference between reading and hunting. */
.scroll-down {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.13);
  z-index: 5;
}
.scroll-down:hover { color: var(--terra); border-color: var(--terra-line); }

.thread {
  max-width: var(--col);
  margin: 0 auto;
  padding: 30px 24px 24px;
}

.msg { padding: 14px 0 22px; }
.msg + .msg { border-top: 1px solid var(--line); }
.msg-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 9px;
}
.msg-sq { width: 9px; height: 9px; flex: none; }
.msg.user  .msg-sq { background: var(--ink); }
.msg.bot   .msg-sq { background: var(--terra); }
.msg-role {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-2);
}
.msg.bot .msg-role { color: var(--terra-ink); }
.msg-provider {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-4);
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  white-space: nowrap;
}
.msg-time { font-family: var(--mono); font-size: 10px; color: var(--ink-4); letter-spacing: 0.05em; margin-left: auto; }

.msg-body {
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.msg.user .msg-body { white-space: pre-wrap; }

.msg-actions {
  display: flex; gap: 4px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity .14s;
}
.msg:hover .msg-actions { opacity: 1; }
.act-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 4px 9px;
}
.act-btn:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface); }
.act-btn:disabled { opacity: 0.45; cursor: default; }
.act-btn.primary { background: var(--terra); color: #fff; border-color: var(--terra); }
.act-btn.primary:hover { background: var(--terra-ink); border-color: var(--terra-ink); color: #fff; }

/* inline edit of a user message */
.msg-edit { display: flex; flex-direction: column; gap: 8px; }
.msg-edit textarea {
  width: 100%; resize: vertical; min-height: 60px;
  font-family: var(--sans); font-size: 15px; line-height: 1.55; color: var(--ink);
  background: var(--surface); border: 1px solid var(--terra-line); border-radius: var(--rad);
  padding: 10px 12px; outline: none;
}
.msg-edit .edit-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* cursor blink */
.caret {
  display: inline-block;
  width: 7px; height: 1.05em;
  background: var(--terra);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 0%,50%{opacity:1} 50.01%,100%{opacity:0} }

/* ====================== markdown ====================== */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h1,.md h2,.md h3,.md h4 { font-weight: 700; line-height: 1.25; margin: 22px 0 10px; letter-spacing: -0.01em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16px; } .md h4 { font-size: 14px; }
.md ul,.md ol { margin: 0 0 14px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--ink-4); }
.md a { color: var(--terra-ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.md strong { font-weight: 700; }
.md blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 16px;
  border-left: 2px solid var(--terra-line);
  color: var(--ink-2);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.md code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.md pre {
  background: #1b1b18;
  border: 1px solid #2c2c27;
  border-radius: var(--rad-lg);
  margin: 0 0 16px;
  overflow: hidden;
}
.md pre .code-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid #2c2c27;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #8d8b83;
}
.md pre .code-copy {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  color: #b4b2a9; background: transparent; border: none; padding: 2px 4px;
}
.md pre .code-copy:hover { color: #fff; }
.md pre code {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #ecebe6;
  background: transparent;
  border: none;
  padding: 13px 14px;
  overflow-x: auto;
}
.md table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; }
.md th { background: var(--surface-3); font-weight: 600; }

/* ---- math (KaTeX) ---- */
.md .katex { font-size: 1.04em; }
.md .katex-display { margin: 12px 0; padding: 2px 0; overflow-x: auto; overflow-y: hidden; }

/* ====================== reasoning panel ====================== */
.reason {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--rad-lg);
  background: var(--surface-2);
  overflow: hidden;
}
.reason-toggle {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  padding: 8px 12px;
  background: transparent; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-4); text-align: left;
}
.reason-toggle:hover { color: var(--terra-ink); }
.reason-caret { font-size: 9px; width: 10px; }
.reason-body {
  padding: 2px 14px 12px;
  border-top: 1px solid var(--line);
  font-size: 13px; line-height: 1.6;
  color: var(--ink-3);
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 360px; overflow-y: auto;
}

/* ====================== generated-file card ====================== */
.msg-files { margin-top: 10px; }
.msg-files .file-art { margin: 0 0 6px; }
.file-art {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0 4px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--rad-lg);
  background: var(--surface-2);
}
.file-art.pending { opacity: 0.7; }
.file-art .fa-ic {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 8px;
  background: var(--terra-wash, rgba(194,86,45,0.1));
  color: var(--terra-ink);
}
.file-art .fa-ic svg { width: 18px; height: 18px; }
.file-art .fa-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.file-art .fa-name { font-weight: 600; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-art .fa-kind {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-4);
}
.file-art .fa-err { color: var(--maroon, #8c3526); text-transform: none; letter-spacing: 0; }
.file-art .fa-btn {
  flex: 0 0 auto;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em;
  padding: 7px 13px; border-radius: var(--rad);
  background: var(--terra); color: #fff; border: none; cursor: pointer;
}
.file-art .fa-btn:hover { filter: brightness(1.05); }
.file-art .fa-btn:disabled { opacity: 0.6; cursor: default; }

/* ====================== empty state ====================== */
.empty {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 24px 80px;
}
.empty-mark {
  width: 54px; height: 54px;
  /* --logo-img, like .logo above: a branded deployment sets ONE logo and the
     empty state honours it too, instead of showing indie.chat's mark. */
  background: var(--logo-img, url(/icons/logo.png)) center / contain no-repeat;
  margin-bottom: 22px;
}
.empty h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 8px; }
.empty h1 b { color: var(--terra); }
.empty .sub { font-size: 15px; color: var(--ink-2); line-height: 1.55; margin: 0 0 28px; max-width: 30rem; }
.eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-4); margin-bottom: 14px;
}
.prompts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.prompt {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 14px 15px;
  transition: border-color .14s, transform .14s;
}
.prompt:hover { border-color: var(--terra-line); transform: translateY(-1px); }
.prompt .p-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--terra); display: block; margin-bottom: 6px; }
.prompt .p-t { font-size: 13.5px; color: var(--ink); line-height: 1.4; }

/* ====================== composer ====================== */
.composer-wrap {
  flex: none;
  padding: 0 24px 20px;
  background: linear-gradient(to top, var(--canvas) 62%, transparent);
}
.composer {
  max-width: var(--col);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg);
  box-shadow: 0 8px 26px -16px rgba(0,0,0,.3);
  transition: border-color .14s;
}
.composer.focus { border-color: var(--terra-line); }
.composer.drag { border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-wash); }
/* In the AGENT layout the footer is a SIBLING of the card rather than inside it
   (chat puts it within), so its border-top landed flush on the card's bottom
   edge — measured 0px — and the card read as sitting on that line. Give the
   footer its own space so the rule belongs to the footer, not to the card. */
.agent-composer + .composer-foot { margin-top: 12px; }

/* Drop a file anywhere on the window. Sits above everything and ignores the
   pointer, so it can never swallow a drop it is only there to advertise. */
.drop-veil {
  position: fixed; inset: 0; z-index: 9000; pointer-events: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--canvas) 72%, transparent);
  backdrop-filter: blur(2px);
}
.drop-veil-box {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 26px; border: 2px dashed var(--terra); border-radius: 4px;
  background: var(--surface); color: var(--ink-1);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: 0 12px 40px rgba(0,0,0,0.16);
}
.drop-veil-box svg { width: 16px; height: 16px; }

/* attachment chips */
.attach-row {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 11px 12px 2px;
}
.chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 5px 7px 5px 8px;
  max-width: 220px;
}
.chip .chip-ic { width: 8px; height: 8px; background: var(--ink-3); flex: none; }
.chip.bin .chip-ic { background: var(--gold); }
.chip .chip-thumb { width: 20px; height: 20px; object-fit: cover; border-radius: 3px; flex: none; }

/* image attachments shown in a message (vision) */
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.msg-img { max-width: 220px; max-height: 220px; border-radius: var(--rad); border: 1px solid var(--line); }
.chip.loading .chip-ic { background: var(--terra); animation: chip-pulse 1s ease-in-out infinite; }
.chip.loading .chip-sz { color: var(--terra-ink); }
@keyframes chip-pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.chip .chip-name { font-family: var(--mono); font-size: 10.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-sz { font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); flex: none; }
.chip .chip-x { border: none; background: transparent; color: var(--ink-4); font-size: 12px; line-height: 1; padding: 0 1px; flex: none; }
.chip .chip-x:hover { color: var(--maroon); }

/* attach + tool buttons in composer */
.attach-btn {
  flex: none;
  width: 34px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: none;
  color: var(--ink-3); border-radius: var(--rad);
  margin-left: -4px;
}
.attach-btn:hover { color: var(--ink); background: var(--surface-2); }
.attach-btn svg { width: 18px; height: 18px; }

.mic-btn {
  flex: none;
  width: 34px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: none;
  color: var(--ink-3); border-radius: var(--rad);
}
.mic-btn:hover { color: var(--ink); background: var(--surface-2); }
.mic-btn svg { width: 18px; height: 18px; }
.mic-btn.rec  { color: #fff; background: var(--maroon); animation: mic-pulse 1.1s ease-in-out infinite; }
.mic-btn.busy { color: var(--terra-ink); }
.mic-btn:disabled { cursor: default; }
@keyframes mic-pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(140,53,38,0.45) } 50%{ box-shadow: 0 0 0 5px rgba(140,53,38,0) } }

.voice-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3);
}
.voice-status.rec { color: var(--maroon); }
.voice-status.err { color: var(--maroon); text-transform: none; letter-spacing: 0; }
.voice-status .rec-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--maroon); flex: none; animation: chip-pulse 1s ease-in-out infinite; }
.voice-status .rec-dot.busy { background: var(--terra); }

.tool-toggle {
  display: flex; align-items: center; gap: 7px;
  flex: none; white-space: nowrap;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 100px;
  color: var(--ink-3);
}
.tool-toggle:hover { border-color: var(--line-2); color: var(--ink-2); }
.tool-toggle.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.tool-toggle .tt-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex: none; }
.tool-toggle.on .tt-dot { background: var(--terra); }
.tool-toggle svg { width: 13px; height: 13px; flex: none; }
.tool-toggle .tt-sub { opacity: 0.6; letter-spacing: 0.04em; }

.composer-foot .foot-left { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }

/* msg attachments display */
.msg-attach { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.search-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); border: 1px solid var(--line); border-radius: 100px; padding: 3px 9px;
  margin-bottom: 9px;
}
.search-pill .tt-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--terra); }
/* prominent "what was redacted" note on a user message */
.redaction-note {
  display: flex; align-items: center; gap: 8px;
  background: var(--green-wash);
  border: 1px solid var(--green-line);
  border-left: 3px solid var(--green);
  border-radius: var(--rad);
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12.5px; line-height: 1.4;
  color: var(--green);
}
.redaction-note .rn-ic { display: inline-flex; flex: none; }
.redaction-note .rn-ic svg { width: 15px; height: 15px; }
.redaction-note b { font-weight: 600; color: var(--ink); }
.stopped-note {
  margin-top: 10px; padding: 5px 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em;
  color: var(--ink-3); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--rad); display: inline-block;
}

/* Tool-call steps shown in an assistant message (agents + MCP chat).
   Collapsed = one line; click to expand the full arguments and result. */
.tool-steps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 11px; }
.tool-step {
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad);
  overflow: hidden;
}
.tool-step.err { border-color: var(--terra-line); color: var(--maroon); }
.tool-step.open { background: var(--surface); border-color: var(--line-2); }
.tool-step .ts-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; padding: 6px 10px; cursor: pointer;
}
.tool-step .ts-row:hover { background: var(--surface-3); }
.tool-step.open .ts-row { border-bottom: 1px solid var(--line); }
.tool-step .ts-ic { display: inline-flex; color: var(--terra); flex: none; }
.tool-step .ts-ic svg { width: 13px; height: 13px; }
.tool-step .ts-name { font-weight: 600; color: var(--ink); flex: none; }
.tool-step .ts-args { color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30%; }
.tool-step .ts-res { color: var(--ink-3); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.tool-step .ts-caret { flex: none; color: var(--ink-4); font-size: 9px; }
/* a result that ends in a link (an export, a report) gets a real chip */
.tool-step .ts-link {
  display: block; margin: 0 10px 8px; padding: 5px 9px;
  font-family: var(--mono); font-size: 11px; text-decoration: none;
  color: var(--terra-ink); background: var(--terra-wash);
  border: 1px solid var(--terra-line); border-radius: var(--rad);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tool-step .ts-link:hover { border-color: var(--terra); }
.tool-step.open .ts-res { display: none; }        /* the full result is right below */
.tool-step .ts-detail { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.tool-step .ts-lbl {
  font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4);
  margin-top: 4px;
}
.tool-step .ts-lbl:first-child { margin-top: 0; }
.tool-step .ts-detail pre {
  margin: 0; padding: 8px 10px; max-height: 340px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad);
  font-family: var(--mono); font-size: 11px; line-height: 1.55; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
}
.tool-step.err .ts-detail pre { color: var(--maroon); }

/* the wiki maintainer can't be deleted — a quiet mark stands in for the ✕ */
.conv-locked { flex: none; font-size: 11px; color: var(--ink-4); padding: 0 4px; cursor: default; }

/* confirm-before-destroy */
.confirm-modal { max-width: 420px; }
.confirm-modal .modal-body p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
/* element+class, so it outranks the paragraph rule above */
.confirm-modal .modal-body p.warn-line { color: var(--maroon); }
.btn.danger { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.btn.danger:hover { background: #732c1f; border-color: #732c1f; }

/* which agent is docked to the open app (switch / disconnect) */
.app-agent-sel { position: relative; }
.app-agent-btn {
  display: inline-flex; align-items: center; gap: 6px; max-width: 190px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em;
  padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); color: var(--ink-2);
}
.app-agent-btn:hover { border-color: var(--line-2); color: var(--ink); }
.app-agent-btn.none { color: var(--ink-4); border-style: dashed; }
.app-agent-btn svg { width: 13px; height: 13px; flex: none; }
.app-agent-btn .aa-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-agent-btn .aa-caret { flex: none; font-size: 9px; color: var(--ink-4); }
.app-agent-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 244px; max-width: 300px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--rad);
  box-shadow: 0 10px 28px rgba(20,18,15,.14);
  padding: 5px; display: flex; flex-direction: column; gap: 2px;
}
.app-agent-menu .aam-head {
  font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-4); padding: 6px 8px 4px;
}
.app-agent-menu .aam-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.app-agent-menu button {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  font-size: 12.5px; padding: 7px 8px; border: 0; border-radius: var(--rad);
  background: none; color: var(--ink-2);
}
.app-agent-menu button:hover { background: var(--surface-2); color: var(--ink); }
.app-agent-menu button.on { background: var(--terra-wash); color: var(--terra-ink); font-weight: 600; }
.app-agent-menu button svg { width: 14px; height: 14px; flex: none; }
.app-agent-menu button .aa-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-agent-menu .aam-new { border-top: 1px solid var(--line); border-radius: 0; margin-top: 3px; padding-top: 9px; }
.app-agent-menu .aam-off { color: var(--maroon); font-family: var(--mono); font-size: 11px; }
.app-agent-menu .aam-off:hover { background: var(--terra-wash); color: var(--maroon); }

/* PWA install banner */
.pwa-banner {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex; align-items: center; gap: 11px;
  max-width: min(440px, calc(100vw - 24px));
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg, 12px);
  box-shadow: 0 16px 40px -14px rgba(0,0,0,.42);
}
.pwa-banner .pwa-ic { width: 34px; height: 34px; border-radius: 8px; flex: none; }
.pwa-banner .pwa-txt { font-size: 13px; line-height: 1.4; color: var(--ink-2); flex: 1; min-width: 0; }
.pwa-banner .pwa-txt b { color: var(--ink); font-weight: 600; }
.pwa-banner .pwa-install {
  flex: none;
  background: var(--terra); color: #fff; border: none;
  border-radius: var(--rad); padding: 8px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
}
.pwa-banner .pwa-install:hover { background: var(--terra-ink); }
.pwa-banner .pwa-x {
  flex: none; border: none; background: transparent; color: var(--ink-4);
  font-size: 14px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.pwa-banner .pwa-x:hover { color: var(--ink); }

.model-warn {
  display: block;
  font-size: 12px; line-height: 1.5;
  color: var(--maroon);
  background: var(--terra-wash);
  border: 1px solid var(--terra-line);
  border-radius: 7px;
  padding: 7px 11px;
  margin-bottom: 11px;
}
.model-warn b { font-weight: 600; }
.model-warn .warn-ic { margin-right: 6px; }

/* composer */
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 10px 10px 16px;
}
.composer textarea {
  flex: 1;
  border: none; outline: none; resize: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  max-height: 220px;
  padding: 6px 0;
}
.composer textarea::placeholder { color: var(--ink-4); }
.send {
  flex: none;
  width: 40px; height: 40px;
  background: var(--terra);
  border: none;
  border-radius: var(--rad);
  color: #fff;
  display: grid; place-items: center;
  transition: background .14s, opacity .14s;
}
.send:hover:not(:disabled) { background: var(--terra-ink); }
.send:disabled { background: var(--line-2); cursor: not-allowed; }
.send svg { width: 18px; height: 18px; }
/* While the agent works: queue the message (it runs when the turn is done),
   beside Stop. Quieter than Send, because the turn is still the main thing. */
.send.queue-send { background: var(--surface); color: var(--terra-ink); border: 1px solid var(--terra-line); margin-right: 6px; }
.send.queue-send:hover:not(:disabled) { background: var(--terra-wash); }

/* The agent asked and waits: a question, or an approval before a tool. */
.agent-asks { max-width: var(--col); margin: 0 auto 8px; display: flex; flex-direction: column; gap: 8px; }
/* the model says nothing: a tested suggestion (ModelHint) */
.model-hint {
  max-width: var(--col); margin: 0 auto 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  border: 1px solid var(--terra-line); border-radius: var(--rad-lg); background: var(--terra-wash);
}
.mh-text { font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.mh-why { margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); word-break: break-word; }
.mh-why.err { color: var(--maroon); }
.mh-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.mh-note { font-size: 12px; color: var(--ink-3); }
.ask-card {
  padding: 12px 14px; border: 1px solid var(--terra); border-radius: var(--rad-lg);
  background: var(--surface); box-shadow: 0 0 0 3px var(--terra-wash);
}
.ask-head { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--terra-ink); }
.ask-card.approve .ask-head { font-family: var(--sans); font-size: 13.5px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.ask-ic {
  flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--terra); color: #fff; font-family: var(--mono); font-size: 11px; font-weight: 700;
}
.ask-q { margin: 8px 0 2px; font-size: 14px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; }
.ask-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ask-opt {
  padding: 6px 12px; border: 1px solid var(--terra-line); border-radius: 100px; background: var(--terra-wash);
  color: var(--terra-ink); font-size: 13px; cursor: pointer;
}
.ask-opt:hover { border-color: var(--terra); }
.ask-hint { margin-top: 8px; font-size: 11.5px; color: var(--ink-4); }
.ask-args {
  margin: 10px 0 0; padding: 8px 10px; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2);
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
}
.ask-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ask-time { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
/* a routine the agent proposes: what, when, for which app */
.rk-rows { display: grid; gap: 4px; margin-top: 10px; }
.rk-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; font-size: 13px; line-height: 1.45; }
.rk-k { color: var(--ink-4); font-size: 12px; }
.rk-v { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.rk-v code { font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.rk-was { color: var(--ink-4); text-decoration: line-through; }
.rk-prompt { margin-top: 10px; }
.rk-prompt summary { cursor: pointer; font-size: 12px; color: var(--ink-3); }
.rk-prompt .ask-args { max-height: 220px; }
/* the email card: the mail as it will go, editable (indie-app.jsx, EmailAskCard) */
/* a tool's view (MCP Apps): its own page, framed under the tool step (indie-app.jsx, McpView) */
.mcp-view { margin: 6px 0 4px; border: 1px solid var(--line); border-radius: var(--rad-lg); background: var(--surface); overflow: hidden; }
.mcp-view.bare { border-color: transparent; background: none; }
.mcp-view-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border-bottom: 1px solid var(--line); }
.mcp-view.bare .mcp-view-head { border-bottom: 0; padding-left: 2px; }
.mcp-view-src { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.mcp-view-btn { display: grid; place-items: center; width: 24px; height: 22px; padding: 0; border: 1px solid transparent; border-radius: var(--rad); background: none; color: var(--ink-3); cursor: pointer; font-size: 13px; }
.mcp-view-btn:hover { border-color: var(--line); color: var(--ink); }
.mcp-view-frame { display: block; width: 100%; border: 0; background: transparent; color-scheme: normal; }
.mcp-view.full {
  position: fixed; inset: 24px; z-index: 900; display: flex; flex-direction: column; margin: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35); background: var(--surface); border-color: var(--line-strong);
}
.mcp-view.full .mcp-view-frame { flex: 1; height: 100% !important; }
.mcp-view-link { display: block; padding: 6px 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--terra-ink); word-break: break-all; }
.mcp-view-dl { margin-right: 8px; padding: 0; border: 0; background: none; color: var(--terra-ink); font: inherit; font-size: 12.5px; cursor: pointer; }
.mcp-view-note { margin: 6px 0; padding: 6px 10px; border-radius: var(--rad); background: var(--surface-2); font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 560px) { .mcp-view.full { inset: 0; border-radius: 0; } }
.email-card .ask-account { margin: 4px 0 8px; }
.email-reply { margin: -2px 0 8px; font-size: 12px; color: var(--ink-3); }
.email-fields { display: grid; gap: 6px; }
.email-row { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 8px; margin: 0; }
.email-row > span { font-size: 12px; color: var(--ink-4); }
.email-row input {
  min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2);
  color: var(--ink); font: inherit; font-size: 13.5px;
}
.email-row input:focus, .email-body:focus { outline: none; border-color: var(--terra); }
.email-copies { justify-self: start; margin-left: 80px; padding: 0; border: 0; background: none; color: var(--terra-ink); font-size: 12px; cursor: pointer; }
.email-body {
  width: 100%; box-sizing: border-box; margin-top: 2px; padding: 8px 10px; resize: vertical; min-height: 110px; max-height: 420px;
  border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 14px; line-height: 1.5;
}
.email-files { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.email-file {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 4px 3px 8px;
  border: 1px solid var(--line); border-radius: 100px; background: var(--surface-2); font-size: 12px; color: var(--ink-2);
}
.email-file svg { width: 12px; height: 12px; flex: none; }
.email-file-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
span.email-file-name { cursor: default; }
.email-file-size { color: var(--ink-4); font-family: var(--mono); font-size: 10.5px; }
.email-file-x { display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-4); cursor: pointer; font-size: 11px; }
.email-file-x:hover { background: var(--terra-wash); color: var(--terra-ink); }
.email-attach {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px dashed var(--line); border-radius: 100px;
  background: none; color: var(--ink-3); font-size: 12px; cursor: pointer;
}
.email-attach svg { width: 12px; height: 12px; }
.email-attach:hover { border-color: var(--terra); color: var(--terra-ink); }
.email-blocked { margin-top: 8px; padding: 6px 10px; border-radius: var(--rad); background: var(--surface-2); font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 560px) {
  .email-row { grid-template-columns: 1fr; gap: 2px; }
  .email-copies { margin-left: 0; }
}
@media (max-width: 560px) { .rk-row { grid-template-columns: 1fr; gap: 0; } }
.send.queue-send.answer { background: var(--terra); color: #fff; border-color: var(--terra); }
.conv-meta .ask-meta, .bg-status.ask { color: var(--terra-ink); font-weight: 600; }
.set-approval {
  flex: none; max-width: 170px; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); color: var(--ink-2); font-size: 11.5px;
}
.set-approval:disabled { opacity: 0.6; }

/* Messages waiting for a busy agent, above its message box. */
.agent-queue {
  max-width: var(--col); margin: 0 auto 8px; padding: 4px 8px 2px;
  border: 1px solid var(--line); border-radius: var(--rad-lg); background: var(--surface);
}
.agent-queue.held { border-color: var(--terra-line); }
.aq-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 4px 4px 6px; }
.aq-title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.aq-held { font-size: 12px; color: var(--terra-ink); }
.aq-acts { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.aq-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 5px 4px; border-top: 1px solid var(--line); }
.aq-row.other .aq-text { color: var(--ink-4); font-style: italic; }
.aq-n { flex: none; width: 14px; text-align: right; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.aq-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.aq-tag { margin-right: 6px; font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.aq-files { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-4); }
.aq-files svg { width: 12px; height: 12px; }
.aq-btn {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 100px;
  background: var(--surface); color: var(--ink-3); cursor: pointer;
}
.aq-btn:hover { border-color: var(--line-2); color: var(--ink); }
.aq-btn.primary { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.aq-x { padding: 2px 4px; border: 0; background: none; color: var(--ink-4); font-size: 12px; cursor: pointer; }
.aq-x:hover { color: var(--maroon); }
@media (max-width: 640px) {
  .aq-row { flex-wrap: wrap; }
  .aq-row .aq-text { flex-basis: 0; }
  .aq-row .aq-acts { width: 100%; justify-content: flex-end; }
}
.stop {
  flex: none;
  width: 40px; height: 40px;
  background: var(--ink);
  border: none; border-radius: var(--rad);
  display: grid; place-items: center;
}
.stop .sq { width: 12px; height: 12px; background: #fff; border-radius: 1px; }
.stop:hover { background: #000; }

.composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 8px 14px;
}
.composer-foot .hint {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em;
  color: var(--ink-4); text-transform: uppercase;
}
.composer-foot .hint b { color: var(--ink-3); }
.composer-foot .count { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }

/* error banner */
.banner {
  max-width: var(--col);
  margin: 0 auto 10px;
  background: var(--terra-wash);
  border: 1px solid var(--terra-line);
  border-radius: var(--rad);
  padding: 9px 13px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
  color: var(--maroon);
  display: flex; align-items: center; gap: 8px;
}
.banner .x { margin-left: auto; cursor: pointer; border: none; background: transparent; color: var(--maroon); font-size: 14px; }

/* ====================== routines ====================== */
.routine-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.routine-grid .field { flex: 1 1 140px; min-width: 0; }
.routine-grid select, .routine-grid input { width: 100%; }
.routine-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.routine-row .hint { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.routine-row code { font-family: var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 3px; color: var(--ink-2); }
.push-row { display: flex; align-items: center; gap: 8px; }
.push-row .btn { display: inline-flex; align-items: center; gap: 7px; }
.push-row .btn svg, .push-on svg { width: 14px; height: 14px; }
.push-on { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11px; color: var(--green); letter-spacing: 0.03em; }
.routine-list { display: flex; flex-direction: column; gap: 8px; }
.routine-item {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--rad-lg);
  background: var(--surface-2); padding: 11px 13px;
}
.routine-item.off { opacity: 0.6; }
.routine-item .ri-main { flex: 1 1 auto; min-width: 0; }
.routine-item .ri-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.routine-item .ri-meta {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink-4); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
}
.routine-item .ri-meta.sub { text-transform: none; letter-spacing: 0; }
.routine-item .ri-dot { opacity: 0.5; }
.routine-item .ri-actions { display: flex; flex-direction: column; gap: 5px; flex: none; }
.routine-item .ri-actions .act-btn { white-space: nowrap; }
.act-btn.danger:hover { color: var(--maroon); border-color: var(--terra-line); }
/* the mode a routine runs in — the one thing that differs between them */
.routine-item .ri-title { display: flex; align-items: baseline; gap: 8px; }
.ri-mode {
  flex: none; font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 10px; padding: 2px 7px; border: 1px solid;
}
.ri-mode.chat  { color: var(--ink-3); background: var(--surface-3); border-color: var(--line-2); }
.ri-mode.agent { color: var(--green); background: var(--green-wash); border-color: var(--green-line); }
.routine-item .ri-prompt {
  margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--ink-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.routine-item .ri-confirm { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--maroon); align-self: center; }

/* filter tabs + the new-routine action above the list */
.routine-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rf-tab {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); color: var(--ink-3);
}
.rf-tab:hover { border-color: var(--line-2); color: var(--ink); }
.rf-tab.on { background: var(--terra-wash); border-color: var(--terra-line); color: var(--terra-ink); }
.rf-tab span { opacity: 0.6; margin-left: 4px; }

/* chat vs agent: the one choice that changes what everything else means */
.mode-seg { display: flex; gap: 8px; }
.mode-seg button {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600; text-align: left;
}
.mode-seg button svg { width: 15px; height: 15px; }
.mode-seg button span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em;
  font-weight: 400; color: var(--ink-4); text-transform: none; line-height: 1.35; }
.mode-seg button:hover:not(:disabled) { border-color: var(--line-2); }
.mode-seg button.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.mode-seg button.on span { color: var(--terra-ink); opacity: 0.8; }
.mode-seg button:disabled { opacity: 0.5; cursor: default; }
.routines-modal { max-width: 620px; }

/* transient "reconnecting" hint — the run continues on the server */
.reconnect-banner {
  max-width: var(--col);
  margin: 0 auto 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 9px 13px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 9px;
}

/* mobile */
.menu-btn { display: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px -10px rgba(0,0,0,.4);
  }
  .app.nav-open .sidebar { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 55; }
  .app.nav-open .scrim { display: block; }
  .menu-btn {
    display: grid; place-items: center;
    width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--rad); margin-right: 12px;
  }
  .prompts { grid-template-columns: 1fr; }
  :root { --col: 100%; }
}

/* phones — keep the topbar and composer from getting cramped */
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { display: none; }          /* sidebar already shows the chat */
  .menu-btn { flex: none; margin-right: 4px; }
  .tools { gap: 6px; min-width: 0; }         /* allow the tool row to shrink */
  .model-sel { min-width: 0; }
  .model-btn { padding: 7px 8px; gap: 6px; font-size: 10px; letter-spacing: 0.03em; min-width: 0; }
  .model-btn .sel-label { max-width: 88px; }
  .model-btn .chev { font-size: 8px; }
  .icon-btn { width: 34px; height: 34px; flex: none; }
  .icon-btn svg { width: 16px; height: 16px; }

  /* dropdown menus must never overflow the viewport */
  .model-menu { min-width: 0; width: max-content; max-width: calc(100vw - 24px); }

  /* the keyboard hint is desktop-only; reclaim the row on phones */
  .composer-foot .hint { display: none; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; }
  .thread { padding-left: 16px; padding-right: 16px; }

  /* let the tool toggles wrap onto a second line instead of overflowing */
  .composer-foot { flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; }
  .composer-foot .foot-left { gap: 6px; }
  .tool-toggle { padding: 6px 9px; }
}

/* very narrow phones (≤380px) — truncate the labels harder so the
   provider+model pickers never collide with the menu/gear buttons */
@media (max-width: 380px) {
  .topbar { padding: 0 8px; gap: 6px; }
  .tools { gap: 4px; }
  .model-btn { padding: 6px 7px; gap: 5px; }
  .model-btn .sel-label { max-width: 56px; }
}

/* ====================== topbar tools + modal ====================== */
.tools { display: flex; align-items: center; gap: 9px; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  color: var(--ink-2);
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.modal-scrim {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20,18,15,.34);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 460px;
  /* never taller than the viewport — head stays put, body scrolls (mobile fix).
     vh first, then dvh for browsers that support the dynamic viewport unit. */
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.45);
  overflow: hidden;
}
.modal-head, .modal-foot { flex: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.modal-head .eb { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--terra); display: block; margin-bottom: 3px; }
.modal-x { width: 28px; height: 28px; border: none; background: transparent; color: var(--ink-3); border-radius: var(--rad); font-size: 16px; }
.modal-x:hover { background: var(--surface-3); color: var(--ink); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.preset-row { display: flex; gap: 6px; }
.preset {
  flex: 1;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 8px 6px; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--rad); color: var(--ink-2);
}
.preset.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.preset:hover { border-color: var(--line-2); }

.field label {
  display: block;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%; box-sizing: border-box;
  font-family: var(--mono); font-size: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink);
  outline: none;
}
.field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--terra-line); background: var(--surface); }
.adm-select {
  width: 100%; font-family: var(--mono); font-size: 12px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink); outline: none;
}
.adm-select:focus { border-color: var(--terra-line); background: var(--surface); }
.field .help { font-family: var(--sans); font-size: 11px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }
.field .help code { font-family: var(--mono); font-size: 10.5px; background: var(--surface-3); padding: 1px 4px; border-radius: 2px; }

.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.test-status { flex: 1; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em; }
.test-status.ok { color: var(--green); }
.test-status.bad { color: var(--maroon); }
.test-status.run { color: var(--ink-3); }
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
  padding: 9px 15px; border-radius: var(--rad); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--terra); border-color: var(--terra); color: #fff; }
.btn.primary:hover { background: var(--terra-ink); border-color: var(--terra-ink); }

.note {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-left: 2px solid var(--terra);
  border-radius: var(--rad);
  padding: 10px 12px;
  font-size: 12px; line-height: 1.5; color: var(--ink-2);
}
.note b { color: var(--ink); }
.note code { font-family: var(--mono); font-size: 11px; background: var(--surface); padding: 1px 4px; border-radius: 3px; }

.settings-sep { border-top: 1px solid var(--line); margin: 2px 0; }
.field-label-row { font-size: 13px; color: var(--ink); }
.mcp-list { display: flex; flex-direction: column; gap: 6px; }
.mcp-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad);
  padding: 7px 10px; font-family: var(--mono); font-size: 11px;
}
.mcp-row .mcp-name { font-weight: 600; color: var(--ink); flex: none; }
.mcp-row .mcp-url { color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mcp-row .mcp-x { border: none; background: transparent; color: var(--ink-4); cursor: pointer; font-size: 13px; flex: none; }
.mcp-row .mcp-x:hover { color: var(--maroon); }
.skill-add { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.skill-add textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 90px; line-height: 1.5;
  font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: var(--rad);
  padding: 9px 11px; background: var(--surface-2); color: var(--ink); outline: none;
}
.skill-add textarea:focus { border-color: var(--terra-line); background: var(--surface); }
.mcp-add { display: flex; gap: 6px; }
.mcp-add input { flex: 1; font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: var(--rad); padding: 8px 10px; background: var(--surface-2); outline: none; }
.mcp-add input:first-child { flex: 0 0 34%; }
.mcp-add input:focus { border-color: var(--terra-line); background: var(--surface); }
.mcp-add .btn { flex: none; }
.mcp-row.off { opacity: 0.55; }

/* pill on/off switch (shared by Settings rows + the Tools dropdown) */
.mcp-switch {
  flex: none; width: 30px; height: 17px; border-radius: 100px; padding: 0;
  border: 1px solid var(--line-2); background: var(--surface-3); cursor: pointer; position: relative;
}
.mcp-switch span { position: absolute; top: 1px; left: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ink-4); transition: transform .15s ease, background .15s ease; }
.mcp-switch.on { background: var(--terra-wash); border-color: var(--terra); }
.mcp-switch.on span { transform: translateX(13px); background: var(--terra); }
.mcp-switch:disabled { cursor: default; opacity: 0.6; }
.mcp-scope { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; color: var(--ink-3); background: var(--surface-3); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; margin-left: 7px; vertical-align: middle; }
.mcp-global-opt { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); cursor: pointer; }
.mcp-global-opt input { width: 15px; height: 15px; accent-color: var(--terra); }

/* Tools toggle + caret + dropdown (in the composer foot) */
.tool-toggle-wrap { position: relative; display: flex; align-items: center; }
.tool-toggle-wrap .tool-toggle { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tt-caret-btn {
  flex: none; align-self: stretch;
  border: 1px solid var(--line); border-left: none;
  border-radius: 0 100px 100px 0;
  background: var(--surface); color: var(--ink-4);
  padding: 0 9px; font-size: 9px; cursor: pointer;
}
.tt-caret-btn:hover { color: var(--ink-2); border-color: var(--line-2); }
.tt-caret-btn.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.mcp-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 40;
  min-width: 200px; max-width: 280px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg);
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.28); padding: 6px;
}
.mcp-menu-head {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-4); padding: 5px 8px 6px;
}
.mcp-menu-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: var(--rad); cursor: pointer; }
.mcp-menu-row:hover { background: var(--surface-2); }
.mcp-menu-name { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the agent composer's Tools menu: web search and each MCP server's tools.
   It hangs from the left of the foot, not from its button, so it stays on a
   phone's screen. */
.composer-foot .foot-left { position: relative; }
.tool-toggle-wrap.atm-wrap { position: static; }
.atm-wrap .tool-toggle { border-radius: 100px; }
.agent-tools-menu { min-width: 260px; max-width: min(380px, calc(100vw - 32px)); max-height: min(440px, 60vh); overflow-y: auto; }
.atm-row { display: flex; align-items: flex-start; gap: 9px; width: 100%; padding: 6px 8px; border: 0; background: none; border-radius: var(--rad); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.atm-row:hover { background: var(--surface-2); }
.atm-row .mcp-switch { display: inline-block; margin-top: 1px; }
.atm-row.nested { padding-left: 24px; }
.atm-row.off .atm-name { color: var(--ink-3); }
.atm-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.atm-name { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atm-name.strong { font-weight: 600; }
.atm-sub { font-size: 11.5px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atm-server { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.atm-note { font-size: 11.5px; line-height: 1.45; color: var(--ink-4); padding: 8px 8px 4px; }
.atm-note.err { color: var(--maroon); }

/* ====================== admin console ====================== */
.admin { min-height: 100%; display: flex; flex-direction: column; }
.admin-top {
  height: 60px; flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.admin-top .logo { width: 28px; height: 28px; }
.admin-brand { display: flex; align-items: baseline; gap: 10px; }
.admin-brand .nm { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; margin-right: 2px; }
.admin-brand .nm b { color: var(--terra); }
.admin-brand .tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-4); }
.admin-top .back {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--rad); padding: 8px 13px;
}
.admin-top .back:hover { border-color: var(--line-2); color: var(--ink); }

.admin-wrap { flex: 1; overflow-y: auto; }
.admin-inner { max-width: 920px; margin: 0 auto; padding: 34px 28px 60px; }

.admin-eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); }
.admin-h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 22px; }

/* ---- New (chat / agent) split button ---- */
/* ---- workspaces: the switcher at the top of the sidebar ---- */
.ws-switch { position: relative; margin: 0 12px 10px; }
.ws-current {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.ws-current:hover { border-color: var(--line-2); }
.ws-ic { flex: none; font-size: 13px; line-height: 1; color: var(--terra); }
.ws-label { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ws-cap { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); }
.ws-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-caret { flex: none; font-size: 10px; color: var(--ink-4); }
.ws-links { display: flex; gap: 4px; margin-top: 5px; }
.ws-links button {
  flex: 1 1 auto; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--rad);
  background: transparent; color: var(--ink-3); cursor: pointer;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
}
.ws-links button:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface); }
.ws-links .ws-gear { flex: none; display: grid; place-items: center; width: 28px; padding: 0; }
.ws-links .ws-gear svg { width: 13px; height: 13px; }
.ws-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 41;
  max-height: min(420px, 70vh); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--rad-lg);
  box-shadow: 0 14px 34px -12px rgba(0,0,0,.4); padding: 5px; display: flex; flex-direction: column; gap: 2px;
}
.ws-opt {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
  padding: 8px 10px; border: none; border-radius: var(--rad); background: transparent; color: var(--ink); cursor: pointer;
}
.ws-opt:hover { background: var(--surface-3); }
.ws-opt.on { background: var(--terra-wash); }
.ws-opt-name { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ws-opt-sub { font-size: 11px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-opt.new { flex-direction: row; align-items: center; gap: 9px; font-size: 13px; }
.ws-opt.new svg { width: 14px; height: 14px; color: var(--ink-3); }
.ws-sep { height: 1px; background: var(--line); margin: 3px 4px; }

/* move an agent or an app to another workspace (its bar) */
.ws-move { position: relative; }
.ws-move .icon-btn .ws-ic { font-size: 13px; }
.ws-move-menu { left: auto; right: 0; top: calc(100% + 6px); min-width: 200px; }

/* the start page, inside a workspace */
.ws-start { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -4px 0 14px; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.ws-start .ws-ic { font-size: 12px; margin-right: 2px; }
.ws-start-links { display: inline-flex; gap: 6px; }
.ws-start-link {
  padding: 2px 9px; border: 1px solid var(--line); border-radius: 100px; background: var(--surface); color: var(--ink-3); cursor: pointer;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
}
.ws-start-link:hover { border-color: var(--line-2); color: var(--ink); }

/* the workspace's own things */
.ws-new { max-width: 480px; }
.ws-panel { max-width: 640px; height: min(640px, calc(100vh - 40px)); }
.ws-panel:has(.ws-view) { max-width: min(980px, calc(100vw - 32px)); height: min(860px, calc(100vh - 40px)); }
.ws-tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.ws-tab {
  padding: 10px 12px 9px; border: none; border-bottom: 2px solid transparent; background: transparent; color: var(--ink-3); cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.ws-tab:hover { color: var(--ink); }
.ws-tab.on { color: var(--terra-ink); border-bottom-color: var(--terra); }
.ws-pane { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1 1 auto; }
.ws-lead { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.ws-lead code, .ws-empty code { font-family: var(--mono); font-size: 11px; background: var(--surface-3); padding: 1px 4px; border-radius: 2px; }
.ws-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.ws-row-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ws-hint { font-size: 11.5px; color: var(--ink-4); }
.ws-err { font-size: 12px; color: var(--maroon); }
.ws-warn { font-size: 12px; color: var(--terra-ink); }
.ws-saved { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--green); }
.ws-empty { padding: 14px 2px; font-size: 12.5px; color: var(--ink-4); }
.ws-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); }
.ws-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 7px 10px; border-top: 1px solid var(--line); }
.ws-item:first-child { border-top: none; }
.ws-item-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--ink); }
.ws-item-meta { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.ws-item-name .ws-item-meta { margin-left: 6px; }
.aq-btn.danger { border-color: var(--maroon); color: var(--maroon); }
/* a company folder as the files (WsFolder) */
.ws-folder { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); }
.ws-folder-head { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.ws-folder-kind { flex: none; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--terra-ink); }
.ws-folder-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; color: var(--ink); }
.ws-folder-state { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--ink-3); }
.ws-folder-types { display: flex; flex-wrap: wrap; gap: 6px; }
.aq-btn.on { border-color: var(--terra-line); color: var(--terra-ink); background: var(--terra-wash); }
.ws-folder-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ws-folder-fields label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ink-3); min-width: 0; }
.ws-folder-fields input { min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface); color: var(--ink); font-family: var(--mono); font-size: 12px; outline: none; }
.ws-folder-fields input:focus { border-color: var(--terra-line); }
.ws-check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
/* a document opened from the list, in its place (DocView) */
.ws-view { gap: 10px; }
.ws-view-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.ws-view-body { flex: 1 1 auto; min-height: 320px; display: flex; border: 1px solid var(--line); border-radius: var(--rad); overflow: hidden; }
.ws-memory-text {
  width: 100%; box-sizing: border-box; min-height: 260px; flex: 1 1 auto; resize: vertical;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12px; line-height: 1.55; outline: none;
}
.ws-memory-text:focus { border-color: var(--terra-line); background: var(--surface); }
.ws-memory-text.ws-skill-new, .ws-skill-edit .ws-memory-text { min-height: 96px; flex: none; }
.ws-skill-edit { flex-direction: column; align-items: stretch; }
.ws-sub { margin: 6px 0 0; font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); }
.ws-add { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-add input {
  flex: 1 1 140px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12px; outline: none;
}
.ws-add input:first-child { flex: 0 1 130px; }
.ws-add input:focus { border-color: var(--terra-line); background: var(--surface); }
.field input:disabled { opacity: 0.7; }

.new-split { position: relative; display: flex; gap: 0; margin: 0 12px 6px; }
.new-split .new-chat { flex: 1; margin: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.new-caret {
  flex: none; width: 34px; border: 1px solid var(--terra); border-left-color: rgba(255,255,255,0.25);
  background: var(--terra); color: #fff; border-top-right-radius: var(--rad); border-bottom-right-radius: var(--rad);
  font-size: 11px; cursor: pointer;
}
.new-caret:hover { filter: brightness(1.06); }
.new-scrim { position: fixed; inset: 0; z-index: 40; }
.new-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 41;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--rad-lg);
  box-shadow: 0 14px 34px -12px rgba(0,0,0,.4); padding: 5px; display: flex; flex-direction: column; gap: 2px;
}
.new-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: none; border-radius: var(--rad); padding: 9px 10px;
  font-size: 13px; color: var(--ink); cursor: pointer;
}
.new-menu button:hover { background: var(--surface-3); }
.new-menu svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.new-menu-ic { width: 15px; flex: none; text-align: center; font-size: 13px; line-height: 1; color: var(--ink-3); }
.beta { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--terra-ink); background: var(--terra-wash); border: 1px solid var(--terra-line); border-radius: 4px; padding: 1px 4px; margin-left: auto; }

/* ---- agent entry badge in the sidebar list ---- */
.entry-badge {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: 1px;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em;
  color: var(--terra-ink); background: var(--terra-wash); border: 1px solid var(--terra-line);
  border-radius: 4px; padding: 0 4px; margin-right: 6px;
}
.entry-badge svg { width: 10px; height: 10px; }

/* ---- agent view ---- */
.agent-tag { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--terra-ink); background: var(--terra-wash); border: 1px solid var(--terra-line); border-radius: 5px; padding: 3px 7px; }
.agent-name-edit { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--terra-line); border-radius: var(--rad); padding: 2px 7px; outline: none; min-width: 180px; }
.agent-empty { max-width: 460px; margin: 8vh auto 0; text-align: center; padding: 0 24px; }
.agent-empty-ic { width: 56px; height: 56px; margin: 0 auto 16px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--terra-ink); }
.agent-empty-ic svg { width: 28px; height: 28px; }
.agent-empty h2 { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.agent-empty p { color: var(--ink-3); line-height: 1.55; margin: 0 0 8px; }
.agent-empty-model { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.agent-empty .agent-empty-purpose { color: var(--ink); font-weight: 600; }
/* the agent-first landing (plain chat off) */
.agent-start .sub { margin-bottom: 18px; }
.start-actions { display: flex; gap: 10px; margin: 0 0 28px; }
.start-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.agent-coming {
  max-width: var(--col); margin: 0 auto; padding: 12px 14px;
  border: 1px dashed var(--line-2); border-radius: var(--rad-lg); background: var(--surface-2);
  font-size: 12.5px; line-height: 1.5; color: var(--ink-3);
}

/* ---- Agent workspace files panel ---- */
.icon-btn.on { background: var(--terra-wash); color: var(--terra-ink); border-color: var(--terra-line); }
.agent-files {
  max-width: var(--col); width: 100%; margin: 0 auto 8px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--rad-lg); background: var(--surface);
}
.agent-files-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.agent-files-head span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--ink-3); text-transform: uppercase; }
.agent-files-refresh { font-family: var(--mono); font-size: 11px; color: var(--terra-ink); background: none; border: none; cursor: pointer; padding: 2px 4px; }
.agent-files-refresh:disabled { color: var(--ink-4); cursor: default; }
.agent-files-empty { font-size: 12.5px; color: var(--ink-4); padding: 4px 2px; }
.agent-files-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; }
.agent-file { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.agent-file:hover { background: var(--surface-2); }
.agent-file-name { flex: 1 1 auto; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-file-size { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); flex: 0 0 auto; }
.agent-file-dl {
  flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.agent-file-dl:hover { color: var(--terra-ink); border-color: var(--terra-line); }
.agent-file-dl:disabled { color: var(--ink-4); cursor: default; }
.agent-file-dl svg { width: 15px; height: 15px; }

/* ---- Sidebar tabs: FOREGROUND (interactive) vs BACKGROUND (unattended) ---- */
.side-tabs {
  display: flex; gap: 0; margin-top: 2px; border-top: 1px solid var(--line);
  padding: 6px 12px 2px;
}
/* the Background tab's own way in to routines */
.bg-actions { display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px; }
.bg-new {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
  border: 1px solid var(--terra-line); background: var(--terra-wash); color: var(--terra-ink); border-radius: var(--rad);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
.bg-new svg { width: 11px; height: 11px; }
.bg-new:hover { border-color: var(--terra); color: var(--terra); }
.bg-all {
  margin-left: auto; border: none; background: none; padding: 4px 2px; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3);
}
.bg-all:hover { color: var(--ink); text-decoration: underline; }
.side-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: none; cursor: pointer; padding: 6px 4px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-4); border-bottom: 2px solid transparent;
}
.side-tab.on { color: var(--ink); border-bottom-color: var(--terra); }
.side-tab-badge {
  font-size: 9px; border-radius: 8px; padding: 1px 6px; font-weight: 700;
}
.side-tab-badge.live   { background: var(--green-wash); color: var(--green); border: 1px solid var(--green-line); }
.side-tab-badge.orphan { background: var(--terra-wash); color: var(--maroon); border: 1px solid var(--terra-line); }
.bg-row { padding-top: 8px; padding-bottom: 8px; }
.bg-status {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.03em; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bg-status.live   { color: var(--green); }
.bg-status.queued { color: var(--ink-3); }
.bg-status.orphan { color: var(--maroon); }
.bg-status.idle   { color: var(--ink-4); }
/* Loop indicator chip + loop control panel */
.loop-chip {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--green); background: var(--green-wash); border: 1px solid var(--green-line);
  border-radius: 10px; padding: 2px 8px;
}
/* read-only variant (wiki consumers) — quieter than the writer/loop chips */
.loop-chip.ro { color: var(--ink-3); background: var(--surface-2); border-color: var(--line); }
/* Interrupted-run banner (server restart) */
.orphan-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--terra-wash); border: 1px solid var(--terra-line); border-left: 3px solid var(--maroon);
  border-radius: var(--rad); padding: 9px 12px; font-size: 12.5px; color: var(--ink-2);
}
.orphan-banner .act-btn { margin-left: auto; flex: none; color: var(--maroon); border-color: var(--terra-line); }
.orphan-banner .x { flex: none; border: 0; background: none; color: var(--ink-3); cursor: pointer; }

/* ---- Apps: modular workspace tabs (central pane + agent chat right) ---- */
.apps-head { display: flex; align-items: center; justify-content: space-between; }
/* A labelled button, not a bare "+": it is the way apps are made, and people
   who missed the small plus went looking under "New agent". */
.apps-add {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border: 1px solid var(--terra-line); background: var(--terra-wash); border-radius: var(--rad);
  color: var(--terra-ink); font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; line-height: 1; cursor: pointer;
}
.apps-add svg { width: 11px; height: 11px; flex: none; }
.apps-add:hover { border-color: var(--terra); color: var(--terra); }
.apps-add:disabled { opacity: 0.6; cursor: progress; }
/* height is the user's if they've dragged the divider, else content-sized */
.apps-list { flex: none; height: var(--apps-h, auto); max-height: var(--apps-h, 32vh); overflow-y: auto; }
.app-tab .app-ic { margin-right: 7px; font-size: 13px; }
.app-scope {
  margin-left: 7px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em;
  color: var(--green); border: 1px solid var(--green-line); background: var(--green-wash);
  border-radius: 3px; padding: 1px 4px; vertical-align: 1px;
}
/* Agent engine picker (Settings, admin) */
.agent-be-opt {
  display: flex; gap: 10px; align-items: center; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface); font-size: 13px; margin-bottom: 8px;
}
.agent-be-opt input { accent-color: var(--terra); }
.agent-be-opt b { font-weight: 700; }
.agent-be-model { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-left: 8px; }

/* WebMCP tool count on the open app */
.app-tools-chip {
  margin-left: 10px; flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em;
  color: var(--green); border: 1px solid var(--green-line); background: var(--green-wash);
  border-radius: 10px; padding: 2px 8px;
}
/* The routines that keep an app up to date (or the way to make one) */
.app-routine-chip {
  /* shrinks long before the app's name does, down to its clock */
  margin-left: 8px; flex: 0 100 auto; min-width: 26px; display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; white-space: nowrap;
  color: var(--ink-2); border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 2px 8px; max-width: 190px; overflow: hidden; text-overflow: ellipsis;
}
.app-routine-chip span { overflow: hidden; text-overflow: ellipsis; }
.app-routine-chip svg { width: 12px; height: 12px; flex: none; }
.app-routine-chip:hover { border-color: var(--ink-3); }
.app-routine-chip.none { color: var(--ink-4); border-style: dashed; }
.app-routine-chip.off { color: var(--ink-4); }
.ri-app { color: var(--ink-2); }
/* Code-lock toggle (user-only): unlocked = agent may rebuild; locked = read-only to the agent */
.app-lock {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  border-radius: var(--rad); padding: 5px 10px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
}
.app-lock svg { width: 14px; height: 14px; }
/* An icon with its word beside it, in the bars where icons alone were not
   understood. The word goes on narrow screens, where the tooltip remains. */
.icon-btn.labelled {
  width: auto; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
}
.icon-btn.labelled svg { width: 15px; height: 15px; flex: none; }
@media (max-width: 1100px) {
  .icon-btn.labelled { width: 36px; padding: 0; justify-content: center; }
  .icon-btn.labelled .btn-label { display: none; }
}
.app-lock:hover { border-color: var(--ink-3); }
.app-lock.on { background: var(--terra-wash); color: var(--terra-ink); border-color: var(--terra-line); font-weight: 700; }
.app-global-opt {
  display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
  font-size: 12px; color: var(--ink-3); line-height: 1.45;
  padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--rad);
}
.app-global-opt input { margin-top: 2px; accent-color: var(--terra); }
.appws { flex: 1; min-height: 0; display: flex; }
/* A pane kept mounted for an app that is not the active entry. The class
   above would win over the UA's [hidden] rule, so say it explicitly. */
.appws[hidden] { display: none; }
.appws-stage { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.appws-frame { flex: 1; width: 100%; border: 0; background: var(--canvas); }
.appws-note { padding: 26px; font-size: 13px; color: var(--ink-3); }
.appws-note.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); }
.appws-chat {
  flex: 0 0 var(--chat-w, 30%); min-width: 280px; min-height: 0;
  display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--surface);
}
/* The docked pane is narrow by design: drop the chrome that only repeats what
   the pane already is, so the agent's NAME gets the width instead. */
.appws-chat .topbar { padding: 0 14px; gap: 8px; }
.appws-chat .topbar-title .tt-kind { display: none; }
.appws-chat .agent-tag { display: none; }
.appws-chat .tools { gap: 6px; }
.appws-chat .agent-shell, .appws-chat .agent-pane { min-width: 0; }
.appws-chat .thread { padding-left: 16px; padding-right: 16px; }
.appws-chat .composer-wrap { padding-left: 12px; padding-right: 12px; }
/* The agent's own canvas split can't fit a 30% column — hide it there. */
.appws-chat .agent-canvas { display: none; }
.appws-chat .agent-empty p { max-width: 260px; }
@media (max-width: 900px) {
  .appws { flex-direction: column; }
  .appws-stage { flex: 1 1 55%; }
  /* stacked, so the stored width is meaningless here */
  .appws-chat { flex: 1 1 45%; max-width: none; min-width: 0; border-left: 0; border-top: 1px solid var(--line); }
  .appws > .splitter { display: none; }
}

/* ---------- draggable pane dividers ----------
   A splitter is a thin hit-target sitting ON the existing 1px border, so the
   layout does not shift when one is added. It only paints on hover/drag. */
.splitter {
  flex: none; position: relative; z-index: 15;
  background: transparent; border: 0; padding: 0;
  touch-action: none;                 /* we handle the drag ourselves */
}
.splitter.v { width: 7px; margin: 0 -3px; cursor: col-resize; align-self: stretch; }
.splitter.h { height: 7px; margin: -3px 0; cursor: row-resize; }
.splitter::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  background: var(--terra); opacity: 0; transition: opacity .12s;
}
.splitter.v::after { width: 2px; }
.splitter.h::after { height: 2px; }
.splitter:hover::after, .splitter.on::after, .splitter:focus-visible::after { opacity: .55; }
.splitter:focus-visible { outline: none; }
/* the sidebar edge is a grid boundary, so its splitter rides the border */
.splitter.side-edge {
  position: absolute; top: 0; bottom: 0; right: -3px; width: 7px;
  cursor: col-resize; margin: 0;
}
/* while dragging, keep the cursor consistent and stop text/iframe selection */
body.resizing { cursor: col-resize; user-select: none; }
body.resizing.row { cursor: row-resize; }
body.resizing iframe { pointer-events: none; }
@media (max-width: 800px) { .splitter.side-edge { display: none; } }
/* right-pane agent picker (app has no linked agent yet) */
.app-agent-pick { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; overflow-y: auto; }
.app-agent-pick .agent-empty-ic { margin-bottom: 2px; }
.app-agent-pick h3 { font-size: 15px; font-weight: 800; margin: 4px 0 0; }
.app-agent-pick p { font-size: 12.5px; color: var(--ink-3); max-width: 250px; margin: 0 0 10px; }
.app-pick-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 260px;
  padding: 9px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rad); font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.app-pick-btn svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.app-pick-btn:hover { border-color: var(--terra); }
.app-pick-btn.new { color: var(--terra); border-style: dashed; }
.app-pick-rec {
  margin-left: auto; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--terra-ink); background: var(--terra-wash); border: 1px solid var(--terra-line); border-radius: 4px; padding: 1px 4px;
}
.app-pick-or { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); margin: 6px 0 0; }
/* template picker modal */
.app-picker { width: min(480px, 92vw); }
.app-picker-intro { font-size: 13px; line-height: 1.55; color: var(--ink-3); margin: 0 0 4px; }
.app-tpl {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rad); cursor: pointer; font: inherit;
}
.app-tpl:hover { border-color: var(--terra); }
.app-tpl:disabled { opacity: 0.6; cursor: default; }
.app-tpl-ic { font-size: 20px; flex: none; }
.app-tpl-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-tpl-tx b { font-size: 13.5px; }
.app-tpl-tx span { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.app-tpl-busy { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--terra); flex: none; }

/* ---- Agent visual canvas (right split panel) ---- */
.agent-shell { flex: 1; min-height: 0; display: flex; flex-direction: row; position: relative; }
.agent-pane { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.agent-canvas {
  flex: 0 0 46%; min-width: 380px; min-height: 0;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: var(--surface);
}
.agent-canvas-head {
  flex: none; height: 48px; display: flex; align-items: center; gap: 9px;
  padding: 0 10px 0 14px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.acv-kind { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--terra-ink); background: var(--terra-wash); border: 1px solid var(--terra-line); border-radius: 4px; padding: 2px 6px; flex: none; }
.acv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.acv-open { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--terra-ink); text-decoration: none; background: none; border: 1px solid var(--terra-line); border-radius: 5px; padding: 3px 7px; cursor: pointer; }
.acv-open:hover { background: var(--terra-wash); }
.acv-close { flex: none; border: none; background: transparent; color: var(--ink-4); font-size: 14px; cursor: pointer; padding: 4px 6px; }
.acv-close:hover { color: var(--maroon); }
.acv-tabs { flex: none; display: flex; gap: 4px; overflow-x: auto; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.acv-tab { flex: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.acv-tab:hover { color: var(--ink); }
.acv-tab.on { color: var(--terra-ink); background: var(--terra-wash); border-color: var(--terra-line); font-weight: 600; }
.agent-canvas-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.canvas-frame { flex: 1; width: 100%; border: none; background: #fff; }
.canvas-md { flex: 1; overflow: auto; padding: 18px 22px; }
.canvas-status { flex: 1; padding: 22px; color: var(--ink-3); font-size: 13px; }
.canvas-status.err { color: var(--maroon); }
.stopped-note.err { color: var(--maroon); }
/* a conversation that no longer fits the window: why, and what helps */
.stopped-note.ctx-full { display: block; max-width: 640px; line-height: 1.5; }
.ctx-full-why { margin-top: 4px; color: var(--ink-3); }
.ctx-full-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mermaid-fig { margin: 14px 0; text-align: center; }
.mermaid-fig svg { max-width: 100%; height: auto; }
.canvas-table table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.canvas-table th, .canvas-table td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.canvas-table th { background: var(--surface-2); }

/* Narrow screens: the canvas overlays the conversation instead of splitting. */
@media (max-width: 900px) {
  .agent-canvas { position: absolute; inset: 0; flex: none; z-index: 30; min-width: 0; }
}

/* ---- Settings page ---- */
/* ---- Settings: the ONE page (settings-app.jsx) ----
   Left nav grouped You / Workspace, one subject per section, and on every card
   a chip saying WHO the setting affects. */
.set-page { height: 100%; }
.set-body { flex: 1; min-height: 0; display: flex; }
.set-nav {
  width: 236px; flex: none; overflow-y: auto;
  padding: 20px 12px 24px; border-right: 1px solid var(--line); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 2px;
}
.set-nav-group {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-4); padding: 14px 10px 6px;
}
.set-nav-group:first-child { padding-top: 2px; }
.set-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid transparent; background: transparent; border-radius: var(--rad);
  padding: 8px 10px; font-size: 13.5px; color: var(--ink-2); cursor: pointer;
}
.set-nav-item svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.set-nav-item:hover { background: var(--surface); color: var(--ink); }
.set-nav-item.on { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; }
.set-nav-item.on svg { color: var(--terra); }
.set-nav-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-nav-item .set-badge { flex: none; }
.set-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--terra); color: #fff; font-family: var(--mono); font-size: 10px; font-weight: 600;
  display: inline-grid; place-items: center;
}
.set-nav-hint { margin-top: auto; padding: 18px 10px 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-4); }

.set-main { flex: 1; min-width: 0; overflow-y: auto; }
.set-inner { max-width: 760px; margin: 0 auto; padding: 30px 32px 90px; }
.set-h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 6px; }
.set-lead { font-size: 14px; line-height: 1.55; color: var(--ink-3); margin: 0 0 22px; max-width: 60ch; }

.set-card-head { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; }
.set-card-head .set-title { margin: 0; flex: 1; min-width: 0; }
.set-card-head + .set-desc { margin-top: 2px; }
.set-saved { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--green); opacity: 0; transition: opacity .2s ease; }
.set-saved.on { opacity: 1; }

/* WHO it affects. Terra = reaches other people; ink = follows your account;
   grey = stays on this browser or device. */
.set-scope {
  flex: none; font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 7px; border-radius: var(--rad); border: 1px solid var(--line); color: var(--ink-3);
  background: var(--surface); white-space: nowrap; cursor: help;
}
.set-scope.account { color: var(--ink-2); border-color: var(--line-2); }
.set-scope.everyone { color: var(--terra-ink); border-color: var(--terra-line); background: var(--terra-wash); }

.set-msg { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.set-msg.ok { color: var(--green); }
.set-msg.bad { color: var(--maroon); }
.set-row { flex-wrap: wrap; }
.set-row > .btn { flex: none; }
/* A disabled button has to LOOK disabled, or an empty form reads as a button
   that does nothing when pressed. */
.btn:disabled, .btn:disabled:hover { opacity: 0.45; cursor: default; }
.btn.primary:disabled:hover { background: var(--terra); border-color: var(--terra); }
.set-form { display: flex; flex-direction: column; }
.set-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.set-3col { display: grid; grid-template-columns: 180px 1fr 110px; gap: 0 12px; }
.set-card select:not(.adm-select) {
  width: 100%; font-family: var(--sans); font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--rad); padding: 8px 10px; background: var(--surface-2); outline: none;
}
.set-card select:not(.adm-select):focus { border-color: var(--terra-line); background: var(--surface); }
/* Code-ish text that must read exactly as typed. NOT the global .mono, which is
   a label style (uppercase, tracked, grey) and turned a connector called
   invoice_lookup into INVOICE_LOOKUP, in the list and while typing it. */
.set-mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0; text-transform: none; }

/* switch rows (composer tools) */
.set-sw-list { display: flex; flex-direction: column; }
.set-sw-row { display: flex; align-items: flex-start; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.set-sw-row:first-child { border-top: none; padding-top: 4px; }
.set-sw-text { flex: 1; min-width: 0; }
.set-sw-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.set-sw-desc { font-size: 12.5px; line-height: 1.45; color: var(--ink-3); margin-top: 2px; }
.set-sw-row.off .set-sw-name { color: var(--ink-3); }
.set-sw-row .switch { margin-top: 2px; flex: none; }
.set-sub { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; max-width: 420px; }
.set-sub-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.set-sub input { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: var(--rad); padding: 8px 10px; background: var(--surface-2); outline: none; }
.set-sub input:focus { border-color: var(--terra-line); background: var(--surface); }
.set-sub .help { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
.set-adv { margin-top: 8px; }
.set-adv summary { font-size: 12px; color: var(--ink-3); cursor: pointer; user-select: none; width: max-content; }
.set-adv summary:hover { color: var(--ink); }

/* lists (MCP servers, connectors, skills, wiki agents) */
.set-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); margin-bottom: 12px; }
.set-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); min-width: 0; }
.set-item:first-child { border-top: none; }
.set-item.off .set-item-name, .set-item.off .set-item-meta { opacity: 0.55; }
.set-item-name { font-size: 13.5px; font-weight: 600; color: var(--ink); flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-item-meta { flex: 1; min-width: 0; font-family: var(--mono); font-size: 11px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-item-meta b { color: var(--ink-3); font-weight: 600; }
.set-item-meta em { color: var(--terra-ink); font-style: normal; }
/* shrinks and wraps: a long one (a managed server's) ran past the card */
.set-item-note { flex: 0 1 auto; min-width: 0; font-size: 11px; color: var(--ink-4); }
.set-item .adm-select { flex: none; width: auto; min-width: 150px; }
.set-empty { font-size: 13px; color: var(--ink-4); padding: 4px 0 12px; }
.set-add { display: flex; gap: 6px; }
.set-add input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: var(--rad); padding: 8px 10px; background: var(--surface-2); outline: none; }
.set-add input:first-child { flex: 0 0 32%; }
.set-add input:focus { border-color: var(--terra-line); background: var(--surface); }
.set-add .btn { flex: none; }
.set-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); cursor: pointer; width: max-content; max-width: 100%; }
.set-check input { width: 15px; height: 15px; accent-color: var(--terra); }
/* skills edited as their SKILL.md, and plugins (Settings -> Integrations) */
.set-item.skill-edit { flex-direction: column; align-items: stretch; }
.set-item.skill-edit textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12px; line-height: 1.5; resize: vertical; outline: none; }
.plugin-item { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); min-width: 0; }
.plugin-item:first-child { border-top: none; }
.plugin-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.plugin-req { flex: none; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--terra-ink); border: 1px solid var(--terra-line); background: var(--terra-wash); border-radius: 3px; padding: 1px 6px; }
.plugin-desc, .plugin-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.plugin-note { color: var(--ink-4); }
.plugin-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.plugin-acts .set-check { margin-top: 0; }
.plugin-src { flex: 1 1 120px; min-width: 0; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plugin-install { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.plugin-or { font-size: 12px; color: var(--ink-4); }
.plugin-git { flex: 1 1 220px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12px; outline: none; }
.plugin-git:focus { border-color: var(--terra-line); background: var(--surface); }
/* the models in order of priority (Settings -> All agents) */
.prio-n { flex: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.prio-item:first-child .prio-n { background: var(--terra); color: #fff; }
.prio-test { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.prio-test.ok { color: var(--green); }
.prio-test.bad { color: var(--maroon); cursor: help; }
.prio-add { margin-top: 10px; }
.prio-add .adm-select { flex: 1 1 220px; min-width: 0; }
.prio-wait { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }
.prio-wait input { width: 80px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12px; }
/* an entry's window in tokens; empty shows the engine's own */
.prio-win { flex: none; width: 88px; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 11px; }
.prio-win::placeholder { color: var(--ink-4); }
/* connections (Settings -> Integrations) */
.conn-cat { flex: none; min-width: 64px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); }
.mini.primary { border-color: var(--terra-line); color: var(--terra-ink); background: var(--terra-wash); }
.conn-setup { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); }
.conn-setup .field { margin: 0; }
.conn-scopes { width: 100%; box-sizing: border-box; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface); color: var(--ink); font-family: var(--mono); font-size: 11.5px; outline: none; }
.conn-setup .set-foot-note code { font-family: var(--mono); font-size: 11px; word-break: break-all; }
.set-subform { border: 1px dashed var(--line-2); border-radius: var(--rad); padding: 14px 14px 10px; background: var(--surface-2); margin-top: 4px; }
.set-subform .field input, .set-subform .field textarea, .set-subform .field select { background: var(--surface); }
.set-foot-note { margin-top: 12px; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.set-foot-note code, .set-foot-note b { color: var(--ink-2); }
.set-foot-note code { font-family: var(--mono); font-size: 11px; background: var(--surface-3); padding: 1px 4px; border-radius: 2px; }
.set-foot-note a { color: var(--terra-ink); text-decoration: none; font-weight: 600; }
.set-foot-note a:hover { text-decoration: underline; }
.set-callout {
  margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--terra-line); border-radius: var(--rad);
  background: var(--terra-wash); color: var(--terra-ink); font-size: 13px; font-weight: 600;
}
.set-callout.bad { margin: 12px 0 0; color: var(--maroon); font-weight: 500; line-height: 1.5; }
.set-callout.bad code { font-family: var(--mono); font-size: 11.5px; }
.set-reach-ok { margin-top: 10px; font-size: 12.5px; color: var(--green); }
.set-reach-pending { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }

/* account */
.set-profile { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.set-avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--terra-wash); color: var(--terra-ink);
  border: 1px solid var(--terra-line); font-weight: 700; font-size: 15px;
}
.set-avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.set-profile-id { flex: 1; min-width: 0; }
.set-profile-name { font-size: 16px; font-weight: 700; }
.set-profile-email { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }

/* users */
.set-users { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); margin-bottom: 14px; }
/* name, then ONE meta line (email · role · status), actions on the right: the
   first cut put role and status in columns and the buttons wrapped under every
   row but your own, so the list looked ragged. */
.set-user { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.set-user:first-child { border-top: none; }
.set-user.waiting { background: var(--terra-wash); }
.set-user-id { flex: 1; min-width: 0; }
.set-user-name { font-size: 13.5px; font-weight: 600; }
.set-user-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; min-width: 0; }
.set-user-email { font-family: var(--mono); font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.set-user-role { font-family: var(--mono); font-size: 11px; color: var(--ink-3); flex: none; }
.set-user-role::before { content: "·"; margin-right: 8px; color: var(--ink-4); }
.set-user-meta .tag-chip { flex: none; padding: 1px 6px; font-size: 9px; }
.set-user .row-acts { flex: none; }
.set-you { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 7px; vertical-align: 1px; }

/* agents: a row per agent, opening onto its own instructions */
.set-agents { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); margin-bottom: 12px; }
.set-agent { border-top: 1px solid var(--line); }
.set-agent:first-child { border-top: none; }
.set-agent-head { display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-width: 0; }
.set-agent-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; text-align: left;
  border: none; background: transparent; padding: 4px 0; cursor: pointer; color: var(--ink);
}
.set-agent-caret { flex: none; width: 12px; font-size: 13px; line-height: 1; color: var(--ink-3); transition: transform .15s ease; }
.set-agent.open .set-agent-caret { transform: rotate(90deg); color: var(--terra); }
.set-agent-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-agent-toggle:hover .set-agent-name { color: var(--terra-ink); }
.set-agent-chip {
  flex: none; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--green); border: 1px solid var(--green-line); background: var(--green-wash); border-radius: 4px; padding: 1px 6px;
}
.set-agent-wiki { flex: none; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.set-agent-wiki .adm-select { width: auto; min-width: 150px; }
.set-agent .set-instr { padding: 2px 12px 12px 31px; }
.set-agent .set-agent-desc { padding: 2px 12px 4px 31px; margin: 0; }
.set-instr { display: flex; flex-direction: column; gap: 6px; }
.set-instr textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 120px;
  font-family: var(--sans); font-size: 13px; line-height: 1.5; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--rad); padding: 9px 11px; background: var(--surface-2); outline: none;
}
.set-instr textarea:focus { border-color: var(--terra-line); background: var(--surface); }
.set-count { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.set-count.over { color: var(--maroon); }
.set-pre {
  margin: 0; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad); padding: 10px 12px;
}
.set-dep { margin: 0 0 12px; }
.set-dep .set-pre { margin-top: 8px; }

/* the whole system prompt, layer by layer, the editable one marked */
.set-agent-prompt { padding: 0 12px 12px 31px; }
.set-prompt-wrap { margin-top: 10px; }
.set-prompt-toggle {
  display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent; padding: 2px 0;
  font-size: 12.5px; font-weight: 600; color: var(--terra-ink); cursor: pointer;
}
.set-prompt-toggle:hover { text-decoration: underline; }
.set-prompt-caret { flex: none; width: 10px; font-size: 12px; line-height: 1; transition: transform .15s ease; }
.set-prompt-toggle[aria-expanded="true"] .set-prompt-caret { transform: rotate(90deg); }
.set-prompt { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.set-prompt .set-foot-note, .set-prompt .set-callout.bad, .set-prompt .set-reach-pending { margin: 0; }
.set-prompt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.set-prompt-lead { flex: 1 1 240px; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.set-prompt-layer { display: flex; flex-direction: column; gap: 5px; padding-left: 10px; border-left: 2px solid var(--line); }
.set-prompt-layer.mine { border-left-color: var(--terra); }
.set-prompt-layer.mine .set-sub-label { color: var(--terra-ink); }
.set-prompt-label { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.set-prompt-where { font-size: 11.5px; color: var(--ink-4); }
a.set-prompt-where { color: var(--terra-ink); text-decoration: none; font-weight: 600; }
a.set-prompt-where:hover { text-decoration: underline; }
.set-prompt-hidden { font-size: 12.5px; line-height: 1.5; color: var(--ink-3); font-style: italic; }
.set-prompt .set-pre { max-height: 300px; }
.set-prompt-tools { margin-top: 0; }
.set-prompt-tools ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.set-prompt-tools li { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 12px; font-size: 12.5px; line-height: 1.45; }
.set-prompt-tools li span:last-child { color: var(--ink-3); }

/* radio lists (agent engine, network access) */
.set-radios { display: flex; flex-direction: column; gap: 6px; }
.set-radio { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); cursor: pointer; font-size: 13.5px; }
.set-radio:hover { border-color: var(--line-2); }
.set-radio.on { border-color: var(--terra); background: var(--terra-wash); }
.set-radio input { accent-color: var(--terra); margin-top: 2px; }
.set-radio-text { display: flex; flex-direction: column; gap: 2px; }
.set-radio-sub { font-size: 12.5px; color: var(--ink-3); font-weight: 400; }
.set-radio-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

@media (max-width: 760px) {
  .set-body { flex-direction: column; }
  .set-nav {
    width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 4px;
    padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav-group, .set-nav-hint { display: none; }
  .set-nav-item { width: auto; flex: none; padding: 7px 10px; }
  .set-nav-item span { overflow: visible; }
  .set-inner { padding: 22px 16px 70px; }
  .set-h1 { font-size: 24px; }
  .set-2col, .set-3col { grid-template-columns: 1fr; }
  .set-item { flex-wrap: wrap; }
  .set-item-name { max-width: none; }
  .set-add { flex-wrap: wrap; }
  .set-add input:first-child { flex: 1 1 100%; }
  .set-agent-head { flex-wrap: wrap; }
  .set-agent-wiki { width: 100%; padding-left: 19px; }
  .set-agent .set-instr { padding-left: 12px; }
  .set-agent-prompt { padding-left: 12px; }
  .set-prompt-tools li { grid-template-columns: 1fr; gap: 2px; }
  .set-user { flex-wrap: wrap; }
  .set-user .row-acts { width: 100%; flex-wrap: wrap; justify-content: flex-start; padding-left: 44px; }
  /* the section heading and the nav strip already say where you are; the tag
     is what pushed "Back to chat" onto two lines */
  .set-page .admin-top { padding: 0 16px; gap: 10px; }
  .set-page .admin-brand .tag { display: none; }
  .set-page .admin-top .back { white-space: nowrap; }
}
.set-card {
  border: 1px solid var(--line); border-radius: var(--rad-lg);
  background: var(--surface); padding: 20px 22px; margin-bottom: 16px;
}
.set-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
.set-desc { font-size: 13px; line-height: 1.5; color: var(--ink-3); margin: 0 0 14px; }
.set-card .field { margin-bottom: 12px; }
.set-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.brand-accent-row { display: flex; align-items: center; gap: 10px; }
/* .field input sets width:100% on every input, the colour swatch included, which
   stretched it across the row and squeezed the hex field to nothing. */
.field .brand-accent-row .brand-swatch { width: 44px; flex: none; padding: 2px; }
.field .brand-accent-row input:not(.brand-swatch) { flex: 1; min-width: 0; width: auto; }
.brand-accent-row > input:last-child { flex: 1; }
.brand-swatch { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface); cursor: pointer; flex: none; }
.set-row .test-status { flex: 1 1 auto; font-family: var(--mono); font-size: 11px; }
.set-actions { position: sticky; bottom: 0; padding: 14px 0 4px; background: linear-gradient(transparent, var(--canvas) 30%); }
.set-actions .btn.primary { min-width: 150px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tab {
  position: relative;
  background: transparent; border: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); padding: 11px 14px;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); font-weight: 600; }
.tab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--terra); }
.tab .n { color: var(--ink-4); margin-left: 6px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.section-head .sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-4); margin-top: 3px; }

.table { border: 1px solid var(--line); border-radius: var(--rad-lg); overflow: hidden; background: var(--surface); }
.trow {
  display: grid; align-items: center;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
}
.trow:first-child { border-top: none; }
.trow.head {
  background: var(--surface-2);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.trow .cell-main { font-weight: 600; font-size: 14px; }
.trow .cell-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 2px; word-break: break-all; }
.trow .mono-cell { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }

.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--rad); border: 1px solid var(--line);
}
.tag-chip .sq { width: 7px; height: 7px; }
.tag-chip.green { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }
.tag-chip.green .sq { background: var(--green); }
.tag-chip.gray { color: var(--ink-3); }
.tag-chip.gray .sq { background: var(--ink-4); }
.tag-chip.terra { color: var(--terra-ink); border-color: var(--terra-line); background: var(--terra-wash); }
.tag-chip.terra .sq { background: var(--terra); }

.row-acts { display: flex; gap: 6px; justify-content: flex-end; }
.mini {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: var(--rad); padding: 5px 9px;
}
.mini:hover { border-color: var(--line-2); color: var(--ink); }
.mini.danger:hover { border-color: var(--terra-line); color: var(--maroon); background: var(--terra-wash); }
.mini.approve { color: var(--green); border-color: var(--green-line); }
.mini.approve:hover { color: var(--green); border-color: var(--green); background: var(--green-wash); }

/* toggle switch */
.switch {
  width: 38px; height: 22px; border-radius: 100px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  position: relative; flex: none; transition: background .14s, border-color .14s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .16s;
}
.switch.on { background: var(--terra); border-color: var(--terra); }
.switch.on::after { transform: translateX(16px); }

.tool-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px;
  border: 1px solid var(--line); border-radius: var(--rad-lg);
  background: var(--surface); margin-bottom: 10px;
}
.tool-card .tc-body { flex: 1; }
.tool-card .tc-name { font-weight: 700; font-size: 14.5px; }
.tool-card .tc-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.45; }
.tool-card .tc-key { margin-top: 12px; }
.tool-card .tc-key input {
  width: 100%; font-family: var(--mono); font-size: 11.5px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink); outline: none;
}
.tool-card .tc-key input:focus { border-color: var(--terra-line); background: var(--surface); }
.tool-card .tc-key label { display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }

.empty-cell { padding: 22px 16px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--ink-4); }

/* ====================== auth screen ====================== */
.auth-screen {
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--canvas);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.28);
  padding: 30px 30px 24px;
}
.auth-brand {
  display: flex;
  align-items: center;
  margin-bottom: 26px;
}
.auth-tabs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--rad);
  overflow: hidden;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
}
.auth-tab.on { background: var(--terra); color: #fff; }
.auth-tab:hover:not(.on) { background: var(--surface-2); }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-error {
  background: var(--terra-wash);
  border: 1px solid var(--terra-line);
  border-radius: var(--rad);
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--maroon);
  line-height: 1.4;
}
.auth-notice {
  background: var(--green-wash, #e6efe8);
  border: 1px solid var(--green-line);
  border-radius: var(--rad);
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--green);
  line-height: 1.4;
}
/* The one sentence on the unreachable screen. No new colour token. */
.auth-offline {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.auth-note-sm {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-4);
  line-height: 1.5;
}
.auth-submit {
  width: 100%;
  padding: 11px;
  font-size: 12px;
  margin-top: 4px;
}
.auth-hint {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ====================== user foot in sidebar ====================== */
.user-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
}
/* The name and avatar open Settings -> Account: where people look first for
   "my account" in any app. */
.user-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none; border-radius: var(--rad);
  margin: -4px -6px; padding: 4px 6px;
}
.user-link:hover { background: var(--surface); }
.user-avatar {
  width: 28px; height: 28px;
  background: var(--terra);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 4px 8px;
  font-size: 13px;
  color: var(--ink-3);
  flex: none;
  cursor: pointer;
  line-height: 1;
}
.logout-btn:hover { color: var(--maroon); border-color: var(--terra-line); background: var(--terra-wash); }

/* Language switcher (Settings). A row of buttons rather than a <select>: with
   two or three languages every option is visible, and the current one reads as
   chosen rather than hidden behind a dropdown. */
.lang-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-btn {
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--rad);
  padding: 8px 14px; transition: border-color .14s, color .14s, background .14s;
}
.lang-btn:hover { border-color: var(--terra-line); color: var(--ink); }
.lang-btn.on { border-color: var(--terra); color: var(--terra-ink); background: var(--terra-wash); }

/* an agent's connections (indie-app.jsx ConnectionsModal) */
.conn-modal { max-width: 580px; }
.conn-intro { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.conn-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-4); }
.conn-note b { color: var(--ink-2); font-weight: 600; }
.conn-note.warn { color: var(--terra-ink); background: var(--terra-wash); border: 1px solid var(--terra-line); border-radius: var(--rad); padding: 9px 11px; }
.conn-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); }
.conn-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); min-width: 0; flex-wrap: wrap; }
.conn-row:first-child { border-top: none; }
.conn-row-main { flex: 1 1 180px; min-width: 0; }
.conn-row-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.conn-row-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-row-sub em { font-style: normal; color: var(--maroon); }
.conn-row-access { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
/* give an account to the person's new agents too (connectorDefaults) */
.conn-fornew { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--ink-2); cursor: pointer; line-height: 1.45; }
.conn-fornew input { margin-top: 3px; flex: none; }
.conn-apply { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.conn-fornew-mini { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11.5px; color: var(--ink-3); cursor: pointer; }
.acct-defaults { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 2px 12px 10px; }
.acct-defaults-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
.acct-default { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.acct-default .adm-select { width: auto; min-width: 0; padding: 4px 8px; font-size: 12px; }
/* Settings -> Memory: the notes a person's agents keep about them */
.mem-text { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; outline: none; }
.mem-text:focus { border-color: var(--terra-line); background: var(--surface); }
.mem-edit { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.mem-list + .mem-edit, .set-empty + .mem-edit { border: 1px solid var(--line); border-radius: var(--rad); margin-bottom: 12px; }
button.mem-item { width: 100%; background: none; border: none; border-top: 1px solid var(--line); font: inherit; text-align: left; cursor: pointer; }
button.mem-item:first-child { border-top: none; }
button.mem-item:hover, button.mem-item.on { background: var(--surface-2); }
.mem-item .set-item-meta { font-family: inherit; font-size: 12.5px; color: var(--ink-3); }
.mem-edit .set-row .test-status { flex: 1 1 auto; }
/* under an answer: the turn wrote to its owner's memory */
a.memory-note { text-decoration: none; }
a.memory-note:hover { color: var(--ink); border-color: var(--line-2, var(--ink-4)); }
.conn-row .conn-access { width: auto; min-width: 170px; flex: none; padding: 6px 9px; }
.conn-glyph { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--rad); background: var(--surface-3); color: var(--ink-2); }
.conn-glyph svg { width: 16px; height: 16px; }
.conn-glyph.g-mail { background: var(--terra-wash); color: var(--terra-ink); }
.conn-glyph.g-calendar { background: var(--green-wash); color: var(--green); }
.conn-legacy { border: 1px dashed var(--line-2); border-radius: var(--rad); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.conn-legacy-head { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.conn-back { align-self: flex-start; border: none; background: transparent; padding: 0; font-size: 12.5px; color: var(--ink-3); cursor: pointer; }
.conn-back:hover { color: var(--ink); }
.conn-search { width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-size: 13px; outline: none; }
.conn-search:focus { border-color: var(--terra-line); background: var(--surface); }
.conn-group { display: flex; flex-direction: column; gap: 2px; }
.conn-group-head { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-4); margin: 2px 0 4px; }
.conn-entry { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--rad); background: transparent; text-align: left; color: var(--ink); cursor: pointer; }
.conn-entry:hover { background: var(--surface-2); border-color: var(--line); }
.conn-entry-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.conn-entry-name { font-size: 13.5px; font-weight: 600; }
.conn-entry-about { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.conn-chip { flex: none; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-4); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; }
.conn-chip.on { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }
.conn-detail-head { display: flex; gap: 12px; align-items: flex-start; }
.conn-detail-head h3 { margin: 0 0 3px; font-size: 15px; font-weight: 700; }
.conn-detail-head p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.conn-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.conn-tool { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 3px; padding: 2px 6px; background: var(--surface-2); }
.conn-tool.w { color: var(--terra-ink); border-color: var(--terra-line); background: var(--terra-wash); }
.conn-choices { display: flex; flex-direction: column; gap: 4px; }
.conn-choices .conn-choice { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad); cursor: pointer; font-size: 13px; line-height: 1.45; color: var(--ink-2); text-transform: none; letter-spacing: 0; font-family: var(--sans); margin: 0; }
.conn-choices .conn-choice.on { border-color: var(--terra-line); background: var(--terra-wash); }
.conn-choices .conn-choice input { width: auto; height: auto; padding: 0; margin: 3px 0 0; border: 0; background: none; accent-color: var(--terra); flex: none; }
/* a mailbox over IMAP: address, password, and the server settings when needed */
.conn-mail { margin: 4px 0 12px; }
.conn-mail .field { margin-bottom: 12px; }
.conn-mail-more { margin-top: 2px; }
.conn-mail-more > summary { cursor: pointer; font-size: 12.5px; color: var(--ink-3); margin-bottom: 10px; }
.conn-mail-row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.conn-mail-row .field { flex: 1 1 140px; min-width: 0; }
.conn-choices .conn-choice b { color: var(--ink); font-weight: 600; }
.conn-choice-sub { color: var(--ink-4); font-size: 12px; }
.ask-account { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin: -2px 0 6px; }
/* Gmail without the Google sign-in (as a mailbox), and the steps a mailbox
   provider wants (connections.jsx, MAIL_HELP) */
.conn-alt, .conn-mailhelp { border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); padding: 11px 13px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.conn-alt b, .conn-mailhelp > b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.conn-alt p { margin: 4px 0 10px; color: var(--ink-3); }
.conn-mailhelp { margin: -2px 0 12px; }
.conn-mailhelp ol { margin: 6px 0 0; padding-left: 19px; }
.conn-mailhelp li { margin: 3px 0; }
.conn-mailhelp li b { color: var(--ink); font-weight: 600; }
.conn-mailhelp p { margin: 7px 0 0; }
.conn-mailhelp a { color: var(--terra-ink); font-weight: 600; text-decoration: none; word-break: break-all; }
.conn-mailhelp a:hover { text-decoration: underline; }
/* a sign-in that ends with copying an address back: numbered steps, what the
   address bar will show, and the field it goes into */
.conn-steps { margin: 0; padding: 0; list-style: none; counter-reset: conn-step; display: flex; flex-direction: column; gap: 14px; }
.conn-steps > li { counter-increment: conn-step; position: relative; padding-left: 34px; font-size: 13px; line-height: 1.5; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.conn-steps > li::before { content: counter(conn-step); position: absolute; left: 0; top: -1px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--terra-wash); border: 1px solid var(--terra-line); color: var(--terra-ink); font-family: var(--mono); font-size: 11px; font-weight: 600; }
.conn-steps b { color: var(--ink); font-weight: 600; }
.conn-steps .conn-choice-sub { color: var(--ink-3); }
.conn-steps label { font: inherit; color: inherit; text-transform: none; letter-spacing: 0; margin: 0; }
.conn-steps a.mini { text-decoration: none; }
.conn-paste-bar { display: flex; align-items: center; gap: 8px; max-width: 100%; box-sizing: border-box; padding: 6px 12px; border: 1px solid var(--line-2, var(--line)); border-radius: 999px; background: var(--surface-2); font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conn-paste-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ink-4); }
.conn-paste-input { width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-family: var(--mono); font-size: 12px; outline: none; }
.conn-paste-input:focus { border-color: var(--terra-line); background: var(--surface); }
.conn-send-mini { margin-left: 12px; }
.conn-row-main .conn-fornew-mini:first-of-type { margin-left: 0; }
/* Settings, Google sign-in: what Google makes of this server's address, the
   steps in its console, its own answer (Check), and what its errors mean */
.set-tip { margin: 0 0 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); }
.set-verdict { margin: 0 0 8px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); }
.set-verdict.ok { border-color: var(--green-line); background: var(--green-wash); }
.set-verdict.bad { border-color: var(--terra-line); background: var(--terra-wash); color: var(--terra-ink); }
.set-verdict code, .set-asked code, .set-steps code, .set-guide .help code { font-family: var(--mono); font-size: 11px; background: var(--surface-3); padding: 1px 4px; border-radius: 2px; word-break: break-all; color: var(--ink-2); }
.set-verdict b, .set-asked b, .set-steps b, .set-trouble dd b { color: var(--ink); font-weight: 600; }
.set-chip { display: inline-block; margin-left: 7px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--green); border: 1px solid var(--green-line); background: var(--green-wash); border-radius: 3px; padding: 1px 5px; vertical-align: 1px; }
.set-way .help { margin-top: 6px; }
.set-guide { margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--rad); }
.set-guide > summary { cursor: pointer; padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.set-guide[open] > summary { border-bottom: 1px solid var(--line); }
.set-steps { margin: 0; padding: 12px 14px 12px 34px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.set-steps ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.set-steps a, .set-trouble a { color: var(--terra-ink); font-weight: 600; text-decoration: none; white-space: nowrap; }
.set-steps a:hover { text-decoration: underline; }
.set-steps .help { margin-top: 6px; }
.set-uri { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.set-uri code { font-size: 11.5px; padding: 4px 7px; }
.set-asked { list-style: none; margin: 4px 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.set-asked li { position: relative; padding: 8px 11px 8px 32px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); }
.set-asked li::before { content: "?"; position: absolute; left: 11px; top: 8px; font-family: var(--mono); font-weight: 700; color: var(--ink-4); }
.set-asked li.ok { border-color: var(--green-line); background: var(--green-wash); }
.set-asked li.ok::before { content: "\2713"; color: var(--green); }
.set-asked li.bad { border-color: var(--terra-line); background: var(--terra-wash); color: var(--terra-ink); }
.set-asked li.bad::before { content: "\2717"; color: var(--maroon); }
.set-trouble { margin-top: 14px; }
.set-trouble dl { margin: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; line-height: 1.5; }
.set-trouble dt { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.set-trouble dd { margin: 0 0 9px; color: var(--ink-3); }
.set-trouble dd:last-child { margin-bottom: 0; }
@media (max-width: 560px) {
  .conn-row .conn-access { min-width: 0; flex: 1 1 140px; }
}
/* who may use a shared workspace (indie-app.jsx WsMembers) */
.ws-members { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); }
.ws-member { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); min-width: 0; }
.ws-member:first-child { border-top: none; }
.ws-member-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ws-member-mail { flex: 1 1 140px; min-width: 0; font-family: var(--mono); font-size: 11px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-member .ws-member-role { width: auto; flex: none; padding: 5px 8px; }
.ws-member-roletext { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.ws-member-add { display: flex; gap: 8px; }
.ws-member-add input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink); font-size: 13px; outline: none; }
.ws-member-add input:focus { border-color: var(--terra-line); background: var(--surface); }

/* what an agent proposed for itself, under its reply (indie-app.jsx ProposalCard) */
.msg-proposals { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.proposal-card { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--line-2); border-radius: var(--rad); background: var(--surface); }
.proposal-card.col { flex-direction: column; align-items: stretch; gap: 8px; }
.proposal-main { flex: 1; min-width: 0; }
.proposal-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.proposal-why { font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.proposal-text { margin: 0; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); color: var(--ink-2); font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.proposal-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.proposal-err { font-size: 12px; color: var(--maroon); }

/* what agents did through the app (ConnActivity, Settings ActivityCard) */
.conn-activity summary { font-size: 12.5px; color: var(--ink-3); cursor: pointer; user-select: none; width: max-content; }
.conn-activity summary:hover { color: var(--ink); }
.conn-activity[open] { display: flex; flex-direction: column; gap: 8px; }
.act-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--rad); max-height: 320px; overflow-y: auto; }
.act-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 7px 10px; border-top: 1px solid var(--line); font-size: 12px; min-width: 0; }
.act-row:first-child { border-top: none; }
.act-when { flex: none; min-width: 84px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.act-agent { flex: none; font-weight: 600; color: var(--ink-2); }
.act-tool { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.act-account { flex: 1 1 120px; min-width: 0; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-chip { flex: none; margin-left: auto; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; color: var(--ink-3); }
.act-chip + .act-chip { margin-left: 0; }
.act-chip.ok { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }
.act-chip.bad { color: var(--maroon); border-color: var(--terra-line); background: var(--terra-wash); }

/* ---- agent bundles: the start row, the catalog and sheet, the setup card, the chip ---- */
.bundle-start { margin: -10px 0 26px; }
.bundle-start .eyebrow { margin-bottom: 10px; }
.bundle-start-row { display: flex; flex-wrap: wrap; gap: 8px; }
.bundle-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
  transition: border-color .14s, transform .14s;
}
.bundle-pill:hover { border-color: var(--terra-line); transform: translateY(-1px); }
.bundle-pill-ic { color: var(--terra); font-size: 14px; line-height: 1; }
.bundle-pill.more { color: var(--ink-3); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.bundle-modal { max-width: 560px; }
.bundle-h-ic { color: var(--terra); margin-right: 8px; }
.bundle-ver { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); font-weight: 400; margin-left: 6px; }
.bundle-loading { font-size: 13px; color: var(--ink-3); }
.bundle-card {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: left;
  padding: 14px 15px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rad); cursor: pointer; font: inherit; color: var(--ink);
}
.bundle-card:hover { border-color: var(--terra); }
.bundle-card-ic { font-size: 22px; color: var(--terra); flex: none; line-height: 1.1; width: 26px; text-align: center; }
.bundle-card-tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bundle-card-tx b { font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bundle-card-tx > span { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.bundle-card-facts { font-family: var(--mono); font-size: 10px !important; letter-spacing: 0.04em; color: var(--ink-4) !important; text-transform: uppercase; }
/* an edition's own agents first, under its heading */
.bundle-group { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); margin: 6px 0 -2px; }
.bundle-sheet section h3 { margin: 0 0 8px; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); }
.bundle-desc { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.bundle-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bundle-list.tight { gap: 4px; padding-left: 2px; }
.bundle-list li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.45; }
.bundle-list li > span:nth-child(2) { flex: 1; min-width: 0; }
.bundle-li-ic { flex: none; width: 22px; height: 22px; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; }
.bundle-li-ic svg { width: 16px; height: 16px; }
.bundle-sub { display: block; font-size: 12px; color: var(--ink-3); line-height: 1.45; }
.bundle-when { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); letter-spacing: 0.02em; }
.bundle-radio { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-size: 13px; cursor: pointer; }
.bundle-radio input { margin-top: 3px; accent-color: var(--terra); }
.bundle-ws { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.bundle-foot { justify-content: space-between; }
.btn.sm { padding: 4px 10px; font-size: 11px; flex: none; }
.entry-bundle { color: var(--terra); font-size: 11px; margin-right: 2px; }
/* the chip in the agent's top bar */
.bundle-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--terra-line); background: var(--terra-wash); color: var(--terra-ink);
  border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer; max-width: 220px;
}
.bundle-chip .btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bundle-chip-ic { font-size: 12px; }
.bundle-chip-n { font-family: var(--mono); font-size: 10px; background: var(--surface); border-radius: 8px; padding: 1px 6px; color: var(--ink-3); }
/* the setup card above the message box */
.bundle-setup {
  margin: 0 24px 10px; border: 1px solid var(--terra-line); border-radius: var(--rad-lg);
  background: var(--surface); overflow: hidden; flex: none; max-height: 52vh; overflow-y: auto;
}
.bsetup-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--terra-wash); border-bottom: 1px solid var(--terra-line); position: sticky; top: 0; z-index: 1; }
.bsetup-ic { color: var(--terra); }
.bsetup-title { font-weight: 700; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bsetup-count { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.bsetup-link { border: none; background: transparent; color: var(--terra-ink); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 4px; text-decoration: underline; text-underline-offset: 2px; }
.bsetup-step { border-bottom: 1px solid var(--line); }
.bsetup-step:last-of-type { border-bottom: none; }
.bsetup-step-h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; background: transparent; border: none; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.bsetup-step-h:hover { background: var(--surface-2); }
.bsetup-check { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); flex: none; }
.bsetup-step-h.done .bsetup-check { background: var(--green-wash); border-color: var(--green-line); color: var(--green); }
.bsetup-step-t { font-size: 13px; font-weight: 600; flex: 1; }
.bsetup-step-s { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.bsetup-body { padding: 2px 14px 14px 44px; display: flex; flex-direction: column; gap: 10px; }
.bsetup-need { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.bsetup-need-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bsetup-met { font-size: 12.5px; color: var(--green); }
.bsetup-warn { display: block; font-size: 12px; color: var(--maroon); }
.bsetup-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bsetup-acts .btn { padding: 6px 11px; font-size: 12px; }
.bsetup-q { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.bsetup-q-l { font-weight: 600; }
.bsetup-q input, .bsetup-q textarea { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: var(--rad); background: var(--surface); color: var(--ink); }
.bsetup-switch { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; font-size: 13px; cursor: pointer; }
.bsetup-switch input { margin-top: 3px; accent-color: var(--terra); width: 16px; height: 16px; flex: none; }
.bsetup-switch.off { opacity: 0.75; }
.bsetup-try { display: flex; flex-direction: column; gap: 6px; }
.bsetup-try-q { text-align: left; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); font: inherit; font-size: 12.5px; color: var(--ink); cursor: pointer; line-height: 1.4; }
.bsetup-try-q:hover { border-color: var(--terra-line); }
.appws-chat .bundle-setup { margin: 0 12px 8px; }
.appws-chat .bsetup-body { padding-left: 14px; }
@media (max-width: 720px) {
  .bundle-setup { margin: 0 10px 8px; max-height: 46vh; }
  .bsetup-body { padding-left: 14px; }
  .bundle-chip { max-width: 150px; }
}

/* ---- onboarding (onboarding.jsx): the admin's setup and a new person's welcome ----
   One frame for both: the steps on the left, the step on the right, the
   actions at the bottom. On a phone the steps become a row of dots. */
.onb-scrim {
  /* above the app and its phone drawer (60), below the dialogs a step opens (.modal-scrim, 80) */
  position: fixed; inset: 0; z-index: 70;
  background: rgba(20,18,15,.34);
  display: grid; place-items: center; padding: 20px;
}
.onb {
  width: 100%; max-width: 900px;
  height: min(640px, calc(100vh - 40px)); height: min(640px, calc(100dvh - 40px));
  display: grid; grid-template-columns: 230px 1fr;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--rad-lg);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.45); overflow: hidden;
}
.onb-rail { background: var(--surface-2); border-right: 1px solid var(--line); padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; }
.onb-eb { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--terra); }
.onb-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin-bottom: 14px; line-height: 1.3; }
.onb-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.onb-step { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: none; background: transparent; color: var(--ink-3); border-radius: var(--rad); font: inherit; font-size: 13px; cursor: pointer; }
.onb-step:hover { background: var(--surface-3); color: var(--ink); }
.onb-step.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 0 var(--line); }
.onb-step-n { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-2); font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); background: var(--surface); }
.onb-step.on .onb-step-n { border-color: var(--terra); color: var(--terra); }
.onb-step.done .onb-step-n { background: var(--green-wash); border-color: var(--green-line); color: var(--green); }
.onb-dots { display: none; }
.onb-main { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.onb-close { position: absolute; top: 14px; right: 16px; border: none; background: transparent; color: var(--ink-3); font: inherit; font-size: 12px; padding: 6px 8px; border-radius: var(--rad); cursor: pointer; z-index: 1; }
.onb-close:hover { background: var(--surface-3); color: var(--ink); }
.onb-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 34px 34px 20px; display: flex; flex-direction: column; gap: 14px; }
.onb-body h2 { margin: 0 110px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; color: var(--ink); }
.onb-body h3 { margin: 10px 0 0; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); }
.onb-lead { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); max-width: 60ch; }
.onb-sub { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-3); }
.onb-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.onb-grow { flex: 1; }
.onb-err { color: var(--maroon); font-size: 12.5px; }
.onb-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface); }
.onb-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.onb-card-main b { font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.onb-card-main span { font-size: 12.5px; color: var(--ink-3); }
.onb-result { font-size: 13px; padding: 9px 12px; border-radius: var(--rad); border: 1px solid var(--line); }
.onb-result.ok { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }
.onb-result.bad { color: var(--maroon); border-color: var(--maroon); background: var(--surface-2); }
.onb-status { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--ink-4); white-space: nowrap; }
.onb-status.ok { color: var(--green); }
.onb-form { display: flex; flex-direction: column; gap: 10px; }
.onb-row2, .onb-row3 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.onb-row3 { grid-template-columns: 1fr 1fr 1fr; }
.onb-inline { display: flex; gap: 6px; }
.onb-inline input { flex: 1; min-width: 0; }
.onb-radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); cursor: pointer; }
.onb-radio:has(input:checked) { border-color: var(--terra-line); background: var(--terra-wash); }
.onb-radio input { margin-top: 3px; accent-color: var(--terra); }
.onb-radio > span { display: flex; flex-direction: column; gap: 2px; }
.onb-radio b { font-size: 13.5px; color: var(--ink); }
.onb-radio > span > span { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.onb-check { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.onb-check > span:not(.onb-status) { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.onb-check b { font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.onb-check > span > span { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.onb-check .onb-status { width: 120px; flex: none; }
.onb-added { display: flex; flex-direction: column; }
.onb-mono { font-family: var(--mono); font-size: 12px !important; color: var(--ink-2) !important; }
.onb-bundle { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface); }
.onb-bundle-ic { font-size: 22px; color: var(--terra); width: 26px; text-align: center; flex: none; }
.onb-bundle-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.onb-bundle-tx b { font-size: 14px; color: var(--ink); }
.onb-bundle-tx > span { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.onb-switch { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; margin-top: 4px; cursor: pointer; }
.onb-switch input { accent-color: var(--terra); }
.onb-edition-item { align-items: flex-start; }
.onb-check .onb-tick { width: 120px; flex: none; margin-top: 0; color: var(--ink-2); }
.onb-summary { display: flex; flex-direction: column; }
.onb-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.onb-tile { padding: 14px; border: 1px solid var(--line); border-radius: var(--rad); background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.onb-tile b { font-size: 14px; color: var(--ink); }
.onb-tile span { font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.onb-choice { display: flex; gap: 8px; flex-wrap: wrap; }
.onb-pill { padding: 8px 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.onb-pill:hover { border-color: var(--ink-3); }
.onb-pill.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); font-weight: 600; }
.onb-alt { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.onb-alt-btn { text-align: left; padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: var(--rad); background: transparent; color: var(--ink); font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.onb-alt-btn:hover { border-color: var(--terra); }
.onb-alt-btn b { font-size: 13.5px; }
.onb-alt-btn span { font-size: 12px; color: var(--ink-3); line-height: 1.45; }
@media (max-width: 720px) {
  .onb-scrim { padding: 0; }
  .onb { height: 100vh; height: 100dvh; max-width: none; border-radius: 0; border: none; grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .onb-rail { border-right: none; border-bottom: 1px solid var(--line); padding: 14px 16px 12px; overflow: visible; }
  .onb-title { margin-bottom: 6px; padding-right: 120px; }
  .onb-steps { display: none; }
  .onb-dots { display: flex; gap: 6px; }
  .onb-dots i { height: 4px; flex: 1; border-radius: 2px; background: var(--line-2); }
  .onb-dots i.on { background: var(--terra); }
  .onb-close { top: 12px; right: 10px; }
  .onb-body { padding: 20px 16px 16px; }
  .onb-body h2 { margin-right: 0; font-size: 19px; }
  .onb-foot { padding: 12px 16px; flex-wrap: wrap; }
  .onb-tiles, .onb-row2, .onb-row3, .onb-alt { grid-template-columns: 1fr; }
  .onb-card, .onb-bundle, .onb-edition-item { flex-wrap: wrap; }
  .onb-check .onb-status, .onb-check .onb-tick { width: auto; }
}

/* ===========================================================
   Dark mode. appearance.js sets <html data-theme="dark"> before anything
   paints; everything above is written in tokens, so most of dark mode is
   this one block of token values. Light mode is the rules above, untouched.
   Below the tokens: the few places that assumed a light page (ink used as a
   FILL, hovers that darken to --terra-ink, which is a TEXT colour here and
   therefore lighter, a white-mixed topbar, a backdrop that a dark page would
   swallow). Adding a rule anywhere? Use tokens and it works in both; a
   literal colour needs its dark twin here.
   A deployment's theme.css overrides :root, which this outranks; it can
   carry its own :root[data-theme="dark"] block to restyle dark mode too.
   =========================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;            /* native scrollbars, inputs, select menus */

  --canvas:      #141416;
  --surface:     #1c1c1f;
  --surface-2:   #232327;
  --surface-3:   #2b2b30;

  --ink:         #ececee;
  --ink-2:       #bdbdc3;
  --ink-3:       #8e8e95;
  --ink-4:       #616168;

  --line:        #2d2d32;
  --line-2:      #3c3c43;
  --line-strong: #ececee;

  /* the accent keeps its fill; its TEXT shade has to get lighter on dark */
  --terra:       #c2562d;
  --terra-ink:   #e8875f;
  --terra-wash:  #35241d;
  --terra-line:  #643a29;
  --terra-press: #a8441f;        /* a filled button's hover, dark mode only */

  --green:       #82b190;
  --green-wash:  #1d2a22;
  --green-line:  #31493a;

  --maroon:      #d65a43;
  --gold:        #9a9aa1;
}
:root[data-theme="dark"] .new-chat:hover,
:root[data-theme="dark"] .send:hover:not(:disabled),
:root[data-theme="dark"] .pwa-banner .pwa-install:hover { background: var(--terra-press); }
:root[data-theme="dark"] .act-btn.primary:hover,
:root[data-theme="dark"] .btn.primary:hover { background: var(--terra-press); border-color: var(--terra-press); }
:root[data-theme="dark"] .btn.danger:hover { background: #b2412d; border-color: #b2412d; }
/* ink is LIGHT here, so the stop button's square takes the page colour */
:root[data-theme="dark"] .stop .sq { background: var(--canvas); }
:root[data-theme="dark"] .stop:hover { background: #ffffff; }
:root[data-theme="dark"] .topbar { background: color-mix(in srgb, var(--canvas) 92%, #fff); }
/* code is already dark; on a dark page it needs its own edge */
:root[data-theme="dark"] .md pre { background: #0f0f11; border-color: var(--line-2); }
:root[data-theme="dark"] .md pre .code-bar { border-bottom-color: var(--line); }
/* a backdrop has to darken a page that is already dark */
:root[data-theme="dark"] .modal-scrim,
:root[data-theme="dark"] .onb-scrim,
:root[data-theme="dark"] .scrim { background: rgba(0, 0, 0, .6); }
