/* ═══════════════════════════════════════════════════════════════════════════
   MJB Claude Wrapper V4 — Industrial Control Room
   Dark-first. Dense. Functional. Bloomberg terminal for AI agents.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Variables (Dark Theme — Default) ─────────────────────────────── */

:root {
  --bg-primary: #080b14;
  --bg-secondary: #0e1220;
  --bg-tertiary: #171c2c;
  --bg-surface: #1e2438;
  --text-primary: #e0e0e8;
  --text-secondary: #8888a0;
  --text-muted: #555568;
  --accent: #5a7ec2;
  --accent-dim: #3d5a80;
  --accent-glow: rgba(33, 51, 93, 0.25);
  --success: #22c55e;
  --warning: #eab308;
  --danger: #C50C44;
  --border: #1e2640;
  --user-msg: #111830;
  --assistant-msg: transparent;
  /* Majorbird brand colors */
  --brand-navy: #21335D;
  --brand-crimson: #C50C44;

  --sidebar-width: 240px;
  --topbar-height: 42px;
  --input-bar-min: 52px;
  --font-ui: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

/* ─── Light Theme ──────────────────────────────────────────────────────── */

[data-theme="light"] {
  --bg-primary: #f5f5f8;
  --bg-secondary: #eeeef2;
  --bg-tertiary: #e0e0e8;
  --bg-surface: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #555568;
  --text-muted: #8888a0;
  --border: #d0d0dd;
  --user-msg: #dde8f5;
  --assistant-msg: transparent;
  --accent-glow: rgba(33, 51, 93, 0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --brand-navy: #21335D;
  --brand-crimson: #C50C44;
}

/* ─── Light Theme: Dark Navy Topbar & Sidebar ─────────────────────────── */

[data-theme="light"] #topbar {
  background: var(--brand-navy);
  border-bottom-color: #1a2849;
}
[data-theme="light"] #topbar .brand {
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="light"] #topbar .topbar-btn {
  color: rgba(255, 255, 255, 0.65);
}
[data-theme="light"] #topbar .topbar-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
[data-theme="light"] #topbar .topbar-btn.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
}
[data-theme="light"] #topbar .topbar-session-info {
  color: rgba(255, 255, 255, 0.85);
}
[data-theme="light"] #topbar .version {
  color: rgba(255, 255, 255, 0.5);
}
[data-theme="light"] #topbar .kill-btn {
  color: #ff6b8a !important;
}
[data-theme="light"] #topbar .kill-btn:hover {
  background: rgba(255, 107, 138, 0.15) !important;
  border-color: #ff6b8a !important;
}
[data-theme="light"] #topbar .activity-badge {
  border-color: var(--brand-navy);
}

[data-theme="light"] #sidebar {
  background: #1a2849;
  border-right-color: #152240;
}
[data-theme="light"] #session-filter {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="light"] #session-filter::placeholder {
  color: rgba(255, 255, 255, 0.35);
}
[data-theme="light"] #session-filter:focus {
  border-color: rgba(255, 255, 255, 0.35);
}
[data-theme="light"] .session-filter-clear {
  color: rgba(255, 255, 255, 0.4);
}
[data-theme="light"] .session-filter-clear:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
}
[data-theme="light"] .session-tab .session-name {
  color: rgba(255, 255, 255, 0.9);
}
/* session-meta removed */
[data-theme="light"] .session-tab .session-last-msg {
  color: rgba(255, 255, 255, 0.35);
}
[data-theme="light"] .session-tab:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .session-tab.active {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: var(--brand-crimson);
}
/* session-actions toggle + buttons in light theme */
[data-theme="light"] .session-actions-toggle {
  color: rgba(255, 255, 255, 0.4);
}
[data-theme="light"] .session-actions-toggle:hover {
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="light"] .session-tab .session-gear,
[data-theme="light"] .session-tab .session-close,
[data-theme="light"] .session-tab .session-reset,
[data-theme="light"] .session-tab .session-bubble-btn,
[data-theme="light"] .session-tab .session-model-btn {
  color: rgba(255, 255, 255, 0.4);
}
[data-theme="light"] .session-tab .session-bubble-btn:hover,
[data-theme="light"] .session-tab .session-bubble-btn.in-bubbles {
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="light"] .session-tab .session-color-btn {
  color: rgba(255, 255, 255, 0.4);
}
[data-theme="light"] .session-tab .session-gear:hover,
[data-theme="light"] .session-tab .session-close:hover,
[data-theme="light"] .session-tab .session-reset:hover,
[data-theme="light"] .session-tab .session-color-btn:hover {
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="light"] .session-pin {
  color: rgba(255, 255, 255, 0.4) !important;
}
[data-theme="light"] .session-pin:hover {
  color: rgba(255, 255, 255, 0.9) !important;
}
[data-theme="light"] .session-pin.pinned {
  color: var(--warning) !important;
}
[data-theme="light"] .new-session-btn {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.2);
}
[data-theme="light"] .new-session-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
[data-theme="light"] .sidebar-action-btn {
  color: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="light"] .sidebar-action-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}
[data-theme="light"] .sidebar-picker select {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="light"] .sidebar-resize {
  background: #152240;
}
/* Mobile topbar overflow dropdown */
[data-theme="light"] #topbar-overflow {
  background: var(--brand-navy);
  border-color: #1a2849;
}
[data-theme="light"] #topbar-overflow .topbar-btn {
  color: rgba(255, 255, 255, 0.65);
}
[data-theme="light"] #topbar-overflow .topbar-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
[data-theme="light"] #topbar-overflow .topbar-overflow-label {
  color: rgba(255, 255, 255, 0.75);
}
/* Activity dropdown in light theme stays on content bg */
[data-theme="light"] .activity-dropdown {
  background: var(--bg-surface);
  border-color: var(--border);
}

/* ─── Reset & Base ─────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  overflow: hidden;
  /* Prevent iOS rubber-band / overscroll on the body */
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--accent-dim);
  color: var(--text-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Utility ──────────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ─── Login Overlay ────────────────────────────────────────────────────── */

/* Animated ambient background glow */
@keyframes login-glow-drift {
  0%   { opacity: 0.5; transform: scale(1)   translate(0, 0); }
  33%  { opacity: 0.8; transform: scale(1.15) translate(3%, -4%); }
  66%  { opacity: 0.6; transform: scale(1.1)  translate(-4%, 3%); }
  100% { opacity: 0.5; transform: scale(1)   translate(0, 0); }
}

/* Login box entrance */
@keyframes login-enter {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Shake on error */
@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  18%, 54% { transform: translateX(-7px); }
  36%, 72% { transform: translateX(7px); }
}

/* Brand text pulse on load */
@keyframes login-brand-pulse {
  0%   { text-shadow: none; }
  50%  { text-shadow: 0 0 20px rgba(33, 51, 93, 0.5); }
  100% { text-shadow: none; }
}

#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  overflow: hidden;
}

/* Animated radial glow behind the form — brand navy */
#login-overlay::before {
  content: "";
  position: absolute;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(33, 51, 93, 0.18) 0%,
    rgba(33, 51, 93, 0.08) 40%,
    transparent 70%);
  animation: login-glow-drift 8s ease-in-out infinite;
  pointer-events: none;
}

/* Secondary smaller glow offset — brand navy */
#login-overlay::after {
  content: "";
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(33, 51, 93, 0.12) 0%,
    transparent 70%);
  transform: translate(120px, -80px);
  animation: login-glow-drift 12s ease-in-out infinite reverse;
  pointer-events: none;
}

.login-box {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 48px 40px;
  max-width: 360px;
  width: 100%;
  animation: login-enter 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.login-box.shake {
  animation: login-shake 0.4s ease;
}

.login-brand {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 4px;
  color: var(--text-primary);
  animation: login-brand-pulse 2s ease-in-out 0.5s 1;
}

.login-version {
  font-size: 14px;
  font-weight: 400;
  color: var(--accent);
  vertical-align: super;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-password {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

#login-password:focus {
  border-color: var(--accent);
}

#login-btn {
  padding: 10px 14px;
  background: var(--brand-navy);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

#login-btn:hover {
  background: color-mix(in srgb, var(--brand-navy) 85%, white 15%);
}

#login-btn:active {
  background: color-mix(in srgb, var(--brand-navy) 70%, black 30%);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

/* Biometric (WebAuthn) login button */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
  color: var(--text-muted);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-biometric-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.login-biometric-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-surface);
}
.login-biometric-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* WebAuthn prompt (shown after password login to offer biometric setup) */
.webauthn-prompt {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  max-width: 300px;
  box-shadow: var(--shadow-lg);
  animation: login-enter 0.3s ease-out;
}
.webauthn-prompt-icon {
  font-size: 24px;
  margin-bottom: 8px;
}
.webauthn-prompt p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}
.webauthn-prompt-actions {
  display: flex;
  gap: 8px;
}
.webauthn-prompt-actions button {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
#webauthn-enable-btn {
  background: var(--accent);
  color: #fff;
}
#webauthn-enable-btn:hover { opacity: 0.85; }
#webauthn-skip-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
#webauthn-skip-btn:hover { opacity: 0.75; }

/* ─── Reconnect Overlay ────────────────────────────────────────────────── */

#reconnect-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(4px);
}

.reconnect-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.reconnect-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── App Container ────────────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;            /* Fallback for older browsers */
  height: 100dvh;           /* Dynamic viewport height — respects mobile address bar */
  width: 100vw;
  overflow: hidden;         /* Never let #app content escape the viewport */
  position: fixed;          /* Lock to viewport — prevents any browser-initiated scroll */
  inset: 0;
}

/* ─── Top Bar ──────────────────────────────────────────────────────────── */

#topbar {
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}
.topbar-session-info {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  cursor: pointer;
}
.topbar-session-info.hidden { display: none; }
/* Voice call overflow button: hidden on desktop, shown on mobile in overflow menu */
.voice-call-overflow-btn { display: none !important; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: color-mix(in srgb, var(--brand-navy) 55%, white 45%);
}

.version {
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  vertical-align: super;
}

.topbar-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn svg {
  display: block;
}

.topbar-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.topbar-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.topbar-btn.active:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

/* ⋯ More button — hidden on desktop, shown on mobile */
.topbar-more-btn {
  display: none !important;
}

/* Overflow button group — inline in topbar on desktop */
#topbar-overflow {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Labels only shown in mobile overflow dropdown */
.topbar-overflow-label {
  display: none;
}

/* ─── Activity Indicator (global busy sessions) ─────────────────────────── */
.activity-btn {
  position: relative;
}

.activity-btn.has-activity {
  color: var(--warning);
}

.activity-btn.has-activity svg {
  animation: activity-pulse 1.5s ease-in-out infinite;
}

@keyframes activity-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.activity-badge {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  min-width: 14px;
  height: 14px;
  line-height: 14px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
  background: var(--warning);
  border-radius: 7px;
  text-align: center;
  pointer-events: none;
}

.activity-btn.has-activity .activity-badge {
  display: block;
}

/* Activity dropdown panel */
.activity-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 240px;
  max-width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  padding: 6px 0;
  max-height: 300px;
  overflow-y: auto;
}

.activity-dropdown.open { display: block; }

.activity-dropdown-header {
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.activity-dropdown-empty {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background var(--transition);
}

.activity-item:hover {
  background: var(--bg-tertiary);
}

.activity-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
  animation: dot-pulse 1.5s ease-in-out infinite;
}

.activity-item-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item-stop {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.activity-item-stop:hover {
  background: var(--danger);
  color: #fff;
}

#hamburger {
  display: flex;
}

/* Personality picker */
#personality-picker {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  max-width: 280px;
  cursor: pointer;
  outline: none;
}

#personality-picker:focus {
  border-color: var(--accent);
}

/* Kill button */
.kill-btn {
  color: var(--danger) !important;
  font-weight: 700;
}

.kill-btn:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: var(--danger) !important;
}

.kill-btn.active {
  animation: kill-pulse 0.6s ease-in-out;
}

@keyframes kill-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.6); }
}

/* Activity toast — slides in from top-right when a background session becomes busy */
.activity-toast {
  position: fixed;
  top: 56px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  z-index: 1100;
  animation: toast-slide 0.3s ease-out;
  max-width: 280px;
}

.activity-toast:hover {
  background: var(--bg-tertiary);
}

.activity-toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: dot-pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

.activity-toast-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes toast-slide {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}


/* ─── Layout ───────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* ─── 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: hidden;
  transition: width 200ms ease, min-width 200ms ease, border-color 200ms ease;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right-color: transparent;
}

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

.sidebar-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 3px 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.sidebar-action-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.new-session-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  transition: all var(--transition);
}

.new-session-btn:hover {
  background: var(--accent-dim);
  color: #fff;
}

/* Sidebar personality picker (mobile only) */
.sidebar-picker {
  display: none;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-picker select {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  outline: none;
}

.sidebar-picker select:focus {
  border-color: var(--accent);
}

/* Session filter */
.session-filter-wrap {
  padding: 8px 8px 4px;
  flex-shrink: 0;
  position: relative;
}
.session-filter-clear {
  position: absolute;
  right: 66px;  /* clear both busy-filter (26px) + switcher (26px) + gaps */
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  z-index: 2;
  transition: color var(--transition), background var(--transition);
}
.session-filter-clear:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* Busy filter toggle */
.session-filter-busy {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.session-filter-busy:hover {
  color: var(--warning);
  border-color: var(--warning);
}
.session-filter-busy.active {
  color: var(--warning);
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 15%, var(--bg-tertiary));
  animation: dot-pulse 1.5s ease-in-out infinite;
}
[data-theme="light"] .session-filter-busy {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.35);
}
[data-theme="light"] .session-filter-busy:hover {
  color: var(--warning);
  border-color: var(--warning);
}
[data-theme="light"] .session-filter-busy.active {
  color: var(--warning);
  border-color: var(--warning);
  background: rgba(234, 179, 8, 0.15);
}

/* + button to open session switcher */
.session-filter-wrap {
  display: flex;
  gap: 4px;
  align-items: center;
}
.session-switcher-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.session-switcher-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-tertiary));
}
[data-theme="light"] .session-switcher-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
}
[data-theme="light"] .session-switcher-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

#session-filter {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 24px 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}

#session-filter::placeholder {
  color: var(--text-muted);
}

