/* ════════════════════════════════════════════════════════════
   CVC Dashboard — Themeable Stylesheet
   Black/white surfaces with CVC maroon accents + full light mode
   ════════════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────── */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-primary:    #0b0c0f;
  --bg-secondary:  #111216;
  --bg-tertiary:   #191b20;
  --bg-hover:      #202329;
  --bg-active:     #292d35;
  --border:        #452222;
  --border-light:  #6a3232;

  --text-primary:  #f5f7fa;
  --text-secondary:#dadde3;
  --text-muted:    #9aa1ab;

  --accent:        #b43b3b;
  --accent-hover:  #d06262;
  --accent-dim:    #b43b3b1f;

  --green:         #4fa86a;
  --green-dim:     #4fa86a20;
  --red:           #d94b4b;
  --red-dim:       #d94b4b20;
  --yellow:        #c4963a;
  --yellow-dim:    #c4963a20;
  --blue:          #b96b6b;
  --blue-dim:      #b96b6b20;

  --overlay:       rgba(0, 0, 0, 0.62);
  --elev-shadow:   0 10px 30px rgba(0, 0, 0, 0.35);
  --particle-opacity: 0.035;
  --particle-dot-1: rgba(180, 59, 59, 0.95);
  --particle-dot-2: rgba(208, 98, 98, 0.85);
  --particle-dot-3: rgba(107, 50, 50, 0.85);
  --particle-glow-1: rgba(180, 59, 59, 0.09);
  --particle-glow-2: rgba(208, 98, 98, 0.05);
  --particle-glow-3: rgba(69, 34, 34, 0.09);

  --font-sans:     'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:     'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

  --sidebar-width: 220px;
  --topbar-height: 52px;
  --radius:        8px;
  --radius-lg:     12px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg-primary:    #ffffff;
  --bg-secondary:  #f6f7f9;
  --bg-tertiary:   #eceef2;
  --bg-hover:      #e3e6eb;
  --bg-active:     #d9dde4;
  --border:        #d7b2b2;
  --border-light:  #c77f7f;

  --text-primary:  #181a20;
  --text-secondary:#3f4652;
  --text-muted:    #6f7784;

  --accent:        #b43b3b;
  --accent-hover:  #d06262;
  --accent-dim:    #b43b3b14;

  --green:         #318757;
  --green-dim:     #31875714;
  --red:           #c44242;
  --red-dim:       #c4424214;
  --yellow:        #a8781d;
  --yellow-dim:    #a8781d14;
  --blue:          #9b5959;
  --blue-dim:      #9b595914;

  --overlay:       rgba(17, 20, 28, 0.18);
  --elev-shadow:   0 10px 24px rgba(15, 20, 30, 0.10);
  --particle-opacity: 0.055;
  --particle-dot-1: rgba(180, 59, 59, 0.60);
  --particle-dot-2: rgba(208, 98, 98, 0.55);
  --particle-dot-3: rgba(151, 89, 89, 0.50);
  --particle-glow-1: rgba(180, 59, 59, 0.05);
  --particle-glow-2: rgba(208, 98, 98, 0.035);
  --particle-glow-3: rgba(151, 89, 89, 0.04);
}

/* ── Reset ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; cursor: pointer; }
button { cursor: pointer; font-family: var(--font-sans); }
input, textarea, select { font-family: var(--font-sans); }

/* ── Layout ──────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  font-family: var(--font-mono);
}

.brand-version {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

.sidebar-section {
  padding: 8px 12px;
}

.section-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 4px 4px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.15s;
  user-select: none;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-hover); }
.nav-icon { font-size: 1rem; width: 22px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ws-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.ws-dot.connected { background: var(--green); box-shadow: 0 0 4px var(--green); }
.ws-dot.disconnected { background: var(--red); }
.ws-label { font-size: 0.7rem; }

.sidebar-clock {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Main Content ────────────────────────── */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

#page-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-hover);
}
.theme-toggle-icon {
  font-size: 0.9rem;
  line-height: 1;
}
.theme-toggle-label {
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 16px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.running, .status-dot.connected { background: var(--green); box-shadow: 0 0 4px var(--green); }
.status-dot.stopped, .status-dot.error { background: var(--red); }
.status-dot.unknown { background: var(--text-muted); }

/* ── Tab Content ─────────────────────────── */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.tab-content.hidden { display: none; }

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 16px 20px; }
.card-actions { display: flex; gap: 6px; }

/* ── Grid ────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* ── Stats ───────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-hover);
  font-family: var(--font-mono);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-green { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.btn-green:hover { background: var(--green); color: #fff; }
.btn-red { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.btn-red:hover { background: var(--red); color: #fff; }
.btn-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid var(--yellow); }
.btn-yellow:hover { background: var(--yellow); color: #fff; }

/* ── Inputs ──────────────────────────────── */
.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; font-family: var(--font-mono); font-size: 0.8rem; }
select.input { cursor: pointer; }

