/* ─── Sable Desktop,  Dark Theme ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --bg-panel:    #12141a;
  --bg-raised:   #1a1d26;
  --bg-hover:    #1e2130;
  --bg-active:   #252840;
  --border:      rgba(255,255,255,0.07);
  --border-mid:  rgba(255,255,255,0.12);
  --accent:      #7c3aed;
  --accent-h:    #6d28d9;
  --accent-glow: rgba(124,58,237,0.25);
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #475569;
  --user-msg-bg: #312e81;
  --user-msg-border: #4338ca;
  --sable-msg-bg: #1a1d26;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --titlebar-h:  44px;
  --sidebar-w:   260px;
}

html, body, #root {
  height: 100%;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: color 0.4s ease;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── App layout ────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}

/* ─── Titlebar ──────────────────────────────────────────────────────────── */
.titlebar {
  height: var(--titlebar-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  -webkit-app-region: drag;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  transition: background 0.4s ease, border-color 0.4s ease;
}

.titlebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.titlebar-logo img {
  height: 22px;
  width: auto;
  object-fit: contain;
  filter: brightness(1.1);
}

.titlebar-logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.titlebar-status {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.titlebar-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #555;
  transition: background 0.3s, box-shadow 0.3s;
}
.titlebar-status-dot.connected {
  background: #22d3a5;
  box-shadow: 0 0 6px #22d3a5;
  animation: pulse 2s ease-in-out infinite;
}
.titlebar-status-dot.connecting {
  background: #f5a623;
  box-shadow: 0 0 4px #f5a623;
  animation: pulse 1s ease-in-out infinite;
}
.titlebar-status-dot.disconnected {
  background: #555;
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.titlebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}

.titlebar-btn:hover { background: var(--bg-hover); color: var(--text); }
.titlebar-btn.close:hover { background: #c0392b; color: #fff; }

/* ─── macOS traffic light controls ───────────────────────────────── */
.mac-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 10px;
  -webkit-app-region: no-drag;
}

.mac-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: filter 0.15s;
  position: relative;
}

.mac-btn svg {
  width: 8px;
  height: 8px;
  opacity: 0;
  transition: opacity 0.15s;
  position: absolute;
}

.mac-btn svg line,
.mac-btn svg polyline {
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 1.5;
  fill: none;
}

.mac-controls:hover .mac-btn svg { opacity: 1; }

