/* Claude Chat — ChatGPT-style layout with a Claude/Apple feel.
   Neutral ink accent (no iOS blue chrome); light/dark follows the system.
   --blue survives only for links, semantic in-progress states, and dots. */

:root {
  --blue: #007aff;
  --blue-press: #0066d6;
  --accent: #0d0d0d;        /* primary actions: send, chips, buttons */
  --accent-press: #2d2d2d;
  --on-accent: #ffffff;
  --bg: #ffffff;
  --side-bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1d1d1f;
  --text-2: rgba(60, 60, 67, 0.6);
  --text-3: rgba(60, 60, 67, 0.35);
  --hairline: rgba(60, 60, 67, 0.12);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.08);
  --bubble-user: #f1f1f3;   /* your messages: quiet gray, ChatGPT-style */
  --bubble-in: #e9e9eb;
  --bubble-in-text: #1d1d1f;
  --code-bg: #f2f2f4;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
  --frost: rgba(255, 255, 255, 0.78);
  --mark: rgba(255, 214, 10, 0.45);
  --danger: #ff3b30;
  --ok: #34c759;
  --dot-telegram: #007aff;
  --dot-tui: #34c759;
  --dot-cli: #ff9f0a;
  --dot-subagent: #af52de;
  --dot-cron: #ff375f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #0a84ff;
    --blue-press: #3395ff;
    --accent: #ececec;
    --accent-press: #d6d6d6;
    --on-accent: #0d0d0d;
    --bg: #000000;
    --side-bg: #171719;
    --panel: #1c1c1e;
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, 0.6);
    --text-3: rgba(235, 235, 245, 0.3);
    --hairline: rgba(84, 84, 88, 0.5);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.14);
    --bubble-user: #2f2f31;
    --bubble-in: #26262a;
    --bubble-in-text: #f5f5f7;
    --code-bg: #131316;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
    --frost: rgba(18, 18, 20, 0.75);
    --mark: rgba(255, 214, 10, 0.35);
  }
}

:root[data-theme="dark"] {
  --blue: #0a84ff;
  --blue-press: #3395ff;
  --accent: #ececec;
  --accent-press: #d6d6d6;
  --on-accent: #0d0d0d;
  --bg: #000000;
  --side-bg: #171719;
  --panel: #1c1c1e;
  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.6);
  --text-3: rgba(235, 235, 245, 0.3);
  --hairline: rgba(84, 84, 88, 0.5);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.14);
  --bubble-user: #2f2f31;
  --bubble-in: #26262a;
  --bubble-in-text: #f5f5f7;
  --code-bg: #131316;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
  --frost: rgba(18, 18, 20, 0.75);
  --mark: rgba(255, 214, 10, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ================================================================ sidebar */
#sidebar {
  position: relative; /* anchors the mode menu */
  width: 320px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  border-right: 1px solid var(--hairline);
}
#side-top { padding: 16px 14px 10px; }
.side-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.side-titlebar h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.titlebar-btns { display: inline-flex; gap: 6px; }
#new-chat-btn, #usage-btn, #ideas-btn, #flow-btn, #terminal-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
  -webkit-appearance: none; appearance: none;
  padding: 0;
  text-decoration: none;
}
#new-chat-btn:hover, #usage-btn:hover, #ideas-btn:hover, #flow-btn:hover, #terminal-btn:hover { background: var(--fill-2); }
#new-chat-btn:active, #usage-btn:active, #ideas-btn:active, #flow-btn:active, #terminal-btn:active { transform: scale(.94); }

#search {
  width: 100%;
  padding: 7px 12px;
  border: none;
  border-radius: 10px;
  background: var(--fill);
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  -webkit-appearance: none;
}
#search::placeholder { color: var(--text-2); }

#side-scroll { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
#side-scroll section h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-2);
}
#filter-btn {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
#filter-btn:hover, #filter-btn.on { color: var(--text); }

#source-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 4px; }
.chip {
  padding: 3px 11px;
  border: none;
  border-radius: 999px;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: var(--on-accent); }

.row {
  padding: 9px 10px;
  border-radius: 11px;
  cursor: pointer;
  user-select: none;
}
.row:hover { background: var(--fill-2); }
.row.active { background: var(--fill); }
.row-title {
  font-size: 14.5px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.row-title.untitled { color: var(--text-2); font-weight: 400; }
.row-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
}
.row-sub .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.row-sub time { flex-shrink: 0; color: var(--text-3); }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-3);
}
.dot.telegram { background: var(--dot-telegram); }
.dot.tui      { background: var(--dot-tui); }
.dot.cli      { background: var(--dot-cli); }
.dot.subagent { background: var(--dot-subagent); }
.dot.cron     { background: var(--dot-cron); }
.dot.hermes   { background: var(--dot-tui); }
.dot.claude   { background: #d97757; }
.dot.codex    { background: var(--text-2); }
.dot.openclaw { background: var(--dot-subagent); }
.dot.radegast { background: #8b5e3c; }  /* Radegast the Brown */

/* =================================================================== main */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; background: var(--bg); }

#back-btn {
  display: none;
  position: absolute;
  top: 11px; left: 8px;
  z-index: 30;
  width: 36px; height: 36px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
}

/* welcome */
#welcome { flex: 1; display: flex; align-items: center; justify-content: center; }
.welcome-inner { text-align: center; max-width: 400px; padding: 24px; }
.welcome-logo { color: var(--text); opacity: .85; }
.welcome-inner h2 { margin: 14px 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.welcome-inner p { margin: 0 0 22px; }
.primary-btn {
  padding: 9px 22px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 590;
  cursor: pointer;
  transition: transform .1s, background .15s;
}
.primary-btn:hover { background: var(--accent-press); }
.primary-btn:active { transform: scale(.97); }
#welcome-stats { margin-top: 26px; font-size: 12.5px; color: var(--text-3); }

#conversation, #search-results {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#conversation { position: relative; }

/* floating jump-to-latest arrow */
#scroll-bottom {
  position: absolute;
  right: 16px;
  bottom: 104px;
  z-index: 20;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  animation: pop .18s ease-out;
}
#scroll-bottom:hover { background: var(--fill-2); }

/* queued (reply-while-busy) messages */
.bubble.queued-bubble { opacity: .65; }
.meta-line.queued-bubble { color: var(--text-3); }

/* conversation header — frosted; ChatGPT-style: title left, actions right
   in normal flex flow (they used to be absolutely positioned and the mic +
   navigate buttons stacked on the same spot — Felix's overlap bug) */
#conv-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 8px 12px 8px 16px;
  background: var(--frost);
  -webkit-backdrop-filter: blur(22px) saturate(1.8);
  backdrop-filter: blur(22px) saturate(1.8);
  border-bottom: 1px solid var(--hairline);
}
#conv-titles { flex: 1; text-align: left; min-width: 0; padding: 0; }
#conv-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#conv-subtitle { font-size: 12px; margin-top: 1px; }
#info-btn, #jump-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 50%;
}
#info-btn:hover, #jump-btn:hover, #rec-btn:hover { background: var(--fill-2); color: var(--text); }
#rec-btn {
  flex-shrink: 0;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px 0 9px;
  border: none;
  background: var(--fill);
  color: var(--text);
  cursor: pointer;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
}
#rec-btn[hidden] { display: none; }