/* ── Detail Grid ─────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.detail-grid .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.detail-grid .value {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
}
.value.code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-hover);
}

/* ── Tools Grid ──────────────────────────── */
.tools-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-chip {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 10px;
  background: var(--accent-dim);
  color: var(--accent-hover);
  border-radius: 16px;
  border: 1px solid var(--accent);
}

/* ── Code Block ──────────────────────────── */
.code-block {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.code-block pre {
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Operations Grid ─────────────────────── */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.op-card {
  padding: 20px;
}
.op-card h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}
.op-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.op-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.op-result {
  margin-top: 12px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  max-height: 200px;
  overflow-y: auto;
}

/* ── Tables ──────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Chat ────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - var(--topbar-height));
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50%;
  text-align: center;
  padding: 40px 20px;
}
.welcome-logo {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
  margin-bottom: 12px;
}
.chat-welcome h2 { color: var(--text-primary); font-weight: 600; margin-bottom: 8px; }
.chat-welcome p { color: var(--text-secondary); max-width: 480px; line-height: 1.6; }

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  justify-content: center;
}
.suggestion-btn {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: all 0.15s;
}
.suggestion-btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.chat-message {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.chat-message:last-child { border-bottom: none; }

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-avatar.user { background: var(--accent-dim); color: var(--accent); }
.chat-avatar.assistant { background: var(--green-dim); color: var(--green); }

.chat-message-body {
  flex: 1;
  min-width: 0;
}
.chat-message-body .role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.chat-message-body .msg-content {
  line-height: 1.7;
  font-size: 0.9rem;
}
.chat-message-body .msg-content p { margin-bottom: 8px; }
.chat-message-body .msg-content pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  margin: 8px 0;
}
.chat-message-body .msg-content code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}
.chat-message-body .msg-content pre code {
  background: none;
  padding: 0;
}

.chat-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 200px;
  min-height: 42px;
  transition: border-color 0.15s;
}
#chat-input:focus { border-color: var(--accent); }

#chat-send {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

#chat-stop {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: var(--red);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
#chat-stop:hover { background: var(--accent-hover); }
#chat-stop.hidden, #chat-send.hidden { display: none; }

.chat-input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 4px;
}
.model-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
}
.chat-hint { font-size: 0.7rem; color: var(--text-muted); }

.streaming-indicator {
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--accent);
  animation: blink 0.8s infinite;
  margin-left: 2px;
  vertical-align: middle;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Tool Cards (Agentic Chat) ───────────── */
.tool-card {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  overflow: hidden;
  font-size: 0.85rem;
  max-width: min(520px, 80%);
}
.tool-card.completed {
  border-color: var(--green);
}
.tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-secondary);
  transition: background 0.15s;
}
.tool-card-header:hover {
  background: var(--bg-tertiary);
}
.tool-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.tool-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.tool-args-preview {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tool-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tool-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.tool-card.expanded .tool-chevron {
  transform: rotate(180deg);
}
.tool-card-body {
  display: none;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.tool-card.expanded .tool-card-body {
  display: block;
}
.tool-card-body pre {
  background: var(--bg-primary);
  padding: 8px;
  border-radius: 4px;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.78rem;
  margin: 4px 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.tool-args, .tool-output {
  margin-bottom: 6px;
}

/* Agent status badge */
.agent-status {
  display: inline-block;
  margin: 6px 0;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  animation: fadeInOut 1.5s ease-in-out infinite;
}
@keyframes fadeInOut {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── Tool Permission Confirm Card ────────── */
.tool-confirm-card {
  margin: 8px 0;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-dim);
  overflow: hidden;
  max-width: min(520px, 80%);
}
.tool-confirm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-dim);
  font-weight: 600;
  font-size: 0.85rem;
}
.tool-confirm-label {
  color: var(--accent-hover);
}
.tool-confirm-body {
  padding: 10px 12px;
}
.tool-confirm-name {
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.tool-confirm-args pre {
  background: var(--bg-primary);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  margin: 4px 0 8px;
}
.tool-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool-confirm-actions .btn {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.78rem;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.tool-confirm-actions .btn:hover { opacity: 0.85; }
.tool-confirm-actions .btn-allow-once {
  background: #55AA55;
  color: #fff;
}
.tool-confirm-actions .btn-allow-always {
  background: #448844;
  color: #fff;
}
.tool-confirm-actions .btn-trust-all {
  background: #CC6666;
  color: #fff;
}
.tool-confirm-actions .btn-deny {
  background: #FF3333;
  color: #fff;
}
.tool-confirm-actions .btn-deny-suggest {
  background: #CC7733;
  color: #fff;
}
.tool-confirm-decision {
  font-weight: 600;
  font-size: 0.85rem;
}
.tool-confirm-decision.allow { color: #55AA55; }
.tool-confirm-decision.deny { color: #FF3333; }

/* ── Toggle Switch ───────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  vertical-align: middle;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-tertiary, #555);
  border-radius: 24px;
  transition: background 0.25s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--green);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ── Toast / Notification ────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  box-shadow: var(--elev-shadow);
  min-width: 220px;
  animation: slideIn 0.3s ease;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Dialog ──────────────────────────────── */
.dialog-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.dialog-overlay.hidden { display: none; }
.dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 360px;
  max-width: 480px;
}
.dialog h3 { margin-bottom: 16px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Timeline ────────────────────────────── */
.timeline-entry {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-left: 2px solid var(--border);
  margin-left: 8px;
  padding-left: 20px;
  position: relative;
}
.timeline-entry::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: -6px;
  top: 16px;
}
.timeline-entry .tl-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 140px;
}
.timeline-entry .tl-body { flex: 1; }
.timeline-entry .tl-msg { font-size: 0.9rem; font-weight: 500; }
.timeline-entry .tl-hash {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.timeline-entry .tl-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent-hover);
  display: inline-block;
  margin-top: 4px;
}

/* ── Model Cards ─────────────────────────── */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.model-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
  cursor: pointer;
}
.model-card:hover { border-color: var(--accent); }
.model-card.active-model { border-color: var(--green); background: var(--green-dim); }
.model-card .model-name { font-weight: 600; margin-bottom: 4px; }
.model-card .model-provider { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.model-card .model-ctx { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }

/* ── Ambient Background Particles ────────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--particle-opacity);
  background:
    radial-gradient(2px 2px at 15% 20%, var(--particle-dot-1), transparent),
    radial-gradient(2px 2px at 72% 12%, var(--particle-dot-3), transparent),
    radial-gradient(3px 3px at 40% 65%, var(--particle-dot-2), transparent),
    radial-gradient(2px 2px at 85% 45%, var(--particle-dot-3), transparent),
    radial-gradient(2px 2px at 28% 88%, var(--particle-dot-2), transparent),
    radial-gradient(3px 3px at 60% 35%, var(--particle-dot-1), transparent),
    radial-gradient(2px 2px at 90% 80%, var(--particle-dot-3), transparent),
    radial-gradient(2px 2px at 5% 50%, var(--particle-dot-2), transparent),
    radial-gradient(600px 600px at 20% 30%, var(--particle-glow-1), transparent),
    radial-gradient(500px 500px at 75% 60%, var(--particle-glow-2), transparent),
    radial-gradient(400px 400px at 50% 80%, var(--particle-glow-3), transparent);
  background-size: 200% 200%;
  animation: ambientDrift 45s ease-in-out infinite alternate;
}
@keyframes ambientDrift {
  0%   { background-position:   0%   0%; }
  25%  { background-position:  30%  20%; }
  50%  { background-position:  60%  50%; }
  75%  { background-position:  40%  80%; }
  100% { background-position: 100% 100%; }
}

/* Ensure all layout sits above the particle layer */
#app { position: relative; z-index: 1; }

/* ── Connection Cards ────────────────────── */
.connection-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.connection-card .conn-icon { font-size: 1.5rem; }
.connection-card .conn-name { font-weight: 600; }
.connection-card .conn-desc { font-size: 0.8rem; color: var(--text-secondary); }

/* ── Misc ────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.tag-green { background: var(--green-dim); color: var(--green); }
.tag-red { background: var(--red-dim); color: var(--red); }
.tag-yellow { background: var(--yellow-dim); color: var(--yellow); }
.tag-blue { background: var(--blue-dim); color: var(--blue); }

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 56px; min-width: 56px; }
  .section-label,
  .nav-link span:not(.nav-icon),
  .brand-version,
  .ws-label,
  .sidebar-clock { display: none; }
  .brand-logo { font-size: 1rem; }
  .nav-link { justify-content: center; padding: 10px; }
  .nav-icon { width: auto; }
  .sidebar-footer { justify-content: center; }
  .tab-content { padding: 12px; }
}

/* ═══════════════════════════════════════════════════════
   Settings Page Styles
   ═══════════════════════════════════════════════════════ */

/* ── Level Tabs ──────────────────────────── */
.settings-level-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
}
.settings-level-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.settings-level-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.settings-level-tab.active { color: var(--text-primary); background: var(--bg-tertiary); box-shadow: var(--elev-shadow); }

/* ── Search ──────────────────────────────── */
.settings-search-bar { margin-bottom: 1rem; }
.settings-search-bar .input { width: 100%; }

/* ── Setting rows ────────────────────────── */
.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; min-width: 0; }
.setting-label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 2px; }
.setting-desc { display: block; font-size: 0.78rem; color: var(--text-muted); }
.setting-control { flex-shrink: 0; min-width: 200px; display: flex; align-items: center; gap: 8px; }
.input-sm { height: 34px; font-size: 0.85rem; padding: 4px 10px; }