.mac-close    { background: #ff5f57; }
.mac-minimize { background: #febc2e; }
.mac-maximize { background: #28c840; }

.mac-close:hover    { background: #ff4136; }
.mac-minimize:hover { background: #f5a623; }
.mac-maximize:hover { background: #1db954; }

.mac-btn:active { filter: brightness(0.8); }

/* Unfocused: gray out traffic lights like macOS native */
.app.window-blurred .mac-btn { background: #d0d0d0 !important; }
.app.window-blurred .mac-btn svg { opacity: 0; }

/* ─── Day / Night toggle button ──────────────────────────────────── */
.theme-toggle input[type="checkbox"] { display: none; }
.theme-toggle { -webkit-app-region: no-drag; }
.theme-toggle-label { cursor: pointer; display: block; }

.theme-box {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 60px;
  height: 28px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  overflow: hidden;
  transition: background 0.4s ease, border-color 0.4s ease;
}

.theme-ball {
  position: absolute;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 6px rgba(124,58,237,0.4);
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1), background 0.4s ease;
  z-index: 2;
}

/* When checkbox is checked (light mode) the ball slides right */
.theme-toggle input:checked ~ .theme-toggle-label .theme-ball {
  transform: translateX(32px);
  background: #f59e0b;
  box-shadow: 0 1px 6px rgba(245,158,11,0.4);
}

.theme-scenary {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 0 5px;
  position: relative;
  z-index: 1;
}

.theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  transition: opacity 0.3s ease, color 0.3s ease;
}
.theme-icon svg { width: 13px; height: 13px; }
.theme-moon { color: #94a3b8; }
.theme-sun  { color: #f59e0b; opacity: 0.7; }

/* In light mode: moon fades, sun brightens */
html.light-theme .theme-moon { color: #c7d2e7; opacity: 0.5; }
html.light-theme .theme-sun  { color: #f59e0b; opacity: 1; }

/* ─── Light theme variable overrides ────────────────────────────────────── */
html.light-theme {
  --bg:            #f0f4ff;
  --bg-panel:      #e4eaf7;
  --bg-raised:     #dce4f5;
  --bg-hover:      #cfd8ef;
  --bg-active:     #c3cfe8;
  --border:        rgba(80,100,160,0.15);
  --border-mid:    rgba(80,100,160,0.25);
  --accent:        #6d28d9;
  --accent-h:      #5b21b6;
  --accent-glow:   rgba(109,40,217,0.20);
  --text:          #1e2a40;
  --text-muted:    #3d4f6e;
  --text-dim:      #6b7fa8;
  --user-msg-bg:   #dde4ff;
  --user-msg-border: #a5b4fc;
  --sable-msg-bg:  #edf1fb;
  --shadow:        0 4px 24px rgba(80,100,160,0.15);
  --shadow-sm:     0 2px 8px rgba(80,100,160,0.10);
}

html.light-theme body,
html.light-theme #root { background: transparent; }

html.light-theme .app { background: var(--bg); }

html.light-theme .titlebar {
  background: #dce4f5;
  border-bottom-color: rgba(80,100,160,0.18);
}

html.light-theme .sidebar {
  background: #e4eaf7;
  border-right-color: rgba(80,100,160,0.18);
}

html.light-theme .chat-area { background: #f0f4ff; }

html.light-theme .theme-box {
  background: var(--bg-raised);
  border-color: var(--border-mid);
}

html.light-theme .sidebar-new-chat { color: var(--text-muted); }
html.light-theme .sidebar-new-chat:hover { background: var(--bg-hover); color: var(--text); }

html.light-theme .message-input {
  background: var(--bg-raised);
  border-color: var(--border-mid);
  color: var(--text);
}
html.light-theme .message-input:focus { border-color: var(--accent); }
html.light-theme .input-area { background: var(--bg-panel); border-top-color: var(--border); }

html.light-theme .session-item { color: var(--text-muted); }
html.light-theme .session-item:hover,
html.light-theme .session-item.active { background: var(--bg-hover); color: var(--text); }

html.light-theme .chat-topbar { border-bottom-color: var(--border); background: var(--bg-panel); }

html.light-theme .titlebar-btn { color: var(--text-muted); }
html.light-theme .titlebar-btn:hover { background: var(--bg-hover); color: var(--text); }
html.light-theme .titlebar-status { color: var(--text-muted); }

html.light-theme ::-webkit-scrollbar-thumb { background: rgba(80,100,160,0.20); }
html.light-theme ::-webkit-scrollbar-thumb:hover { background: rgba(80,100,160,0.35); }

html.light-theme .message-bubble.user { color: var(--text); }
html.light-theme .message-bubble.assistant { color: var(--text); }
html.light-theme .message-bubble.system { color: var(--text-muted); }

/* ─── Main area ─────────────────────────────────────────────────────────── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.4s ease, border-color 0.4s ease;
}

.sidebar-header {
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  transform: translateX(-2px);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0 4px;
}

.sidebar-logo img {
  height: 26px;
  width: auto;
  object-fit: contain;
  opacity: 0.9;
}

.new-chat-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  justify-content: center;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.new-chat-btn:hover { background: var(--accent-h); box-shadow: 0 4px 18px var(--accent-glow); }

.sidebar-section-label {
  padding: 12px 14px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Agent Selector ─────────────────────────────────────── */
.agent-selector {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 6px 8px;
  flex-shrink: 0;
}

.agent-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: capitalize;
}

.agent-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.agent-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.agent-btn.offline {
  opacity: 0.45;
}

.agent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: all 0.2s;
}

.agent-dot.online {
  background: var(--green, #22c55e);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.agent-btn.active .agent-dot.online {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow, rgba(99, 102, 241, 0.4));
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
  overflow: hidden;
}

.session-item:hover { background: var(--bg-hover); color: var(--text); }

.session-item.active {
  background: var(--bg-active);
  color: var(--text);
}

.session-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

.session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 14px;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-btn {
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.settings-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-mid); }

.dev-studio-btn {
  margin-bottom: 6px;
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.2);
  color: var(--text-muted);
}
.dev-studio-btn:hover {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.4);
  color: #818cf8;
}

/* ─── Chat area ─────────────────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  transition: background 0.4s ease;
}

/* Session name top bar */
.chat-topbar {
  height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg);
}

.chat-topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--accent);
  opacity: 0.85;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: fadeIn 0.2s ease;
}

/* When the model is actively streaming tokens */
.agent-progress.responding {
  color: #4ade80;
}

.agent-progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: pulse 1s ease-in-out infinite;
}

/* Elapsed time counter shown inline next to the phase label */
.elapsed-counter {
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  opacity: 0.75;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
  margin-left: 2px;
}

/* ─── Messages ──────────────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-row {
  display: flex;
  padding: 2px 24px;
}

.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }
.message-row.system { justify-content: center; }

.message-bubble {
  max-width: 75%;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 14px;
  line-height: 1.65;
  position: relative;
  word-break: break-word;
}

.message-bubble.user {
  background: var(--user-msg-bg);
  border: 1px solid var(--user-msg-border);
  color: #e0e7ff;
  border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
  background: var(--sable-msg-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message-bubble.system {
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.2);
  color: var(--text-muted);
  font-size: 12px;
  max-width: 60%;
  text-align: center;
}

.message-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-avatar.assistant {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 8px var(--accent-glow);
}

.message-row.assistant { align-items: flex-start; gap: 10px; }
.message-row.user { align-items: flex-start; gap: 10px; flex-direction: row-reverse; }

.msg-copy-btn {
  opacity: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.message-bubble:hover .msg-copy-btn { opacity: 1; }
.msg-copy-btn:hover { color: var(--text); }

/* ─── Message footer (duration + copy) ─────────────────────────────────── */
.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.msg-response-time {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  transition: opacity 0.2s;
}
.message-bubble:hover .msg-response-time { opacity: 0.85; }
.message-bubble:hover .msg-copy-btn { opacity: 1; }

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Markdown styles inside bubbles */
.message-bubble pre {
  background: #0d0f16;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.message-bubble code:not(pre code) {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ── Code block with Run button ──────────────────────────────────────────── */
.code-block-wrap {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: #181a24;
  border-bottom: 1px solid var(--border);
  min-height: 30px;
}

.code-lang {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-transform: lowercase;
  letter-spacing: 0.5px;
}

.code-block-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.code-run-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #22c55e18;
  border: 1px solid #22c55e55;
  color: #4ade80;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.code-run-btn:hover:not(:disabled) {
  background: #22c55e33;
  color: #86efac;
}
.code-run-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.code-run-btn.running {
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.code-copy-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  transition: color 0.15s;
}
.code-copy-btn:hover { color: var(--text); }

.code-block-pre {
  background: #0d0f16;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.code-output {
  border-top: 1px solid var(--border);
  background: #0a0c12;
}
.code-output.error { border-top-color: #ef444455; }

.code-output-label {
  display: block;
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #4ade80;
  background: #0d0f16;
  border-bottom: 1px solid var(--border);
}
.code-output.error .code-output-label { color: #f87171; }

.code-output-pre {
  margin: 0;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* Stdin modal */
.stdin-modal-backdrop {
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.stdin-modal {
  width: 680px; max-width: 92%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.stdin-modal-header { font-weight: 700; margin-bottom: 8px; }
.stdin-modal-textarea {
  width: 100%; height: 160px; resize: vertical; padding: 10px; font-family: var(--font-mono);
  background: #071018; color: #e6eef6; border: 1px solid var(--border); border-radius: 6px;
}
.stdin-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px }
.stdin-modal-btn { padding: 6px 12px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border-mid); }
.stdin-modal-btn.cancel { background: transparent; color: var(--text-dim); }
.stdin-modal-btn.confirm { background: #22c55e22; color: #4ade80; font-weight: 700; border-color: #22c55e55 }

.message-bubble p { margin: 6px 0; }
.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { padding-left: 20px; margin: 6px 0; }
.message-bubble li { margin: 3px 0; }
.message-bubble h1,.message-bubble h2,.message-bubble h3 { 
  font-weight: 600; color: var(--text); margin: 10px 0 6px; 
}
.message-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-muted);
}
.message-bubble a { color: #a78bfa; text-decoration: underline; }
.message-bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  padding: 40px;
}

.empty-state-glyph {
  font-size: 48px;
  opacity: 0.3;
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 13px;
  text-align: center;
  max-width: 320px;
  color: var(--text-dim);
}

.empty-shortcut {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-family: var(--font-mono);
}

/* ─── Input area ────────────────────────────────────────────────────────── */
.input-area {
  border-top: 1px solid var(--border);
  padding: 14px 20px 18px;
  flex-shrink: 0;
  background: var(--bg);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  max-height: 160px;
  min-height: 22px;
  overflow-y: auto;
}

.chat-input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.send-btn:hover:not(:disabled) { background: var(--accent-h); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.send-btn svg { width: 16px; height: 16px; }

/* File / Mic action buttons */
.input-action-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.input-action-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-hover);
}
.input-action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.input-action-btn svg { width: 15px; height: 15px; }
.input-action-btn.recording {
  color: #ef4444;
  animation: pulse 1s ease-in-out infinite;
}

/* Attachment preview row */
.attachments-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
}
.attachment-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  max-width: 220px;
}
.attachment-icon { font-size: 13px; flex-shrink: 0; }
.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.attachment-thumb {
  width: 28px; height: 28px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.attachment-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  opacity: 0.6;
  flex-shrink: 0;
}
.attachment-remove:hover { opacity: 1; color: #ef4444; }

.input-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: right;
}

/* ─── Settings Modal ────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 16px;
  padding: 24px;
  width: 460px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow);
  animation: slideUp 0.18s ease;
}

@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-dim); }

.form-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  border: none;
}

.btn-secondary {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
}

.btn-secondary:hover { background: var(--bg-hover); color: var(--text); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover { background: var(--accent-h); }

/* ─── Status badge ──────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.status-badge.connected { background: rgba(34,211,165,0.12); color: #22d3a5; }
.status-badge.connecting { background: rgba(251,191,36,0.12); color: #fbbf24; }
.status-badge.disconnected { background: rgba(239,68,68,0.12); color: #ef4444; }

/* ─── Typing indicator ──────────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--sable-msg-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typingDot 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Welcome screen ───────────────────────────────────────────────────── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 32px 28px;
  gap: 14px;
  width: 100%;
  max-width: 600px;
  overflow-y: auto;
}

.welcome-logo-wrap {
  margin-bottom: 4px;
}

.welcome-logo {
  height: 52px;
  width: auto;
  object-fit: contain;
  filter: brightness(1.05);
  animation: logoFadeIn 0.5s ease;
}

@keyframes logoFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.welcome-tagline {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  max-width: 380px;
  line-height: 1.6;
}

.welcome-status {
  margin-top: 2px;
}

/* Capabilities grid */
.capabilities-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 560px;
  margin: 10px 0 4px;
}