/* info panel */
#info-panel {
  z-index: 9;
  margin: 10px auto 0;
  max-width: 640px;
  width: calc(100% - 32px);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  font-size: 13.5px;
}
.info-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 5px 16px;
}
.info-grid dt { color: var(--text-2); }
.info-grid dd { margin: 0; overflow-wrap: anywhere; }
.info-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.info-actions button, .info-actions a {
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
}
.info-actions .danger { color: var(--danger); }
.info-actions button:hover, .info-actions a:hover { background: var(--fill-2); }

/* messages */
#messages { flex: 1; overflow-y: auto; padding: 18px 16px 26px; scroll-behavior: smooth; }
.msg-col, .setup-col { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; }

.day-sep {
  align-self: center;
  margin: 14px 0 10px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-3);
}

.bubble {
  position: relative;
  max-width: 78%;
  padding: 8px 14px;
  margin-bottom: 3px;
  border-radius: 19px;
  overflow-wrap: break-word;
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--text);
  max-width: 72%;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 6px;
}
.bubble.compacted { opacity: .55; }
.bubble.flash { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 35% { box-shadow: 0 0 0 3px var(--mark); } 100% { box-shadow: 0 0 0 3px transparent; } }
.bubble.gap { margin-bottom: 12px; }

.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 6px 0; }
.md pre {
  background: var(--code-bg);
  border-radius: 10px;
  padding: 10px 12px;
  overflow-x: auto;
  font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  max-width: 100%;
}
.bubble.user .md pre { background: rgba(120, 120, 128, 0.16); color: inherit; }
.md code {
  background: var(--code-bg);
  border-radius: 5px;
  padding: 1px 5px;
  font: 12.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.bubble.user .md code { background: rgba(120, 120, 128, 0.16); color: inherit; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--blue); }
.bubble.user .md a { color: var(--blue); text-decoration: underline; }
.md blockquote {
  margin: 6px 0;
  padding: 2px 10px;
  border-left: 3px solid var(--text-3);
  color: var(--text-2);
}
.md h1, .md h2, .md h3, .md h4 { margin: 10px 0 4px; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16.5px; }
.md h3 { font-size: 15.5px; } .md h4 { font-size: 15px; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md hr { border: none; border-top: 1px solid var(--hairline); margin: 8px 0; }
.md del { color: var(--text-2); }

.meta-line {
  font-size: 10.5px;
  color: var(--text-3);
  margin: 0 6px 8px;
}
.meta-line.right { align-self: flex-end; }
.meta-line.left { align-self: flex-start; }

/* collapsed extras: tools, thinking */
.extra {
  align-self: center;
  max-width: min(680px, 96%);
  margin: 2px 0 8px;
  border: none;
}
.extra > summary {
  list-style: none;
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.extra > summary::-webkit-details-marker { display: none; }
.extra > summary:hover { color: var(--text); background: var(--fill); }
.extra[open] { align-self: stretch; }
.extra[open] > summary { border-radius: 12px 12px 0 0; display: block; }
.extra .extra-body {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 0 0 12px 12px;
  padding: 10px 12px;
  box-shadow: var(--card-shadow);
}
.extra .extra-body pre {
  margin: 0;
  background: var(--code-bg);
  border-radius: 8px;
  padding: 9px 11px;
  overflow: auto;
  max-height: 380px;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
}
.extra .extra-body.thinking {
  color: var(--text-2);
  font-size: 13px;
  white-space: pre-wrap;
}

.trunc {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.trunc button {
  border: none;
  background: none;
  color: var(--text);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}

/* typing indicator */
.typing {
  align-self: flex-start;
  background: var(--bubble-in);
  border-radius: 19px;
  border-bottom-left-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 4px;
  display: flex;
  gap: 5px;
}
.typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: blink 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.typing-tail {
  align-self: flex-start;
  margin: 0 6px 10px;
  font: 11px ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-3);
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-bubble {
  align-self: center;
  background: color-mix(in srgb, var(--danger) 10%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  border-radius: 12px;
  padding: 8px 14px;
  margin: 4px 0 10px;
  font-size: 13px;
  max-width: 90%;
}

/* ============================================================== composer */
#composer-wrap {
  position: relative;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--frost);
  -webkit-backdrop-filter: blur(22px) saturate(1.8);
  backdrop-filter: blur(22px) saturate(1.8);
  border-top: 1px solid var(--hairline);
}
#composer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 26px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.05);
}
#backend-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
  margin-bottom: 2px;
}
#backend-btn:hover { background: var(--fill-2); }
#backend-btn .dot { width: 8px; height: 8px; }
#backend-btn.locked { cursor: default; opacity: .85; }
#chat-input {
  flex: 1;
  resize: none;
  border: none;
  border-radius: 18px;
  background: transparent;
  color: var(--text);
  padding: 7px 10px;
  font: 15px/1.4 inherit;
  font-family: inherit;
  outline: none;
  max-height: 160px;
}
#send-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  margin-bottom: 1px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: transform .1s, opacity .15s;
}
#send-btn:disabled { opacity: .35; cursor: default; }
#send-btn:not(:disabled):active { transform: scale(.92); }

/* backend menu popover */
#backend-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  z-index: 40;
}
.backend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}
.backend-item:hover { background: var(--fill-2); }
.backend-item + .backend-item { border-top: 1px solid var(--hairline); }
.backend-item .b-name { font-weight: 560; font-size: 14px; }
.backend-item .b-detail { font-size: 12px; color: var(--text-2); }
.backend-item .check { margin-left: auto; color: var(--text); font-weight: 700; }
.backend-item.unavailable { opacity: .45; }

/* ======================================================== search results */
#results-header {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--hairline);
}
#results-header h2 { margin: 0; font-size: 15px; font-weight: 650; }
#results-list { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }
.result-group { max-width: 680px; margin: 0 auto 20px; }
.result-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 8px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.result-group-head:hover { color: var(--text); }
.result-hit {
  padding: 9px 13px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  margin-bottom: 6px;
  background: var(--panel);
  cursor: pointer;
  font-size: 13.5px;
  transition: border-color .12s;
}
.result-hit:hover { border-color: var(--text-3); }
.result-hit .hit-meta { font-size: 11px; color: var(--text-2); margin-bottom: 2px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

#error-banner {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--card-shadow);
  z-index: 50;
  max-width: 80%;
}

.muted { color: var(--text-2); }
.flag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--fill-2);
  color: var(--text-2);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--fill); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ==================================================== multi-agent extras */
.sender {
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  margin: 2px 12px 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}
.sender .dot { width: 6px; height: 6px; }

.dots-row { display: inline-flex; align-items: center; }
.dots-row .dot + .dot { margin-left: -2px; }

.sysnote {
  align-self: center;
  max-width: 92%;
  text-align: center;
  margin: 4px 0 10px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 12px;
}
.sysnote.err {
  background: color-mix(in srgb, var(--danger) 10%, var(--bg));
  color: var(--danger);
}

