:root {
  --bg: #0b0d12;
  --bg-2: #12151c;
  --bg-3: #1a1f29;
  --line: #232937;
  --text: #aeb8c8;
  --muted: #8a93a6;
  --accent: #7aa2ff;
  --accent-2: #5b87ff;
  --user-bg: #1e3a8a;
  --user-text: #e8efff;
  --assistant-bg: #181c25;
  --danger: #ff6b6b;
  --drawer-w: 300px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* ---------- scrollbars (dark mode to match UI) ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: #2a3142 transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: #2a3142;
  border-radius: 8px;
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover {
  background: #3a445c;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

#app { display: flex; height: 100vh; height: 100dvh; }
.hidden { display: none !important; }

/* ---------- drawer ---------- */
#drawer {
  width: var(--drawer-w);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  transform: translateX(-100%);
  transition: transform .22s ease;
  z-index: 20;
  padding-top: var(--safe-top);
}
#drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}
.drawer-search {
  padding: 0 12px 10px;
}
.drawer-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 11px;
  outline: none;
  font: inherit;
}
.drawer-search input:focus {
  border-color: rgba(122,162,255,.55);
  background: var(--bg-3);
}
.drawer-search input::placeholder {
  color: var(--muted);
}
.brand {
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.drawer-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.drawer-foot {
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  display: grid;
  gap: 8px;
}
.panel-badge {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #b91c1c;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.panel-badge.hidden { display: none; }

.agent {
  padding: 10px 16px 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 8px;
  margin: 2px 8px;
}
.agent-head:hover { background: var(--bg-3); }
.agent-head.active { background: var(--bg-3); }
.agent-name { font-weight: 600; letter-spacing: -0.01em; }
.agent-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }

.threads { padding: 6px 8px 8px; }
.thread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}
.thread:hover { background: var(--bg-3); color: var(--text); }
.thread.active { background: var(--bg-3); color: var(--text); }
.thread-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-actions { display: none; gap: 4px; }
.thread:hover .thread-actions, .thread.active .thread-actions { display: flex; }
.thread-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 4px;
}
.thread-btn:hover { color: var(--text); background: rgba(255,255,255,.04); }

#scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 15;
  display: none;
}
#scrim.show { display: block; }

/* ---------- main ---------- */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--safe-top);
}

#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
#title { flex: 1; min-width: 0; }
.t-agent { font-weight: 600; font-size: 15px; line-height: 1.15; letter-spacing: -0.01em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.t-thread { font-size: 12px; color: var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.usage-meter {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font: 500 11px/1.2 "JetBrains Mono", ui-monospace, monospace;
  white-space: nowrap;
}
.usage-meter.hot {
  color: #ffd28a;
  border-color: rgba(255, 210, 138, .35);
  background: rgba(255, 210, 138, .08);
}

.topbar-orb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}

.icon-btn {
  background: transparent; border: 0;
  color: var(--text);
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-3); }

/* ---------- messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 20px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  display: flex;
  margin: 8px 0;
}
.msg .bubble {
  max-width: min(82%, 720px);
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 15px;
  letter-spacing: -0.005em;
}
/* User bubbles still come in as raw text - preserve line breaks. */
.msg.user .bubble { white-space: pre-wrap; }
/* Assistant bubbles are real markdown-rendered HTML. Default white-space. */
.msg.assistant .bubble, .msg.error .bubble { white-space: normal; }

.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  background: var(--assistant-bg);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.045);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 0 rgba(255,255,255,.025) inset;
}
.msg.assistant .bubble.has-chart {
  width: min(96vw, 1120px);
  max-width: min(96%, 1120px);
}
.msg.error .bubble {
  background: #2a1212;
  color: #ffb4b4;
}
.msg {
  flex-wrap: wrap;
}
.msg.user .message-actions {
  width: 100%;
  justify-content: flex-end;
}
.msg.assistant .message-actions,
.msg.error .message-actions {
  width: 100%;
  justify-content: flex-start;
}
.message-actions {
  display: flex;
  gap: 6px;
  margin: 4px 2px 0;
  padding: 0;
}
.message-actions.empty-actions {
  display: none;
}
.message-action {
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.035);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
}
.message-action:hover {
  background: rgba(122,162,255,.12);
  color: var(--text);
  border-color: rgba(122,162,255,.25);
}
.message-action.stop {
  color: #ffb4b4;
  border-color: rgba(255,107,107,.28);
}
.message-action.stop:hover {
  background: rgba(255,107,107,.12);
}