#session-filter:focus {
  border-color: var(--accent);
}

/* Session list */
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.session-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.session-tab:hover {
  background: var(--bg-tertiary);
}

/* Separator between pinned and unpinned sessions */
.pinned-separator {
  height: 1px;
  margin: 4px 12px;
  background: var(--border);
  opacity: 0.5;
}

.session-tab.active {
  background: var(--bg-tertiary);
  border-left-color: var(--brand-crimson);
}

.session-tab .session-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-tab .session-dot.idle { background: var(--success); }
.session-tab .session-dot.busy { background: var(--warning); animation: dot-pulse 1.5s ease-in-out infinite; }
.session-tab .session-dot.error { background: var(--danger); }

.session-tab .session-info {
  flex: 1;
  min-width: 0;
}

.session-tab .session-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.session-tab .session-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ⋯ toggle button — hidden until hover on desktop, always visible on mobile */
.session-actions-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
  line-height: 1;
  letter-spacing: 1px;
  opacity: 0;
}
.session-tab:hover .session-actions-toggle,
.session-actions-toggle:focus,
.session-tab.actions-open .session-actions-toggle {
  opacity: 1;
}
.session-actions-toggle:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

/* Action bar — hidden by default, shown on toggle */
.session-actions {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 0 2px;
  height: 16px;
  flex-shrink: 0;
}
.session-actions.sa-open {
  display: flex;
}

.session-tab .session-gear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.session-tab .session-gear:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.session-tab .session-reset {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.session-tab .session-reset:hover {
  color: var(--warning);
  background: rgba(234, 179, 8, 0.15);
}

.session-tab .session-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.session-tab .session-close:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ─── Chat Area ────────────────────────────────────────────────────────── */

#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
  position: relative;
}

/* Scroll-to-bottom floating button */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 90px;
  right: 72px;  /* sits to the left of floating bubbles (16px + 40px bubble + 16px gap) */
  z-index: 52;  /* above floating-bubbles (z-index: 51) */
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
  opacity: 1;
  transform: translateY(0);
}

.scroll-to-bottom-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.scroll-to-bottom-btn.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.scroll-to-bottom-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.scroll-to-bottom-badge.hidden {
  display: none;
}

/* Queue bubble — floating indicator above scroll-to-bottom button */
.queue-bubble {
  position: relative;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 2px solid var(--warning);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  user-select: none;
  pointer-events: auto;
  flex-shrink: 0;
}

.queue-bubble.hidden {
  display: none;
}

.queue-bubble-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--warning);
  color: #000;
  font-weight: 700;
  font-size: 9px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  z-index: 1;
}

.queue-bubble-label {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1;
}

.queue-bubble-clear {
  position: absolute;
  top: -6px;
  left: -6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition);
}

.queue-bubble:hover .queue-bubble-clear {
  opacity: 1;
}

.queue-bubble-clear:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Queue dropdown — list of individual messages */
.queue-dropdown {
  position: fixed;
  bottom: auto;
  right: 16px;
  top: auto;
  min-width: 240px;
  max-width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}

.queue-dropdown-header {
  padding: 4px 10px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.queue-dropdown-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
}

.queue-dropdown-item:hover {
  background: var(--bg-tertiary);
}

.queue-dropdown-src {
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 4px;
  border-radius: 3px;
  flex-shrink: 0;
}

.queue-dropdown-text {
  flex: 1;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-dropdown-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: 0.5;
}

.queue-dropdown-cancel:hover {
  color: var(--danger);
  opacity: 1;
}

/* Drag-over visual feedback */
#chat-area.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

/* Abort flash animation */
#chat-area.abort-flash {
  animation: abort-flash 0.4s ease-out;
}

@keyframes abort-flash {
  0% { box-shadow: inset 0 0 40px rgba(239, 68, 68, 0.3); }
  100% { box-shadow: none; }
}

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

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

.empty-state p {
  font-size: 14px;
}

/* ─── Session Panels (Todos, Agents) ───────────────────────────────────── */

.session-panels {
  flex-shrink: 0;
  z-index: 10;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.session-panels:empty,
.session-panels:not(:has(.session-panel:not(.hidden))) {
  border-bottom: none;
}

.session-panel {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.session-panel:last-child {
  border-bottom: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.panel-header:hover {
  color: var(--text-secondary);
}

.panel-header svg {
  flex-shrink: 0;
}

.panel-chevron {
  margin-left: auto;
  font-size: 8px;
  transition: transform var(--transition);
}

.session-panel.collapsed .panel-chevron {
  transform: rotate(-90deg);
}

.panel-content {
  padding: 4px 16px 8px;
  max-height: 200px;
  overflow-y: auto;
}

.session-panel.collapsed .panel-content {
  display: none;
}

/* Todo items */
.todo-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.todo-item.completed {
  color: var(--text-muted);
  text-decoration: line-through;
}

.todo-item.in_progress {
  color: var(--accent);
}

.todo-icon {
  font-size: 10px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.todo-item.completed .todo-icon { color: var(--success); }
.todo-item.in_progress .todo-icon { color: var(--accent); }
.todo-item.pending .todo-icon { color: var(--text-muted); }

/* Agent badges */
.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  margin: 2px 4px 2px 0;
  font-size: 11px;
  font-family: var(--font-mono);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.agent-badge.running {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}

.agent-badge.done {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
  opacity: 0.7;
}

.agent-icon {
  font-size: 10px;
}

/* ─── Messages ─────────────────────────────────────────────────────────── */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

/* Message container */
.msg {
  position: relative;
  max-width: 85%;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* User messages */
.msg.user {
  align-self: flex-end;
  background: var(--user-msg);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.msg.user .msg-content {
  white-space: pre-wrap;
}

.msg.user .msg-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

/* Assistant messages */
.msg.assistant {
  align-self: flex-start;
  background: var(--assistant-msg);
  max-width: 92%;
}

.msg.assistant .msg-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

/* Empty assistant bubble (tool-only turn, no text) — collapse to compact metrics line */
.msg.assistant.msg-empty {
  background: none;
  padding: 0;
  margin: 2px 0;
  border: none;
  max-width: 92%;
}
.msg.assistant.msg-empty .msg-label { display: none; }
.msg.assistant.msg-empty .msg-content { display: none; }
.msg.assistant.msg-empty .msg-metrics {
  border-top: none;
  margin: 0;
  padding: 2px 8px;
  opacity: 0.6;
  font-size: 10px;
}
.msg.assistant.msg-empty .msg-metrics-detail { display: none; }
.msg.assistant.msg-empty .msg-metrics.expanded .msg-metrics-detail { display: flex; }
.msg.assistant.msg-empty .quote-btn,
.msg.assistant.msg-empty .copy-msg-btn { display: none; }

/* Quote & Copy message buttons — hover-reveal on desktop, hidden on mobile */
.msg-quote-btn,
.msg-copy-btn {
  position: absolute;
  bottom: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  z-index: 2;
  padding: 0;
  line-height: 1;
}
.msg-quote-btn { right: 36px; }
.msg-copy-btn  { right: 6px; }
.msg:hover .msg-quote-btn,
.msg:hover .msg-copy-btn {
  opacity: 1;
}
.msg-quote-btn:hover,
.msg-copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}
/* On touch devices, never show hover-reveal action buttons */
@media (hover: none) {
  .msg-quote-btn,
  .msg-copy-btn {
    display: none;
  }
}

/* Streaming cursor */
.msg.assistant.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s steps(2) infinite;
}

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

/* System messages */
.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 4px 12px;
  max-width: 100%;
  text-align: center;
}

/* Webhook / Cron source messages */
.msg.user .msg-source {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 2px;
  display: block;
}

/* ─── Webhook Compact Bubbles ──────────────────────────────────────────── */

.msg.user.webhook-compact {
  background: transparent;
  border: none;
  padding: 2px 0;
  max-width: 350px;
  align-self: flex-end;
}

.webhook-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
  float: right;
}

.webhook-pill:hover {
  background: var(--bg-surface);
  border-color: var(--accent-dim);
}

.webhook-pill-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.webhook-pill-name {
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
}

.webhook-pill-time {
  color: var(--text-muted);
  font-size: 9px;
}

.webhook-pill-time .timestamp { font-size: 9px; }

/* Expanded body below the pill */
.webhook-expand-body {
  display: none;
  clear: both;
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--user-msg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  max-width: 500px;
  word-break: break-word;
  white-space: pre-wrap;
  float: right;
}

.msg.user.webhook-compact.expanded .webhook-expand-body {
  display: block;
}

/* Hide quote/copy on collapsed webhook bubbles */
.msg.user.webhook-compact .msg-quote-btn,
.msg.user.webhook-compact .msg-copy-btn {
  display: none;
}

/* ─── Webhook/Cron Pill Grouping ──────────────────────────────────────── */
.webhook-group {
  align-self: flex-end;
  max-width: 350px;
  margin: 1px 0;
}
.webhook-group-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 7px;
  min-height: 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.webhook-group-header:hover {
  background: color-mix(in srgb, var(--bg-tertiary) 80%, var(--accent) 20%);
}
.webhook-group-icon {
  display: inline-flex;
  color: var(--text-muted);
  font-size: 8px;
  transition: transform 0.15s ease;
}
.webhook-group.expanded .webhook-group-icon {
  transform: rotate(90deg);
}
.webhook-group-pill-icon { font-size: 12px; }
.webhook-group-label { white-space: nowrap; font-weight: 600; }
.webhook-group-time {
  color: var(--text-muted);
  font-size: 9px;
}
.webhook-group-body {
  display: none;
  padding: 4px 0 4px 12px;
  border-right: 2px solid var(--border);
  margin: 2px 10px 2px 0;
}
.webhook-group.expanded .webhook-group-body {
  display: block;
}

/* ─── Command Palette ─────────────────────────────────────────────────── */

.command-palette {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  padding: 4px 0;
  margin-bottom: 4px;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition);
}

.command-item:hover,
.command-item.selected {
  background: var(--accent-glow);
}

.command-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.command-desc {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Message timestamps */
.msg-time {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-mono);
  margin-left: 6px;
  opacity: 0.7;
}

/* Message content rendering */
.msg-content {
  overflow-wrap: break-word;
}

.msg-content p {
  margin: 0 0 8px 0;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content strong, .msg-content b {
  font-weight: 600;
  color: var(--text-primary);
}

.msg-content em, .msg-content i {
  font-style: italic;
}

.msg-content code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* Code blocks */
.msg-content pre {
  position: relative;
  margin: 8px 0;
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.msg-content pre code {
  display: block;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-secondary);
  border: none;
  border-radius: 0;
  white-space: pre;
  tab-size: 2;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition);
}

.copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* Lists */
.msg-content ul, .msg-content ol {
  margin: 2px 0;
  padding-left: 18px;
}

.msg-content li {
  margin: 1px 0;
  line-height: 1.4;
}

/* Blockquote */
.msg-content blockquote {
  border-left: 3px solid var(--accent-dim);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}

/* Horizontal rule */
.msg-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Tables (GFM) */
.msg-content table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13px;
  overflow-x: auto;
  display: block;
}

.msg-content thead {
  background: var(--bg-tertiary);
}

.msg-content th,
.msg-content td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
  white-space: nowrap;
}

.msg-content th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

.msg-content tr:nth-child(even) {
  background: var(--bg-secondary);
}

.msg-content tr:hover {
  background: var(--accent-glow);
}

/* Task lists (GFM checkbox) */
.msg-content ul.contains-task-list {
  list-style: none;
  padding-left: 4px;
}

.msg-content .task-list-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.msg-content .task-list-item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}

/* ─── Typing Indicator ─────────────────────────────────────────────────── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  align-self: flex-start;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.typing-label {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.compacting-indicator .typing-label {
  color: var(--warning, #f59e0b);
}
.compacting-indicator .typing-dots span {
  background: var(--warning, #f59e0b);
}

/* ─── Tool Cards (Redesigned) ──────────────────────────────────────────── */

/* ─── Tool Pills (Compact Inline Cards) ──────────────────────────────── */

.tool-card {
  margin: 1px 0;
  align-self: flex-start;
  width: auto;
  max-width: 700px;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.tool-card.completed {
  opacity: 0.8;
}

/* Pill header: compact rounded capsule */
.tool-card-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 7px;
  min-height: 22px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tool-card-header:hover {
  background: var(--bg-surface);
  border-color: var(--accent-dim);
}

.tool-card-icon {
  color: var(--accent);
  font-size: 8px;
  flex-shrink: 0;
  transition: transform var(--transition);
  display: flex;
  align-items: center;
}

.tool-card.expanded .tool-card-icon {
  transform: rotate(90deg);
}

.tool-card-name {
  color: var(--warning);
  font-weight: 600;
  flex-shrink: 0;
  font-size: 11px;
}

/* Preview hidden in collapsed pill, visible in expanded body */
.tool-card-preview {
  display: none;
}

.tool-card-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* SVG progress ring (replaces CSS border-spin) */
.tool-ring { display: block; flex-shrink: 0; }
.tool-ring-arc {
  animation: tool-ring-spin 1s linear infinite;
  transform-origin: center;
}
@keyframes tool-ring-spin { to { transform: rotate(360deg); } }

/* Legacy CSS spinner (hidden — replaced by SVG ring) */
.tool-spinner { display: none; }

.tool-check {
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

/* Body: drops below the pill, bordered block */
.tool-card-body {
  display: none;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  max-height: 400px;
  overflow-y: auto;
  max-width: 700px;
}

.tool-card.expanded .tool-card-body {
  display: block;
}

/* Show preview as first line inside expanded body */
.tool-card.expanded .tool-card-preview {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  padding: 4px 12px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-card-input {
  padding: 8px 12px;
  max-height: 250px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-card-result {
  display: none; /* hidden by default — visible only when card is expanded */
  padding: 8px 12px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-muted);
}

.tool-card.expanded .tool-card-result:not(:empty) {
  display: block;
}

.tool-card-result:empty {
  display: none;
}

.tool-card-result.truncated {
  cursor: pointer;
}

/* ─── Tool Group (collapsed consecutive tool cards) ──────────────────── */

.tool-group {
  align-self: flex-start;
  max-width: 700px;
  margin: 1px 0;
}
.tool-group-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 7px;
  min-height: 22px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.8;
  transition: background var(--transition);
}
.tool-group-header:hover {
  background: color-mix(in srgb, var(--bg-tertiary) 80%, var(--accent) 20%);
}
.tool-group-icon {
  display: inline-flex;
  color: var(--text-muted);
  font-size: 8px;
  transition: transform 0.15s ease;
}
.tool-group.expanded .tool-group-icon {
  transform: rotate(90deg);
}
.tool-group-label {
  white-space: nowrap;
}
.tool-group-check {
  color: var(--success, #22c55e);
  font-size: 11px;
}
.tool-group-breakdown {
  color: var(--text-muted);
  font-size: 10px;
  margin-left: 2px;
}
.tool-group-cards {
  display: none;
  padding: 2px 0 2px 8px;
  border-left: 2px solid var(--border);
  margin: 2px 0 2px 10px;
}
.tool-group.expanded .tool-group-cards {
  display: block;
}

/* Collapsed tool result pill — clean replacement for raw code dumps */
.tool-result-pill-wrap {
  align-self: flex-start;
  max-width: 320px;
  margin: 1px 0;
}

.tool-result-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  transition: all var(--transition);
  user-select: none;
}

.tool-result-pill:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-dim);
}