/* new-chat setup card */
.setup-card {
  align-self: center;
  width: min(440px, 100%);
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 14px 16px 16px;
}
.setup-card h4 {
  margin: 14px 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.setup-card h4:first-child { margin-top: 0; }
.agent-list {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
}
.agent-pick {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 13px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}
.agent-pick + .agent-pick { border-top: 1px solid var(--hairline); }
.agent-pick:hover:not(:disabled) { background: var(--fill-2); }
.agent-pick:disabled { opacity: .45; cursor: default; }
.agent-pick .a-text { display: flex; flex-direction: column; }
.agent-pick .a-name { font-size: 14.5px; font-weight: 560; }
.agent-pick .a-sub { font-size: 12px; color: var(--text-2); }
.agent-pick .tick {
  margin-left: auto;
  color: var(--text);
  font-weight: 700;
  visibility: hidden;
}
.agent-pick.sel .tick { visibility: visible; }

.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
  gap: 2px;
}
.seg button {
  padding: 5px 16px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.seg button.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.lead-row { display: flex; flex-wrap: wrap; gap: 7px; }
.lead-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: none;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.lead-pick.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lead-pick.on .dot { background: var(--on-accent); }

.hint { margin: 8px 2px 0; font-size: 12px; color: var(--text-3); }

/* access levels in setup card */
.access-list { display: flex; flex-direction: column; gap: 8px; }
.access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.access-row .a-agent {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 550;
}
.seg-sm button { padding: 4px 10px; font-size: 12px; }

.agent-cfg {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 10px 12px;
}
.agent-cfg .cfg-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.agent-cfg .cfg-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 12px;
  align-items: center;
}
.cfg-label { font-size: 12px; color: var(--text-2); }
.cfg-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: 13px inherit;
  font-family: inherit;
  outline: none;
}
.cfg-select:focus { border-color: var(--text-3); }

/* approval prompts */
.approval {
  align-self: center;
  width: min(560px, 96%);
  margin: 4px 0 10px;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--text) 25%, var(--hairline));
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 11px 14px;
  animation: pop .18s ease-out;
}
.approval .ap-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  flex-wrap: wrap;
}
.approval .ap-head.done { color: var(--text-2); font-size: 12.5px; }
.approval .ap-body {
  margin: 8px 0 10px;
  background: var(--code-bg);
  border-radius: 8px;
  padding: 8px 10px;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 180px;
  overflow-y: auto;
}
.approval .ap-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.approval .ap-actions button {
  padding: 6px 18px;
  border: none;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 590;
  cursor: pointer;
}
.approval .ap-deny { background: var(--fill); color: var(--danger); }
.approval .ap-allow { background: var(--accent); color: var(--on-accent); }
.approval .ap-allow:active, .approval .ap-deny:active { transform: scale(.96); }

/* slash-command menu */
#cmd-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  z-index: 40;
}
.cmd-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}
.cmd-item:hover { background: var(--fill-2); }
.cmd-item + .cmd-item { border-top: 1px solid var(--hairline); }
.cmd-item .c-cmd {
  font: 13px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
}
.cmd-item .c-desc { font-size: 12.5px; color: var(--text-2); }

/* ================================================================ mobile */
@media (max-width: 760px) {
  #sidebar { width: 100%; min-width: 0; border-right: none; }
  #main { display: none; }
  #app.show-main #sidebar { display: none; }
  #app.show-main #main { display: flex; }
  #app.show-main #back-btn { display: grid; place-items: center; }
  #conv-header { padding-left: 46px; } /* room for the absolute back button */
  .bubble { max-width: 86%; }
  #messages { padding: 14px 10px 20px; }

  /* iOS zooms into any focused input under 16px — keep these at 16px */
  #chat-input, #search { font-size: 16px; }
  /* cap the composer's growth on phones (~4 rows) — it was eating the screen */
  #chat-input { max-height: 96px; }
  /* phones: agent chip shows just its dot (name is in the header) and the
     icon buttons tighten up, so the text box gets the width back */
  #backend-btn .b-label { display: none; }
  #backend-btn { padding: 7px 9px; gap: 0; }
  #attach-btn, #pdf-btn { width: 30px; min-width: 30px; }
  #mic-btn { width: 34px; min-width: 34px; padding: 0; }
  #chat-input { padding: 7px 6px; }

  /* lift the composer above the on-screen keyboard (--kb set via
     visualViewport in app.js); content scrolls up like native chat apps */
  #composer-wrap {
    transform: translateY(calc(-1 * var(--kb, 0px)));
    transition: transform .12s ease-out;
  }
  #messages { padding-bottom: calc(20px + var(--kb, 0px)); }

  button, .row, .chip { touch-action: manipulation; }
}

/* ============================================== v0.4: prose replies, live
   activity, agent chips/panel, attachments, mentions */

/* text is selectable everywhere a reply lives (the old bubbles fought iOS) */
.bubble, .prose, .extra-body, .live {
  user-select: text;
  -webkit-user-select: text;
}

/* AI replies: full-width prose, ChatGPT/Claude style — no bubble */
.prose {
  align-self: stretch;
  max-width: 100%;
  padding: 2px 4px 6px;
  margin-bottom: 10px;
  overflow-wrap: break-word;
  animation: pop .18s ease-out;
}
.prose .md { font-size: 15px; line-height: 1.6; }

.msg-head, .msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}
.msg-head, .msg-actions:first-child { margin: 2px 0 4px; }
.msg-head .dot, .msg-actions .dot { width: 6px; height: 6px; }
.msg-head time, .msg-actions time { font-weight: 400; color: var(--text-3); }
.msg-head .who, .msg-actions .who { min-width: 0; }
.msg-copy, .msg-speak, .msg-reply, .code-copy {
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 999px;
}
.msg-speak { margin-left: 0; }
.msg-copy, .msg-reply { opacity: 0; transition: opacity .15s; }
.msg-speak {
  opacity: 1;
  background: transparent !important;
  color: var(--text-2);
  border: none;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}
.msg-speak svg { display: block; }
.prose:hover .msg-copy, .prose:hover .msg-reply,
.msg-copy.did-copy, .msg-speak.speaking { opacity: 1; }
.msg-copy:hover, .msg-speak:hover, .msg-reply:hover, .code-copy:hover { background: var(--fill-2); color: var(--text); }
.msg-copy.did-copy, .code-copy.did-copy { color: var(--ok); }
.msg-speak.speaking { color: var(--danger); }
@media (hover: none) {
  .msg-copy, .msg-reply { opacity: .8; }
  .msg-speak { opacity: 1; }
}
@media (max-width: 760px) {
  .msg-head, .msg-actions { gap: 5px; }
  .msg-head time, .msg-actions time { display: none; }
  .msg-copy, .msg-reply { display: none; }
  .msg-speak { flex-basis: auto; }
}

/* code blocks: header strip with language + copy */
.codewrap { position: relative; margin: 8px 0; }
.codewrap pre { margin: 0; padding-top: 26px; }
.code-lang {
  position: absolute;
  top: 5px; left: 12px;
  font: 10.5px ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-3);
}
.code-copy { position: absolute; top: 3px; right: 6px; }