/* ---- markdown-rendered content inside assistant bubbles ---- */

.msg .bubble code {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9em;
  background: rgba(255,255,255,.06);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg .bubble pre {
  background: rgba(0,0,0,.35);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre;
}
.msg .bubble .copy-block {
  position: relative;
  margin: 8px 0;
}
.msg .bubble .copy-block pre {
  margin: 0;
  padding-top: 34px;
}
.copy-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 1;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 7px;
  padding: 4px 8px;
  background: rgba(18,21,28,.92);
  color: var(--muted);
  font: 700 10px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
}
.copy-btn:hover,
.copy-btn.copied {
  color: var(--text);
  border-color: rgba(122,162,255,.42);
  background: rgba(122,162,255,.16);
}
.msg .bubble pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.chart-artifact {
  margin: 12px 0;
  border: 1px solid rgba(122,162,255,.22);
  border-radius: 14px;
  background: rgba(8,10,16,.42);
  overflow: hidden;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.chart-title {
  color: #dce3ee;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-toggle { flex: 0 0 auto; }
.chart-toggle {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 7px;
  padding: 5px 8px;
  background: rgba(18,21,28,.92);
  color: var(--muted);
  font: 700 10px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
}
.chart-toggle:hover {
  color: var(--text);
  border-color: rgba(122,162,255,.42);
  background: rgba(122,162,255,.16);
}
.chart-plot {
  width: 100%;
  min-height: 240px;
  padding: 6px 6px 2px;
}
.chart-error .chart-plot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  color: var(--muted);
  padding: 16px;
}
.chart-raw {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 8px 12px 12px;
  color: var(--muted);
}
.chart-raw summary {
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 8px;
}
.chart-raw pre {
  max-height: 260px;
}

.msg .bubble p { margin: 0 0 8px 0; }
.msg .bubble p:last-child { margin-bottom: 0; }

.msg .bubble ul, .msg .bubble ol { margin: 4px 0 8px 0; padding-left: 22px; }
.msg .bubble li { margin: 2px 0; }
.msg .bubble li > p { margin: 0; }

.msg .bubble h1, .msg .bubble h2, .msg .bubble h3,
.msg .bubble h4, .msg .bubble h5, .msg .bubble h6 {
  margin: 14px 0 6px 0;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.msg .bubble h1 { font-size: 1.42em; color: #d7dee9; }
.msg .bubble h2 { font-size: 1.24em; color: #c8d1de; }
.msg .bubble h3 { font-size: 1.12em; color: #bac4d2; }
.msg .bubble h4 { font-size: 1.02em; color: #aeb8c8; }
.msg .bubble h5, .msg .bubble h6 { font-size: .95em; color: var(--muted); }
.msg .bubble :first-child { margin-top: 0; }

.msg .bubble strong { color: #bdc6d4; font-weight: 600; }
.msg .bubble em { color: var(--text); }

.msg .bubble blockquote {
  margin: 6px 0;
  padding: 6px 12px;
  background: rgba(255,255,255,.018);
  color: var(--muted);
  font-style: italic;
  border-left: 3px solid rgba(122,162,255,.35);
  border-radius: 8px;
}
.msg .bubble blockquote.tool-status {
  position: relative;
  font-style: normal;
  background: rgba(122,162,255,.07);
  color: #aebcf2;
  border-left-color: rgba(122,162,255,.75);
  padding-top: 18px;
}
.msg .bubble blockquote.tool-status::before {
  content: "tool/status";
  position: absolute;
  top: 4px;
  left: 12px;
  color: var(--muted);
  font: 600 10px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.review-section {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.035);
}
.review-section h2,
.review-section h3 {
  margin-top: 3px !important;
}
.review-section-label {
  margin-bottom: 4px;
  color: var(--muted);
  font: 700 10px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.review-section-action {
  border-color: rgba(255, 210, 138, .42);
  background: rgba(255, 210, 138, .075);
}
.review-section-action .review-section-label,
.review-section-action h2,
.review-section-action h3 {
  color: #ffd28a;
}
.review-section-threshold {
  border-color: rgba(255, 107, 107, .35);
  background: rgba(255, 107, 107, .06);
}
.review-section-threshold .review-section-label,
.review-section-threshold h2,
.review-section-threshold h3 {
  color: #ffb0b0;
}
.review-section-watch,
.review-section-risk {
  border-color: rgba(122,162,255,.35);
  background: rgba(122,162,255,.055);
}
.review-section-watch .review-section-label,
.review-section-risk .review-section-label,
.review-section-watch h2,
.review-section-risk h2,
.review-section-watch h3,
.review-section-risk h3 {
  color: #aebcf2;
}
.review-section-meeting {
  border-color: rgba(139, 224, 180, .32);
  background: rgba(139, 224, 180, .055);
}
.review-section-meeting .review-section-label,
.review-section-meeting h2,
.review-section-meeting h3 {
  color: #aee7c4;
}

.msg .bubble hr {
  border: none;
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 12px 0;
}

.msg .bubble a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(122,162,255,.35);
}
.msg .bubble a:hover { border-bottom-color: var(--accent); }

.msg .bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.92em;
  display: block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}
.msg .bubble th, .msg .bubble td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.msg .bubble th {
  background: rgba(255,255,255,.04);
  font-weight: 600;
}
.msg .bubble tr:nth-child(even) td {
  background: rgba(255,255,255,.02);
}

.caret {
  display: inline-block;
  width: 8px;
  background: currentColor;
  opacity: .6;
  height: 1em;
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.run-status-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}
.run-status {
  border: 1px solid rgba(122,162,255,.18);
  background: rgba(122,162,255,.055);
  color: #c9d6ff;
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 12px;
}
.run-status::before {
  content: "status";
  color: var(--muted);
  font: 700 10px/1 "JetBrains Mono", ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 8px;
}

.empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.empty-inner { text-align: center; color: var(--muted); max-width: 360px; }
.empty-title { color: var(--text); font-size: 18px; font-weight: 600; margin-bottom: 6px; }

/* ---------- composer ---------- */
.composer {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 10px calc(10px + var(--safe-bottom));
  background: var(--bg);
}
.image-preview-tray {
  width: 100%;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 2px 2px;
}
.image-preview {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  background: var(--bg-3);
  flex: 0 0 auto;
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.68);
  color: white;
  cursor: pointer;
}
.attach {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.attach:hover { background: #222838; }
.record-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}
.record-audio.recording {
  background: #7f1d1d;
  border-color: #ef4444;
  color: white;
  animation: recordPulse 1.2s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.35); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
#input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  background: var(--bg-2);
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  border-radius: 22px;
  outline: none;
}
#input:focus { background: var(--bg-3); }
.send {
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-2);
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.send:hover { background: var(--accent); }
.send:disabled {
  background: var(--bg-3);
  color: var(--muted);
  cursor: default;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.message-attachment {
  display: block;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  overflow: hidden;
  max-width: 240px;
  background: rgba(0,0,0,.25);
}
.message-attachment img {
  display: block;
  max-width: 240px;
  max-height: 240px;
  object-fit: contain;
}

button.primary {
  width: 100%;
  background: var(--accent-2);
  color: white;
  border: 0;
  padding: 12px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { background: var(--accent); }
button.secondary {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.secondary:hover { background: #222838; }

/* ---------- local side panels ---------- */
#alertsPanel,
#reminderPanel,
#watchlistPanel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg-2);
  z-index: 25;
  transform: translateX(100%);
  transition: transform .22s ease;
  padding-top: var(--safe-top);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}
#alertsPanel.open,
#reminderPanel.open,
#watchlistPanel.open { transform: translateX(0); }
#exapacsPanel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: var(--bg);
  z-index: 35;
  transform: translateY(100%);
  transition: transform .22s ease;
  padding-top: var(--safe-top);
  display: flex;
  flex-direction: column;
}
#exapacsPanel.open { transform: translateY(0); }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title { font-weight: 700; color: var(--text); }
.panel-sub { font-size: 12px; color: var(--muted); }
#exapacsPanel .panel-head {
  min-height: 74px;
  padding: 14px clamp(14px, 2.2vw, 30px);
}
.exapacs-titlebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.exapacs-title-logo {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
#exapacsPanel .panel-title {
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 850;
  letter-spacing: -.03em;
}
#closeExapacs {
  width: 58px;
  height: 58px;
  font-size: 48px;
  line-height: 1;
  border-radius: 16px;
}
.reminder-form,
.watchlist-form {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.reminder-form input,
.reminder-form textarea,
.watchlist-form input,
.watchlist-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 11px;
  font: inherit;
  outline: none;
}
.reminder-form input:focus,
.reminder-form textarea:focus,
.watchlist-form input:focus,
.watchlist-form textarea:focus {
  border-color: rgba(122,162,255,.55);
}
.watchlist-form textarea {
  min-height: 120px;
  resize: vertical;
}
.alerts-list,
.reminder-list {
  overflow-y: auto;
  padding: 10px 12px 16px;
}
.alert-empty,
.reminder-empty {
  color: var(--muted);
  padding: 18px 4px;
}
.alert-row {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 9px;
}
.alert-row.urgent {
  border-color: rgba(239,68,68,.55);
  background: rgba(127,29,29,.25);
}
.alert-row.warning {
  border-color: rgba(245,158,11,.45);
  background: rgba(120,53,15,.18);
}
.alert-title { color: var(--text); font-weight: 800; }
.alert-meta,
.alert-action-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.alert-body {
  color: var(--text);
  font-size: 13px;
  white-space: pre-wrap;
  margin-top: 8px;
}
.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.exapacs-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.exapacs-actions button {
  flex: 1;
}
.exapacs-status {
  overflow-y: auto;
  padding: 14px clamp(12px, 2.2vw, 28px) 24px;
}
.exapacs-loading,
.exapacs-empty {
  color: var(--muted);
  padding: 18px 4px;
}
.exapacs-summary-card,
.exapacs-section,
.exapacs-chart-card,
.exapacs-metric-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 10px;
}
.exapacs-hero-grid {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(280px, 1.1fr);
  gap: 12px;
  align-items: stretch;
}
.exapacs-hero-grid .exapacs-summary-card,
.exapacs-hero-grid .exapacs-chart-card {
  margin-bottom: 0;
}
.exapacs-metrics-grid,
.exapacs-chart-grid,
.exapacs-list-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.exapacs-metrics-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}
.exapacs-chart-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}
.exapacs-chart-grid.single {
  grid-template-columns: 1fr;
}
.exapacs-list-grid {
  grid-template-columns: repeat(4, minmax(190px, 1fr));
}
.exapacs-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.exapacs-total {
  color: var(--text);
  font-size: 44px;
  line-height: 1;
  font-weight: 800;
  margin-top: 8px;
}
.exapacs-label {
  color: #b9c7ff;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}
.exapacs-meta,
.exapacs-policy {
  color: var(--muted);
  font-size: 12px;
  margin-top: 7px;
}
.exapacs-warn {
  color: #ffd28a;
  font-size: 12px;
  margin-top: 8px;
}
.exapacs-section-title {
  color: var(--text);
  font-weight: 800;
  margin-bottom: 8px;
}
.exapacs-count-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 7px 0;
  font-size: 13px;
}
.exapacs-count-row:first-of-type {
  border-top: 0;
}
.exapacs-count-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exapacs-count-row strong {
  color: #d8e1ff;
}
.exapacs-chart {
  min-height: 220px;
}
.exapacs-chart.small {
  min-height: 170px;
}
.exapacs-chart.medium {
  min-height: 260px;
}
.exapacs-chart-placeholder {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  border: 1px dashed rgba(148,163,184,.25);
  border-radius: 10px;
}
.exapacs-chart-sub {
  color: var(--muted);
  font-size: 12px;
  margin: -2px 0 8px;
}
.exapacs-metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.exapacs-metric-value {
  color: var(--text);
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
  font-weight: 850;
  margin-top: 8px;
}
.exapacs-metric-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 1100px) {
  .exapacs-metrics-grid,
  .exapacs-list-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}
@media (max-width: 760px) {
  .exapacs-hero-grid,
  .exapacs-chart-grid,
  .exapacs-metrics-grid,
  .exapacs-list-grid {
    grid-template-columns: 1fr;
  }
  .exapacs-actions {
    flex-wrap: wrap;
  }
  .exapacs-total {
    font-size: 52px;
  }
}
.reminder-row {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}
.reminder-main { flex: 1; min-width: 0; }
.reminder-title { color: var(--text); font-weight: 600; }
.reminder-due {
  margin-top: 2px;
  color: #ffd28a;
  font-size: 12px;
}
.reminder-notes {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
}
.reminder-actions {
  display: grid;
  gap: 6px;
  align-content: start;
}
.reminder-actions button {
  border: 0;
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--text);
  background: var(--bg-3);
  cursor: pointer;
  font: 600 12px/1 "Inter", sans-serif;
}
.reminder-actions .reminder-done {
  background: #1f3a2a;
  color: #c8f0d4;
}
.reminder-actions .reminder-delete {
  background: #3a1f25;
  color: #f5c8cc;
}

