/* Invincible harness — minimal chat-first theme (ChatGPT/Claude/Grok style).
   Light is the default; html[data-theme="dark"] overrides below.
   No CDNs, no webfonts, no build step. */

:root {
  color-scheme: light;
  --bg: #faf9f7;
  --surface: #ffffff;
  --raise: #f1ede6;
  --border: #e7e1d6;
  --border-soft: #efe9dd;
  --ink: #1f1e1b;
  --muted: #6f6a5e;
  --faint: #a39d8d;
  --accent: #c15f3c;
  --accent-ink: #9c4a2d;
  --accent-dim: rgba(193, 95, 60, 0.10);
  --user-bubble: #ece7d9;
  --ok: #1a7f4b;
  --ok-dim: rgba(26, 127, 75, 0.10);
  --warn: #9a6b0f;
  --warn-bg: #fdf3e1;
  --warn-border: #d9a441;
  --err: #b3261e;
  --err-dim: rgba(179, 38, 30, 0.08);
  --code-bg: #f1ede4;
  --shadow: 0 1px 2px rgba(31, 30, 27, 0.06), 0 4px 16px rgba(31, 30, 27, 0.06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1b1b;
  --surface: #2e2e2e;
  --raise: #3a3a3a;
  --border: #454545;
  --border-soft: #383838;
  --ink: #ececec;
  --muted: #a8a8a8;
  --faint: #757575;
  --accent: #d08a63;
  --accent-ink: #e0a37e;
  --accent-dim: rgba(208, 138, 99, 0.14);
  --user-bubble: #333333;
  --ok: #3fd68f;
  --ok-dim: rgba(63, 214, 143, 0.12);
  --warn: #e3b341;
  --warn-bg: rgba(227, 179, 65, 0.10);
  --warn-border: #e3b341;
  --err: #f28b82;
  --err-dim: rgba(242, 139, 130, 0.12);
  --code-bg: #262626;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.shell-body {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --raise: #edf1f4;
  --border: #dce3e8;
  --border-soft: #e8edf0;
  --ink: #202a32;
  --muted: #5d6871;
  --faint: #68757e;
  --accent: #bd4d2c;
  --accent-ink: #92391f;
  --accent-dim: rgba(189, 77, 44, 0.10);
  --user-bubble: #f2e8e3;
  --warn-bg: #fff6e5;
  --warn-border: #e6bd68;
  --code-bg: #f1f3f5;
  --shadow: 0 1px 2px rgba(24, 36, 45, 0.04), 0 5px 18px rgba(24, 36, 45, 0.045);
  --radius: 8px;
  --radius-sm: 5px;
  accent-color: var(--accent);
}

html[data-theme="dark"] body.shell-body {
  --bg: #171c20;
  --surface: #20272c;
  --raise: #2a3339;
  --border: #39454d;
  --border-soft: #303a40;
  --ink: #e9eef1;
  --muted: #b0bbc1;
  --faint: #a7b3bb;
  --accent: #f08a67;
  --accent-ink: #ffad8e;
  --accent-dim: rgba(240, 138, 103, 0.14);
  --user-bubble: #3a302d;
  --warn-bg: rgba(227, 179, 65, 0.09);
  --code-bg: #1a2024;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 5px 18px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}
::selection { background: var(--accent-dim); }

/* ---------- shell ---------- */
body.shell-body {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: 100vh;
}
body.bare-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.1rem 0.8rem;
  overflow-y: auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  padding: 0.25rem 0.6rem 0.9rem;
}
.brand:hover { color: var(--accent-ink); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.5rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 800;
}
html[data-theme="dark"] .brand-mark { background: var(--accent); color: #1e1e1e; }
body.shell-body .brand-mark { border-radius: 5px; background: var(--accent); color: #fff; }
html[data-theme="dark"] body.shell-body .brand-mark { color: #251b17; }

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
button.new-chat-btn { font-family: inherit; }
.new-chat-btn:hover { border-color: var(--accent-ink); background: var(--accent-ink); color: #fff; text-decoration: none; }
html[data-theme="dark"] .new-chat-btn { color: #251b17; }
html[data-theme="dark"] .new-chat-btn:hover { color: #251b17; }

.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.42rem 0.65rem;
  border-radius: 5px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  border: 0;
  border-left: 2px solid transparent;
  padding-left: calc(0.65rem - 2px);
}
.nav-link:hover { color: var(--ink); background: var(--raise); text-decoration: none; }
.nav-link.active { color: var(--accent-ink); background: var(--accent-dim); border-left-color: var(--accent); font-weight: 650; }
/* Inline line icons (templates/_icons.html): a fixed 18px box that never
   shrinks, painted with currentColor so an icon rides the link text color
   through muted -> hover -> active without any rule of its own. */
.nav-link svg, .new-chat-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: inherit;
}

.side-section-label {
  display: block;
  padding: 1rem 0.65rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.side-search {
  width: 100%;
  margin: 0 0 0.4rem;
  padding: 0.42rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
}
.side-history { list-style: none; margin: 0; padding: 0; }
.side-history li { margin: 0; padding: 0; }
.side-history a.sess {
  display: block;
  padding: 0.42rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-history a.sess:hover { color: var(--ink); background: var(--raise); }
.side-history a.sess.active { color: var(--accent-ink); background: var(--accent-dim); font-weight: 600; }
.side-history .empty { color: var(--faint); font-size: 0.84rem; padding: 0.4rem 0.65rem; }
.side-history-more { padding: 0.35rem 0.65rem; font-size: 0.78rem; }

/* Per-chat actions: a ⋮ button revealed on hover/focus whose menu offers
   Rename / Pin / Delete (Claude-style). Same tokens as the rest of the
   shell; the menu is plain CSS + static/sidebar.js, no htmx needed. */
.side-history li.chat-row { position: relative; }
.side-history a.sess {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-right: 1.9rem;
}
.side-history a.sess .sess-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-history a.sess .sess-pin { flex: 0 0 auto; font-size: 0.72rem; opacity: 0.75; }
/* Pinned rows are ordered first server-side; the inset rule keeps that
   state readable in lists where the glyph scrolls out of view. */
.side-history li.chat-row.pinned > a.sess {
  box-shadow: inset 2px 0 0 var(--accent);
}
.chat-menu-btn {
  position: absolute;
  right: 0.28rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}
.chat-row:hover .chat-menu-btn, .chat-row:focus-within .chat-menu-btn,
.chat-row.menu-open .chat-menu-btn { opacity: 1; }
.chat-menu-btn:hover { background: var(--border-soft); color: var(--ink); }
.chat-menu {
  position: absolute;
  right: 0.28rem;
  top: calc(100% - 0.15rem);
  z-index: 30;
  min-width: 9rem;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.chat-menu[hidden] { display: none; }
.chat-menu button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0.5rem;
  text-align: left;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 0.84rem;
  cursor: pointer;
}
.chat-menu button:hover { background: var(--raise); color: var(--ink); }
.chat-menu button.danger { color: var(--err); }
.chat-menu button.danger:hover { background: var(--err-dim); color: var(--err); }
/* Inline rename field (Enter saves, Esc reverts). */
.sess-rename {
  width: 100%;
  margin: 0;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
}

.side-foot {
  margin-top: auto;
  padding: 0.9rem 0.65rem 0.2rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.side-user {
  font-size: 0.78rem;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- content ---------- */
main.content {
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 4rem;
  max-width: 72rem;
  width: 100%;
  margin-inline: auto;
}
body.shell-body main.content { padding: 2.25rem clamp(1.5rem, 4vw, 3.5rem) 4rem; max-width: 78rem; }
main.content.chat-home { max-width: 56rem; padding-top: 1.25rem; }
main.bare { max-width: 27rem; }
main.bare .brand { font-size: 1.2rem; padding-bottom: 1.2rem; }

/* ---------- typography ---------- */
h2 { font-size: 1.3rem; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
h3 { font-size: 1rem; font-weight: 650; margin: 1.6rem 0 0.5rem; letter-spacing: -0.01em; }
body.shell-body h2 { font-size: 1.38rem; font-weight: 680; letter-spacing: 0; }
body.shell-body h3 { margin-top: 1.8rem; margin-bottom: 0.6rem; letter-spacing: 0; }
h4 { font-size: 0.9rem; font-weight: 600; margin: 1.2rem 0 0.4rem; color: var(--muted); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--err); margin-top: 0.75rem; }
hr { border: none; border-top: 1px solid var(--border-soft); margin: 1.5rem 0; }

/* ---------- forms ---------- */
label { display: block; margin-top: 0.95rem; font-weight: 600; font-size: 0.85rem; }
input[type=email], input[type=password], input[type=text],
input[type=number], input[type=url], select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  margin-top: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
button {
  font: inherit;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 1.15rem;
  cursor: pointer;
  margin-top: 1rem;
}
body.shell-body button { transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease; }
button:hover { border-color: var(--accent); color: var(--accent-ink); }
.inline-form { display: inline; margin: 0; }
button.linklike {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--accent-ink); cursor: pointer; font: inherit;
  text-decoration: underline; text-underline-offset: 3px;
}
.connect-form input { margin-bottom: 0.35rem; }

/* ---------- cards / stats ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.9rem;
  margin: 1.3rem 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card .num { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card .label { display: block; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 0.3rem; }
body.shell-body .card { padding: 1rem 1.05rem; }
body.shell-body .card .num { font-size: 1.7rem; }
body.shell-body .card .label { font-weight: 600; letter-spacing: 0.04em; margin-top: 0.35rem; }


/* ---------- callouts ---------- */
.banner, .banner-ok {
  border-radius: 10px;
  padding: 0.7rem 0.95rem;
  margin: 1rem 0;
  font-size: 0.88rem;
}
.banner { border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--ink); }
.banner-ok { border: 1px solid rgba(26, 127, 75, 0.4); background: var(--ok-dim); color: var(--ink); }
body.shell-body .banner, body.shell-body .banner-ok { border-radius: var(--radius-sm); padding: 0.75rem 0.95rem; }
body.shell-body .banner { border-left-width: 3px; }
body.shell-body .banner-ok { border-left-width: 3px; }
.status-badge { padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; border: 1px solid; white-space: nowrap; }
.status-ok { color: var(--ok); background: var(--ok-dim); border-color: currentColor; }
.status-failed { color: var(--err); background: var(--err-dim); border-color: currentColor; }
.status-untested { color: var(--muted); background: var(--raise); border-color: var(--border); }
.status-running { color: var(--accent-ink); background: var(--accent-dim); border-color: currentColor; }
.status-awaiting-approval { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.status-completed { color: var(--ok); background: var(--ok-dim); border-color: currentColor; }
.status-cancelled { color: var(--muted); background: var(--raise); border-color: var(--border); }
.status-timed-out { color: var(--err); background: var(--err-dim); border-color: currentColor; }
.status-stalled { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.status-interrupted { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.task-status-summary { margin-left: 0.45rem; }

/* ---------- background tasks ---------- */
.task-start {
  margin: 1rem 0 1.5rem;
  padding: 0.9rem 1.1rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.task-start h3 { margin-top: 0; }
.task-start textarea { min-height: 5rem; font-family: inherit; }
.task-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.55rem;
}
.task-form-row button { margin-top: 0; }
.task-form-mode-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.55rem;
}
.task-form-mode-row label { margin: 0; }
.task-form-mode-row select { width: auto; margin: 0; }
.char-counter { font-variant-numeric: tabular-nums; }
#background-task-error[hidden] { display: none; }

.task-result {
  margin: 1rem 0 1.5rem;
  padding: 0.9rem 1.1rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.task-result h3 { margin: 0; }
.task-result h4 { margin-top: 1.1rem; }
.task-result-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.task-result-head .task-stop { margin-top: 0; margin-left: auto; }
.task-result-head .task-retry { margin-top: 0; margin-left: auto; }
.task-interrupted-note { margin: 0.6rem 0 0; }
.task-result-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0.35rem 0 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--raise);
  font: inherit;
  font-size: 0.9rem;
}

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); background: var(--surface); }
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tbody tr:hover td { background: var(--raise); }
body.shell-body th { padding: 0.65rem 0.75rem; font-size: 0.68rem; font-weight: 650; letter-spacing: 0.06em; color: var(--muted); background: var(--raise); }
body.shell-body td { padding: 0.68rem 0.75rem; }
body.shell-body tbody tr:hover td { background: var(--accent-dim); }
td.empty, .empty { color: var(--faint); text-align: center; padding: 1.7rem 0.5rem; }

/* ---------- code ---------- */
code { font-family: var(--mono); background: var(--code-bg); border: 1px solid var(--border-soft); border-radius: 6px; padding: 0.08em 0.35em; font-size: 0.88em; }
code.payload { font-size: 0.75rem; word-break: break-all; }
code.user-code { font-size: 1.3rem; letter-spacing: 0.14em; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { padding: 0.15rem 0; }
.config-block {
  position: relative;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin: 0.6rem 0 0.4rem;
  font-size: 0.82rem;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}
.copy-btn { position: absolute; top: 0.5rem; right: 0.5rem; margin: 0; padding: 0.18rem 0.6rem; font-size: 0.72rem; }
main.bare .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem 1.7rem; box-shadow: var(--shadow); }

/* ---------- chat main panel ---------- */
.chat-topbar { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.theme-btn {
  margin: 0;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover { color: var(--accent-ink); }
.chat-hero { text-align: center; padding: 3rem 1rem 1rem; }
.chat-hero .brand-mark-hero {
  width: 3rem; height: 3rem; font-size: 1.35rem; border-radius: 12px;
  margin: 0 auto 1rem;
}
.chat-hero h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
#chat-log { display: flex; flex-direction: column; gap: 1.1rem; margin: 0.5rem 0 1.25rem; }
.bubble { font-size: 0.96rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.bubble-user { align-self: auto; background: var(--user-bubble); border-radius: 14px; padding: 0.6rem 0.9rem; }
.bubble-assistant { align-self: auto; white-space: normal; }
.bubble .meta { display: block; margin-top: 0.4rem; font-size: 0.72rem; color: var(--faint); }
.bubble.error { color: var(--err); }
.bubble.pending { color: var(--faint); white-space: pre-wrap; }
/* Assistant markdown (server-rendered, raw HTML disabled): plain streaming
   text swaps to this on done. Scoped to .md so user bubbles keep pre-wrap. */
.bubble .md > :first-child { margin-top: 0; }
.bubble .md > :last-child { margin-bottom: 0; }
.bubble .md p { margin: 0 0 0.6rem; }
.bubble .md h1, .bubble .md h2, .bubble .md h3 { margin: 0.9rem 0 0.45rem; line-height: 1.35; }
.bubble .md h1 { font-size: 1.2rem; }
.bubble .md h2 { font-size: 1.1rem; }
.bubble .md h3 { font-size: 1rem; }
.bubble .md ul, .bubble .md ol { margin: 0 0 0.6rem 1.25rem; padding: 0; }
.bubble .md li { margin: 0.2rem 0; }
.bubble .md li::marker { color: var(--accent); }
.bubble .md code { font-family: var(--mono); font-size: 0.85em; background: var(--code-bg); border-radius: 6px; padding: 0.1rem 0.35rem; }
.bubble .md pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; overflow-x: auto; margin: 0 0 0.6rem; }
.bubble .md pre code { background: transparent; padding: 0; border-radius: 0; font-size: 0.82rem; }
.bubble .md blockquote { margin: 0 0 0.6rem; padding: 0.1rem 0 0.1rem 0.75rem; border-left: 3px solid var(--accent); color: var(--muted); }
.bubble .md table { border-collapse: collapse; margin: 0 0 0.6rem; font-size: 0.87rem; display: block; overflow-x: auto; }
.bubble .md th, .bubble .md td { border: 1px solid var(--border); padding: 0.35rem 0.6rem; text-align: left; }
.bubble .md th { background: var(--raise); }
.bubble .md a { color: var(--accent-ink); }
/* B0.2 Bmax marker: soft dot + name (no image assets, no Disney
   likeness). F19: the dot wears the web face's pink — navy ink eyes,
   theme-accent ring. */
.baymax-dot {
  display: inline-block;
  width: 1.05rem; height: 1.05rem;
  margin-right: 0.45rem;
  vertical-align: -0.18rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 42%, var(--ink) 0 0.14rem, transparent 0.15rem),
    radial-gradient(circle at 65% 42%, var(--ink) 0 0.14rem, transparent 0.15rem),
    #ff5fa6;
  border: 2px solid var(--accent);
}
.baymax-name {
  margin-right: 0.5rem;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--faint);
}
/* F19 web Bmax face (robot-heads port, /static/robot-head.js): a mount is
   a sized box whose canvas bleeds outside it for hops, the antenna glow
   and the floor shadow. The chat hero shows the still reference pose;
   the small head beside the status line reacts to the turn lifecycle. */
.chat-face { display: inline-block; margin-bottom: 0.4rem; }
.chat-face-sm { display: inline-flex; flex: none; }
.phone-face-head { display: inline-flex; flex: none; }
/* B0.3 simulated pointing: screenshot preview inside the collapsed tool
   item detail. Bounded, lazy-loaded, theme-border. */
.shot-preview {
  display: block;
  max-width: 100%;
  margin-top: 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}
.tool-line { font-size: 0.82rem; color: var(--muted); }
.tool-line.ok { color: var(--faint); }
.tool-line.failed { color: var(--err); }
/* Collapsible tool-activity group (Claude/Grok style): one summary row per
   assistant turn, expandable to the individual tools, each of which is itself
   expandable. Native <button aria-expanded> head -> keyboard accessible. */
.tool-group { font-size: 0.82rem; }
.tool-group-head {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.15rem 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-align: left;
}
.tool-group-head:hover { color: var(--ink); background: var(--raise); }
.tool-group-head .caret {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--faint);
  transition: transform 0.12s ease;
}
.tool-group-head[aria-expanded="true"] .caret { transform: rotate(90deg); }
.tool-group-head .count { color: var(--faint); font-variant-numeric: tabular-nums; }
.tool-group-head .badge-ok { color: var(--ok); }
.tool-group-head .badge-warn { color: var(--warn); }
.tool-group.running .caret { color: var(--accent); animation: tool-spin 0.9s linear infinite; }
@keyframes tool-spin { to { transform: rotate(360deg); } }
.tool-group-body[hidden] { display: none; }
.tool-group-body {
  margin: 0.3rem 0 0.1rem 0.35rem;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tool-item { display: flex; flex-direction: column; gap: 0.15rem; }
.tool-item-head {
  margin: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}
.tool-item-head:hover { color: var(--ink); }
.tool-item-head.ok { color: var(--faint); }
.tool-item-head.failed { color: var(--err); }
.tool-item-head .state { font-weight: 600; }
.tool-item-detail[hidden] { display: none; }
.tool-item-detail {
  margin: 0.1rem 0 0.15rem 1.35rem;
  font-size: 0.78rem;
  color: var(--faint);
  white-space: pre-wrap;
  word-break: break-word;
}
.tool-item-detail .out {
  display: block;
  margin-top: 0.2rem;
  padding: 0.4rem 0.6rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink);
  max-height: 14rem;
  overflow: auto;
}
.approval-card { border: 1px solid var(--warn-border); background: var(--warn-bg); border-radius: 10px; padding: 0.7rem 0.9rem; font-size: 0.87rem; }
.approval-card pre { white-space: pre-wrap; word-break: break-word; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.65rem; font-size: 0.78rem; font-family: var(--mono); max-height: 12rem; overflow-y: auto; }
.approval-card .row { display: flex; gap: 0.6rem; margin-top: 0.55rem; }
.approval-card button { margin-top: 0; }
.approval-card button.approve { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .approval-card button.approve { color: #1e1e1e; }
.approval-card button.resolved { opacity: 0.55; }
.task-approval-card { margin: 0.65rem 0; }
.approval-card-title { font-weight: 600; overflow-wrap: anywhere; }
.approval-meta { margin: 0.25rem 0 0.45rem; font-size: 0.78rem; }
.approval-warning { margin: 0 0 0.4rem; color: var(--warn); font-size: 0.8rem; font-weight: 500; }
.approval-card .approval-detail {
  max-height: 18rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.approval-decision-status { margin-top: 0.4rem; font-size: 0.78rem; }
.approval-group { margin: 1rem 0 1.4rem; }
.approval-group h3 { margin-bottom: 0.5rem; }
#chat-composer { position: sticky; bottom: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 0.6rem 0.6rem 0.5rem; }
#chat-form { display: block; margin: 0; }
#chat-form textarea { width: 100%; margin: 0; padding: 0.35rem 0.5rem; min-height: 2.4rem; font-size: 0.96rem; line-height: 1.55; font-family: inherit; color: var(--ink); background: transparent; border: 0; resize: vertical; }
#chat-form textarea:focus { outline: none; border: 0; box-shadow: none; }
#chat-composer:focus-within { border-color: var(--accent); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.15rem 0.2rem 0; }
.composer-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; min-width: 0; }
.composer-picks .pick { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; font-size: 0.76rem; font-weight: 500; color: var(--faint); }
.composer-picks .pick select {
  width: auto;
  min-width: 0;
  max-width: 12rem;
  margin: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 999px;
  background: var(--bg);
  text-overflow: ellipsis;
}
#chat-status { font-size: 0.76rem; color: var(--faint); }
.mode-hint { min-height: 1.25rem; font-size: 0.78rem; padding: 0.15rem 0.2rem 0; }
#chat-send { margin-top: 0; width: 2.4rem; height: 2.4rem; padding: 0; border-radius: 50%; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 1.05rem; line-height: 1; flex-shrink: 0; }
html[data-theme="dark"] #chat-send { color: #1e1e1e; }
#chat-send:disabled { opacity: 0.45; cursor: default; }

.hint-chips { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0 0; }
.hint-chips button { margin: 0; border-radius: 999px; font-size: 0.82rem; color: var(--muted); }

/* ---------- confirm modal + toasts (destructive actions) ---------- */
#confirm-modal[hidden] { display: none; }
#confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.confirm-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  max-width: 26rem;
  width: 100%;
}
.confirm-card h3 { margin: 0 0 0.35rem; }
.confirm-card p { margin: 0 0 1rem; }
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}
.confirm-actions button { margin-top: 0; }
#confirm-ok {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}
#confirm-ok:hover { color: #fff; filter: brightness(1.08); }
html[data-theme="dark"] #confirm-ok { color: #1e1e1e; }
button.linklike:disabled {
  color: var(--faint);
  cursor: default;
  text-decoration: none;
}
#toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.95rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  max-width: 22rem;
  animation: toast-in 0.18s ease;
}
.toast-error { background: var(--err); color: #fff; }
html[data-theme="dark"] .toast-error { color: #1e1e1e; }
@keyframes toast-in {
  from { transform: translateY(0.5rem); opacity: 0; }
}

/* ---------- a11y / motion ---------- */
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
label:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.htmx-indicator { opacity: 0; transition: opacity 0.2s ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- mobile drawer ---------- */
.nav-drawer-input, .drawer-btn, .content-backdrop { display: none; }
@media (max-width: 920px) {
  body.shell-body { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 17rem; z-index: 40; transform: translateX(-100%); transition: transform 0.22s ease; }
  .nav-drawer-input:checked ~ .sidebar { transform: none; box-shadow: 1rem 0 3rem rgba(0, 0, 0, 0.25); }
  .drawer-btn { display: flex; flex-direction: column; justify-content: center; gap: 4px; width: 2.4rem; height: 2.4rem; padding: 0 0.55rem; position: fixed; top: 0.75rem; left: 0.75rem; z-index: 45; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
  .drawer-btn i { display: block; height: 2px; background: var(--muted); }
  .content-backdrop { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.3); cursor: pointer; }
  .nav-drawer-input:checked ~ .content-backdrop { display: block; }
  body.shell-body main.content { padding-top: 3.6rem; }
  /* No hover on touch: the per-chat ⋮ stays visible in the drawer. */
  .chat-menu-btn { opacity: 1; }
}

/* B2 phone shell: thumb-first PWA layout reusing the chat bubbles +
   the Bmax marker (no new assets, no Disney likeness). */
.phone-wrap { max-width: 34rem; margin: 0 auto; padding-bottom: 2rem; }
.phone-face { display: flex; align-items: center; gap: 0.2rem; margin: 0.6rem 0 0; }
#phone-log { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }
#phone-composer { display: flex; gap: 0.5rem; align-items: flex-end; }
#phone-input { flex: 1; min-height: 2.6rem; }
.mic-btn { width: 3.4rem; height: 3.4rem; font-size: 1.5rem; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--surface); cursor: pointer; }
.mic-btn.live { background: var(--accent-dim); }