/* markdown tables */
.tablewrap { overflow-x: auto; margin: 8px 0; }
.md table { border-collapse: collapse; font-size: 13.5px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--hairline); padding: 5px 10px; text-align: left; }
.md th { background: var(--fill-2); font-weight: 600; }

/* live block while an agent works */
.live { align-self: stretch; margin-bottom: 10px; }
.live-badge { font-weight: 400; font-size: 11px; color: var(--text-3); }
.live-badge i { animation: blink 1.3s infinite; font-style: normal; }
.live .live-prose { margin: 0; padding: 0 4px; }
.prose.streaming .md::after {
  content: "▍";
  color: var(--text);
  animation: blink 1.1s infinite;
}

/* terminal-style activity feed */
.act-feed { margin: 2px 0 6px; }
.act-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 1px 4px;
  font: 11.5px/1.7 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
}
.act-line .act-mark { flex-shrink: 0; width: 11px; color: var(--ok); }
.act-line.run .act-mark { color: var(--blue); animation: blink 1.1s infinite; }
.act-line .act-label { flex-shrink: 0; font-weight: 600; }
.act-line .act-detail { overflow: hidden; text-overflow: ellipsis; color: var(--text-3); }

/* collapsed steps pill on finished replies */
.steps { margin: 0 0 6px; }
.steps > summary {
  list-style: none;
  display: inline-block;
  padding: 2px 11px;
  border-radius: 999px;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.steps > summary::-webkit-details-marker { display: none; }
.steps > summary:hover { color: var(--text); background: var(--fill); }
.steps .steps-body {
  margin: 6px 0 2px;
  border-left: 2px solid var(--hairline);
  padding-left: 8px;
}

/* agent chips in the conversation header */
.chip-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border: none;
  border-radius: 999px;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
}
.agent-chip:hover { background: var(--fill); color: var(--text); }
.agent-chip .dot { width: 6px; height: 6px; }
.agent-chip .lead-star { color: #ff9f0a; font-size: 10px; margin-left: 2px; }
.agent-chip.add { padding: 2px 8px; color: var(--text); }

/* per-agent panel (tap a chip) */
#agent-panel {
  z-index: 9;
  margin: 10px auto 0;
  max-width: 480px;
  width: calc(100% - 32px);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 12px 14px;
  font-size: 13.5px;
}
#agent-panel .panel-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
#agent-panel .panel-sub { font-size: 11px; font-weight: 400; }
#agent-panel .panel-close {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
}
#agent-panel .panel-close:hover { background: var(--fill-2); color: var(--text); }
#agent-panel .cfg-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 9px 12px;
  align-items: center;
}
.cfg-note { font-size: 12px; color: var(--text-3); }
#agent-panel .panel-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.panel-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.panel-btn.danger { color: var(--danger); }
.panel-btn:hover { background: var(--fill-2); }
#agent-panel .add-list { display: flex; flex-direction: column; }

/* attachments: composer chips */
#attach-btn, #mic-btn, #pdf-btn, #read-latest-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  margin-bottom: 1px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
#attach-btn:hover, #mic-btn:hover, #pdf-btn:hover, #read-latest-btn:hover { background: var(--fill-2); color: var(--text); }
#mic-btn { background: var(--fill); color: var(--text); }
#mic-btn.on { background: var(--danger); color: var(--on-accent); }
#attach-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 760px;
  margin: 0 auto 8px;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 5px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12px;
  max-width: 220px;
}
.attach-chip img {
  width: 26px; height: 26px;
  object-fit: cover;
  border-radius: 6px;
}
.attach-chip .ac-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .ac-x {
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
}
.attach-chip .ac-x:hover { color: var(--danger); }

/* attachments on sent messages */
.att-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.att-img img {
  max-width: 220px;
  max-height: 180px;
  border-radius: 10px;
  display: block;
}
.att-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  font-size: 12.5px;
  text-decoration: none;
  max-width: 240px;
}
.att-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose .att-file, .msg-col > .att-file { background: var(--fill-2); }

/* drop target overlay */
#drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.drop-box {
  padding: 26px 42px;
  border: 2px dashed var(--text-2);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--card-shadow);
}

#mention-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  z-index: 40;
}
#mention-menu .c-cmd { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 760px) {
  .att-img img { max-width: 170px; max-height: 140px; }
  .prose { padding: 2px 2px 6px; }
}

/* approval tray — pinned above the composer, compact one-line rows */
#approval-tray {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 760px;
  margin: 0 auto 8px;
  max-height: 190px;
  overflow-y: auto;
}
.ap-tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-2);
  padding: 0 2px;
}
#ap-allow-all {
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  padding: 4px 13px;
  font-size: 12px;
  font-weight: 590;
  cursor: pointer;
}
.ap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--text) 22%, var(--hairline));
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  animation: pop .18s ease-out;
}
.ap-row .ap-text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-row .ap-sum {
  color: var(--text-2);
  font: 11.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.ap-row button {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 590;
  cursor: pointer;
}
.ap-row .ap-deny { background: var(--fill); color: var(--danger); }
.ap-row .ap-allow { background: var(--accent); color: var(--on-accent); }
.ap-row button:active { transform: scale(.95); }

/* AskUserQuestion bridge — tappable option chips pinned above the composer */
#question-tray {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto 8px;
  max-height: 46vh;
  overflow-y: auto;
}
.q-card {
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--text) 22%, var(--hairline));
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 11px 12px 12px;
  animation: pop .18s ease-out;
}
.q-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.q-group { margin-top: 8px; }
.q-group:first-of-type { margin-top: 0; }
.q-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-3);
  margin-bottom: 2px;
}
.q-text { font-size: 14px; font-weight: 550; color: var(--text); margin-bottom: 8px; }
.q-opts { display: flex; flex-direction: column; gap: 6px; }
.q-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  text-align: left;
  width: 100%;
  padding: 9px 12px;
  background: var(--fill);
  border: 1.5px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  color: var(--text);
  transition: border-color .12s, background .12s;
}
.q-opt:active { transform: scale(.99); }
.q-opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--fill)); }
.q-opt-label { font-size: 13.5px; font-weight: 580; }
.q-opt-desc { font-size: 12px; color: var(--text-2); line-height: 1.3; }
.q-opt.q-other { font-size: 13px; font-weight: 550; color: var(--text-2); }
.q-other-input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 11px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--text) 22%, var(--hairline));
  border-radius: 10px;
}
.q-group.q-missing .q-opts { outline: 1.5px solid var(--danger); outline-offset: 3px; border-radius: 12px; }
.q-actions { display: flex; justify-content: flex-end; margin-top: 11px; }
.q-submit { padding: 7px 18px; font-size: 13.5px; border-radius: 999px; }
.q-submit:disabled { opacity: .6; }

/* ============================== v0.5: projects, knowledge, navigate,
   artifacts */

#projects-section .h3-btns { margin-left: auto; display: inline-flex; gap: 2px; }
#projects-section .h3-btns button {
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 6px;
}
#projects-section .h3-btns button:hover { color: var(--text); }
#projects-section .h3-btns button.busy { animation: blink 1s infinite; color: var(--text); }
.row.proj .row-title { font-size: 14px; }
.proj-k {
  border: none;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}