.tool-result-pill-icon {
  font-size: 7px;
  transition: transform 0.2s;
  display: inline-block;
}

.tool-result-pill-wrap.expanded .tool-result-pill-icon {
  transform: rotate(90deg);
}

.tool-result-pill-label {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
}

.tool-result-pill-size {
  color: var(--text-muted);
  opacity: 0.6;
  font-family: var(--font-mono);
}

.tool-result-pill-body {
  display: none;
  margin: 4px 0 2px 0;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.35;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-result-pill-wrap.expanded .tool-result-pill-body {
  display: block;
}

/* ─── AskUserQuestion Cards ───────────────────────────────────────────── */

.ask-user-card {
  margin: 8px 0;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  align-self: flex-start;
  width: 100%;
  max-width: 600px;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
}

.ask-user-header {
  padding: 8px 14px 0;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.ask-user-question {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}

.ask-user-options {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.ask-user-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
  line-height: 1.4;
}

.ask-user-option:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  transform: translateX(2px);
}

.ask-user-option.selected {
  background: var(--accent-glow);
  border-color: var(--accent);
  opacity: 0.6;
  pointer-events: none;
}

.ask-user-option-label {
  font-weight: 600;
  color: var(--text-primary);
}

.ask-user-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.ask-user-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: #fff;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .ask-user-card {
    max-width: 98%;
  }
}

/* ─── Queued Message Indicator ────────────────────────────────────────── */

.msg.user.is-queued {
  opacity: 0.7;
  position: relative;
}

.msg-queued-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  animation: queued-pulse 2s ease-in-out infinite;
}

.msg-queued-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: queued-dot 1.5s ease-in-out infinite;
}

@keyframes queued-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes queued-dot {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ─── Personality Info Popover ────────────────────────────────────────── */

.personality-info-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 4px;
  font-family: var(--font-mono);
  transition: color var(--transition);
}

.personality-info-btn:hover {
  color: var(--accent);
}

.personality-popover {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  z-index: 200;
  min-width: 180px;
}

.personality-popover-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.personality-popover-label {
  color: var(--text-muted);
  min-width: 55px;
}

.personality-popover-value {
  color: var(--text-primary);
}

/* ─── Metrics Footer ───────────────────────────────────────────────────── */

.msg-metrics {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px 0 0 0;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  display: block;
}
.msg-metrics-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.msg-metrics-summary:hover {
  background: var(--bg-tertiary);
}
.msg-metrics-model { font-weight: 600; }
.msg-metrics-ts { color: var(--text-muted); }
.msg-metrics-detail {
  display: none;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 3px;
  padding-left: 4px;
}
.msg-metrics.expanded .msg-metrics-detail {
  display: flex;
}
.msg-metrics span {
  white-space: nowrap;
}

/* ─── Attachment Bar ───────────────────────────────────────────────────── */

.attach-bar {
  padding: 4px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.attach-thumb {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
}

.attach-name {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition);
}

.attach-remove:hover {
  color: var(--danger);
}

/* ─── Input Bar ────────────────────────────────────────────────────────── */

.input-bar {
  padding: 8px 16px 12px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

.upload-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--transition);
}

.upload-btn:hover {
  color: var(--accent);
}

#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}

#input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: var(--brand-navy);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), opacity var(--transition);
}

.send-btn:hover {
  background: color-mix(in srgb, var(--brand-navy) 85%, white 15%);
}

.send-btn:active {
  background: color-mix(in srgb, var(--brand-navy) 70%, black 30%);
}

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

/* Input character counter */
.input-counter {
  position: absolute;
  right: 44px;
  bottom: 8px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 1;
}
.input-counter.warn {
  color: var(--warning);
}

/* ─── Modal ────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: 90%;
  max-width: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}

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

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-input {
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

.modal-close-btn {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

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

.modal-submit-btn {
  padding: 6px 14px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.modal-submit-btn:hover {
  background: color-mix(in srgb, var(--accent) 85%, white 15%);
}

/* ─── Settings Module ──────────────────────────────────────────────────── */

/* Sidebar settings button */
.sidebar-settings-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  margin-top: auto;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.sidebar-settings-btn:hover {
  color: var(--accent);
  background: var(--bg-tertiary);
}

.sidebar-settings-btn svg {
  flex-shrink: 0;
}

/* Settings panel (replaces chat area content) */
.settings-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  z-index: 10;
  overflow: hidden;
}

/* Settings header */
.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.settings-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.settings-back-btn:hover {
  color: var(--accent);
  background: var(--bg-tertiary);
}

.settings-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.settings-version {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Settings tab bar */
.stab-bar {
  display: flex;
  gap: 2px;
  padding: 6px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

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

.stab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.stab-btn svg {
  opacity: 0.6;
  flex-shrink: 0;
}

.stab-btn.active svg {
  opacity: 1;
}

/* Settings tab content panels */
.stab-content {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.stab-content.active {
  display: flex;
}

/* Settings body (scrollable) */
.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Settings toolbar (New button + search) */
.settings-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
}

.settings-new-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
}

.settings-import-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
}
.settings-import-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.settings-import-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.settings-search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.settings-search-icon {
  position: absolute;
  left: 8px;
  color: var(--text-muted);
  pointer-events: none;
}

.settings-search {
  width: 100%;
  padding: 6px 8px 6px 26px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color var(--transition);
}

.settings-search:focus {
  border-color: var(--accent);
}

/* Personality list */
.personality-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Personality row */
.personality-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.personality-row.expanded {
  border-color: var(--accent-dim);
  overflow: visible;
}

.personality-row.highlight-flash {
  animation: personality-flash 1.5s ease-out;
}

@keyframes personality-flash {
  0% { background: var(--accent-glow); border-color: var(--accent); }
  100% { background: var(--bg-surface); border-color: var(--accent-dim); }
}

.personality-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--bg-secondary);
  transition: background var(--transition);
  user-select: none;
}

.personality-row-header:hover {
  background: var(--bg-tertiary);
}