.watchlist-filter {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.watch-filter {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font: 700 12px/1 "Inter", sans-serif;
}
.watch-filter.active {
  color: var(--text);
  border-color: rgba(122,162,255,.45);
  background: rgba(122,162,255,.12);
}
.watchlist-list {
  overflow-y: auto;
  padding: 10px 12px 16px;
}
.watchlist-empty {
  color: var(--muted);
  padding: 18px 4px;
}
.watch-item {
  display: grid;
  gap: 10px;
  padding: 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 9px;
}
.watch-title {
  color: var(--text);
  font-weight: 700;
}
.watch-subject {
  margin-top: 2px;
  color: #b9c7ff;
  font-size: 13px;
}
.watch-reason {
  margin-top: 6px;
  color: var(--text);
  font-size: 13px;
  white-space: pre-wrap;
}
.watch-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.watch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.watch-action {
  border: 0;
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--text);
  background: var(--bg-3);
  cursor: pointer;
  font: 700 12px/1 "Inter", sans-serif;
}
.watch-action.done {
  background: #1f3a2a;
  color: #c8f0d4;
}
.watch-action.danger {
  background: #3a1f25;
  color: #f5c8cc;
}

/* ---------- desktop breakpoint ---------- */
@media (min-width: 900px) {
  #drawer {
    position: static;
    transform: none;
  }
  #scrim { display: none !important; }
  #openDrawer { display: none; }
  #closeDrawer { display: none; }
}

