*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:          #080808;
  --color-surface-1:   #0f0f0f;
  --color-surface-2:   #141414;
  --color-surface-3:   #1c1c1c;
  --color-border:      rgba(255,255,255,0.06);
  --color-border-mid:  rgba(255,255,255,0.10);
  --color-text-primary:#f5f5f5;
  --color-text-2:      #a1a1aa;
  --color-text-3:      #52525b;
  --color-accent:      #1B6BF5;  /* ZSC blue — was #7c3aed */
  --color-user-bubble: #18181b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--color-bg); color: var(--color-text-primary); height: 100vh; overflow: hidden; font-size: 13px; line-height: 1.55; }
.hidden { display: none !important; }
.ui-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-icon {
  width: 14px;
  height: 14px;
}

/* ── Logo Mark ──────────────────────────────────────────────────────────── */
.logo-mark { background: #fff; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-mark-inner { background: #000; }
.logo-mark--sm  { width: 22px; height: 22px; }
.logo-mark--sm  .logo-mark-inner { width: 8px; height: 8px; }
.logo-mark--md  { width: 26px; height: 26px; }
.logo-mark--md  .logo-mark-inner { width: 10px; height: 10px; }
.logo-mark--lg  { width: 40px; height: 40px; }
.logo-mark--lg  .logo-mark-inner { width: 15px; height: 15px; }
.logo-mark--xl  { width: 44px; height: 44px; }
.logo-mark--xl  .logo-mark-inner { width: 17px; height: 17px; }


/* ── App layout ─────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar { width: 232px; background: var(--color-surface-1); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; flex-shrink: 0; }

.sidebar-top { padding: 14px; border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }
.sidebar-logo-row { display: flex; align-items: center; gap: 8px; }
.sidebar-logo-text { color: var(--color-text-primary); font-weight: 600; font-size: 13px; letter-spacing: -0.3px; }

/* ── ZSC Logo in sidebar ────────────────────────────────────────────────── */
.sidebar-logo-img { height: 18px; width: auto; filter: brightness(0) invert(1); }

/* ── User avatar (sidebar footer) ──────────────────────────────────────── */
.user-avatar-img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.sign-out-btn { margin-left: auto; background: none; border: none; color: var(--color-text-3); cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; }
.sign-out-btn:hover { color: var(--color-text-2); background: var(--color-surface-3); }

/* Client dropdown */
.client-dropdown { position: relative; }
.dropdown-trigger { background: var(--color-surface-2); border: 1px solid var(--color-border-mid); border-radius: var(--radius-sm); padding: 6px 10px; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; transition: border-color 0.15s; }
.dropdown-trigger:hover { border-color: rgba(255,255,255,0.16); }
.client-icon { width: 14px; height: 14px; color: var(--color-text-2); }
#client-name-label { flex: 1; color: var(--color-text-2); font-size: 12px; }
.chevron { color: var(--color-text-3); font-size: 11px; }
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--color-surface-2); border: 1px solid var(--color-border-mid); border-radius: var(--radius-sm); z-index: 100; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.dropdown-item { padding: 7px 10px; font-size: 12px; color: var(--color-text-2); cursor: pointer; transition: background 0.1s; }
.dropdown-item:hover, .dropdown-item.active { background: var(--color-surface-3); color: var(--color-text-primary); }

/* Sidebar body */
.sidebar-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 12px; gap: 12px; }

/* Project picker */
.project-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 0;
  margin-top: 8px;
}
.project-picker .project-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
  margin-right: 2px;
}
.project-picker select {
  flex: 1;
  padding: 4px 6px;
  font-size: 12px;
  background: #1b2a3f;
  color: #cfe0ff;
  border: 1px solid #2a4060;
  border-radius: 6px;
}
.project-picker .btn-sm {
  padding: 2px 8px;
  font-size: 12px;
}

/* New chat */
.new-chat-btn { width: 100%; background: none; border: 1px dashed var(--color-border-mid); border-radius: var(--radius-sm); padding: 7px 10px; color: var(--color-text-2); font-size: 12px; font-family: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; transition: all 0.15s; }
.new-chat-btn:hover { border-color: rgba(255,255,255,0.18); color: var(--color-text-primary); background: var(--color-surface-2); }