.proj-k:hover { color: var(--text); background: var(--fill); }
.row.filter-note { padding: 4px 10px; }
.row.filter-note .row-sub { color: var(--text); font-size: 12px; }

/* header voice/navigate buttons flow in the header flex row (see #conv-header) */

/* navigate panel */
#jump-panel {
  z-index: 9;
  margin: 10px auto 0;
  max-width: 560px;
  width: calc(100% - 32px);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 12px 14px;
}
#jump-panel .panel-head { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
#jump-panel .panel-sub { font-size: 11px; font-weight: 400; }
#jump-panel .panel-close {
  margin-left: auto;
  border: none; background: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
}
#jump-panel .panel-close:hover { background: var(--fill-2); color: var(--text); }
#jump-search {
  width: 100%;
  padding: 7px 12px;
  border: none;
  border-radius: 10px;
  background: var(--fill);
  color: var(--text);
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  margin-bottom: 8px;
}
#jump-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; }
.jump-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  border-radius: 9px;
  font-size: 13px;
}
.jump-item:hover { background: var(--fill-2); }
.jump-item .j-who {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 650;
  color: var(--text-2);
  width: 46px;
}
.jump-item .j-who.me { color: var(--text); }
.jump-item .j-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.jump-item time { flex-shrink: 0; font-size: 11px; color: var(--text-3); }
.prose.flash { animation: flash 1.8s ease-out; border-radius: 12px; }

/* knowledge view */
#knowledge-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
#knowledge-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
}
#knowledge-header > div { flex: 1; min-width: 0; }
#knowledge-header h2 { margin: 0; font-size: 16px; font-weight: 650; }
#knowledge-sub { font-size: 12px; }
#k-back-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; background: none;
  color: var(--text);
  cursor: pointer;
  border-radius: 50%;
}
#k-add-btn { font-size: 13.5px; padding: 7px 16px; }
#knowledge-list { flex: 1; overflow-y: auto; padding: 14px 18px 30px; max-width: 680px; width: 100%; margin: 0 auto; }
.k-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--panel);
}
.k-row .k-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 550;
}
.k-row .k-name:hover { text-decoration: underline; }
.k-row .k-meta { flex-shrink: 0; font-size: 11.5px; color: var(--text-3); }
.k-row .k-del {
  flex-shrink: 0;
  border: none; background: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 12px;
}
.k-row .k-del:hover { color: var(--danger); background: var(--fill-2); }
.k-empty { padding: 26px 10px; text-align: center; font-size: 13.5px; }

/* artifact cards in messages */
.art-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: min(420px, 100%);
  margin: 8px 0;
  padding: 11px 13px;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  text-align: left;
}
.art-card:hover { border-color: var(--text-3); }
.art-card .art-ico { font-size: 20px; }
.art-card .art-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.art-card .art-name { font-size: 13.5px; font-weight: 600; }
.art-card .art-sub { font-size: 11.5px; color: var(--text-2); }
.art-card .art-open { color: var(--text-2); font-weight: 700; }

/* artifact viewer sheet */
#artifact-sheet {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, #000 45%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 14px;
}
.art-sheet-inner {
  width: min(920px, 100%);
  height: min(760px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.art-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}
.art-head .grow { flex: 1; }
.art-head button {
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 570;
  cursor: pointer;
}
.art-head #art-close { background: none; color: var(--text-2); padding: 5px 8px; }
.art-head { position: relative; flex-wrap: wrap; }
#art-dl-pop {
  position: absolute;
  top: calc(100% - 4px);
  right: 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
#art-dl-pop button {
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
#art-dl-pop button:active { background: var(--fill); }
.art-body { flex: 1; min-height: 0; display: flex; }
.art-body iframe { flex: 1; border: none; background: #fff; }
.art-body pre {
  flex: 1;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  background: var(--code-bg);
  font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

#error-banner.ok {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
}

@media (max-width: 760px) {
  .art-sheet-inner { height: 100%; }
  #jump-panel { max-width: none; }
}

/* ================================================================= modes */

#mode-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 10px;
  border: none;
  border-radius: 10px;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
#mode-btn .mode-ico { font-size: 15px; }
#mode-btn .chev { margin-left: auto; color: var(--text-3); font-size: 11px; }

#mode-menu {
  position: absolute;
  top: 74px;
  left: 10px;
  right: 10px;
  z-index: 60;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--hairline);
  max-height: 60vh;
  overflow: auto;
}
.mode-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.mode-item:hover { background: var(--fill-2); }
.mode-item.on { font-weight: 600; }
.mode-item .mode-ico { width: 20px; text-align: center; }
.mode-item .mode-n { color: var(--text-3); font-size: 12px; }
.mode-foot {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--hairline);
}
.mode-foot button {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: 8px;
  background: var(--fill-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* generic sheet (recorder / recording detail / modes / pdf / usage) */
#recorder-sheet, #rec-detail-sheet, #mode-sheet, #pdf-sheet, #usage-sheet {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, #000 45%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 14px;
}
.sheet-inner {
  width: min(640px, 100%);
  max-height: min(760px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
}
.sheet-head .panel-sub { font-size: 12px; }
.sheet-close, #rec-hide {
  border: none;
  background: var(--fill-2);
  color: var(--text-2);
  border-radius: 8px;
  padding: 5px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.sheet-body { padding: 14px; overflow: auto; }

/* recorder sheet */
.rec-cards { display: grid; gap: 8px; }
.rec-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.rec-card:hover:not(:disabled) { background: var(--fill-2); }
.rec-card:disabled { opacity: .45; cursor: default; }
.rc-ico { font-size: 24px; }
.rc-text { line-height: 1.35; font-size: 14px; }
.rc-text .muted { font-size: 12.5px; }
.rec-opts { display: grid; gap: 10px; margin-top: 14px; }
.rec-opts label {
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
}
.rec-opts input, .rec-opts select {
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--danger);
  animation: recpulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.rec-live { display: grid; justify-items: center; gap: 12px; padding: 22px 14px; }
.rec-time { font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums; }
.level-wrap {
  width: min(320px, 90%);
  height: 6px;
  border-radius: 3px;
  background: var(--fill);
  overflow: hidden;
}
.level-wrap i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--ok);
  transition: width .12s ease;
}
.rec-note { font-size: 12px; text-align: center; }
.rec-actions { display: flex; gap: 8px; margin-top: 6px; }
.rec-actions button {
  padding: 9px 16px;
  border: none;
  border-radius: 11px;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.rec-actions .danger { color: var(--danger); }
.rec-actions .primary-btn { background: var(--accent); color: var(--on-accent); }

.rec-live-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--danger); font-size: 12px; }
.rec-err { color: var(--danger); font-size: 12.5px; }
.rec-h { margin: 16px 0 6px; font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.rec-summary { font-size: 14px; }
.rec-transcript {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--code-bg);
  font: 12.5px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}