.personality-expand-icon {
  font-size: 10px;
  color: var(--text-muted);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.personality-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.personality-row-meta {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

.personality-enabled-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.personality-enabled-dot.on {
  background: var(--success);
}

.personality-enabled-dot.off {
  background: var(--text-muted);
}

/* Personality edit form */
.personality-edit-form {
  padding: 12px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Personality form sub-tabs ── */
.pf-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  padding-bottom: 0;
}

.pf-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.pf-tab:hover {
  color: var(--text-primary);
}

.pf-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.pf-tab-badge {
  font-size: 9px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 8px;
  padding: 0 5px;
  min-width: 14px;
  text-align: center;
  line-height: 1.6;
}

.pf-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.pf-pane.active {
  display: flex;
}

/* Form elements */
.settings-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-form-group label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.settings-form-row {
  display: flex;
  gap: 10px;
}

.settings-form-row .settings-form-group {
  flex: 1;
}

.settings-input {
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.settings-input:focus {
  border-color: var(--accent);
}

.settings-textarea {
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
  min-height: 48px;
  line-height: 1.5;
  width: 100%;
}

.settings-textarea:focus {
  border-color: var(--accent);
}

.settings-select {
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  width: 100%;
}

.settings-select:focus {
  border-color: var(--accent);
}

/* CWD row with browse button */
.settings-cwd-row {
  display: flex;
  gap: 6px;
}

.settings-cwd-row .settings-cwd-input {
  flex: 1;
}

.settings-browse-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  transition: all var(--transition);
  flex-shrink: 0;
}

.settings-browse-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Checkbox row */
.settings-checkbox-row {
  display: flex;
  gap: 16px;
  padding: 4px 0;
}

.settings-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.settings-checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Webhook section */
.webhook-section {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding-bottom: 2px;
}

/* Token row */
.settings-token-row {
  display: flex;
  gap: 4px;
}

.settings-token-input {
  flex: 1;
  font-size: 11px !important;
  opacity: 0.8;
}

.settings-token-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  transition: all var(--transition);
  flex-shrink: 0;
  line-height: 1;
}

.settings-token-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Cron section */
.cron-section {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cron-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cron-item.cron-disabled {
  opacity: 0.6;
}

.cron-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cron-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cron-item-schedule {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

.cron-toggle-btn {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.cron-toggle-btn.cron-enabled {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.cron-toggle-btn.cron-disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.cron-toggle-btn:hover {
  opacity: 0.8;
}

.cron-item-meta {
  display: flex;
  gap: 12px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.cron-item-message {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cron-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.cron-edit-btn,
.cron-delete-btn {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.cron-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cron-delete-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.cron-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
}

.cron-add-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.cron-add-form,
.cron-edit-inline {
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Schedule presets */
.schedule-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 4px;
}

.schedule-preset-btn {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.schedule-preset-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.schedule-preset-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ── Skills section ── */
.skills-section {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}

.skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-tag:hover {
  background: var(--accent-dim);
}

.skill-tag.skill-src-gstack {
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
}

.skill-tag.skill-src-gstack:hover {
  background: rgba(99, 102, 241, 0.2);
}

.skill-tag.skill-src-aitmpl {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.skill-tag.skill-src-aitmpl:hover {
  background: rgba(16, 185, 129, 0.2);
}

.skill-tag.skill-src-manual {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.skill-tag-remove {
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  flex-shrink: 0;
}

.skill-tag-remove:hover {
  opacity: 1;
  color: var(--danger);
}

.skills-picker-wrap {
  position: relative;
}

.skills-search-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
}

.skills-search-input:focus {
  border-color: var(--accent-dim);
}

.skills-picker {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 100;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.skills-picker-item {
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.skills-picker-item:last-child {
  border-bottom: none;
}

.skills-picker-item:hover {
  background: var(--accent-glow);
}

.skills-picker-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.skills-picker-source {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.skills-picker-desc {
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skills-picker-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Skill detail preview */
.skill-detail {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 4px;
}

.skill-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.skill-detail-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.skill-detail-source {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
}

.skill-detail-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.skill-detail-close:hover {
  color: var(--text-primary);
}

.skill-detail-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 8px 0;
  line-height: 1.5;
}

.skill-detail-tools {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.skill-detail-content {
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Skills catalog (top-level tab) ── */
.skills-catalog-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.skills-catalog-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.skills-catalog-search {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
}

.skills-catalog-search:focus {
  border-color: var(--accent-dim);
}

.skills-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.skills-catalog-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.sc-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: all var(--transition);
}

.sc-item:hover {
  border-color: var(--accent-dim);
  background: var(--bg-secondary);
}

.sc-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sc-item-name {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.sc-item-source {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
}

.sc-item-usage {
  margin-left: auto;
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
}

.sc-item-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.sc-item-agents {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.sc-agent-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

.sc-item-detail {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Action buttons */
.settings-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.settings-save-btn,
.settings-create-btn {
  padding: 6px 16px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background var(--transition);
}

.settings-save-btn:hover,
.settings-create-btn:hover {
  background: color-mix(in srgb, var(--accent) 85%, white 15%);
}

.settings-save-btn:disabled,
.settings-create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-delete-btn {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
  margin-left: auto;
}

.settings-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

.settings-cancel-btn {
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
}

.settings-cancel-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Toast notifications — top-right, stacks below activity toasts */
.settings-toast {
  position: fixed;
  top: 56px;
  right: 16px;
  transform: translateY(-12px);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  color: #fff;
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  max-width: 320px;
}

.settings-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.settings-toast.success {
  background: var(--success);
}

.settings-toast.error {
  background: var(--danger);
}

.settings-toast.info {
  background: var(--accent);
}

/* ─── Token Limit Warning ────────────────────────────────────────────── */
.token-warning {
  margin-top: 6px;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--warning, #f59e0b) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 40%, transparent);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.token-warning.critical {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.token-warning-action {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.token-warning-action:hover {
  color: var(--text-primary);
}

/* ─── Context Gauge Bar (persistent warning below topbar) ────────────── */

.context-gauge-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--warning, #f59e0b) 12%, var(--bg-secondary));
  border-bottom: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 30%, transparent);
  z-index: 50;
  transition: background 0.3s, border-color 0.3s;
}
.context-gauge-bar.visible {
  display: flex;
}
.context-gauge-bar.critical {
  background: color-mix(in srgb, var(--danger) 15%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.context-gauge-track {
  flex: 0 0 100px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.context-gauge-fill {
  height: 100%;
  background: var(--warning, #f59e0b);
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s;
}
.context-gauge-bar.critical .context-gauge-fill {
  background: var(--danger);
}
.context-gauge-text {
  flex: 1;
  min-width: 0;
}
.context-gauge-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.context-gauge-actions a {
  font-size: 11px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}
.context-gauge-actions a:hover {
  color: var(--text-primary);
}

/* ─── Compaction Banner ──────────────────────────────────────────────── */

.compaction-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 8px 0;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  animation: compaction-fade-in 0.3s ease;
}
.compaction-banner .compaction-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.compaction-banner .compaction-text {
  flex: 1;
}
.compaction-banner .compaction-detail {
  color: var(--text-muted);
  font-size: 11px;
}

.compaction-in-progress {
  background: color-mix(in srgb, var(--warning, #f59e0b) 10%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--warning, #f59e0b) 25%, transparent);
}
.compaction-in-progress .compaction-icon {
  animation: compaction-spin 1.2s linear infinite;
}
@keyframes compaction-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes compaction-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Settings: Chat Button ───────────────────────────────────────────── */

.personality-chat-btn {
  background: none;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.personality-chat-btn:hover {
  background: var(--accent-glow);
}

/* ─── Settings: Trash Delete ──────────────────────────────────────────── */

.personality-row.marked-for-delete {
  opacity: 0.5;
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.settings-trash-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition);
  margin-left: auto;
}
.settings-trash-btn.confirm-delete {
  background: var(--danger);
  color: white;
  font-weight: 600;
}

/* ─── Settings: Webhook URL ───────────────────────────────────────────── */

.settings-webhook-url-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.settings-webhook-url {
  font-size: 11px;
  color: var(--text-muted);
}

/* Webhook help snippet */
.webhook-help {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.webhook-help summary {
  cursor: pointer;
  padding: 6px 10px;
  color: var(--accent);
  font-weight: 500;
  font-size: 11px;
  user-select: none;
}

.webhook-help summary:hover {
  color: var(--accent-hover);
}

.webhook-help-body {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
}

.webhook-help-body p {
  margin: 6px 0 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.webhook-help-body p:first-child {
  margin-top: 0;
}

.webhook-help-code {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre;
  overflow-x: auto;
}

.webhook-help-fields {
  margin-top: 6px;
}

.webhook-help-fields p {
  margin: 4px 0 2px;
  font-size: 11px;
}

.webhook-help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin: 2px 0 6px;
}

.webhook-help-table td {
  padding: 2px 8px 2px 0;
  color: var(--text-secondary);
  vertical-align: top;
}

.webhook-help-table td:first-child {
  white-space: nowrap;
  color: var(--text-primary);
}

.webhook-help-table code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ─── Mobile Responsive ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  :root {
    --sidebar-width: 260px;
  }

  #sidebar {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 200ms ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    border-right: none;
    border-left: 1px solid var(--border);
  }

  #sidebar.collapsed {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    border-left-color: var(--border);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .messages {
    padding: 12px 12px;
  }

  .msg {
    max-width: 95%;
  }

  .msg.assistant {
    max-width: 98%;
  }

  .input-bar {
    padding: 6px 8px 8px 8px;
  }

  /* On mobile: show session name in center, hide brand + version */
  .topbar-center {
    display: flex;
    justify-content: flex-start;
    padding-left: 0;
  }
  .topbar-session-info {
    font-size: 13px;
    max-width: 180px;
  }
  .brand { display: none; }
  /* Move voice call button into overflow on mobile */
  .voice-call-btn { display: none !important; }
  .voice-call-overflow-btn { display: flex !important; }

  /* Show ⋯ more button on mobile */
  .topbar-more-btn {
    display: flex !important;
  }

  /* Hide overflow group by default on mobile, show as dropdown when open */
  #topbar-overflow {
    display: none;
    position: absolute;
    top: calc(var(--topbar-height) - 2px);
    right: 4px;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 6px 0;
    z-index: 200;
    min-width: 180px;
    gap: 0;
  }

  #topbar-overflow.open {
    display: flex;
  }

  /* In mobile dropdown: buttons become full-width rows with labels */
  #topbar-overflow .topbar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    border-radius: 0;
    justify-content: flex-start;
    font-size: 13px;
  }

  #topbar-overflow .topbar-btn:hover {
    background: var(--bg-tertiary);
  }

  /* Show labels in mobile dropdown */
  #topbar-overflow .topbar-overflow-label {
    display: inline;
    font-size: 13px;
    color: var(--text-primary);
  }

  .sidebar-picker {
    display: block;
  }

  .tool-card, .tool-result-pill-wrap {
    max-width: 100%;
  }

  .tool-card-body {
    max-width: 100%;
  }

  .msg.user.webhook-compact {
    max-width: 80%;
  }

  .webhook-expand-body {
    max-width: 100%;
  }

  .modal-dialog {
    width: 95%;
  }

  /* Terminal full-screen on mobile */
  .terminal-panel {
    height: calc(100% - var(--topbar-height)) !important;
    max-height: none !important;
    position: fixed !important;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
  }

  /* Settings responsive */
  .settings-body {
    padding: 8px 12px;
  }

  .settings-form-row {
    flex-direction: column;
    gap: 8px;
  }

  .settings-checkbox-row {
    flex-direction: column;
    gap: 8px;
  }

  .personality-row-meta {
    display: none;
  }

  /* Session tabs: wrap so action bar sits below the name on mobile */
  .session-tab {
    flex-wrap: wrap;
  }
  .session-tab .session-info {
    flex: 1 1 auto;
    min-width: 60%;
  }
  /* Always show ⋯ on mobile (no hover) */
  .session-actions-toggle {
    opacity: 1;
  }
  .session-actions.sa-open {
    height: auto;
    flex: 0 0 100%;
    padding: 2px 0 0 14px; /* align with name (dot 6px + gap 8px) */
  }

  /* Pin button always fully visible on mobile */
  .session-tab .session-pin {
    opacity: 1;
  }
}

/* ─── Tablet adjustments ───────────────────────────────────────────────── */

@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }
}

/* ─── Wide screen ──────────────────────────────────────────────────────── */

@media (min-width: 1400px) {
  .messages {
    padding: 20px 40px;
  }

  .msg {
    max-width: 75%;
  }

  .msg.assistant {
    max-width: 80%;
  }
}

/* ─── Print (hide sidebar, inputs) ─────────────────────────────────────── */

@media print {
  #sidebar, #topbar, .input-bar, #reconnect-overlay, #login-overlay, .session-panels {
    display: none !important;
  }

  #chat-area {
    width: 100% !important;
  }

  .messages {
    overflow: visible !important;
  }
}

/* ─── Upload Progress Label ──────────────────────────────────────────── */

.msg-upload-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
  opacity: 0.7;
}

/* ─── Lightbox ────────────────────────────────────────────────────────── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* ─── Message Attachments ─────────────────────────────────────────────── */

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Unified clickable attachment chip (images + non-images) */
.msg-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  max-width: 260px;
  overflow: hidden;
}
.msg-attach-chip:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
}
.msg-attach-thumb {
  max-width: 120px;
  max-height: 80px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}
.msg-attach-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
  padding: 2px;
}
.msg-attach-name {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-attach-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  background: #1a6b3a;
  color: #7dffb3;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ─── Upload Progress States ──────────────────────────────────────────── */

.msg-uploads {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Upload status text inside chip */
.upload-status {
  font-size: 10px;
  font-style: italic;
  white-space: nowrap;
  margin-left: auto;
  padding-left: 4px;
}

/* Uploading state — dashed border, pulsing opacity */
.msg-attach-chip.uploading {
  border-style: dashed;
  border-color: var(--accent);
  opacity: 0.75;
  animation: upload-pulse 1.5s ease-in-out infinite;
}
.msg-attach-chip.uploading .upload-status {
  color: var(--accent);
}

/* Processing state — solid accent border, slower pulse */
.msg-attach-chip.processing {
  border-color: #d4a017;
  opacity: 0.85;
  animation: upload-pulse 2s ease-in-out infinite;
}
.msg-attach-chip.processing .upload-status {
  color: #d4a017;
}

/* Upload done — green accent */
.msg-attach-chip.upload-done {
  border-color: #1a6b3a;
  opacity: 1;
  animation: none;
}
.msg-attach-chip.upload-done .upload-status {
  color: #7dffb3;
  font-style: normal;
  font-weight: 600;
}

/* Upload failed — red border */
.msg-attach-chip.upload-failed {
  border-color: #a83232;
  opacity: 1;
  animation: none;
}
.msg-attach-chip.upload-failed .upload-status {
  color: #ff6b6b;
  font-style: normal;
}

/* Pulsing animation for in-progress uploads */
@keyframes upload-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Upload label — hidden by default, shown during uploads */
.msg.user .msg-upload-label {
  display: none;
}
.msg.user.uploading-active .msg-upload-label {
  display: block;
}

/* ─── File Modal ──────────────────────────────────────────────────────── */

.file-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.file-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.file-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}
.file-modal-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}
.file-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.file-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.file-modal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.file-modal-path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
  text-decoration: none;
  cursor: pointer;
}
a.file-modal-path:hover {
  text-decoration: underline;
}
.file-modal-quick-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.file-modal-qbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  padding: 0;
  line-height: 1;
}
.file-modal-qbtn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-tertiary);
}
.file-modal-meta-extra {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.file-modal-preview {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  background: var(--bg-primary);
}
.file-modal-preview img {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.file-modal-no-preview {
  font-size: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
}
.file-modal-md-pane {
  padding: 0 16px 12px;
}
.file-modal-md-pane.hidden { display: none; }
.file-modal-md-preview {
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  color: var(--text-secondary);
}
.file-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.file-modal-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.file-modal-action-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 72px;
  flex-shrink: 0;
}
.file-modal-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.file-modal-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Path Chips (inline in assistant messages) ───────────────────────── */

.path-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  transition: border-color var(--transition), color var(--transition);
  margin: 0 2px;
}
.path-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Load More Button ────────────────────────────────────────────────── */

/* ─── Idle Session Warning ────────────────────────────────────────────── */
.idle-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9500;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--warning, #f59e0b) 90%, black);
  color: #000;
  font-size: 12px;
  text-align: center;
  animation: idle-slide-in 0.3s ease;
}
.idle-warning-action {
  color: #000;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
@keyframes idle-slide-in {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* ─── File Preview Shortcode Cards ────────────────────────────────────── */
.preview-card {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  margin: 6px 0;
  max-width: 360px;
  overflow: hidden;
  transition: border-color var(--transition);
}
.preview-card:hover { border-color: var(--accent-dim); }
.preview-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background var(--transition);
}
.preview-card-header:hover { background: var(--bg-hover); }
.preview-card-icon { font-size: 16px; flex-shrink: 0; }
.preview-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-card-path {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: auto;
  max-width: 180px;
}
.preview-card-thumb { padding: 0 10px 8px; }
.preview-card-thumb img {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}
.preview-card-actions {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.preview-card-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
}
.preview-card-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ─── HTML Preview (inline iframe + fullscreen overlay) ──────────────── */

.preview-card-iframe-wrap {
  position: relative;
  padding: 0 10px 8px;
}
.preview-card-iframe {
  width: 100%;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.preview-card-iframe-overlay {
  position: absolute;
  inset: 0 10px 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.preview-card-iframe-overlay:hover {
  background: rgba(99,102,241, 0.08);
}
.preview-card-fullscreen {
  color: var(--accent) !important;
}

/* Fullscreen HTML preview overlay */
.html-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}
.html-preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.html-preview-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
}
.html-preview-actions {
  display: flex;
  gap: 8px;
}
.html-preview-btn {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
}
.html-preview-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.html-preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ─── HTML Artifact Preview (inline iframe) ──────────────────────────── */

.html-artifact {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 0;
  background: var(--bg-secondary);
}

.html-artifact-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.html-artifact-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.html-artifact-tab:hover {
  color: var(--text-primary);
}

.html-artifact-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.html-artifact-name {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 10px 6px 4px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.html-artifact-expand {
  margin-left: auto;
  font-size: 14px;
  padding: 6px 10px;
}
.html-artifact-expand + .html-artifact-expand {
  margin-left: 0;
}

/* Keep the <pre> styling flush inside the artifact */
.html-artifact > pre {
  margin: 0;
  border-radius: 0;
  border: none;
}

.html-artifact-preview {
  background: #fff;
  min-height: 200px;
}

.html-artifact-preview.hidden {
  display: none;
}

.html-artifact-iframe {
  width: 100%;
  height: 400px;
  border: none;
  display: block;
  background: #fff;
}

/* ─── HTML Artifact Side Panel ───────────────────────────────────────── */

.html-artifact-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
  animation: artifact-panel-fadein 0.2s ease-out;
}

@keyframes artifact-panel-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.html-artifact-panel {
  width: min(600px, 85vw);
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  animation: artifact-panel-slidein 0.2s ease-out;
}

@keyframes artifact-panel-slidein {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.html-artifact-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.html-artifact-panel-close {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.html-artifact-panel-close:hover {
  color: var(--danger);
  background: var(--bg-tertiary);
}

.html-artifact-panel-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ─── File Modal: HTML Preview Tabs ──────────────────────────────────── */

.fm-html-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.fm-html-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.fm-html-tab:hover {
  color: var(--text-primary);
}

.fm-html-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.fm-html-expand {
  margin-left: auto;
  font-size: 14px;
  padding: 6px 10px;
}

.fm-html-preview {
  background: #fff;
  flex: 1;
  min-height: 0;
}

.fm-html-preview.hidden {
  display: none;
}

.fm-html-iframe {
  width: 100%;
  height: 50vh;
  border: none;
  display: block;
  background: #fff;
}

.fm-html-code {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.fm-html-code.hidden {
  display: none;
}

.fm-html-code-inner {
  max-height: 50vh;
  overflow: auto;
}

.fm-html-code-inner pre {
  margin: 0;
  border-radius: 0;
  border: none;
}

/* When showing HTML preview, make file modal taller */
.file-modal:has(.fm-html-tabs) {
  max-height: 85vh;
}

/* ─── Load More Sentinel (lazy-load trigger) ─────────────────────────── */
.load-more-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
}

/* ─── Previous Conversations Banner ────────────────────────────────────── */
.prev-gen-banner {
  position: sticky;
  top: 4px; /* near top, sentinel is invisible */
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 0 auto 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  width: fit-content;
}
.prev-gen-icon { font-size: 14px; }
.prev-gen-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.prev-gen-btn:hover {
  opacity: 0.85;
}

/* ─── Generation Divider (between reset generations) ───────────────────── */
.generation-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.generation-divider::before,
.generation-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.generation-divider span {
  padding: 2px 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ─── Brain Dump Modal ─────────────────────────────────────────────────── */

.braindump-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 72px;
}

.braindump-modal.hidden { display: none; }

.braindump-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 500px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.braindump-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.braindump-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.braindump-hint {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.braindump-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition);
}

.braindump-close:hover { color: var(--danger); }

.braindump-textarea {
  resize: vertical;
  min-height: 140px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  line-height: 1.6;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.braindump-textarea::placeholder { color: var(--text-muted); }

.braindump-status {
  font-size: 11px;
  color: var(--danger);
  padding: 5px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(239, 68, 68, 0.05);
}

.braindump-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

.braindump-record-btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.braindump-record-btn:hover { border-color: var(--accent-dim); color: var(--accent); }
.braindump-record-btn.recording { border-color: var(--danger); color: var(--danger); background: rgba(239, 68, 68, 0.1); }

.braindump-send-btn {
  margin-left: auto;
  font-size: 12px;
  padding: 5px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-dim);
  background: var(--accent-glow);
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition);
}

.braindump-send-btn:hover { background: var(--accent); color: var(--bg-primary); }
.braindump-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Kill Switch Modal ────────────────────────────────────────────────────── */

.ks-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 250;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}