.capability-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.capability-chip:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.capability-icon {
  font-size: 12px;
}

.capability-label {
  font-size: 11px;
}

.welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  margin-top: 12px;
}

.welcome-input-wrap {
  width: 100%;
  max-width: 560px;
  margin-top: 4px;
}

.welcome-input-wrap .input-area {
  background: transparent;
  border-top: none;
  padding-top: 0;
}

.suggestion-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.3s, color 0.3s, border-color 0.15s, transform 0.1s;
}

.suggestion-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-mid);
  transform: translateX(2px);
}

.suggestion-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.suggestion-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}
.suggestion-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.suggestion-text {
  flex: 1;
}

/* ─── Error toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1215;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 2000;
  animation: slideUp 0.2s ease;
  box-shadow: var(--shadow);
}

/* ─── Video previews ────────────────────────────────────────────────────── */
.video-preview {
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 480px;
}

.video-thumb {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: #000;
}

.video-thumb-img {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.video-thumb:hover .video-thumb-img {
  opacity: 1;
}

.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  background: rgba(239, 68, 68, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: transform 0.2s, background 0.2s;
}

.video-thumb:hover .video-play-btn {
  background: rgba(239, 68, 68, 1);
  transform: translate(-50%, -50%) scale(1.08);
}

.video-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-iframe-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.video-iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ─── Titlebar left cluster ─────────────────────────────────────────────── */
.titlebar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--bg-hover); color: var(--text); }