.rec-detail-actions { display: flex; gap: 8px; margin: 10px 0 2px; flex-wrap: wrap; }
.rec-detail-actions button {
  padding: 7px 12px;
  border: none;
  border-radius: 9px;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.rec-detail-actions .danger { color: var(--danger); }
.rec-detail-actions .primary-btn { background: var(--accent); color: var(--on-accent); }

/* dictation bar */
#dictate-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  box-shadow: var(--card-shadow);
}
#dictate-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
#dictate-level { flex: 1; height: 5px; border-radius: 3px; background: var(--fill); overflow: hidden; }
#dictate-level i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .12s ease; }
#dictate-hint { font-size: 12px; }
#dictate-cancel {
  border: none; background: var(--fill-2); color: var(--text-2);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
#dictate-done { padding: 6px 14px; border: none; border-radius: 9px; font-size: 13px; }
#mic-btn.on { color: var(--danger); }
#dictate-tidy {
  border: 1px solid var(--hairline);
  background: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  cursor: pointer;
  opacity: .4;
}
#dictate-tidy.on { opacity: 1; border-color: var(--text-3); background: var(--fill-2); }

/* voice chat overlay */
#voice-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
/* header Voice button retired — voice/dictate/recorder all live behind the
   composer mic button now */
#rec-btn { display: none !important; }

/* mini mode — the voice pill replaces the composer row; the chat stays fully
   visible and readable above it */
#voice-overlay.split {
  inset: auto 0 0 0;
  width: auto;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
}
body.vc-split-on #composer { display: none; }
#voice-overlay.split .vc-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  width: 100%;
  max-width: none;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