.ks-modal.hidden { display: none; }

.ks-dialog {
  background: var(--bg-secondary);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  width: 480px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(239, 68, 68, 0.15), 0 0 0 1px rgba(239, 68, 68, 0.1);
  overflow: hidden;
}

.ks-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(239, 68, 68, 0.05);
}

.ks-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  flex: 1;
}

.ks-subtitle {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.ks-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition);
}

.ks-close:hover { color: var(--danger); }

.ks-status {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.ks-status-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.ks-stat {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.ks-stat-val {
  font-weight: 700;
  color: var(--text-primary);
}

.ks-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
}

.ks-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  position: relative;
}

.ks-btn:hover {
  border-color: var(--text-muted);
  background: var(--bg-surface);
}

.ks-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ks-btn-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.ks-btn-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.ks-btn-desc {
  font-size: 11px;
  color: var(--text-muted);
  display: none;
}

.ks-btn:hover .ks-btn-desc {
  display: block;
  position: absolute;
  left: 48px;
  top: 28px;
}

/* Color variants */
.ks-btn-orange:hover { border-color: var(--warning); }
.ks-btn-orange:hover .ks-btn-label { color: var(--warning); }

.ks-btn-red { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.05); }
.ks-btn-red:hover { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.ks-btn-red .ks-btn-label { color: var(--danger); }

.ks-btn-green:hover { border-color: var(--success); }
.ks-btn-green:hover .ks-btn-label { color: var(--success); }

/* Confirm state */
.ks-btn.confirming {
  animation: ks-pulse 0.6s ease-in-out infinite alternate;
}

.ks-btn.confirming .ks-btn-label::after {
  content: " — Click again to confirm";
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
}

@keyframes ks-pulse {
  from { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  to   { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* Output log */
.ks-output {
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.ks-output.hidden { display: none; }

.ks-output .ks-line-ok { color: var(--success); }
.ks-output .ks-line-err { color: var(--danger); }
.ks-output .ks-line-info { color: var(--accent); }

/* Master kill button — extra emphasis */
.ks-btn-master {
  border-width: 2px;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.08);
}
.ks-btn-master:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
}
.ks-btn-master .ks-btn-label {
  font-size: 16px;
  letter-spacing: 1px;
}

/* Process Monitor Section */
.ks-process-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.ks-process-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ks-process-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ks-refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ks-refresh-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ks-process-list {
  max-height: 200px;
  overflow-y: auto;
}

.ks-process-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 16px 0;
}

.ks-proc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--font-mono);
}

.ks-proc-table thead th {
  text-align: left;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.ks-proc-table tbody td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.05));
  color: var(--text-secondary);
}

.ks-proc-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ks-proc-pid {
  font-weight: 600;
  color: var(--accent);
}

.ks-proc-cmd {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ks-proc-kill {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.ks-proc-kill:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
}
.ks-proc-kill:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Dev environment indicator ────────────────────────────────────────────── */
/* Applied when window.location.hostname contains 'dev' or 'localhost'        */

.dev-badge {
  display: none; /* hidden by default */
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #fff;
  background: #f97316;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  margin-left: 2px;
  vertical-align: middle;
  line-height: 1;
}

.dev-env .dev-badge {
  display: inline-block;
}

.dev-env .brand {
  background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dev-env #topbar {
  border-bottom: 1px solid rgba(249, 115, 22, 0.35);
}

/* ─── Changelog + Help Modal ────────────────────────────────────────────── */

.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.help-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg, 0 20px 60px rgba(0,0,0,0.4));
}

/* Header: tabs + close button */
.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-tabs {
  display: flex;
}

.help-tab {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px; /* Overlap the header border */
}

.help-tab:hover {
  color: var(--text-secondary);
}

.help-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.help-version {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: auto;
  margin-right: 10px;
}

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

.help-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* Tab content panels */
.help-tab-content {
  overflow-y: auto;
  flex: 1;
}

/* ── Changelog tab ── */
.help-changelog-list {
  padding: 8px 0;
}

.cl-entry {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.cl-entry:last-child {
  border-bottom: none;
}

.cl-entry-latest {
  background: var(--accent-glow, rgba(99,102,241,0.06));
}

.cl-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.cl-version {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.cl-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  letter-spacing: 0.3px;
}

.cl-label {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

.cl-date {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: auto;
}

.cl-changes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cl-changes li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 14px;
  position: relative;
}

.cl-changes li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

.cl-error {
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ── Help tab ── */
.help-content {
  padding: 8px 0 16px;
}

.help-section {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
}

.help-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.help-shortcuts {
  border-collapse: collapse;
  width: 100%;
}

.help-shortcuts td {
  padding: 4px 8px 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  vertical-align: middle;
}

.help-shortcuts td:first-child {
  white-space: nowrap;
  width: 160px;
}

.help-shortcuts kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-tertiary);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-right: 2px;
}

.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.help-list li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 14px;
  position: relative;
}

.help-list li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

.help-list code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

/* Mobile */
@media (max-width: 768px) {
  .help-dialog {
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
    align-self: flex-end;
  }

  .help-modal {
    align-items: flex-end;
    padding: 0;
  }
}

/* ─── Session Tab — Unread Badge ───────────────────────────────────────── */

.session-tab.has-unread .session-name::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--brand-crimson);
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  animation: unread-pulse 2s ease-in-out infinite;
}

@keyframes unread-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ─── Session Tab — Response Pulse ─────────────────────────────────────── */

.session-tab.tab-pulse {
  animation: tab-response-pulse 0.5s ease-in-out 3;
}

/* ─── Session Tab — Drag & Drop ────────────────────────────────────────── */
.session-tab.pinned { cursor: grab; }
.session-tab.pinned:active { cursor: grabbing; }
.session-tab.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent);
  background: var(--bg-tertiary);
}

@keyframes tab-response-pulse {
  0%, 100% { background: var(--bg-secondary); }
  50% { background: color-mix(in srgb, var(--accent) 15%, var(--bg-secondary)); }
}

/* Light theme: sidebar is dark navy, so pulse must use subtle white glow */
[data-theme="light"] .session-tab.tab-pulse {
  animation: tab-response-pulse-light 0.5s ease-in-out 3;
}
@keyframes tab-response-pulse-light {
  0%, 100% { background: transparent; }
  50% { background: rgba(255, 255, 255, 0.15); }
}

/* ─── Session Tab — Inline Rename Input ────────────────────────────────── */

.session-rename-input {
  background: var(--bg-primary);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  padding: 1px 5px;
  width: 100%;
  outline: none;
}

/* ─── Global Settings Card ─────────────────────────────────────────────── */

.global-settings-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.global-settings-card .settings-section-title {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.global-settings-card .settings-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ─── File Explorer Sidebar (right panel) ──────────────────────────────── */

:root {
  --file-panel-width: 300px;
}

.file-panel {
  width: var(--file-panel-width);
  min-width: var(--file-panel-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 200ms ease, min-width 200ms ease, border-color 200ms ease;
  flex-shrink: 0;
}

.file-panel.collapsed {
  width: 0;
  min-width: 0;
  border-left-color: transparent;
}

/* Header */
.fp-header {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  gap: 4px;
  flex-shrink: 0;
  min-height: 36px;
}

.fp-breadcrumb {
  flex: 1;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fp-bc-link {
  color: var(--accent);
  cursor: pointer;
}
.fp-bc-link:hover { text-decoration: underline; }
.fp-bc-current { color: var(--text-secondary); }

.fp-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.fp-toolbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.fp-toolbar-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* File tree */
.fp-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.fp-status {
  padding: 12px 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.fp-empty-dir { color: var(--text-muted); }
.fp-error-msg { color: var(--danger); font-style: normal; }

/* File/folder rows */
.fp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: background var(--transition);
  user-select: none;
  min-height: 28px;
}

.fp-row:hover { background: var(--bg-tertiary); }

.fp-row-icon {
  font-size: 13px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.fp-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
}

.fp-row-size {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.fp-row-actions {
  display: flex;
  gap: 1px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.fp-row:hover .fp-row-actions { opacity: 1; }

.fp-act-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 2px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: all var(--transition);
}

.fp-act-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

/* Drag-over highlight */
.fp-drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

/* ── File Panel Modals ── */

.fp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fp-modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  width: 90%;
  max-width: 700px;
  max-height: 82vh;
  overflow: hidden;
}

.fp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.fp-modal-title {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fp-modal-acts {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.fp-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}

.fp-modal-close:hover { color: var(--text-primary); }

.fp-modal-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.fp-modal-btn-pri {
  background: var(--accent);
  border: none;
  color: #fff;
}
.fp-modal-btn-pri:hover { background: var(--accent-dim); }
.fp-modal-btn-pri:disabled { opacity: 0.5; cursor: not-allowed; }

.fp-modal-btn-sec {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none !important;
}
.fp-modal-btn-sec:hover { background: var(--bg-surface); }

.fp-modal-content {
  flex: 1;
  overflow: auto;
  padding: 12px;
}

.fp-preview-pre {
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.fp-preview-pre.hidden { display: none; }

.fp-html-iframe {
  width: 100%;
  height: 500px;
  border: none;
  border-radius: var(--radius-sm);
  background: #fff;
}
.fp-html-iframe.hidden { display: none; }

/* Edit dialog */
.fp-edit-dialog {
  max-height: 90vh;
}

.fp-edit-textarea {
  flex: 1;
  min-height: 420px;
  max-height: 72vh;
  background: var(--bg-tertiary);
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 12px;
  resize: vertical;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

/* Mobile: file panel as bottom sheet / full overlay */
@media (max-width: 768px) {
  .file-panel {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: 92vw !important;
    min-width: unset !important;
    z-index: 110;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 200ms ease, border-color 200ms ease;
    border-left: 1px solid var(--border);
  }
  .file-panel:not(.collapsed) {
    transform: translateX(0);
  }
  .file-panel.collapsed {
    transform: translateX(100%);
    width: 92vw !important;
    border-left-color: var(--border);
  }
}

/* ─── Session Switcher (Ctrl+K) ─────────────────────────────────────────── */

.session-switcher-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.session-switcher-dialog {
  width: 480px;
  max-width: 90vw;
  max-height: 58vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ss-input-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ss-input-icon { color: var(--text-muted); flex-shrink: 0; }

.ss-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
}

.ss-input::placeholder { color: var(--text-muted); }

.ss-list {
  flex: 1;
  overflow-y: auto;
  min-height: 40px;
}

.ss-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--transition);
}

.ss-item:hover,
.ss-item.ss-selected {
  background: var(--bg-tertiary);
}

.ss-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ss-dot.idle { background: var(--success); }
.ss-dot.busy { background: var(--warning); animation: dot-pulse 1.5s ease-in-out infinite; }
.ss-dot.error { background: var(--danger); }

.ss-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ss-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-preview {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.ss-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.ss-check {
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}

.ss-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.ss-footer {
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.ss-footer kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--font-mono);
}

/* Divider between open sessions and unopened personalities */
.ss-divider {
  padding: 6px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

/* Unopened personality items — slightly dimmer */
.ss-item.ss-unopened {
  opacity: 0.7;
}
.ss-item.ss-unopened:hover,
.ss-item.ss-unopened.ss-selected {
  opacity: 1;
}

/* + icon for unopened personalities (replaces status dot) */
.ss-dot-new {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px dashed var(--text-muted);
  margin-right: 4px;
}
.ss-item.ss-unopened:hover .ss-dot-new,
.ss-item.ss-unopened.ss-selected .ss-dot-new {
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Metrics Card (Settings Panel) ─────────────────────────────────────── */

.metrics-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.metrics-period-tabs {
  display: inline-flex;
  gap: 2px;
  margin-left: 10px;
  vertical-align: middle;
}

.metrics-period-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 7px;
  transition: background 0.15s, color 0.15s;
}

.metrics-period-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.metrics-period-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.metrics-loading,
.metrics-error {
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.metrics-error { color: var(--danger); }

.metrics-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.metrics-tile {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 12px;
  min-width: 80px;
  flex: 1;
  text-align: center;
}

.metrics-tile-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1.2;
}

.metrics-tile-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metrics-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.metrics-table thead tr {
  border-bottom: 1px solid var(--border);
}

.metrics-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 4px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metrics-table td {
  padding: 4px 6px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-family: var(--font-mono);
}

.metrics-table td.metrics-agent-name {
  color: var(--text-secondary);
  font-family: var(--font-sans, inherit);
  font-size: 12px;
}

.metrics-table tr:last-child td { border-bottom: none; }
.metrics-table tr:hover td { background: var(--bg-tertiary); }

.metrics-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 0;
  text-align: center;
}

.metrics-footnote {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  font-family: var(--font-mono);
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* ─── In-Chat Search Bar ────────────────────────────────────────────────── */

.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
}

.chat-search-bar > svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.chat-search-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-ui);
  padding: 3px 8px;
  outline: none;
  min-width: 0;
}
.chat-search-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.chat-search-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-mono);
  min-width: 52px;
  text-align: right;
}

.chat-search-nav {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1.4;
  transition: background var(--transition), color var(--transition);
}
.chat-search-nav:hover { background: var(--bg-surface); color: var(--text-primary); }

.chat-search-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.chat-search-close:hover { color: var(--text-primary); }