.titlebar-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ─── Sidebar collapsed ─────────────────────────────────────────────────── */
.sidebar {
  transition: width 0.25s cubic-bezier(.4,0,.2,1),
              opacity 0.2s ease,
              min-width 0.25s ease;
}
.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  opacity: 0;
  border-right: none;
}

/* ─── Welcome screen (redesigned) ──────────────────────────────────────── */
.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.welcome-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.3px;
}

/* Taller input in welcome - like Claude */
.welcome-input-wrap .chat-input {
  min-height: 120px;
  max-height: 280px;
  resize: none;
}

/* Suggestion chips: 2-column grid */
.welcome-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin-top: 8px;
}

.suggestion-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s, border-color 0.15s, transform 0.1s;
  min-height: 46px;
}
.suggestion-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-mid);
  transform: translateY(-1px);
}
.suggestion-btn:disabled { opacity: 0.38; cursor: not-allowed; }

html.light-theme .welcome-title { color: var(--text); }
html.light-theme .suggestion-btn { color: var(--text-muted); }
html.light-theme .suggestion-btn:hover:not(:disabled) { color: var(--text); }

/* ─── Settings modal,  wide + tabs ─────────────────────────────────────── */
.modal-wide {
  width: 540px;
  max-width: calc(100vw - 40px);
}