#voice-overlay.split .vc-status { flex: 1; text-align: left; }
#voice-overlay.split #vc-end { margin-left: auto; }
#voice-overlay.split .vc-orb { width: 38px; height: 38px; }
#voice-overlay.split .vc-status { font-size: 12px; font-weight: 600; }
#voice-overlay.split .vc-heard,
#voice-overlay.split .vc-reply,
#voice-overlay.split .vc-out,
#voice-overlay.split .vc-hint { display: none; }
#voice-overlay.split #vc-end { padding: 5px 10px; font-size: 12px; border-radius: 999px; }
#vc-split-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 1px solid var(--hairline);
  background: var(--fill-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
#voice-overlay.split #vc-split-toggle {
  position: static;
  order: -1;
  padding: 4px 8px;
}
#vc-split-toggle:hover { color: var(--text); }
.vc-inner { display: grid; justify-items: center; gap: 14px; padding: 22px; max-width: 480px; text-align: center; }
.vc-orb {
  --amp: 0;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, color-mix(in srgb, var(--blue) 85%, #fff), var(--blue));
  box-shadow: 0 0 0 calc(6px + var(--amp) * 26px) color-mix(in srgb, var(--blue) 18%, transparent);
  transition: box-shadow .1s ease, background .3s ease;
  cursor: pointer;
}
.vc-orb.capture { box-shadow: 0 0 0 calc(8px + var(--amp) * 34px) color-mix(in srgb, var(--ok) 26%, transparent);
  background: radial-gradient(circle at 32% 30%, color-mix(in srgb, var(--ok) 85%, #fff), var(--ok)); }
.vc-orb.think { animation: vcthink 1.1s ease-in-out infinite; }
.vc-orb.speak { background: radial-gradient(circle at 32% 30%, #c99cff, #af52de);
  animation: vcspeak 1.6s ease-in-out infinite; }
@keyframes vcthink { 0%,100% { transform: scale(.94); } 50% { transform: scale(1.04); } }
@keyframes vcspeak { 0%,100% { box-shadow: 0 0 0 8px color-mix(in srgb, #af52de 20%, transparent); }
  50% { box-shadow: 0 0 0 26px color-mix(in srgb, #af52de 10%, transparent); } }
.vc-status { font-size: 17px; font-weight: 700; }
.vc-heard { color: var(--text-2); font-size: 14px; min-height: 21px; }
.vc-hint { font-size: 12px; }
/* reply captions — always shown while speaking; the fallback when a browser
   has no speech output */
.vc-reply {
  width: 100%;
  max-height: 26vh;
  overflow-y: auto;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-2);
  text-align: left;
  white-space: pre-wrap;
}
#vc-end { padding: 10px 22px; border: none; border-radius: 12px; }

/* mode manager sheet */
.mode-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.mode-row:last-child { border-bottom: none; }
.mode-row .m-icon {
  width: 44px;
  text-align: center;
  padding: 7px 4px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.mode-row .m-main { flex: 1; display: grid; gap: 5px; }
.mode-row input.m-name, .mode-row input.m-brief {
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
.mode-row input.m-brief { font-size: 12.5px; color: var(--text-2); }
.mode-row .m-del {
  border: none; background: none; color: var(--text-3);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; margin-top: 3px;
}
.mode-row .m-del:hover { color: var(--danger); background: var(--fill-2); }

/* ================================================================= boards */

#board-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
}
#board-header > div { flex: 1; min-width: 0; }
#board-header h2 { margin: 0; font-size: 17px; }
#board-header #b-back-btn {
  border: none; background: none; color: var(--text); cursor: pointer;
  width: 34px; height: 34px; display: grid; place-items: center;
}
#b-present-btn {
  border: none;
  background: var(--fill);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
#b-ai-btn { padding: 7px 13px; font-size: 13.5px; }
#board-body { padding: 16px 18px 40px; overflow-y: auto; height: 100%; }
.bd-top { max-width: 760px; margin: 0 auto 6px; display: grid; gap: 10px; }
.bd-progress { height: 7px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.bd-progress i { display: block; height: 100%; background: var(--ok); border-radius: 4px; transition: width .3s ease; }
#bd-note {
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.bd-section { max-width: 760px; margin: 14px auto 0; }
.bd-section h4 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.bd-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 8px;
  border-radius: 11px;
}
.bd-item:hover { background: var(--fill-2); }
.bd-status {
  width: 26px; height: 26px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1.6px solid var(--text-3);
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.bd-item.doing .bd-status { border-color: var(--blue); color: var(--blue); }
.bd-item.done .bd-status { border-color: var(--ok); background: var(--ok); color: #fff; }
.bd-mid { flex: 1; display: grid; gap: 2px; min-width: 0; }
.bd-title, .bd-notes, .bd-add input {
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  padding: 3px 4px;
  border-radius: 6px;
  width: 100%;
}
.bd-title:focus, .bd-notes:focus, .bd-add input:focus, #bd-note:focus { outline: none; background: var(--fill-2); }
.bd-item.done .bd-title { color: var(--text-3); text-decoration: line-through; }
.bd-notes { font-size: 12.5px; color: var(--text-2); }
.bd-notes:placeholder-shown { opacity: 0; transition: opacity .15s; }
.bd-item:hover .bd-notes:placeholder-shown, .bd-notes:focus { opacity: 1; }
.bd-due {
  border: none;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  width: 118px;
  margin-top: 4px;
  border-radius: 6px;
}
.bd-del {
  border: none; background: none; color: var(--text-3);
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; margin-top: 2px;
  opacity: 0;
}
.bd-item:hover .bd-del { opacity: 1; }
.bd-del:hover { color: var(--danger); background: var(--fill); }
.bd-add { padding: 2px 8px 0 42px; }
.bd-add input { color: var(--text-2); font-size: 13.5px; }

.proj-prog {
  height: 3px;
  border-radius: 2px;
  background: var(--fill);
  overflow: hidden;
  margin-top: 5px;
}
.proj-prog i { display: block; height: 100%; background: var(--ok); }

/* present view */
#present-overlay {
  position: absolute;
  inset: 0;
  z-index: 90;
  overflow: auto;
  background: var(--bg);
  padding: 40px clamp(20px, 7vw, 90px);
}
.pr-inner { max-width: 860px; margin: 0 auto; }
.pr-close {
  position: fixed;
  top: 18px; right: 20px;
  border: none;
  background: var(--fill);
  color: var(--text-2);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}
.pr-inner h1 { font-size: clamp(28px, 4.5vw, 44px); margin: 8px 0 4px; }
.pr-note { font-size: clamp(16px, 2.2vw, 21px); color: var(--text-2); margin: 4px 0; }
.pr-prog { color: var(--ok); font-weight: 700; font-size: 15px; }
.pr-inner h3 {
  margin: 26px 0 8px;
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
}
.pr-list { list-style: none; margin: 0; padding: 0; }
.pr-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: clamp(17px, 2.4vw, 23px);
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
}
.pr-list li.done { color: var(--text-3); }
.pr-mark { color: var(--ok); font-weight: 700; }
.pr-list li.todo .pr-mark { color: var(--text-3); }
.pr-list li.doing .pr-mark { color: var(--blue); }
.pr-due { margin-left: auto; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .sheet-inner { max-height: 100%; }
  #mode-menu { top: 70px; }
  .bd-due { width: 108px; }
}

/* ====================== v0.7: continuity, usage tracking, PDF tools ====== */

/* welcome — jump back into recent chats from any device */
#welcome-continue { margin-top: 22px; display: grid; gap: 6px; text-align: left; }
#welcome-continue .continue-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 2px 2px;
  text-align: center;
}
.continue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.continue-row:hover { background: var(--fill-2); }
.continue-row .c-main { flex: 1; min-width: 0; }
.continue-row .c-title {
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.continue-row .c-sub {
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.continue-row time { flex-shrink: 0; font-size: 11px; color: var(--text-3); }

/* quiet context-fill badge next to the agent chips */
.ctx-badge {
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--fill-2);
  color: var(--text-3);
  white-space: nowrap;
}

/* usage sheet */
.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th, .usage-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}
.usage-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
}
.usage-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.usage-table th.num { text-align: right; }
.usage-note { margin-top: 10px; font-size: 12px; color: var(--text-3); }

/* global approval indicator — visible from any view, tap to jump there */
#approval-flag {
  position: fixed; /* viewport-level: visible on the mobile list screen too */
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  max-width: min(480px, calc(100% - 24px));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 18px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--hairline));
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 590;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  animation: pop .18s ease-out;
}
#approval-flag:hover { background: var(--fill-2); }

/* voice overlay: approval chip + output-mode pills */
.vc-approval {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--hairline));
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 590;
  animation: pop .18s ease-out;
}
.vc-ap-text { flex: 1; min-width: 140px; text-align: left; }
.vc-ap-btns { display: inline-flex; gap: 6px; }
.vc-ap-btns button {
  padding: 5px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--ok);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.vc-ap-btns button.vc-ap-deny { background: var(--danger); }
/* in split mode the chip floats above the voice pill so the buttons stay
   tappable instead of getting squeezed into the pill row */
#voice-overlay.split .vc-approval {
  position: absolute;
  bottom: 100%;
  left: 10px;
  right: 10px;
  margin-bottom: 2px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
.vc-out { display: inline-flex; gap: 6px; }
.vc-out-pill {
  padding: 4px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.vc-out-pill.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* pdf tools sheet */
.pdf-input, .pdf-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.pdf-textarea { min-height: 120px; resize: vertical; font-size: 13.5px; }
.pdf-row { display: grid; gap: 5px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.pdf-files { margin: 2px 0 8px; font-size: 12.5px; color: var(--text-2); }
.pdf-files b { color: var(--text); }

/* ---- ideas (quick-capture inbox) ---- */
#ideas-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#ideas-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--hair, rgba(128,128,128,.18)); }
#ideas-header h2 { margin: 0; font-size: 18px; }
#ideas-back-btn { background: none; border: none; cursor: pointer; color: inherit; padding: 4px; display: flex; }
#ideas-compose { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px 6px; width: 100%; max-width: 820px; margin: 0 auto; box-sizing: border-box; }
#idea-input { resize: vertical; min-height: 92px; border: 1px solid var(--hair, rgba(128,128,128,.3)); border-radius: 14px; padding: 11px 14px; font: inherit; line-height: 1.45; background: var(--bubble-user, rgba(128,128,128,.08)); color: inherit; }
#ideas-compose-row { display: flex; gap: 8px; align-items: stretch; }
#ideas-compose-row .primary-btn { flex: 1; }
#idea-type-pick { flex: none; background: var(--fill, rgba(128,128,128,.12)); color: inherit; border: 1px solid var(--hair, rgba(128,128,128,.28)); border-radius: 12px; font: inherit; font-size: 13px; padding: 0 12px; cursor: pointer; -webkit-appearance: none; appearance: none; }
#ideas-filters { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 18px 4px; width: 100%; max-width: 820px; margin: 0 auto; box-sizing: border-box; }
.idea-filter-chip { border: 1px solid var(--hair, rgba(128,128,128,.28)); background: none; color: inherit; cursor: pointer; font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; opacity: .72; transition: background .12s, opacity .12s; }
.idea-filter-chip:hover { opacity: 1; background: rgba(128,128,128,.1); }
.idea-filter-chip.active { opacity: 1; background: var(--accent, #2f6fed); color: #fff; border-color: transparent; }
.idea-filter-chip .chip-n { opacity: .7; font-size: 11px; }
#ideas-list { flex: 1; overflow-y: auto; padding: 6px 18px 28px; width: 100%; max-width: 820px; margin: 0 auto; box-sizing: border-box; }
.idea-group-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .55; margin: 16px 2px 4px; }
.idea-item { display: flex; align-items: flex-start; gap: 8px; padding: 11px 4px; border-bottom: 1px solid var(--hair, rgba(128,128,128,.14)); }
.idea-item .idea-text { flex: 1; white-space: pre-wrap; line-height: 1.45; word-break: break-word; }
.idea-item.done .idea-text { opacity: .5; text-decoration: line-through; }
.idea-type-sel { flex: none; align-self: flex-start; background: var(--fill, rgba(128,128,128,.12)); color: inherit; border: 1px solid var(--hair, rgba(128,128,128,.22)); border-radius: 8px; font: inherit; font-size: 12px; padding: 3px 4px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.idea-mode-chip { flex: none; align-self: flex-start; font-size: 15px; line-height: 1.5; opacity: .85; }
.idea-mode-sel { flex: none; align-self: flex-start; max-width: 132px; background: var(--fill, rgba(128,128,128,.12)); color: inherit; border: 1px solid var(--hair, rgba(128,128,128,.22)); border-radius: 8px; font: inherit; font-size: 12px; padding: 3px 4px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.idea-check, .idea-del { background: none; border: none; cursor: pointer; color: inherit; opacity: .5; font-size: 15px; line-height: 1; padding: 3px 5px; border-radius: 8px; }
.idea-check:hover, .idea-del:hover { opacity: 1; background: rgba(128,128,128,.12); }
.ideas-empty { padding: 32px 6px; text-align: center; }

/* ---- failure banner (C3) ---- */
#failure-flag { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 61; background: #c0392b; color: #fff; border: none; border-radius: 20px; padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.28); max-width: 92%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#failure-flag[hidden] { display: none; }

/* ---- inline reply-to-message (C1) ---- */
.msg-reply { background: none; border: none; color: var(--muted, #8a8a8a); cursor: pointer; font: inherit; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.msg-reply:hover { color: inherit; background: rgba(128,128,128,.14); }
.reply-box { margin: 4px 0 16px; padding: 10px 12px; border-left: 2px solid var(--accent, #6a6a6a); background: rgba(128,128,128,.06); border-radius: 8px; max-width: 760px; }
.reply-input { width: 100%; box-sizing: border-box; resize: vertical; border: 1px solid rgba(128,128,128,.3); border-radius: 10px; padding: 8px 10px; font: inherit; background: var(--bubble-user, rgba(128,128,128,.06)); color: inherit; }
.reply-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.reply-cancel { background: none; border: none; color: var(--muted, #8a8a8a); cursor: pointer; font: inherit; padding: 6px 10px; border-radius: 8px; }
.reply-cancel:hover { background: rgba(128,128,128,.14); }

/* ---- flow / worker-board view (C2) ---- */
#flow-btn { position: relative; }
#flow-badge { position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; color: #fff; box-sizing: border-box; }
#flow-badge.run { background: var(--blue, #2f6fed); }
#flow-badge.bad { background: #c0392b; }
#flow-badge[hidden] { display: none; }
#browser-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#browser-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--hair, rgba(128,128,128,.18)); }
#browser-header h2 { margin: 0; font-size: 18px; }
#browser-header .muted { font-size: 12px; }
#browser-back-btn { background: none; border: none; color: inherit; cursor: pointer; padding: 4px 8px; font-size: 16px; border-radius: 8px; }
#browser-start-btn { margin-left: auto; }
#browser-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #111; overflow: hidden; }
#browser-frame { max-width: 100%; max-height: 100%; cursor: pointer; }
#browser-frame:not([src]) { display: none; }
#browser-empty { color: #999; }
#browser-cursor { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -2px;
  pointer-events: none; border: 2px solid #2f6fed; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: rgba(47,111,237,.25); }

#flow-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#flow-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--hair, rgba(128,128,128,.18)); }
#flow-header h2 { margin: 0; font-size: 18px; }
#flow-header .muted { font-size: 12px; }
#flow-back-btn, #flow-refresh { background: none; border: none; color: inherit; cursor: pointer; padding: 4px 8px; font-size: 16px; border-radius: 8px; }
#flow-refresh { margin-left: auto; }
#flow-refresh:hover { background: rgba(128,128,128,.14); }
#flow-body { flex: 1; overflow-y: auto; padding: 12px 18px 28px; max-width: 820px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.flow-summary { font-weight: 600; margin: 4px 0 14px; opacity: .8; }
.flow-group { margin-bottom: 18px; }
.flow-group-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .6; margin-bottom: 6px; }
.flow-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: 10px; background: rgba(128,128,128,.06); margin-bottom: 6px; border-left: 3px solid rgba(128,128,128,.3); }
.flow-item.s-running { border-left-color: var(--blue, #2f6fed); }
.flow-item.s-done, .flow-item.s-verified { border-left-color: #2e9e5b; opacity: .72; }
.flow-item.s-failed, .flow-item.s-blocked { border-left-color: #c0392b; }
.flow-item.s-approval_needed { border-left-color: #e0a000; }
.flow-title { font-weight: 500; }
.flow-meta { font-size: 12px; opacity: .6; }
.flow-empty { padding: 32px 6px; text-align: center; }

/* ============================================ collapsible sidebar + row menu */
.side-titlebar h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.titlebar-btns { flex: none; }
#sidebar-collapse {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: none; border-radius: 50%; background: var(--fill); color: var(--text);
  cursor: pointer; transition: background .15s; -webkit-appearance: none; appearance: none; padding: 0;
}
#sidebar-collapse:hover { background: var(--fill-2); }
#sidebar-collapse:active { transform: scale(.94); }
#app.sidebar-collapsed #sidebar { display: none; }
.sidebar-reveal {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--hairline);
  background: var(--side-bg); color: var(--text); cursor: pointer; place-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
#app.sidebar-collapsed .sidebar-reveal { display: grid; }

/* per-chat row options menu (⋯) */
.row { position: relative; }
.row-title { padding-right: 20px; }
.row-menu {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 24px; height: 22px; border: none; border-radius: 6px;
  background: transparent; color: var(--muted, #888); cursor: pointer;
  font-size: 17px; line-height: 1; display: grid; place-items: center;
  opacity: 0; transition: opacity .12s, background .12s; padding: 0;
}
.row:hover .row-menu { opacity: .8; }
.row-menu:hover { opacity: 1; background: var(--fill-2); }
@media (hover: none) { .row-menu { opacity: .55; } }

.row-menu-pop {
  position: fixed; z-index: 200; min-width: 178px; max-width: 244px;
  background: var(--side-bg, #1b1b1d); border: 1px solid var(--hairline);
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.32);
  padding: 5px; display: flex; flex-direction: column; gap: 1px;
  max-height: 62vh; overflow-y: auto;
}
.row-menu-pop .rm-item {
  text-align: left; border: none; background: transparent; color: var(--text);
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
.row-menu-pop .rm-item:hover { background: var(--fill-2); }
.row-menu-pop .rm-danger { color: var(--danger, #e5534b); }
.row-menu-pop .rm-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #888); padding: 6px 10px 3px;
}
.row-menu-pop .rm-sep { height: 1px; background: var(--hairline); margin: 4px 2px; }

/* ---- v1.8 Radegast capability-provenance chip + context gate ---- */
.prov-chip {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; line-height: 1.3; user-select: none;
  border: 1px solid var(--hairline);
  color: var(--muted, #888); background: transparent;
}
.prov-chip.warn { color: #b45309; border-color: #f0c27a; background: rgba(244, 178, 76, .10); }
.prov-chip.ok { color: var(--ok); border-color: rgba(52, 199, 89, .45); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .prov-chip.warn { color: #f5b04d; border-color: rgba(245, 176, 77, .4); background: rgba(245, 176, 77, .08); }
}
:root[data-theme="dark"] .prov-chip.warn { color: #f5b04d; border-color: rgba(245, 176, 77, .4); background: rgba(245, 176, 77, .08); }
.ctx-gate {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid #f0c27a; background: rgba(244, 178, 76, .08);
  font-size: 13px; line-height: 1.45;
}
.ctx-gate-btns { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.ctx-gate-btns button {
  padding: 6px 12px; border-radius: 9px; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--accent); color: var(--on-accent);
}
.ctx-gate-btns button:last-child { background: transparent; color: inherit; }
.ctx-gate-btns button:disabled { opacity: .5; cursor: default; }