/* Section labels */
.section-label { color: var(--color-text-3); font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }

/* Conversations */
.sidebar-convos { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.conversation-list { flex: 1; overflow-y: auto; }
.conv-item { padding: 6px 8px; margin-bottom: 1px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s; }
.conv-item:hover { background: var(--color-surface-2); }
.conv-item.active { background: var(--color-surface-3); }
.conv-item.active .conv-title { color: var(--color-text-primary); }
.conv-inner { display: flex; flex-direction: column; gap: 2px; }
.conv-title { color: var(--color-text-2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-date { color: var(--color-text-3); font-size: 10px; }

/* Sidebar footer */
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--color-border); flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--color-surface-3); border: 1px solid var(--color-border-mid); display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--color-text-2); flex-shrink: 0; }
.user-label { font-size: 11px; color: var(--color-text-2); }

/* ── Chat panel ─────────────────────────────────────────────────────────── */
.chat-panel { flex: 1; display: flex; flex-direction: column; background: var(--color-bg); overflow: hidden; position: relative; }

/* Particle canvas */
#particle-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }

/* Header */
.chat-header { height: 48px; padding: 0 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; position: relative; z-index: 1; }
#chat-title { color: var(--color-text-2); font-size: 12px; font-weight: 500; letter-spacing: -0.2px; }
.chat-header-actions { display: flex; gap: 4px; }
.header-btn { background: none; border: none; color: var(--color-text-3); font-size: 11px; cursor: pointer; padding: 3px 8px; border-radius: var(--radius-sm); font-family: inherit; transition: color 0.1s; }
.header-btn:hover { color: var(--color-text-2); }

/* ── Messages ───────────────────────────────────────────────────────────── */
.messages { flex: 1; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 24px; position: relative; z-index: 1; }

/* Welcome / Empty state */
.suggestions-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; text-align: center; gap: 20px; min-height: 300px; }
.suggestions-heading { font-size: 26px; font-weight: 700; color: var(--color-text-primary); letter-spacing: -0.8px; line-height: 1.2; max-width: 380px; }
.suggestions-sub { color: var(--color-text-2); font-size: 13px; }
.suggestions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 440px; width: 100%; }
.suggestion-chip { background: var(--color-surface-1); border: 1px solid var(--color-border-mid); border-radius: var(--radius-md); padding: 12px 16px; color: var(--color-text-2); font-size: 12px; font-family: inherit; cursor: pointer; text-align: left; line-height: 1.4; transition: all 0.15s; }
.suggestion-chip:hover { border-color: rgba(255,255,255,0.18); color: var(--color-text-primary); background: var(--color-surface-2); }