.settings-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.settings-tab-btn:hover { color: var(--text); }
.settings-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.settings-tab-content { min-height: 200px; }

.input-with-action {
  display: flex;
  gap: 6px;
}
.input-with-action .form-input { flex: 1; }
.input-peek-btn {
  padding: 0 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.input-peek-btn:hover { background: var(--bg-hover); }

.copy-row {
  display: flex;
  gap: 6px;
}
.copy-row .form-input { flex: 1; }
.copy-btn {
  padding: 0 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.settings-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.settings-info-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.settings-info-dot.connected { background: #22d3a5; box-shadow: 0 0 6px #22d3a580; }

/* Dashboard links */
.dashboard-links-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
  width: 100%;
  color: var(--text);
  font-family: var(--font);
}
.dash-link-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateX(3px);
}
.dash-link-icon { font-size: 22px; flex-shrink: 0; }
.dash-link-body { flex: 1; }
.dash-link-title { font-size: 13px; font-weight: 500; color: var(--text); }
.dash-link-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.dash-link-arrow { font-size: 16px; color: var(--text-dim); flex-shrink: 0; }

/* Preferences */
.pref-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.pref-row-info { flex: 1; }
.pref-row-title { font-size: 13px; font-weight: 500; color: var(--text); }
.pref-row-sub { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.pref-toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.pref-toggle input { opacity: 0; width: 0; height: 0; }
.pref-toggle-track {
  position: absolute; inset: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border-mid);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.pref-toggle-track::before {
  content: '';
  position: absolute;
  height: 14px; width: 14px;
  left: 2px; bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.pref-toggle input:checked + .pref-toggle-track { background: var(--accent); border-color: var(--accent); }
.pref-toggle input:checked + .pref-toggle-track::before { transform: translateX(16px); background: #fff; }

.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  min-width: 86px;
  justify-content: center;
  white-space: nowrap;
}

/* About tab */
.about-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 0 18px;
}
.about-name { font-size: 18px; font-weight: 600; color: var(--text); }
.about-version { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.about-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.about-feature-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.about-feature-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

.about-footer {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ─── Dashboard Panel (embedded) ───────────────────────────────────────── */
.dashboard-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
  gap: 10px;
}
.dashboard-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
}
.dashboard-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.dashboard-url-pill {
  padding: 2px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.dash-btn:hover { background: var(--bg-hover); color: var(--text); }
.dash-btn-close { color: var(--text-dim); }
.dash-btn-close:hover { background: rgba(239,68,68,0.12); color: #ef4444; border-color: #ef4444; }

.dashboard-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.dashboard-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-dim);
  font-size: 13px;
}

.dashboard-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 40px;
}
.dashboard-error-icon { font-size: 32px; }
.dashboard-error-title { font-size: 16px; font-weight: 600; color: var(--text); }
.dashboard-error-sub { font-size: 13px; color: var(--text-muted); }

/* ── ModelSelector (titlebar) ─────────────────────────────────────── */
.model-selector-wrapper {
  position: relative;
  display: inline-flex;
  -webkit-app-region: no-drag;
}
.model-selector-trigger {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  display: flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; transition: all .15s;
}
.model-selector-trigger:hover {
  border-color: var(--accent); background: rgba(124,58,237,.08);
}
.model-selector-icon { font-size: 12px; }
.model-selector-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.model-selector-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 280px; max-height: 420px; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
  z-index: 9999; padding: 6px 0;
}
.model-selector-header {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px 8px; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--border);
}
.model-selector-count { font-weight: 400; opacity: 0.7; }
.model-selector-refresh {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 0 2px;
}
.model-selector-refresh:hover { color: var(--text); }
.model-selector-empty {
  padding: 16px 14px; font-size: 12px; color: var(--text-muted); text-align: center;
}
.model-selector-group-header {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px 4px; display: flex; align-items: center; gap: 6px;
}
.model-selector-item {
  font-size: 12px; padding: 7px 14px 7px 28px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  color: var(--text); transition: background .1s;
}
.model-selector-item:hover { background: var(--surface-2); }
.model-selector-item.active {
  color: var(--accent-light, #a78bfa); background: rgba(124,58,237,.06); font-weight: 600;
}
.model-selector-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border); background: transparent;
}
.model-selector-dot.on {
  background: #22c55e; border: none; box-shadow: 0 0 6px rgba(34,197,94,.4);
}
.model-selector-item-name { flex: 1; }
.model-selector-active-label { font-size: 10px; color: #22c55e; }
.model-selector-footer {
  border-top: 1px solid var(--border); padding: 8px 14px;
  font-size: 10px; color: var(--text-muted); text-align: center;
}

/* ── BrainPanel (desktop) ─────────────────────────────────────────── */
.brain-panel {
  display: flex; flex-direction: column; flex: 1; overflow: hidden;
  background: var(--bg, #0a0a0f);
}
.brain-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  min-height: 42px; flex-shrink: 0;
}
.brain-topbar-title { font-size: 13px; font-weight: 600; }
.brain-topbar-btn {
  margin-left: auto; background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); cursor: pointer;
  padding: 4px 10px; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; gap: 4px; transition: all .15s;
}
.brain-topbar-btn:hover { border-color: var(--accent); color: var(--text); }
.brain-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.brain-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.brain-card-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text);
}
.brain-card-icon { font-size: 16px; }
.brain-card-body { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.brain-stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px;
}
.brain-stat {
  background: var(--surface-2); border-radius: 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.brain-stat-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.brain-stat-value { font-size: 16px; font-weight: 700; color: var(--text); }
.brain-memory-item {
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
}
.brain-memory-item:last-child { border-bottom: none; }
.brain-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; color: var(--text-muted);
}
.brain-empty-icon { font-size: 36px; opacity: 0.5; }
.brain-empty-text { font-size: 13px; }