/* ---------- mobile / coarse-pointer tweaks ---------- */
@media (max-width: 899px) {
  /* iOS zooms inputs <16px on focus; force 16px on the composer only. */
  #input { font-size: 16px; }

  /* Slim scrollbars further; native iOS overlay scrollbars take over anyway. */
  *::-webkit-scrollbar { width: 6px; height: 6px; }
  *::-webkit-scrollbar-thumb { border-width: 1px; }

  /* Tighten the topbar so the title gets more room. */
  #topbar { padding: 8px 8px; }
  .icon-btn { width: 38px; height: 38px; }

  /* Drawer covers more of the screen on phones. */
  :root { --drawer-w: 86vw; }
  #drawer { max-width: 360px; }

  /* Bubbles can use more width on narrow screens. */
  .msg .bubble { max-width: 88%; }
  .msg.assistant .bubble.has-chart {
    width: 96vw;
    max-width: 96vw;
  }
  .chart-plot {
    min-height: 220px;
  }
  .chart-title {
    font-size: 12px;
    white-space: normal;
  }
}

/* ---------- confirmation cards (mutating tools) ---------- */
.confirm-card {
  margin-top: 10px;
  padding: 12px 14px;
  background: #1d2330;
  border-radius: 10px;
  font-size: 14px;
}
.confirm-card.decided { opacity: 0.85; }
.confirm-card.decided.yes { background: #1b2a22; }
.confirm-card.decided.no  { background: #2a1b20; }

.confirm-kind {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.confirm-kind strong { color: var(--text); }

.confirm-summary {
  margin-bottom: 12px;
}
.confirm-summary p { margin: 0 0 6px 0; }
.confirm-summary blockquote {
  margin: 6px 0;
  padding: 6px 10px;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 8px;
}

.confirm-footer {
  display: flex;
  gap: 8px;
}
.confirm-footer.decided {
  font-size: 13px;
  color: var(--muted);
}
.confirm-footer.decided.yes  { color: #4ade80; }
.confirm-footer.decided.no   { color: var(--danger); }

.confirm-origin {
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 500;
}

.confirm-btn {
  flex: 1;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.confirm-btn:hover { background: var(--bg-3); }
.confirm-btn:active { transform: translateY(1px); }
.confirm-btn.yes {
  background: #1f3a2a;
  color: #c8f0d4;
}
.confirm-btn.yes:hover { background: #25492f; }
.confirm-btn.no {
  background: #3a1f25;
  color: #f5c8cc;
}
.confirm-btn.no:hover { background: #471f25; }

/* On mobile the buttons should stack to give big tap targets. */
@media (max-width: 460px) {
  .confirm-footer { flex-direction: column; }
  .confirm-btn { padding: 12px 16px; font-size: 16px; }
}

/* ---------- live tool activity ---------- */
.tool-activity-list {
  margin-top: 10px;
  display: grid;
  gap: 7px;
}
.tool-activity {
  border: 1px solid rgba(122,162,255,.22);
  background: rgba(122,162,255,.045);
  border-radius: 10px;
  overflow: hidden;
}
.tool-activity.running {
  border-color: rgba(255, 210, 138, .35);
  background: rgba(255, 210, 138, .06);
}
.tool-activity.error {
  border-color: rgba(255, 107, 107, .38);
  background: rgba(255, 107, 107, .065);
}
.tool-activity-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.tool-activity-state {
  flex-shrink: 0;
  color: var(--muted);
  font: 700 10px/1 "JetBrains Mono", ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.tool-activity.running .tool-activity-state { color: #ffd28a; }
.tool-activity.error .tool-activity-state { color: #ffb0b0; }
.tool-activity-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.tool-activity-chevron {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 11px;
}
.tool-activity-elapsed {
  flex-shrink: 0;
  color: var(--muted);
  font: 600 11px/1 "JetBrains Mono", ui-monospace, monospace;
}
.tool-activity-body {
  padding: 0 10px 10px;
}
.tool-activity-label {
  margin: 4px 0 3px;
  color: var(--muted);
  font: 700 10px/1 "JetBrains Mono", ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.tool-activity pre {
  margin: 0 0 8px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0,0,0,.25);
}
.tool-activity-waiting {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0 0;
}

/* ---------- slash-command autocomplete (tribute.js) ---------- */
/* We don't load the CDN tribute.css; this block owns positioning + theme. */
.tribute-container {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  height: auto;
  max-width: min(560px, 94vw);
  z-index: 9999;
  background: var(--bg-2, #11151c);
  border: 1px solid var(--line, rgba(255,255,255,.08));
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
  overflow: hidden;
  font: 14px/1.35 "Inter", system-ui, sans-serif;
  color: var(--text, #e6e9ef);
}
.tribute-container ul {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 320px;
  overflow-y: auto;
  background: transparent;
}
.tribute-container li {
  padding: 8px 12px;
  margin: 0 6px;
  cursor: pointer;
  border-radius: 8px;
  background: transparent;
  color: var(--text, #e6e9ef);
}
.tribute-container li:hover,
.tribute-container li.highlight {
  background: rgba(122,162,255,.14);
}
.tribute-container li.no-match {
  cursor: default;
  color: var(--muted, #8b94a3);
}
.tribute-container li span { font-weight: 600; }
.slash-row { display: flex; flex-direction: column; gap: 3px; }
.slash-label {
  color: var(--text, #e6e9ef);
  font-weight: 600;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}
.slash-desc {
  color: var(--muted, #8b94a3);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
}
.slash-empty {
  padding: 10px 14px;
  color: var(--muted, #8b94a3);
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
   Guest (loaner) mode - hide the admin operator chrome.
   The server already 403s these routes for guests; this just keeps the UI
   clean so a borrowed agent looks like a plain assistant, not GoD Mode.
   --------------------------------------------------------------------------- */
body.guest-mode #usageMeter,
body.guest-mode #alertsBtn,
body.guest-mode #exapacsBtn,
body.guest-mode #watchlistBtn,
body.guest-mode #remindersBtn {
  display: none !important;
}

body.guest-mode.chloe-mode #exapacsBtn {
  display: inline-flex !important;
}