/* User message */
.message-user { display: flex; justify-content: flex-end; }
.user-bubble { background: var(--color-user-bubble); border: 1px solid var(--color-border-mid); border-radius: 12px 12px 2px 12px; padding: 10px 14px; max-width: 70%; color: var(--color-text-primary); line-height: 1.55; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* AI message */
.message-ai { display: flex; gap: 12px; max-width: 90%; }
.ai-avatar { flex-shrink: 0; margin-top: 2px; }
.ai-content { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ai-text { color: var(--color-text-primary); font-size: 13px; line-height: 1.65; }
.ai-text p { margin-bottom: 10px; }
.ai-text p:last-child { margin-bottom: 0; }
.ai-text ul, .ai-text ol { margin: 6px 0 10px 20px; }
.ai-text li { margin-bottom: 4px; }
.ai-text code { background: var(--color-surface-2); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 0.875em; }
.ai-text pre { background: var(--color-surface-1); padding: 16px; border-radius: 8px; overflow-x: auto; margin: 10px 0; border: 1px solid var(--color-border); }
.ai-text pre code { background: none; padding: 0; }
.ai-text a { color: var(--color-text-2); }
.ai-text strong { color: #fff; }
.message-actions { display: flex; gap: 8px; }
.action-btn { background: none; border: none; color: var(--color-text-3); font-size: 10px; cursor: pointer; padding: 2px 4px; border-radius: 3px; font-family: inherit; }
.action-btn:hover { color: var(--color-text-2); }

/* ── Tool Blocks ────────────────────────────────────────────────────────── */
.tool-blocks-area { display: flex; flex-direction: column; gap: 4px; }
.tool-block { border-radius: 8px; overflow: hidden; font-size: 11px; }

/* Running state */
.tool-block--running { border: 1px solid var(--color-border); }
.tool-block--running .tool-block-header { background: var(--color-surface-2); }
.tool-block--running .tool-icon { color: var(--color-text-3); display: inline-block; animation: spin 1s linear infinite; }
.tool-block--running .tool-label { color: var(--color-text-3); }

/* Search done state */
.tool-block--search { border: 1px solid var(--color-border); }
.tool-block--search .tool-block-header { background: var(--color-surface-1); cursor: pointer; }
.tool-block--search .tool-icon { color: var(--color-text-2); animation: none; }
.tool-block--search .tool-label { color: var(--color-text-2); font-weight: 500; }
.tool-block--search .tool-toggle { color: var(--color-text-3); }
.tool-block--search .tool-block-body { background: var(--color-bg); border-top: 1px solid var(--color-border); }

/* Non-search done state */
.tool-block--done { border: 1px solid var(--color-border); }
.tool-block--done .tool-block-header { background: var(--color-surface-1); cursor: pointer; }
.tool-block--done .tool-label { color: var(--color-text-2); font-weight: 500; }
.tool-block--done .tool-toggle { color: var(--color-text-3); }
.tool-block--done .tool-block-body { background: var(--color-bg); border-top: 1px solid var(--color-border); }
.tool-icon--done { color: var(--color-text-2) !important; animation: none !important; }

.tool-block-header { padding: 7px 12px; display: flex; align-items: center; gap: 7px; user-select: none; }
.tool-icon { width: 14px; text-align: center; flex-shrink: 0; }
.tool-label { flex: 1; }
.tool-toggle { font-size: 10px; margin-left: auto; white-space: nowrap; }
.tool-block-body { padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; }
.tool-query { color: var(--color-text-3); font-size: 10px; width: 100%; margin-bottom: 4px; }
.source-pill { background: var(--color-surface-2); border-radius: 3px; padding: 2px 6px; color: var(--color-text-2); display: inline-flex; align-items: center; gap: 4px; font-size: 10px; }
.source-score { color: var(--color-text-3); }
.tool-result-pre { color: var(--color-text-2); font-size: 10px; font-family: monospace; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; width: 100%; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Composer ───────────────────────────────────────────────────────────── */
.composer-area { padding: 12px 20px 16px; flex-shrink: 0; position: relative; z-index: 1; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip { background: var(--color-surface-2); border: 1px solid var(--color-border-mid); border-radius: var(--radius-sm); padding: 4px 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--color-text-2); }
.file-chip--uploading { opacity: 0.6; }
.file-chip-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-status { color: var(--color-text-3); font-style: italic; }
.file-chip-remove { background: none; border: none; color: var(--color-text-3); cursor: pointer; font-size: 14px; padding: 0 0 0 2px; line-height: 1; }
.file-chip-remove:hover { color: var(--color-text-2); }
.composer-box { background: var(--color-surface-1); border: 1px solid var(--color-border-mid); border-radius: var(--radius-lg); padding: 8px 10px; display: flex; align-items: flex-end; gap: 8px; transition: border-color 0.15s; }
.composer-box:focus-within { border-color: rgba(255,255,255,0.16); }
.attach-btn { background: none; border: none; color: var(--color-text-3); cursor: pointer; font-size: 15px; padding: 0; line-height: 1; flex-shrink: 0; margin-bottom: 2px; }
.attach-btn:hover { color: var(--color-text-2); }
.message-input { flex: 1; background: none; border: none; color: var(--color-text-primary); font-size: 13px; line-height: 1.55; resize: none; max-height: 200px; font-family: inherit; outline: none; }
.message-input::placeholder { color: var(--color-text-3); }
.send-btn { width: 28px; height: 28px; background: #fff; border: none; border-radius: var(--radius-sm); color: #000; font-size: 14px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: inherit; transition: background 0.15s; }
.send-btn:hover:not(:disabled) { background: #e8e8e8; }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.composer-footer { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.composer-disclaimer { color: var(--color-text-3); font-size: 10px; }
.model-badge { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 2px 8px; color: var(--color-text-3); font-size: 10px; letter-spacing: 0.2px; }

/* ── Document viewer modal ──────────────────────────────────────────────── */
.doc-viewer-modal { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; }
.doc-viewer-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.72); }
.doc-viewer-modal__panel { position: relative; background: #111; border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; width: min(780px, calc(100vw - 48px)); max-height: calc(100vh - 80px); display: flex; flex-direction: column; }
.doc-viewer-modal__header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.doc-viewer-modal__title { color: #e4e4e7; font-size: 12px; font-weight: 500; }
.doc-viewer-modal__close { background: none; border: none; color: #52525b; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }
.doc-viewer-modal__close:hover { color: #a1a1aa; }
.doc-viewer-modal__body { flex: 1; overflow-y: auto; padding: 16px; margin: 0; color: #a1a1aa; font-size: 11px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; font-family: inherit; }

/* ── Drag overlay ───────────────────────────────────────────────────────── */
.drag-overlay { position: fixed; inset: 0; background: rgba(8,8,8,0.92); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.drag-overlay-inner { border: 1px dashed var(--color-border-mid); border-radius: 16px; padding: 48px 80px; color: var(--color-text-2); font-size: 16px; font-weight: 500; pointer-events: none; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ── Client Panel ─────────────────────────────────────────────────────────── */

.client-panel {
  width: 280px;
  flex-shrink: 0;
  background: #0f0f0f;
  border-left: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease;
}

.client-panel.hidden {
  width: 0;
  overflow: hidden;
  border-left: none;
}

.client-panel__header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.client-panel__header h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-panel__close {
  background: none;
  border: none;
  color: #52525b;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.client-panel__close:hover { color: #a1a1aa; }

.client-panel__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 11px;
}

.panel-section {
  padding: 9px;
  background: rgba(255,255,255,0.03);
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.07);
}

.panel-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.panel-section__label {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #52525b;
}

.panel-section__action {
  color: #52525b;
  cursor: pointer;
  font-size: 11px;
  background: none;
  border: none;
  padding: 0;
}

.panel-section__action:hover { color: #a1a1aa; }

/* Memory */
.memory-text {
  color: #a1a1aa;
  line-height: 1.5;
  font-size: 10px;
}

.memory-timestamp {
  color: #52525b;
  font-size: 9px;
  margin-top: 5px;
}

/* Instructions */
.instructions-text {
  color: #a1a1aa;
  line-height: 1.5;
  font-size: 10px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.instructions-text.expanded {
  -webkit-line-clamp: unset;
  display: block;
}

.instructions-show-more {
  color: #52525b;
  font-size: 9px;
  margin-top: 4px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.instructions-show-more:hover { color: #a1a1aa; }

.instructions-edit-area {
  width: 100%;
  background: #141414;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #f5f5f5;
  font-size: 10px;
  font-family: inherit;
  padding: 7px;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
}

.instructions-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
}

.btn-sm--primary {
  background: #fff;
  color: #000;
  border: none;
  font-weight: 600;
}

.btn-sm--secondary {
  background: none;
  color: #a1a1aa;
  border: 1px solid rgba(255,255,255,0.1);
}

/* Skills */
.skill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.skill-row__label {
  color: #a1a1aa;
  font-size: 10px;
}

.skill-row__label.disabled { color: #52525b; }

.toggle {
  width: 26px;
  height: 13px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  position: relative;
  border: none;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s;
}

.toggle.on { background: var(--color-accent); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: left 0.15s, background 0.15s;
}

.toggle.on::after {
  left: 15px;
  background: #fff;
}

.add-custom-block {
  margin-top: 8px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: 4px;
  color: #52525b;
  cursor: pointer;
  text-align: center;
  font-size: 10px;
  width: 100%;
  font-family: inherit;
  box-sizing: border-box;
}

.add-custom-block:hover { color: #a1a1aa; border-color: rgba(255,255,255,0.15); }

.custom-block-form {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.custom-block-form input,
.custom-block-form textarea {
  background: #141414;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  color: #f5f5f5;
  font-size: 10px;
  font-family: inherit;
  padding: 5px 7px;
  width: 100%;
  box-sizing: border-box;
}

.custom-block-form textarea { resize: vertical; min-height: 60px; }

/* Files */
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 7px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  font-size: 10px;
  margin-bottom: 3px;
}

.file-row__name { color: #a1a1aa; }
.file-row__action { color: #52525b; cursor: pointer; background: none; border: none; padding: 0; font-size: 10px; }
.file-row__action:hover { color: #a1a1aa; }
.file-row__delete:hover { color: #f87171; }

/* ── Wizard ───────────────────────────────────────────────────────────────── */

.wizard-progress {
  height: 2px;
  background: rgba(255,255,255,0.06);
}

.wizard-progress__bar {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s ease;
}

.wizard-body {
  padding: 14px;
  font-size: 11px;
  flex: 1;
  overflow-y: auto;
}

.wizard-step { display: none; }
.wizard-step.active { display: block; }

.wizard-step__title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.wizard-step__subtitle {
  color: #52525b;
  font-size: 10px;
  margin-bottom: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  color: #a1a1aa;
  font-size: 10px;
  margin-bottom: 4px;
}

.field-input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  background: #141414;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  color: #f5f5f5;
  font-size: 11px;
  font-family: inherit;
}

.field-input::placeholder { color: #52525b; }
.field-input:focus { outline: none; border-color: rgba(255,255,255,0.25); }

.field-input--textarea {
  resize: vertical;
  min-height: 80px;
}

/* Email chip input */
.email-chips-wrapper {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  background: #141414;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  font-size: 11px;
  font-family: inherit;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-height: 34px;
  cursor: text;
}

.email-chips-wrapper:focus-within {
  border-color: rgba(255,255,255,0.25);
  transition: border-color 0.15s;
}

.email-chip {
  background: #1c1c1c;
  border: 1px solid rgba(255,255,255,0.10);
  color: #a1a1aa;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.email-chip__remove {
  background: none;
  border: none;
  color: #52525b;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  transition: color 0.1s;
}

.email-chip__remove:hover {
  color: #a1a1aa;
}

.email-chips-wrapper input {
  background: transparent;
  border: none;
  outline: none;
  color: #f5f5f5;
  font-size: 11px;
  font-family: inherit;
  flex: 1;
  min-width: 120px;
  padding: 0 2px;
}

.email-chips-wrapper input::placeholder {
  color: #52525b;
}

/* Scrape progress */
.scrape-stats {
  padding: 10px;
  background: #141414;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 8px;
}

.scrape-stats__row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 10px;
}

.scrape-stats__row span:first-child { color: #a1a1aa; }
.scrape-stats__row span:last-child { color: #f5f5f5; font-weight: 600; }

.scrape-bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
}

.scrape-bar__fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.scrape-log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 140px;
  overflow-y: auto;
}

.scrape-log__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px;
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
  font-size: 10px;
}

.scrape-log__icon--done { color: #4ade80; }
.scrape-log__icon--loading { color: #a1a1aa; animation: spin 1s linear infinite; display: inline-block; }
.scrape-log__icon--error { color: #f87171; }
.scrape-log__url { color: #a1a1aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Wizard footer */
.wizard-footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

/* ── Sidebar Sources ─────────────────────────────────────────────────────── */
.sidebar-sources { flex-shrink: 0; border-top: 1px solid var(--color-border); padding-top: 10px; overflow-y: auto; max-height: 180px; }
.source-item { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s; }
.source-item:hover { background: var(--color-surface-2); }
.source-item__icon { font-size: 12px; flex-shrink: 0; }
.source-item__icon .ui-icon,
.source-type-icon {
  width: 14px;
  height: 14px;
  color: var(--color-text-3);
  vertical-align: -2px;
}
.source-type-icon { margin-right: 6px; }
.source-item__info { flex: 1; min-width: 0; }
.source-item__label { font-size: 11px; color: var(--color-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-item__meta { font-size: 9px; color: var(--color-text-3); margin-top: 1px; }
.source-item__count { font-size: 9px; color: var(--color-text-3); flex-shrink: 0; background: var(--color-surface-3); padding: 1px 5px; border-radius: 10px; }

/* ── Source Data Modal ───────────────────────────────────────────────────── */
.source-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.source-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.65); }
.source-modal__panel { position: relative; background: var(--color-surface-1); border: 1px solid var(--color-border-mid); border-radius: var(--radius-lg); width: 820px; max-width: calc(100vw - 40px); max-height: calc(100vh - 80px); display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,0.6); }
.source-modal__header { padding: 14px 18px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.source-modal__title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.source-modal__close { background: none; border: none; color: var(--color-text-3); font-size: 14px; cursor: pointer; padding: 2px 4px; border-radius: 4px; font-family: inherit; }
.source-modal__close:hover { color: var(--color-text-2); }
.source-modal__body { flex: 1; overflow-y: auto; }
.source-modal__footer { padding: 10px 18px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.source-modal__page-info { font-size: 10px; color: var(--color-text-3); }
.source-modal__page-btns { display: flex; gap: 6px; }
.source-page-btn { background: var(--color-surface-2); border: 1px solid var(--color-border-mid); border-radius: var(--radius-sm); padding: 4px 10px; color: var(--color-text-2); font-size: 10px; font-family: inherit; cursor: pointer; transition: background 0.1s; }
.source-page-btn:hover:not(:disabled) { background: var(--color-surface-3); color: var(--color-text-primary); }
.source-page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.source-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.source-table th { padding: 8px 14px; text-align: left; color: var(--color-text-3); font-weight: 500; font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: var(--color-surface-1); z-index: 1; }
.source-table td { padding: 8px 14px; color: var(--color-text-2); border-bottom: 1px solid var(--color-border); vertical-align: top; }
.source-table td.trunc { max-width: 380px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.source-table tr:last-child td { border-bottom: none; }
.source-table tr:hover td { background: var(--color-surface-2); }

/* ── Bug Report Modal ────────────────────────────────────────────────────── */
.bug-modal { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; }
.bug-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.72); }
.bug-modal__panel { position: relative; background: var(--color-surface-1); border: 1px solid var(--color-border-mid); border-radius: var(--radius-lg); width: min(520px, calc(100vw - 40px)); max-height: calc(100vh - 80px); display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,0.6); }
.bug-modal__header { padding: 14px 18px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.bug-modal__title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.bug-modal__close { background: none; border: none; color: var(--color-text-3); font-size: 14px; cursor: pointer; padding: 2px 4px; border-radius: 4px; font-family: inherit; }
.bug-modal__close:hover { color: var(--color-text-2); }
.bug-modal__body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.bug-modal__footer { padding: 12px 18px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.bug-field { display: flex; flex-direction: column; gap: 5px; }
.bug-label { font-size: 11px; font-weight: 500; color: var(--color-text-2); }
.bug-label--optional { color: var(--color-text-3); font-weight: 400; }
.bug-select, .bug-textarea { background: var(--color-surface-2); border: 1px solid var(--color-border-mid); border-radius: var(--radius-sm); color: var(--color-text-primary); font-size: 12px; font-family: inherit; padding: 8px 10px; outline: none; resize: vertical; }
.bug-select:focus, .bug-textarea:focus { border-color: rgba(255,255,255,0.20); }
.bug-textarea::placeholder { color: var(--color-text-3); }
.bug-submit-status { font-size: 11px; color: var(--color-text-3); flex: 1; }
.bug-submit-btn { background: #fff; color: #000; border: none; border-radius: var(--radius-sm); padding: 7px 16px; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; }
.bug-submit-btn:hover { background: #e8e8e8; }
.bug-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Report bug button in sidebar footer */
.report-bug-btn { background: none; border: none; color: var(--color-text-3); font-size: 10px; cursor: pointer; font-family: inherit; padding: 2px 4px; border-radius: 3px; margin-left: auto; }
.report-bug-btn:hover { color: var(--color-text-2); }

/* ── Stop-generation button variant ────────────────────────────────────── */
.send-btn--stop { background: #c0392b !important; color: white !important; }
.send-btn--stop:hover { background: #a93226 !important; }

/* ── Client dropdown favourites ─────────────────────────────────────────── */
.dropdown-section-label {
  padding: 6px 10px 4px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
  letter-spacing: 0.5px;
}
.fav-toggle:hover { color: gold !important; opacity: 1 !important; }

/* ── Conversation search bar ─────────────────────────────────────────────── */
.conv-search-row { padding: 6px 10px; }
.conv-search-input {
  width: 100%;
  background: var(--color-surface, #1f1f1f);
  border: 1px solid var(--color-border, #333);
  color: var(--color-text, #eee);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  box-sizing: border-box;
}
.conv-search-input::placeholder { color: var(--color-text-muted, #888); }
.conv-snippet {
  font-size: 12px;
  color: var(--color-text-muted, #999);
  margin-top: 4px;
  line-height: 1.4;
}
.conv-empty { padding: 12px; color: var(--color-text-muted, #888); font-size: 13px; }
mark { background: rgba(255, 220, 0, 0.3); color: inherit; padding: 0 1px; }

.msg-stopped-badge {
  display: inline-block;
  margin: 4px 0;
  padding: 2px 8px;
  font-size: 11px;
  background: rgba(192, 57, 43, 0.15);
  color: #c0392b;
  border: 1px solid rgba(192, 57, 43, 0.3);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Confidence badge (trust calibration) ───────────────────────────────────── */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  padding: 4px 10px 4px 8px;
  font-size: 11.5px;
  border-radius: 999px;
  border: 1px solid;
  background: rgba(255, 255, 255, 0.03);
  letter-spacing: 0.02em;
}
.confidence-badge .confidence-icon {
  font-weight: 700;
  font-size: 12px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.confidence-badge .confidence-label {
  font-weight: 600;
}
.confidence-badge .confidence-meta {
  opacity: 0.65;
  font-size: 11px;
}
.confidence-badge .confidence-info {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
}
.confidence-badge .confidence-info:hover { opacity: 1; }

.confidence-high {
  background: rgba(31, 159, 107, 0.10);
  color: #2bbf85;
  border-color: rgba(31, 159, 107, 0.35);
}
.confidence-high .confidence-icon { background: rgba(31, 159, 107, 0.20); }

.confidence-partial {
  background: rgba(217, 154, 43, 0.10);
  color: #e0a83b;
  border-color: rgba(217, 154, 43, 0.35);
}
.confidence-partial .confidence-icon { background: rgba(217, 154, 43, 0.20); }

.confidence-no-source {
  background: rgba(154, 154, 158, 0.10);
  color: #b0b0b6;
  border-color: rgba(154, 154, 158, 0.35);
}
.confidence-no-source .confidence-icon { background: rgba(154, 154, 158, 0.20); }

/* ── Thoughts Pill ───────────────────────────────────────────────────────────── */
.thoughts-pill { margin: 0 0 8px; }
.thoughts-pill.hidden { display: none; }
.thoughts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border, #333);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-muted, #999);
  font-family: inherit;
}
.thoughts-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.thoughts-body {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--color-accent, #4a90e2);
  font-size: 13px;
  color: var(--color-text-muted, #aaa);
  white-space: pre-wrap;
  border-radius: 4px;
}
.thoughts-body.hidden { display: none; }

/* ── User message edit controls ─────────────────────────────────────────── */
.message-actions--user {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.message-user:hover .message-actions--user { opacity: 1; }

.msg-edit-textarea {
  width: 100%;
  background: var(--color-surface, #1f1f1f);
  border: 1px solid var(--color-accent, #4a90e2);
  color: var(--color-text, #eee);
  padding: 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.msg-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.msg-edit-actions button {
  background: var(--color-surface, #2a2a2a);
  border: 1px solid var(--color-border, #444);
  color: var(--color-text, #fff);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.msg-edit-actions .msg-edit-save {
  background: var(--color-accent, #4a90e2);
  border-color: var(--color-accent, #4a90e2);
}

/* ── Mic / Voice input ───────────────────────────────────────────────────── */
.mic-btn {
  background: transparent;
  border: 0;
  color: var(--color-text-muted, #888);
  font-size: 18px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.mic-btn:hover { color: var(--color-text, #fff); background: rgba(255, 255, 255, 0.05); }
.mic-btn--recording {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.12);
  animation: mic-pulse 1.2s infinite;
}
@keyframes mic-pulse {
  0%, 100% { background: rgba(231, 76, 60, 0.12); }
  50%      { background: rgba(231, 76, 60, 0.25); }
}

/* ── Attach menu ────────────────────────────────────────────────────────────── */
.attach-menu-wrap { position: relative; }
.attach-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  background: var(--color-surface, #1f1f1f);
  border: 1px solid var(--color-border, #333);
  border-radius: 8px;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  padding: 4px;
  z-index: 100;
}
.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--color-text, #eee);
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.attach-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.attach-menu.hidden { display: none; }

/* ── Artifact Pane ───────────────────────────────────────────────────────────── */
.artifact-pane {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--color-surface, #1a1a1a);
  border-left: 1px solid var(--color-border, #333);
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.artifact-pane.hidden { display: none; }
.artifact-pane__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border, #333);
}
.artifact-pane__title { font-weight: 600; color: var(--color-text, #eee); }
.artifact-pane__close {
  background: transparent;
  border: 0;
  color: var(--color-text-muted, #888);
  font-size: 16px;
  cursor: pointer;
}
.artifact-pane__close:hover { color: var(--color-text, #fff); }

.artifact-pane__list {
  max-height: 30vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--color-border, #333);
  padding: 6px;
}
.artifact-list-item {
  display: flex;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--color-text, #eee);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  align-items: center;
}
.artifact-list-item:hover { background: rgba(255, 255, 255, 0.05); }
.artifact-list-item.active { background: rgba(74, 144, 226, 0.15); }

.artifact-pane__viewer {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.artifact-loading, .artifact-error {
  padding: 14px;
  color: var(--color-text-muted, #888);
  font-size: 13px;
}
.artifact-error { color: #e74c3c; }

.artifact-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border, #333);
}
.artifact-title { font-weight: 500; font-size: 14px; color: var(--color-text, #eee); }
.artifact-btn {
  background: transparent;
  border: 1px solid var(--color-border, #444);
  color: var(--color-text, #eee);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-left: 6px;
}
.artifact-btn:hover { background: rgba(255, 255, 255, 0.05); }

.artifact-body { flex: 1; padding: 14px; overflow-y: auto; }
.artifact-iframe { width: 100%; height: 100%; min-height: 400px; border: 0; background: white; }
.artifact-body pre {
  white-space: pre-wrap;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 6px;
  color: var(--color-text, #eee);
}
.artifact-body p, .artifact-body li, .artifact-body h1, .artifact-body h2, .artifact-body h3 {
  color: var(--color-text, #eee);
}

/* Push the chat panel left when artifact pane is open (desktop only) */
@media (min-width: 1100px) {
  body.artifact-pane-open .chat-panel { margin-right: 400px; }
}

/* Loading indicator for in-flight agent responses.
   Applied to an assistant message while waiting for the first text / thinking
   / tool_start event. Three animated dots, pulsing in sequence. */
.message--pending .pending-dots {
  display: inline-flex;
  gap: 6px;
  padding: 6px 2px;
}
.message--pending .pending-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8a8a90;
  opacity: 0.35;
  animation: pending-pulse 1.3s infinite ease-in-out;
}
.message--pending .pending-dots span:nth-child(2) { animation-delay: 0.18s; }
.message--pending .pending-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes pending-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%          { opacity: 0.95; transform: scale(1); }
}
/* Hide the dots once the message transitions out of the pending state */
.message:not(.message--pending) .pending-dots { display: none; }

/* ============================================================
   View rail — thin left strip for in-page navigation between
   chat and the management pages (KB / SEO News / Client / Cost).
   Leadership-only icons (kb, cost) have display:none inline in
   index.html; the probe in the same file flips them back on.
   ============================================================ */
.view-rail {
  width: 52px;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 6px;
  flex-shrink: 0;
}
.view-rail__icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-mid, #cfe0ff);
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.view-rail__icon .ui-icon { width: 19px; height: 19px; }
.view-rail__icon:hover { background: var(--color-surface-1); border-color: var(--color-border); }
.view-rail__icon.active {
  background: var(--color-surface-2, #1b2a3f);
  border-color: var(--color-border-mid, #2a4060);
  color: #fff;
}

/* Frame host — fills the space where the chat panel normally sits.
   Shown only when a non-chat rail icon is active. Flex-1 so it expands
   identically to the chat panel. Iframes inside are 100% × 100%. */
.view-frame-host {
  flex: 1;
  min-width: 0;
  background: var(--color-bg);
  position: relative;
}

/* Reddit Listening — small red dot for unread mentions on the view-rail icon */
.view-rail__icon { position: relative; }
.rail-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e2412a;
  box-shadow: 0 0 0 2px var(--rail-bg, #1a1a1a);
}