/* ── Collapsible sections ────────────────── */
.card-header.collapsible { cursor: pointer; user-select: none; }
.card-header.collapsible:hover { background: var(--bg-hover); }
.collapse-arrow { font-size: 0.75rem; color: var(--text-muted); transition: transform 0.2s; }
.section-icon { margin-right: 6px; }

/* ── API Key rows ────────────────────────── */
.api-key-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.api-key-provider { min-width: 90px; font-weight: 500; font-size: 0.85rem; text-transform: capitalize; }

/* ── Hooks ────────────────────────────────── */
.hook-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.hook-row:last-child { border-bottom: none; }
.hook-add-row { display: flex; gap: 8px; align-items: center; }

/* ── Plugin rows ─────────────────────────── */
.plugin-row { padding: 6px 0; }
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; }

/* ── Save Bar ────────────────────────────── */
.settings-save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-top: 2px solid var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 1rem;
  font-size: 0.9rem;
  z-index: 10;
}
.settings-save-bar span { flex: 1; color: var(--yellow); font-weight: 500; }

/* ═══════════════════════════════════════════════════════
   SDK / Hive Mind — Sub-tabs + Agent Creator
   ═══════════════════════════════════════════════════════ */

/* ── Sub-tabs ────────────────────────────── */
.sdk-subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.25rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
}
.sdk-subtab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.sdk-subtab:hover { color: var(--text-primary); background: var(--bg-hover); }
.sdk-subtab.active { color: var(--text-primary); background: var(--bg-tertiary); box-shadow: var(--elev-shadow); }