/* Search highlights */
mark.sh {
  background: rgba(234, 179, 8, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
mark.sh.sh-current {
  background: rgba(234, 179, 8, 0.75);
  outline: 1px solid rgba(234, 179, 8, 0.9);
}

/* Light theme adjustments */
[data-theme="light"] mark.sh { background: rgba(234, 179, 8, 0.4); }
[data-theme="light"] mark.sh.sh-current { background: rgba(234, 179, 8, 0.85); }
[data-theme="light"] .chat-search-bar { background: var(--bg-secondary); }

/* ─── Knowledge Pipeline Card ───────────────────────────────────────────── */

.kp-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 16px;
}

.kp-card .settings-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.kp-refresh-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  margin-left: auto;
}
.kp-refresh-btn:hover { color: var(--accent); }

/* Pipeline stage flow */
.kp-pipeline-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.kp-stage-tile {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  text-align: center;
  min-width: 72px;
}
.kp-stage-tile.kp-tile-done { border-color: var(--success); }

.kp-stage-val {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.2;
}

.kp-stage-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.kp-stage-arrow {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}

/* Summary badges */
.kp-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.kp-badge {
  font-size: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.kp-badge.kp-badge-warn { border-color: var(--warning); color: var(--warning); }
.kp-badge.kp-badge-err  { border-color: var(--danger);  color: var(--danger); }

/* Approval queue */
.kp-approval-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.kp-approval-row {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.kp-approval-row:last-child { margin-bottom: 0; }

.kp-approval-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.kp-channel {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 1px 5px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.kp-ch-email   { color: #60a5fa; border-color: #60a5fa33; background: #60a5fa0d; }
.kp-ch-whatsapp { color: #4ade80; border-color: #4ade8033; background: #4ade800d; }
.kp-ch-teams   { color: #a78bfa; border-color: #a78bfa33; background: #a78bfa0d; }
.kp-ch-helpdesk { color: #fb923c; border-color: #fb923c33; background: #fb923c0d; }

.kp-approval-recipient {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.kp-approval-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.kp-approval-by {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.kp-approval-subject {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kp-approval-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  margin-bottom: 8px;
  max-height: 80px;
  overflow: hidden;
  position: relative;
}

.kp-approval-actions {
  display: flex;
  gap: 6px;
}

.kp-approve-btn, .kp-reject-btn {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  cursor: pointer;
  font-weight: 500;
  transition: background var(--transition);
}

.kp-approve-btn {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--success);
}
.kp-approve-btn:hover { background: rgba(34, 197, 94, 0.22); }

.kp-reject-btn {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.kp-reject-btn:hover { background: rgba(239, 68, 68, 0.16); }


/* ── Knowledge Facts Browser ─────────────────────────────────────────────── */

.facts-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.facts-search-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.facts-search-input:focus { border-color: var(--accent); }

.facts-type-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  max-width: 140px;
}
.facts-type-select:focus { border-color: var(--accent); }

.facts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.facts-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.facts-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  max-width: 0;
}
.facts-table tbody tr[data-id] {
  cursor: pointer;
  transition: background var(--transition);
}
.facts-table tbody tr[data-id]:hover { background: var(--bg-hover); }
.facts-table tbody tr[data-id]:last-child td { border-bottom: none; }

.fact-type-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(var(--accent-rgb, 99, 102, 241), 0.12);
  color: var(--accent);
}
.fact-type-badge.fact-type-contact   { background: rgba(34,197,94,.12); color: #22c55e; }
.fact-type-badge.fact-type-project   { background: rgba(59,130,246,.12); color: #3b82f6; }
.fact-type-badge.fact-type-decision  { background: rgba(245,158,11,.12); color: #f59e0b; }
.fact-type-badge.fact-type-preference{ background: rgba(168,85,247,.12); color: #a855f7; }
.fact-type-badge.fact-type-config    { background: rgba(20,184,166,.12); color: #14b8a6; }
.fact-type-badge.fact-type-note      { background: rgba(156,163,175,.12); color: #9ca3af; }

.fact-key {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.fact-summary {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fact-ts {
  color: var(--text-tertiary);
  font-size: 11px;
  white-space: nowrap;
}

.fact-value-row td {
  padding: 0 8px 8px 8px;
  background: var(--bg-secondary);
}
.fact-value-json {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.fact-del-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  transition: color var(--transition), background var(--transition);
}
.fact-del-btn:hover { color: var(--danger); background: rgba(239,68,68,.1); }

.facts-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.facts-count { flex: 1; }
.facts-pag-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.facts-pag-btn:hover { background: var(--bg-hover); }
.facts-page-info { color: var(--text-secondary); }

/* ── Facts — Add Form ────────────────────────────────────────────────────── */
.kp-add-fact-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  transition: background var(--transition), color var(--transition);
}
.kp-add-fact-btn:hover { background: var(--accent); color: #fff; }

.facts-add-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.facts-form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}
.facts-form-row .settings-form-group { flex: 1; }
.fact-value-textarea {
  width: 100%;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  resize: vertical;
}
.facts-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ── Facts toolbar action buttons ───────────────────────────────────────── */
.facts-toolbar-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.facts-toolbar-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
.facts-toolbar-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.facts-toolbar-btn-muted { color: var(--text-muted); }
.facts-toolbar-btn-muted:hover { color: #ef4444; border-color: #ef4444; background: rgba(239,68,68,.06); }

/* ── Security / Biometric Credentials card ───────────────────────────────── */
.security-section { }
.security-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
  line-height: 1.5;
}
.credential-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.credential-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.credential-icon {
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.credential-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.credential-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.credential-date {
  font-size: 11px;
  color: var(--text-muted);
}
.credential-remove-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.credential-remove-btn:hover {
  background: rgba(239,68,68,.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* ── Credential Profiles (Dual Subscription Rotation) ─────────────────── */
.cred-profiles-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cred-settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}

.cred-setting-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.cred-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.cred-scan-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  margin-left: auto;
}
.cred-scan-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.cred-profile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cred-profile-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color var(--transition);
}
.cred-profile-item.active {
  border-color: var(--accent-dim);
}

.cred-profile-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cred-status-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.cred-status-badge.cred-active { background: rgba(34,197,94,.15); color: var(--success); }
.cred-status-badge.cred-standby { background: var(--bg-tertiary); color: var(--text-muted); }
.cred-status-badge.cred-disabled { background: var(--bg-tertiary); color: var(--border); text-decoration: line-through; }

.cred-label-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.cred-label-input:hover,
.cred-label-input:focus {
  border-color: var(--border);
  background: var(--bg-tertiary);
}

.cred-profile-meta {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-wrap: wrap;
}

.cred-error-text {
  color: #f59e0b;
  cursor: help;
}

.cred-profile-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.cred-activate-btn,
.cred-test-btn,
.cred-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.cred-activate-btn:hover,
.cred-test-btn:hover,
.cred-toggle-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.cred-activate-btn:disabled,
.cred-test-btn:disabled,
.cred-toggle-btn:disabled { opacity: 0.5; cursor: default; }
.cred-activate-btn { color: var(--accent); border-color: var(--accent-dim); }

/* Delete button — small red × */
.cred-delete-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  margin-left: auto;
}
.cred-delete-btn:hover {
  color: #ef4444;
  border-color: rgba(239,68,68,.3);
  background: rgba(239,68,68,.08);
}
.cred-delete-btn:disabled { opacity: 0.5; cursor: default; }

/* Token type badge */
.cred-type-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cred-type-token {
  background: rgba(139,92,246,.15);
  color: #a78bfa;
}

/* ── Add token section ─────────────────────────────────────────────────── */
.cred-add-token-section {
  margin-bottom: 8px;
}

.cred-add-token-toggle {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius);
  width: 100%;
  text-align: left;
  transition: all var(--transition);
}
.cred-add-token-toggle:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: rgba(99,102,241,.04);
}

.cred-add-token-form {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cred-add-token-form.hidden { display: none; }

.cred-token-label-input,
.cred-token-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
  font-family: var(--font-mono);
}
.cred-token-label-input {
  font-family: var(--font-primary);
}
.cred-token-label-input:focus,
.cred-token-input:focus {
  border-color: var(--accent);
}
.cred-token-input::placeholder {
  font-family: var(--font-mono);
  font-size: 11px;
}

.cred-add-token-actions {
  display: flex;
  gap: 8px;
}

.cred-token-save-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition);
}
.cred-token-save-btn:hover { opacity: 0.85; }
.cred-token-save-btn:disabled { opacity: 0.5; cursor: default; }

.cred-token-cancel-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.cred-token-cancel-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text-primary);
}

.cred-token-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}
.cred-token-hint code {
  background: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}

/* ── Personality export button ───────────────────────────────────────────── */
.personality-export-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}
.personality-export-btn:hover { color: var(--accent); }

/* ── DB Explorer ──────────────────────────────────────────────────────────── */

.dbe-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  z-index: 10;
  overflow: hidden;
}
.dbe-panel.hidden { display: none !important; }

/* Header */
.dbe-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dbe-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.dbe-subtitle {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: 4px;
}

/* Body */
.dbe-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar toggle */
.dbe-sidebar-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.dbe-sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* Sidebar */
.dbe-sidebar {
  width: 192px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 6px 0;
  background: var(--bg-secondary);
  transition: width 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
}
.dbe-sidebar.dbe-sidebar-collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
  opacity: 0;
}

/* CSV export button */
.dbe-csv-btn {
  font-size: 11px !important;
  font-family: var(--font-mono);
}
.dbe-group { margin-bottom: 6px; }
.dbe-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 6px 12px 3px;
}
.dbe-tbl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.1s;
  gap: 4px;
}
.dbe-tbl-item:hover { background: var(--bg-hover); }
.dbe-tbl-active {
  background: var(--accent-dim, rgba(99,102,241,0.1));
  border-right: 2px solid var(--accent);
}
.dbe-tbl-active .dbe-tbl-name { color: var(--accent); }
.dbe-tbl-name {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dbe-tbl-count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 5px;
  flex-shrink: 0;
}

/* Main area */
.dbe-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Toolbar */
.dbe-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.dbe-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input, var(--bg-tertiary));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  flex: 1;
  min-width: 120px;
  max-width: 260px;
}
.dbe-search-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.dbe-search {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  width: 100%;
  font-family: var(--font-ui, inherit);
}
.dbe-search-clr {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.dbe-search-clr:hover { color: var(--text-primary); }
.dbe-count-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  margin-left: auto;
}
.dbe-pager {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dbe-page-btn {
  background: var(--bg-surface, var(--bg-secondary));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 8px;
  line-height: 1.3;
  transition: background 0.1s, color 0.1s;
}
.dbe-page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.dbe-page-btn:disabled { opacity: 0.35; cursor: default; }

/* Table */
.dbe-tbl-wrap {
  flex: 1;
  overflow: auto;
}
table.dbe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dbe-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-secondary);
}
.dbe-th {
  text-align: left;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.dbe-th:hover { color: var(--text-primary); }
.dbe-th-on { color: var(--accent); }
.dbe-table td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-secondary);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 11.5px;
  vertical-align: middle;
}
.dbe-table tr:hover td { background: var(--bg-hover); }
.dbe-empty-row {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 28px;
  max-width: none !important;
}

/* Cell types */
.dbe-null  { color: var(--text-muted); font-style: italic; }
.dbe-ts    { color: var(--text-muted); cursor: default; }
.dbe-bool-t { color: var(--success); }
.dbe-bool-f { color: var(--danger); }
.dbe-json  { color: var(--text-muted); cursor: default; font-size: 10.5px; }
.dbe-trunc { cursor: default; }
.dbe-state-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
}

/* Placeholder / Loading */
.dbe-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  height: 120px;
}

/* ─── Export Format Picker ───────────────────────────────────────────────── */
.export-picker {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  z-index: 9999;
  min-width: 160px;
}
.export-picker-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 6px 6px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.export-picker-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition);
}
.export-picker-btn span {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-left: 4px;
}
.export-picker-btn:hover { background: var(--bg-tertiary); }

/* ─── Collapsible Help Sections ──────────────────────────────────────────── */
.help-section-title::after {
  content: " ▾";
  font-size: 10px;
  opacity: 0.5;
  transition: transform 0.15s;
  display: inline-block;
}
.help-section.collapsed .help-section-title::after {
  transform: rotate(-90deg);
}
.help-section.collapsed > *:not(.help-section-title) {
  display: none;
}

/* ─── Compact / Dense Mode ───────────────────────────────────────────────── */
body.compact-mode .msg { padding: 5px 16px; }
body.compact-mode .msg-content { font-size: 13px; line-height: 1.55; }
body.compact-mode .tool-card { margin: 1px 0; }
body.compact-mode .tool-card-header { padding: 2px 8px; font-size: 11px; }
body.compact-mode .session-tab { padding: 5px 12px; }
body.compact-mode .msg-time { font-size: 9px; }

/* ─── Session Pin Button ──────────────────────────────────────────────────── */
.session-tab .session-pin {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  opacity: 0.18;
  filter: grayscale(1);
  transition: all var(--transition);
  flex-shrink: 0;
}

.session-tab .session-pin:hover {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.session-tab .session-pin.pinned {
  opacity: 1;
  filter: grayscale(0);
  color: var(--accent);
}

/* ─── Session Color Labels ────────────────────────────────────────────────── */
/* ─── Model Switcher Badge ────────────────────────────────────────────────── */
.session-tab .session-model-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  padding: 0px 4px;
  border-radius: 3px;
  opacity: 0.7;
  transition: all var(--transition);
  flex-shrink: 0;
  line-height: 1.4;
}
.session-tab .session-model-btn:hover {
  opacity: 1;
}
.session-tab .session-model-btn.model-sonnet {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.session-tab .session-model-btn.model-sonnet:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
}
.session-tab .session-model-btn.model-opus {
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.4);
}
.session-tab .session-model-btn.model-opus:hover {
  background: rgba(192, 132, 252, 0.12);
  border-color: #c084fc;
}
.session-tab .session-model-btn.model-haiku {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
}
.session-tab .session-model-btn.model-haiku:hover {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border-color: var(--success);
}
[data-theme="light"] .session-tab .session-model-btn {
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.5);
}
[data-theme="light"] .session-tab .session-model-btn:hover {
  opacity: 1;
}
[data-theme="light"] .session-tab .session-model-btn.model-sonnet {
  color: rgba(129, 178, 255, 0.9);
  border-color: rgba(129, 178, 255, 0.3);
}
[data-theme="light"] .session-tab .session-model-btn.model-opus {
  color: rgba(200, 160, 255, 0.9);
  border-color: rgba(200, 160, 255, 0.3);
}
[data-theme="light"] .session-tab .session-model-btn.model-haiku {
  color: rgba(134, 239, 172, 0.9);
  border-color: rgba(134, 239, 172, 0.3);
}