/* ── GGUF Import Dialog ───────────────────────────────────────────── */
.gguf-import-section {
  margin-top: 16px; padding: 14px; background: var(--surface-2, rgba(255,255,255,.03));
  border: 1px dashed var(--border); border-radius: 10px;
}
.gguf-import-title {
  font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.gguf-import-row {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.gguf-import-input {
  flex: 1; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg, #0a0a0f);
  color: var(--text); font-size: 12px; font-family: var(--mono, monospace);
  outline: none;
}
.gguf-import-input:focus { border-color: var(--accent); }
.gguf-import-btn {
  padding: 7px 14px; border-radius: 6px; border: none;
  background: var(--accent, #7c3aed); color: #fff; font-size: 12px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.gguf-import-btn:hover { opacity: 0.9; }
.gguf-import-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.gguf-import-hint {
  font-size: 10px; color: var(--text-muted); margin-top: 4px; line-height: 1.5;
}

/* ─── Permission Dialog ───────────────────────────────────────────────── */
.permission-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
.permission-dialog {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 14px; width: 380px; max-width: 90vw;
  padding: 20px; box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.permission-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.permission-icon { font-size: 22px; }
.permission-title { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; }
.permission-countdown {
  font-size: 11px; color: var(--text-muted); background: var(--bg-secondary);
  padding: 2px 7px; border-radius: 8px; font-variant-numeric: tabular-nums;
}
.permission-body { margin-bottom: 14px; }
.permission-question { font-size: 13px; color: var(--text-secondary); margin: 0 0 8px; line-height: 1.5; }
.permission-question strong { color: var(--text-primary); }
.permission-tool {
  background: var(--bg-secondary); border-radius: 6px; padding: 6px 10px;
  font-size: 12px; color: var(--accent); margin-bottom: 8px;
}
.permission-tool code { font-family: 'SF Mono', monospace; }
.permission-args {
  background: var(--bg-secondary); border-radius: 6px; padding: 8px 10px;
  font-size: 11px; max-height: 120px; overflow-y: auto;
}
.permission-arg { display: flex; gap: 6px; padding: 2px 0; }
.permission-arg-key { color: var(--text-muted); min-width: 60px; flex-shrink: 0; }
.permission-arg-val { color: var(--text-secondary); word-break: break-all; }
.permission-remember {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  color: var(--text-muted); margin-bottom: 14px; cursor: pointer;
}
.permission-remember input { accent-color: var(--accent); }
.permission-actions { display: flex; gap: 8px; justify-content: flex-end; }
.permission-btn {
  padding: 7px 18px; border-radius: 8px; font-size: 12px; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s;
}
.permission-btn.deny {
  background: var(--bg-secondary); color: var(--text-secondary);
}
.permission-btn.deny:hover { background: var(--border); }
.permission-btn.allow {
  background: var(--accent); color: #fff;
}
.permission-btn.allow:hover { opacity: 0.9; }

/* ═══════════════════════════════════════════════════════════════════════════
   Loading Overlay,  full-screen splash while connecting to SableCore
   ═══════════════════════════════════════════════════════════════════════════ */

.loading-overlay {
  position: fixed; inset: 0;
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary, #0d0f11);
  transition: opacity 0.6s ease-out;
}
.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
.loading-content {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(14px, 3vh, 24px);
  padding: clamp(16px, 4vw, 40px);
  user-select: none;
  max-width: 90vw;
}

/* ── Pulsing logo with spinning ring ────────────────────────────── */
.loading-logo-wrap {
  position: relative;
  width: clamp(64px, 12vmin, 100px);
  height: clamp(64px, 12vmin, 100px);
  display: flex; align-items: center; justify-content: center;
}
.loading-logo {
  width: 60%;
  height: 60%;
  border-radius: clamp(10px, 2vmin, 18px);
  animation: loading-pulse 2s ease-in-out infinite;
  z-index: 1;
  object-fit: contain;
}
.loading-ring {
  position: absolute; inset: 0;
  border: clamp(2px, 0.4vmin, 3px) solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 1.2s linear infinite;
}

/* ── Status text ────────────────────────────────────────────────── */
.loading-status {
  font-size: clamp(13px, 2vmin, 16px);
  font-weight: 500;
  color: var(--text-secondary);
  min-height: 1.4em;
  text-align: center;
  line-height: 1.4;
}
.loading-connected {
  color: var(--green, #22d3a5);
  font-weight: 600;
}
.loading-text {
  animation: loading-fade-text 2.6s ease-in-out infinite;
}

/* ── Indeterminate progress bar ─────────────────────────────────── */
.loading-bar-track {
  width: clamp(140px, 30vw, 240px);
  height: clamp(2px, 0.4vmin, 4px);
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}
.loading-bar-fill {
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  animation: loading-bar-slide 1.5s ease-in-out infinite;
}

/* ── Subtext / attempt counter ──────────────────────────────────── */
.loading-sub {
  font-size: clamp(10px, 1.6vmin, 12px);
  color: var(--text-muted);
  opacity: 0.65;
  text-align: center;
  line-height: 1.4;
}

/* ── Keyframes ──────────────────────────────────────────────────── */
@keyframes loading-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}
@keyframes loading-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.05); opacity: 0.85; }
}
@keyframes loading-bar-slide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(150%); }
  100% { transform: translateX(250%); }
}
@keyframes loading-fade-text {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}