.sdk-subtab-content.hidden { display: none; }

/* ── Grid ────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 1.25rem; }
@media (max-width: 768px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── Agent Creator ───────────────────────── */
.agent-creator-modes {
  display: flex;
  gap: 4px;
  margin-bottom: 1rem;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 3px;
}
.creator-mode-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.creator-mode-btn:hover { color: var(--text-primary); }
.creator-mode-btn.active { color: var(--text-primary); background: var(--accent-dim); border: 1px solid var(--accent); }
.creator-panel.hidden { display: none; }

/* ── Agent form grid ─────────────────────── */
.agent-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.agent-form-grid .form-group { display: flex; flex-direction: column; gap: 4px; }
.agent-form-grid .form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
.agent-form-grid .full-width { grid-column: 1 / -1; }

/* ── Agent preview ───────────────────────── */
.agent-preview { margin-top: 1rem; }
.agent-preview-card {
  background: var(--bg-primary);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 16px;
}
.agent-preview-card h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.preview-details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 0.85rem; margin-top: 8px; }
.preview-actions { display: flex; gap: 8px; }

/* ── Template cards ──────────────────────── */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.template-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.15s;
}
.template-card:hover { border-color: var(--accent); }
.template-name { font-weight: 600; margin-bottom: 4px; }
.template-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }
.template-meta { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }

/* ── Squad cards ─────────────────────────── */
.squad-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.squad-card h4 { margin: 0 0 6px; }
.squad-meta { font-size: 0.82rem; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.squad-agents { display: flex; gap: 4px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   Hive Memory Feed
   ═══════════════════════════════════════════════════════ */

.hive-write-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.hive-write-form textarea { grid-column: 1 / -1; }
.hive-write-form button { grid-column: 1 / -1; justify-self: start; }

.hive-feed-filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.hive-entry {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.hive-entry:hover { background: var(--bg-hover); }
.hive-entry:last-child { border-bottom: none; }
.hive-entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.82rem; }
.hive-entry-agent { font-weight: 600; }
.hive-entry-time { margin-left: auto; color: var(--text-muted); font-size: 0.75rem; }
.hive-entry-content { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; }
.hive-entry-tags { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.hive-entry-hash { margin-top: 4px; font-size: 0.72rem; color: var(--text-muted); }
.hive-summary-pre { white-space: pre-wrap; font-size: 0.85rem; line-height: 1.5; max-height: 300px; overflow: auto; }

/* ── Category color tags ─────────────────── */
.tag-purple { background: #7c3aed20; color: #a78bfa; border-color: #7c3aed44; }
.tag-cyan { background: #06b6d420; color: #67e8f9; border-color: #06b6d444; }
.tag-pink { background: #ec489920; color: #f472b6; border-color: #ec489944; }
.tag-yellow { background: var(--yellow-dim); color: var(--yellow); border-color: rgba(196, 150, 58, 0.3); }
.tag-sm { font-size: 0.7rem; padding: 1px 6px; }

/* ── Green button ────────────────────────── */
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover { background: #3d9558; }