.session-tab .session-bubble-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 2px;
  opacity: 0.35;
  transition: all var(--transition);
  flex-shrink: 0;
  line-height: 1;
}
.session-tab .session-bubble-btn:hover {
  opacity: 0.8;
  color: var(--accent);
}
.session-tab .session-bubble-btn.in-bubbles {
  opacity: 1;
  color: var(--accent);
}

.session-tab .session-color-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  opacity: 0.35;
  filter: grayscale(1);
  transition: all var(--transition);
  flex-shrink: 0;
}
.session-tab .session-color-btn:hover {
  opacity: 0.8;
  filter: grayscale(0);
  color: var(--text-primary);
}
/* When a color is set — show button in that color, always visible */
.session-tab[class*="sc-"] .session-color-btn {
  opacity: 1;
  filter: grayscale(0);
}
/* Border-left color overrides */
.session-tab.sc-red    { border-left-color: #ef4444 !important; }
.session-tab.sc-orange { border-left-color: #f97316 !important; }
.session-tab.sc-green  { border-left-color: #22c55e !important; }
.session-tab.sc-blue   { border-left-color: #3b82f6 !important; }
.session-tab.sc-purple { border-left-color: #a855f7 !important; }
.session-tab.sc-pink   { border-left-color: #ec4899 !important; }
/* Color dot tint for the button when color is set */
.session-tab.sc-red    .session-color-btn { color: #ef4444; }
.session-tab.sc-orange .session-color-btn { color: #f97316; }
.session-tab.sc-green  .session-color-btn { color: #22c55e; }
.session-tab.sc-blue   .session-color-btn { color: #3b82f6; }
.session-tab.sc-purple .session-color-btn { color: #a855f7; }
.session-tab.sc-pink   .session-color-btn { color: #ec4899; }

/* ─── Session Last Message Preview ─────────────────────────────────────── */
.session-tab .session-last-msg {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  opacity: 0.7;
}
.session-tab.active .session-last-msg {
  opacity: 0.85;
}

/* ─── Sidebar Resize Handle ─────────────────────────────────────────────── */
.sidebar-resize {
  width: 4px;
  flex-shrink: 0;
  background: transparent;
  cursor: col-resize;
  transition: background var(--transition);
  z-index: 10;
  position: relative;
}
.sidebar-resize:hover,
.sidebar-resize.dragging {
  background: var(--accent-dim);
}
/* Hide resize handle when sidebar is collapsed / in focus mode */
body.focus-mode #sidebar {
  display: none;
}
body.focus-mode .sidebar-resize {
  display: none;
}
@media (max-width: 768px) {
  .sidebar-resize {
    display: none;
  }
}

/* ─── Session Tab Context Menu ──────────────────────────────────────────── */
.session-ctx-menu {
  position: fixed;
  z-index: 9000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  min-width: 170px;
  padding: 4px 0;
  font-size: 13px;
  user-select: none;
}
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
}
.ctx-menu-item:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}
.ctx-menu-item.ctx-menu-danger:hover {
  color: var(--danger);
}
.ctx-menu-icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
}
.ctx-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.ctx-menu-colors {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
}
.ctx-menu-color-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 2px;
  flex-shrink: 0;
}
.ctx-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.ctx-color-swatch:hover {
  transform: scale(1.25);
}
.ctx-color-swatch.active {
  border-color: var(--text-primary);
}
.ctx-color-none {
  background: var(--bg-tertiary);
  border-color: var(--border);
  font-size: 9px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── File Panel Resize Handle ─────────────────────────────────────────── */
.file-panel-resize {
  width: 4px;
  flex-shrink: 0;
  background: transparent;
  cursor: col-resize;
  transition: background var(--transition);
  z-index: 10;
  position: relative;
}
.file-panel-resize:hover,
.file-panel-resize.dragging {
  background: var(--accent-dim);
}
.file-panel.collapsed + .file-panel-resize,
.file-panel-resize.hidden {
  display: none;
}
body.focus-mode .file-panel-resize {
  display: none;
}
@media (max-width: 768px) {
  .file-panel-resize {
    display: none;
  }
}

/* ─── File Extension Icon Badges ───────────────────────────────────────── */
.fp-row-icon {
  display: inline-flex;
  width: 26px;
  height: 16px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 3px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
  letter-spacing: -0.3px;
  line-height: 1;
}
.fp-row-icon.fp-icon-emoji {
  font-size: 13px;
  width: 20px;
  background: none;
}
.fp-icon-js   { background: #f7df1e22; color: #f7df1e; }
.fp-icon-ts   { background: #3178c622; color: #3178c6; }
.fp-icon-py   { background: #3776ab22; color: #5ba0d0; }
.fp-icon-json { background: #f9731622; color: #f97316; }
.fp-icon-md   { background: #14b8a622; color: #14b8a6; }
.fp-icon-css  { background: #a855f722; color: #a855f7; }
.fp-icon-html { background: #e3490022; color: #e34900; }
.fp-icon-sh   { background: #22c55e22; color: #22c55e; }
.fp-icon-sql  { background: #3b82f622; color: #3b82f6; }
.fp-icon-cfg  { background: #6b728022; color: #9ca3af; }
.fp-icon-go   { background: #00add822; color: #00add8; }
.fp-icon-rs   { background: #dea58422; color: #dea584; }
.fp-icon-java { background: #ed8b0022; color: #ed8b00; }
.fp-icon-c    { background: #55555522; color: #a8b1c0; }
.fp-icon-pdf  { background: #ef444422; color: #ef4444; }
.fp-icon-doc  { background: #2563eb22; color: #60a5fa; }
.fp-icon-xls  { background: #16a34a22; color: #4ade80; }
.fp-icon-zip  { background: #78716c22; color: #a8a29e; }
.fp-icon-log  { background: #6b728022; color: #9ca3af; }
.fp-icon-yml  { background: #ef444422; color: #f87171; }
.fp-icon-rb   { background: #cc342d22; color: #cc342d; }
.fp-icon-php  { background: #777bb322; color: #777bb3; }

/* ─── Syntax Highlighted File Editor ───────────────────────────────────── */
.fp-edit-dialog {
  max-width: 860px !important;
  width: 90vw;
  height: 82vh;
  display: flex;
  flex-direction: column;
}
.fp-editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
.fp-editor-wrap textarea,
.fp-editor-wrap .fp-editor-highlight {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  margin: 0;
  border: none;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  -moz-tab-size: 2;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  resize: none;
}
.fp-editor-wrap textarea {
  color: transparent;
  caret-color: var(--text-primary);
  background: transparent;
  z-index: 2;
  outline: none;
  -webkit-text-fill-color: transparent;
}
.fp-editor-wrap .fp-editor-highlight {
  z-index: 1;
  pointer-events: none;
  background: var(--bg-primary);
  color: var(--text-primary);
}
.fp-editor-wrap .fp-editor-highlight code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  display: block;
  min-height: 100%;
}
/* Override hljs background to match our theme */
.fp-editor-wrap .fp-editor-highlight pre {
  background: transparent !important;
  margin: 0;
  padding: 0;
}
.fp-editor-wrap .fp-editor-highlight code.hljs {
  background: transparent !important;
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Analytics Panel
   ═══════════════════════════════════════════════════════════════════════════ */

.analytics-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  z-index: 50;
  overflow: hidden;
}

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.analytics-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.analytics-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-controls select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary, var(--bg-primary));
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.analytics-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary, var(--bg-primary));
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.analytics-btn:hover {
  background: var(--bg-tertiary);
}

.analytics-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.analytics-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted, #999);
  font-size: 14px;
}

.analytics-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted, #999);
  font-size: 14px;
  line-height: 1.6;
}

/* Cards grid */
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.analytics-card {
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}

.ac-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent, #3b82f6);
  line-height: 1.2;
}

.ac-label {
  font-size: 11px;
  color: var(--text-muted, #999);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ac-sub {
  font-size: 10px;
  color: var(--text-muted, #777);
  margin-top: 2px;
}

/* Archetype bars */
.analytics-archetypes {
  margin-bottom: 24px;
}

.analytics-archetypes h3,
.analytics-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.archetype-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.arch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.arch-label {
  width: 90px;
  font-size: 12px;
  color: var(--text-muted, #999);
  text-align: right;
  flex-shrink: 0;
}

.arch-track {
  flex: 1;
  height: 16px;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  border-radius: 8px;
  overflow: hidden;
}

.arch-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.4s ease;
}

.arch-count {
  width: 30px;
  font-size: 12px;
  color: var(--text-muted, #999);
  text-align: left;
}

/* Daily chart */
.daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 170px;
  padding-bottom: 24px;
  overflow-x: auto;
}

.daily-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 20px;
}

.daily-bar {
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}

.daily-label {
  font-size: 9px;
  color: var(--text-muted, #777);
  margin-top: 4px;
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: top center;
}

/* Tables */
.analytics-section {
  margin-bottom: 24px;
}

.analytics-table-wrap {
  overflow-x: auto;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.analytics-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted, #999);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.analytics-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.analytics-table tbody tr:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.03));
}

.at-agent {
  font-weight: 500;
  color: var(--accent, #3b82f6) !important;
}

.at-time {
  font-size: 11px;
  color: var(--text-muted, #999) !important;
  white-space: nowrap;
}

.arch-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* ─── Time Split Bar ──────────────────────────────────────────────────── */

.time-split-bar {
  display: flex;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.ts-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  transition: width 0.4s ease;
}

.ts-inference { background: #3b82f6; }
.ts-human    { background: #f59e0b; }

.ts-label {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.ts-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.ts-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted, #999);
}

.ts-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Stacked Daily Chart ─────────────────────────────────────────────── */

.daily-chart-container {
  position: relative;
}

.daily-bar-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

.daily-bar-output {
  background: var(--accent);
  width: 100%;
}

.daily-bar-input {
  background: #3b82f6;
  width: 100%;
}

.daily-score-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 140px;
  pointer-events: none;
}

.daily-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-left: 4px;
}

/* ─── Skills Chart ────────────────────────────────────────────────────── */

.skills-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skill-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skill-name {
  width: 120px;
  font-size: 12px;
  color: var(--text-muted, #999);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-track {
  flex: 1;
  height: 16px;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  border-radius: 8px;
  overflow: hidden;
}

.skill-fill {
  height: 100%;
  border-radius: 8px;
  background: var(--accent, #5a7ec2);
  transition: width 0.4s ease;
}

.skill-count {
  width: 35px;
  font-size: 12px;
  color: var(--text-muted, #999);
  text-align: left;
  flex-shrink: 0;
}

/* ─── Activity Heatmap ────────────────────────────────────────────────── */

.heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heatmap-table {
  border-collapse: separate;
  border-spacing: 2px;
  min-width: 600px;
  font-size: 10px;
}

.heatmap-table th {
  padding: 2px 4px;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted, #777);
  text-align: center;
}

.heatmap-day {
  padding: 2px 8px 2px 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted, #999);
  text-align: right;
  white-space: nowrap;
}

.heatmap-cell {
  width: 28px;
  height: 24px;
  text-align: center;
  vertical-align: middle;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  border-radius: 3px;
  cursor: default;
  transition: opacity 0.2s;
}

.heatmap-cell:hover {
  outline: 2px solid var(--accent, #5a7ec2);
  outline-offset: -1px;
}

/* ─── Response Cadence ────────────────────────────────────────────────── */

.cadence-stats {
  font-size: 13px;
  color: var(--text-muted, #999);
  margin-bottom: 10px;
}

.cadence-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cadence-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cadence-label {
  width: 130px;
  font-size: 12px;
  color: var(--text-muted, #999);
  text-align: right;
  flex-shrink: 0;
}

.cadence-track {
  flex: 1;
  height: 16px;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  border-radius: 8px;
  overflow: hidden;
}

.cadence-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.4s ease;
}

.cadence-count {
  width: 90px;
  font-size: 12px;
  color: var(--text-muted, #999);
  text-align: left;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ─── Session Expandable Detail Rows ──────────────────────────────────── */

.sessions-table .session-row {
  cursor: pointer;
  transition: background 0.15s;
}

.sessions-table .session-row:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.05));
}

.sessions-table .session-row-open {
  background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.session-detail-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
}

.session-detail {
  padding: 12px 16px;
  background: var(--bg-secondary, rgba(255,255,255,0.02));
  border-top: 1px solid var(--border);
}

.sd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 16px;
}

.sd-item {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
}

.sd-item b {
  color: var(--text-muted, #999);
  font-weight: 500;
}

/* ─── Mobile Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .analytics-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .analytics-controls {
    flex-wrap: wrap;
  }
  .daily-chart {
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
  }
  .skill-name {
    width: 80px;
    font-size: 10px;
  }
  .cadence-label {
    width: 90px;
    font-size: 10px;
  }
  .cadence-count {
    width: 70px;
    font-size: 10px;
  }
  .heatmap-table {
    min-width: 500px;
  }
  .heatmap-cell {
    width: 20px;
    height: 20px;
    font-size: 8px;
  }
  .sd-grid {
    grid-template-columns: 1fr 1fr;
  }
  .ts-label {
    font-size: 9px;
  }
  .time-split-bar {
    height: 26px;
  }
}

/* ─── Outbound Queue ───────────────────────────────────────────────────── */

.outbound-stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ob-stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  min-width: 70px;
}

.ob-stat-num {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.ob-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ob-stat-queued .ob-stat-num { color: var(--accent); }
.ob-stat-processing .ob-stat-num { color: var(--warning); }
.ob-stat-sent .ob-stat-num { color: var(--success); }
.ob-stat-failed .ob-stat-num { color: var(--danger); }
.ob-stat-quiet {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.2);
}
.ob-stat-quiet .ob-stat-num { color: var(--warning); font-size: 18px; }

.outbound-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.outbound-filter-select,
.outbound-filter-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  outline: none;
}

.outbound-filter-select:focus,
.outbound-filter-input:focus {
  border-color: var(--accent-dim);
}

.outbound-filter-input {
  flex: 1;
  min-width: 120px;
}

.ob-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ob-queue-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--transition);
}

.ob-queue-item:hover {
  border-color: var(--accent-dim);
}

.ob-queue-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.ob-channel-icon {
  font-size: 14px;
}

.ob-queue-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.ob-status-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.ob-status-queued { background: rgba(90, 126, 194, 0.15); color: var(--accent); }
.ob-status-processing { background: rgba(234, 179, 8, 0.15); color: var(--warning); }
.ob-status-sent { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.ob-status-failed { background: rgba(197, 12, 68, 0.15); color: var(--danger); }

.ob-channel-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.ob-priority {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
}
.ob-priority-urgent { background: rgba(197, 12, 68, 0.2); color: var(--danger); }
.ob-priority-low { background: rgba(136, 136, 160, 0.15); color: var(--text-muted); }

.ob-badge {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
}
.ob-badge-held { background: rgba(234, 179, 8, 0.2); color: var(--warning); }

.ob-queue-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

.ob-queue-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ob-meta-from { font-weight: 600; color: var(--accent); }
.ob-meta-arrow { color: var(--text-muted); }
.ob-meta-to { font-weight: 600; }
.ob-meta-subject { color: var(--text-muted); }

.ob-queue-body {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  max-height: 40px;
  overflow: hidden;
  margin-bottom: 4px;
}

.ob-queue-error {
  font-size: 10px;
  color: var(--danger);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

.ob-queue-scheduled {
  font-size: 10px;
  color: var(--warning);
  margin-bottom: 4px;
}

.ob-queue-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.ob-action-btn {
  font-size: 10px;
  padding: 2px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: all var(--transition);
}

.ob-action-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text-primary);
}

.ob-action-approve {
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--success);
}
.ob-action-approve:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--success);
}

.ob-action-cancel {
  border-color: rgba(197, 12, 68, 0.3);
  color: var(--danger);
}
.ob-action-cancel:hover {
  background: rgba(197, 12, 68, 0.1);
  border-color: var(--danger);
}

.ob-action-retry {
  border-color: rgba(234, 179, 8, 0.3);
  color: var(--warning);
}
.ob-action-retry:hover {
  background: rgba(234, 179, 8, 0.1);
  border-color: var(--warning);
}

/* ─── Floating Bubbles ─────────────────────────────────────────────────── */
/* Positioned bottom-left inside chat-area, just above the input bar.      */

#floating-bubbles {
  position: absolute;
  bottom: 90px;
  right: 16px;  /* desktop: inside chat area, right-aligned */
  display: flex;
  flex-direction: column-reverse; /* newest at the bottom, closest to input */
  align-items: flex-end;
  gap: 10px;
  z-index: 51;
  pointer-events: none;
  transition: bottom 0.15s ease;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  overflow-x: visible;
  padding: 8px 8px;
  scrollbar-width: none; /* Firefox */
}
#floating-bubbles::-webkit-scrollbar { display: none; } /* Chrome/Safari */
#floating-bubbles.hidden { display: none; }

/* ── Collapsed state: hide individual bubbles, show only toggle ── */
#floating-bubbles.fb-collapsed .floating-bubble {
  display: none;
}

/* ── Toggle button (collapse/expand) ── */
.fb-toggle {
  pointer-events: auto;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  aspect-ratio: 1;
  flex-shrink: 0;
  flex-grow: 0;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  font-size: 14px;
  box-sizing: border-box;
}
.fb-toggle:hover {
  transform: scale(1.1);
  border-color: var(--accent);
  color: var(--accent);
}
.fb-toggle-icon { line-height: 1; }
.fb-toggle-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1px solid var(--bg-primary);
}
.fb-toggle.has-activity .fb-toggle-count {
  background: #22c55e;
}
.fb-toggle.has-busy {
  border-color: var(--accent);
  animation: fb-busy-ring 1.8s linear infinite;
}
.fb-toggle-busy {
  position: absolute;
  bottom: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #f59e0b;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1px solid var(--bg-primary);
}

.floating-bubble {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  aspect-ratio: 1;
  flex-shrink: 0;
  flex-grow: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.3px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}
.floating-bubble:hover {
  transform: scale(1.15);
}

.fb-letter {
  line-height: 1;
  font-family: var(--font-mono);
}

.fb-close {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: auto;
  border: 1px solid var(--border);
}
.floating-bubble:hover .fb-close { opacity: 1; }

/* Unread activity indicator (green dot) */
.floating-bubble.has-activity::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-primary);
}

/* ── Busy animation: spinning ring around the bubble ── */
.floating-bubble.fb-busy {
  box-shadow: 0 0 0 2px var(--warning);
  animation: fb-busy-ring 1.8s linear infinite;
}
.floating-bubble.fb-busy::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--warning);
  animation: fb-spin 1s linear infinite;
}

/* ── Error state: red outline ── */
.floating-bubble.fb-error {
  box-shadow: 0 0 0 2px var(--danger);
}

/* Color label overrides */
.floating-bubble.fb-color-red    { background: #ef4444; }
.floating-bubble.fb-color-orange { background: #f97316; }
.floating-bubble.fb-color-green  { background: #22c55e; }
.floating-bubble.fb-color-blue   { background: #3b82f6; }
.floating-bubble.fb-color-purple { background: #a855f7; }
.floating-bubble.fb-color-pink   { background: #ec4899; }

@keyframes fb-slide-in {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

@keyframes fb-busy-ring {
  0%   { box-shadow: 0 0 0 2px var(--warning); }
  50%  { box-shadow: 0 0 8px 2px var(--warning); }
  100% { box-shadow: 0 0 0 2px var(--warning); }
}

/* ── Mobile: vertical column on right side, smaller bubbles ── */
@media (max-width: 768px) {
  #floating-bubbles {
    flex-direction: column-reverse;
    right: 10px;
    left: auto;
    transform: none;
    gap: 8px;
    justify-content: flex-end;
  }
  .floating-bubble {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    font-size: 9px;
  }
  .floating-bubble .fb-close {
    width: 14px;
    height: 14px;
    font-size: 9px;
    top: -4px;
    right: -4px;
  }
  .fb-toggle {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    font-size: 12px;
  }
  /* Scroll button: sits to the left of mobile floating-bubbles column */
  .scroll-to-bottom-btn {
    right: 56px;  /* 10px bubble-right + 34px bubble + 12px gap */
  }
}

/* ─── Performance: Sidebar Preview Toggle ──────────────────────────────── */
body.no-sidebar-preview .session-last-msg {
  display: none !important;
}

/* ─── Performance: DOM Pruned Notice ───────────────────────────────────── */
.dom-pruned-notice {
  text-align: center;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px dashed var(--border);
  margin-bottom: 8px;
}
.dom-pruned-notice .load-more-link {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.dom-pruned-notice .load-more-link:hover {
  text-decoration: underline;
}

/* ─── Dashboard Control Room ──────────────────────────────────────────── */

.dash-root {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  width: 100%;
}

.dash-header {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

/* ── Fleet Stats Row ── */
.dash-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.dash-stat {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}

.dash-stat-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
}

.dash-stat-label {
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dash-stat-busy .dash-stat-value { color: var(--warning); }
.dash-stat-queue .dash-stat-value { color: var(--accent); }

/* ── Card Grid ── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 80px;
}

.dash-card-title {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dash-empty {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
  font-style: italic;
  padding: 6px 0;
}

/* Active sessions list */
.dash-active-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 12px;
}

.dash-active-item:hover {
  background: var(--accent-glow);
}

.dash-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: dash-pulse 2s ease-in-out infinite;
}

@keyframes dash-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.dash-active-name {
  flex: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.dash-active-time {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Queue bars */
.dash-queue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}

.dash-queue-slug {
  width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
}

.dash-queue-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.dash-queue-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.dash-queue-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 20px;
  text-align: right;
}

/* Error items */
.dash-error-item {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}

.dash-error-item:last-child { border-bottom: none; }

.dash-error-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 10px;
  width: 50px;
}

.dash-error-msg {
  color: var(--danger);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Today stats */
.dash-today-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-today-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
}

.dash-today-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.dash-today-lbl {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Quick Actions */
.dash-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.dash-action-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
}

.dash-action-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Override empty-state when dashboard renders inside it */
.empty-state:has(.dash-root) {
  justify-content: flex-start;
  align-items: stretch;
  overflow-y: auto;
}

/* ── Scheduled Message Pill ── */
.scheduled-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 6px 0;
  background: var(--bg-surface);
  border: 1px dashed var(--accent-dim);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 520px;
}

.scheduled-pill-icon { flex-shrink: 0; }
.scheduled-pill-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scheduled-pill-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.scheduled-pill-cancel {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.scheduled-pill-cancel:hover { opacity: 0.7; }

/* ── Schedule Popover ── */
.schedule-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 220px;
}

.schedule-popover label {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.schedule-popover input[type="datetime-local"] {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 13px;
  font-family: var(--font-ui);
  margin-bottom: 8px;
}

.schedule-popover-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.schedule-popover-actions button {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-mono);
}

.schedule-popover-actions .schedule-confirm {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.schedule-popover-actions .schedule-cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* ── Summary Card ── */
.summary-card {
  margin: 8px 16px 4px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  position: relative;
}

.summary-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.summary-card-label {
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.summary-card-actions {
  display: flex;
  gap: 4px;
}

.summary-card-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.summary-card-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.summary-card-text {
  color: var(--text-secondary);
}

.summary-card.collapsed .summary-card-text { display: none; }

/* ── Audio Record Button ── */
.mic-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.mic-btn:hover { color: var(--text-primary); }

.mic-btn.recording {
  color: var(--danger);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Dashboard Mobile ── */
@media (max-width: 768px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .dash-stats {
    flex-wrap: wrap;
  }
  .dash-stat {
    flex: 1 0 45%;
  }
  .dash-root {
    padding: 16px 12px 32px;
  }
  .schedule-popover {
    right: -8px;
    left: -8px;
    min-width: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Workspace Sessions — Parallel session tabs, merge button, floating bubbles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Workspace tab in sidebar ── */

.session-tab.workspace-tab {
  margin-left: 18px;
  border-left: 2px solid var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding-left: 10px;
  font-size: 12px;
  min-height: 36px;
  opacity: 0.92;
}

.session-tab.workspace-tab .session-name {
  font-size: 12px;
}

.session-tab.workspace-tab .session-dot {
  width: 6px;
  height: 6px;
}

.session-tab.workspace-tab:hover {
  opacity: 1;
}

.session-tab.workspace-tab.active {
  border-left-color: var(--accent);
  opacity: 1;
}

/* Merge animation */
.session-tab.workspace-merging {
  opacity: 0.5;
  pointer-events: none;
  animation: ws-merge-pulse 1s ease-in-out infinite;
}

@keyframes ws-merge-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.25; }
}

/* ── Workspace button in session actions (⋯ menu) ── */

.session-workspace-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition);
}

.session-workspace-btn:hover {
  color: var(--accent);
}

/* ── Merge button in session actions ── */

.session-merge {
  background: none;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all var(--transition);
  white-space: nowrap;
}

.session-merge:hover {
  background: var(--accent-dim);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ── Workspace badge in session switcher (Ctrl+K) ── */

.ss-ws-badge {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 6px;
  line-height: 16px;
  vertical-align: middle;
}

/* ── Workspace button (⊕) in session switcher ── */

.ss-workspace-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  margin-left: auto;
}

.ss-workspace-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

/* ── Floating bubble: workspace variant (smaller, nested) ── */

.floating-bubble.fb-workspace {
  width: 32px;
  height: 32px;
  font-size: 10px;
  margin-left: -4px;
  border: 1.5px dashed var(--accent-dim);
}

.floating-bubble.fb-workspace .fb-letter {
  font-size: 10px;
}

.floating-bubble.fb-workspace .fb-ws-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 8px;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0 2px;
  line-height: 12px;
}

.floating-bubble.fb-workspace .fb-close {
  width: 12px;
  height: 12px;
  font-size: 8px;
  top: -3px;
  right: -3px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Tab Groups — Collapsible sidebar groups
   ═══════════════════════════════════════════════════════════════════════════ */

.tab-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  transition: color var(--transition);
}

.tab-group-header:first-child {
  border-top: none;
  margin-top: 0;
}

.tab-group-header:hover {
  color: var(--text-primary);
}

.tg-chevron {
  font-size: 10px;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}

.tg-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-count {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 0 6px;
  line-height: 16px;
}

.tg-busy {
  font-size: 9px;
  color: var(--success);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.tg-edit,
.tg-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  opacity: 0;
  transition: all var(--transition);
}

.tab-group-header:hover .tg-edit,
.tab-group-header:hover .tg-remove {
  opacity: 1;
}

.tg-edit:hover { color: var(--accent); }
.tg-remove:hover { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════════
   Context Menu — Right-click session menu
   ═══════════════════════════════════════════════════════════════════════════ */

.ctx-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px 0;
  font-size: 13px;
}

.ctx-item {
  padding: 7px 14px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
  white-space: nowrap;
}

.ctx-item:hover {
  background: var(--bg-tertiary);
}

.ctx-item.ctx-danger {
  color: var(--danger);
}

.ctx-item.ctx-danger:hover {
  background: rgba(197, 12, 68, 0.1);
}

.ctx-sep {
  height: 1px;
  margin: 4px 8px;
  background: var(--border);
}

/* Light theme overrides */
[data-theme="light"] .ctx-menu {
  background: var(--bg-surface);
  border-color: var(--bg-tertiary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

[data-theme="light"] .ctx-item:hover {
  background: var(--bg-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile: Toasts top-left, queue dropdown full-width
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Activity toast → top-left */
  .activity-toast {
    right: auto;
    left: 12px;
    max-width: 240px;
  }

  /* Settings toast → top-left */
  .settings-toast {
    right: auto;
    left: 12px;
    max-width: 240px;
  }

  /* Queue dropdown → full-width bottom sheet style */
  .queue-dropdown {
    left: 8px !important;
    right: 8px !important;
    bottom: 80px !important;
    top: auto !important;
    max-width: none;
    min-width: auto;
  }
}
