/* ============================================================
   AgenticIDE � Premium Dark Theme
   Glassmorphism � Neon Accents � Smooth Animations
   ============================================================ */

/* --- CSS VARIABLES --- */
:root {
  /* Surfaces */
  --bg-void: #0a0a0f;
  --bg-primary: #0f1019;
  --bg-secondary: #13141f;
  --bg-tertiary: #1a1b2e;
  --bg-elevated: #1e1f35;
  --bg-hover: rgba(27, 58, 92, 0.15);
  --bg-active: rgba(27, 58, 92, 0.25);
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.07);

  /* Glass */
  --glass-bg: rgba(15, 16, 25, 0.75);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-blur: 20px;

  /* Text */
  --text-primary: #e2e4f0;
  --text-secondary: #8b8fa8;
  --text-muted: #505370;
  --text-bright: #ffffff;

  /* Accent Palette — Navy Blue */
  --accent: #1b3a5c;
  --accent-light: #2a5a8c;
  --accent-glow: rgba(27, 58, 92, 0.4);
  --accent-gradient: linear-gradient(135deg, #0d2137, #2a5a8c);
  --accent-gradient-h: linear-gradient(90deg, #0d2137, #2a5a8c);

  /* Status */
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.25);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.2);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  --info: #38bdf8;
  --info-glow: rgba(56, 189, 248, 0.2);

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(27, 58, 92, 0.5);

  /* Scrollbar */
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --scrollbar-track: transparent;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Layout */
  --titlebar-height: 42px;
  --statusbar-height: 26px;
  --activity-bar-width: 52px;
  --sidebar-width: 270px;
  --tab-height: 38px;
  --bottom-panel-height: 260px;

  /* Fonts */
  --font-code: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-void);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

::selection { background: rgba(27, 58, 92, 0.4); color: #fff; }

/* --- ANIMATIONS --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--accent-glow); }
  50%      { box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(99,102,241,0.15); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* --- APP SHELL --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
  position: relative;
}
#app::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(13, 33, 55, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(27, 58, 92, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(42, 90, 140, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ====== TITLEBAR ====== */
#titlebar {
  height: var(--titlebar-height);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 4px;
  user-select: none;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}
.titlebar-left, .titlebar-center, .titlebar-right { display: flex; align-items: center; gap: 10px; }
.logo {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
  margin-right: 16px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo i {
  -webkit-text-fill-color: unset;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  font-size: 16px;
}
.menu-bar { display: flex; gap: 2px; align-items: center; }
.menu-item {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-name { font-size: 12px; color: var(--text-muted); letter-spacing: 0.5px; }

/* Buttons */
.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all var(--transition-fast);
  position: relative;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-icon.active { color: var(--accent-light); background: var(--bg-active); }
.btn-icon .notif-dot {
  position: absolute;
  top: 4px; right: 6px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
.btn-icon-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all var(--transition-fast);
}
.btn-icon-sm:hover { color: var(--text-primary); background: var(--bg-hover); }

#collabUsers { display: flex; gap: 4px; }
.collab-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  transition: transform var(--transition-fast);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
}
.collab-avatar:hover { transform: scale(1.15); z-index: 1; }

/* ====== MAIN LAYOUT ====== */
#main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  z-index: 1;
  transition: margin-right 0.35s var(--ease-out);
}
/* When AI chat is open, push main layout left */
#main-layout.ai-panel-open {
  margin-right: 380px;
}
@media (max-width: 1200px) {
  #main-layout.ai-panel-open { margin-right: 340px; }
}
@media (max-width: 900px) {
  #main-layout.ai-panel-open { margin-right: 0; }
}

/* ====== ACTIVITY BAR — "curved navigation" pattern ======
   A vertical cyan stripe runs down the right edge. The active icon's tile
   extends to that stripe with rounded LEFT corners; two pseudo circles above
   and below the active tile paint concave curve cutouts where the stripe
   meets the tile. CSS-only, no JS, no SVG.

   Critical numeric invariant: stripe width === curve box-shadow offset === 4px.
   If you change one, change all three. */
#activity-bar {
  width: var(--activity-bar-width);
  background: var(--bg-secondary);
  border-right: none;                          /* dropped — stripe replaces it */
  position: relative;                          /* anchor for the right-edge stripe pseudo */
  display: flex;
  flex-direction: column;
  align-items: stretch;                        /* stretch so buttons fill the bar width */
  flex-shrink: 0;
  overflow: visible;                           /* don't clip curve pseudos */
  z-index: 5;
}
/* Always-on cyan stripe down the right edge */
#activity-bar::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 4px;
  background: #38bdf8;
  pointer-events: none;
  z-index: 1;
}

.activity-btn {
  width: 100%;                                  /* span full bar width */
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  margin: 0 0 4px 0;
  position: relative;                           /* anchor for curve pseudos */
  padding-right: 4px;                           /* visually re-center icon in the 48px area left of stripe */
  overflow: visible;                            /* don't clip the -12px pseudo curves */
  transition: color var(--transition-fast), background var(--transition-fast);
}
.activity-btn:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }

/* Active tile — rounded LEFT only, flush right so it meets the stripe. */
.activity-btn.active {
  color: #fff;
  background: #38bdf8;
  border-radius: 14px 0 0 14px !important;
  transform: none;
  z-index: 3;                                   /* above stripe (z 1) so tile + stripe read continuous */
}
/* Top curve cutout — circle filled with bar bg, box-shadow paints accent
   corner. z-index 4 puts it above stripe AND tile so the cutout-with-shadow
   cleanly carves the stripe and bridges into the tile. */
.activity-btn.active::before {
  content: '';
  position: absolute;
  top: -12px;
  right: 4px;
  width: 12px; height: 12px;
  background: var(--bg-secondary);
  border-radius: 50% !important;
  box-shadow: 4px 4px 0 #38bdf8;
  pointer-events: none;
  display: block;
  visibility: visible;
  opacity: 1;
  z-index: 10;
}
/* Bottom curve cutout — mirrors top, shadow goes upward. */
.activity-btn.active::after {
  content: '';
  position: absolute;
  bottom: -12px;
  right: 4px;
  width: 12px; height: 12px;
  background: var(--bg-secondary);
  border-radius: 50% !important;
  box-shadow: 4px -4px 0 #38bdf8;
  pointer-events: none;
  display: block;
  visibility: visible;
  opacity: 1;
  z-index: 10;
}
.activity-btn.ai-glow { animation: glow 3s ease-in-out infinite; }
.activity-btn .badge-count {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.activity-spacer { flex: 1; }

/* ====== SIDEBAR ====== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  animation: slideInLeft 0.3s var(--ease-out);
}
.sidebar-panel { display: none; height: 100%; flex-direction: column; }
.sidebar-panel.active { display: flex; animation: fadeIn 0.2s var(--ease-out); }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-actions { display: flex; gap: 4px; }

/* File Tree */
.file-tree { flex: 1; overflow-y: auto; padding: 6px 0; }
.tree-item {
  display: flex;
  align-items: center;
  padding: 4px 10px 4px calc(var(--depth, 0) * 16px + 10px);
  cursor: pointer;
  font-size: 13px;
  gap: 7px;
  user-select: none;
  border-radius: var(--radius-sm);
  margin: 0 4px;
  transition: all var(--transition-fast);
}
.tree-item:hover { background: var(--bg-hover); }
.tree-item.active { background: var(--bg-active); color: var(--text-bright); }
.tree-item .tree-icon { width: 16px; text-align: center; font-size: 12px; flex-shrink: 0; }
.tree-item .tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item.directory .tree-icon { color: var(--accent-light); }
.tree-item.file .tree-icon { color: var(--text-muted); }

/* Search */
.search-container { padding: 10px 14px; flex: 1; overflow-y: auto; }
.search-input, .git-commit-input, .debug-eval-input, .chat-input, .setting-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: var(--font-ui);
  outline: none;
  transition: all var(--transition-fast);
}
.search-input:focus, .git-commit-input:focus, .debug-eval-input:focus,
.chat-input:focus, .setting-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-results { margin-top: 10px; }
.search-result-item {
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.search-result-item:hover { background: var(--bg-hover); }

/* Git */
.git-container { padding: 10px 14px; flex: 1; overflow-y: auto; }
.git-branch {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.git-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.git-commit-input { margin-bottom: 10px; }
.git-changes { font-size: 12px; }
.git-change {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.git-change:hover { background: var(--bg-hover); }
.git-change .badge {
  font-size: 9px; padding: 2px 6px;
  border-radius: var(--radius-sm); font-weight: 700;
  letter-spacing: 0.5px;
}
.badge-modified { background: var(--warning-glow); color: var(--warning); }
.badge-added { background: var(--success-glow); color: var(--success); }
.badge-deleted { background: var(--danger-glow); color: var(--danger); }

/* Buttons */
.btn-sm {
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.btn-sm:hover { background: var(--bg-elevated); border-color: var(--border-light); }
.btn-success { border-color: rgba(34,197,94,0.3); color: var(--success); }
.btn-success:hover { background: var(--success-glow); }
.btn-danger { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.btn-danger:hover { background: var(--danger-glow); }
.btn-accent {
  padding: 6px 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 600;
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}
.btn-accent:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

/* Debug */
.debug-container { padding: 10px 14px; flex: 1; overflow-y: auto; }
.debug-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 12px;
  outline: none;
}
.debug-select:focus { border-color: var(--accent); }
.debug-actions { display: flex; gap: 5px; margin-bottom: 14px; }
.debug-variables, .debug-breakpoints, .debug-console { margin-bottom: 14px; }
#debugOutput {
  max-height: 160px; overflow-y: auto;
  font-family: var(--font-code); font-size: 11px;
  padding: 8px; background: var(--bg-tertiary); border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--border);
}
.section-label {
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* Collab / Chat */
.collab-container { padding: 10px 14px; display: flex; flex-direction: column; height: 100%; }
#onlineUsers { margin-bottom: 10px; }
.online-user {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; font-size: 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.online-user:hover { background: var(--bg-hover); }
.user-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px; }
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 8px; min-height: 100px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.chat-msg { padding: 6px 0; font-size: 12px; }
.chat-msg .chat-user { font-weight: 600; }
.chat-msg .chat-time { color: var(--text-muted); font-size: 10px; margin-left: 6px; }
.chat-input-container { display: flex; gap: 6px; }

/* Settings */
.settings-container { padding: 14px; }
.setting-group { margin-bottom: 14px; }
.setting-group label {
  display: block; font-size: 12px;
  color: var(--text-secondary); margin-bottom: 5px; font-weight: 500;
}

/* Resize Handles */
.resize-handle {
  width: 4px;
  cursor: col-resize;
  background: var(--bg-primary);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.resize-handle:hover, .resize-handle.dragging {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.resize-handle-h {
  height: 4px;
  cursor: row-resize;
  background: var(--bg-primary);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.resize-handle-h:hover, .resize-handle-h.dragging {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ====== EDITOR AREA ====== */
#editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-primary);
}
/* Tab Bar */
.tab-bar {
  height: var(--tab-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  flex-shrink: 0;
}
.tab-bar::-webkit-scrollbar { height: 0; }
.tabs { display: flex; min-width: 0; }
.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  height: 100%;
  cursor: pointer;
  font-size: 12px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  max-width: 200px;
  position: relative;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab.active { background: var(--bg-primary); color: var(--text-bright); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-gradient-h);
  border-radius: 2px 2px 0 0;
}
.tab .tab-icon { font-size: 11px; }
.tab .tab-name { overflow: hidden; text-overflow: ellipsis; }
.tab .tab-close {
  opacity: 0;
  font-size: 10px;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.tab:hover .tab-close { opacity: 0.6; }
.tab .tab-close:hover { opacity: 1; background: var(--bg-active); }
.tab.modified .tab-name::after { content: ' '; color: var(--warning); font-size: 10px; }

/* Breadcrumb */
.breadcrumb {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 26px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 5;
}
.breadcrumb span { cursor: pointer; transition: color var(--transition-fast); }
.breadcrumb span:hover { color: var(--accent-light); }
.breadcrumb .sep { margin: 0 5px; opacity: 0.4; }

.editor-split { flex: 1; display: flex; overflow: hidden; position: relative; }
.editor-container { flex: 1; position: relative; overflow: hidden; }
#editor { position: absolute; top: 26px; left: 0; right: 0; bottom: 0; font-family: var(--font-code); }

/* Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 16px;
  animation: fadeIn 0.5s var(--ease-out);
}
.welcome-screen .welcome-logo {
  font-size: 56px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: float 3s ease-in-out infinite;
}
.welcome-screen i { font-size: 56px; opacity: 0.3; }
.welcome-screen h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.welcome-screen .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 400px;
  text-align: center;
  line-height: 1.6;
}
.welcome-screen .shortcuts {
  font-size: 12px;
  text-align: left;
  margin-top: 20px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 24px;
}
.welcome-screen .shortcuts div { display: contents; }
.welcome-screen kbd {
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  border: 1px solid var(--border-light);
  font-family: var(--font-code);
  color: var(--text-secondary);
}

/* Preview */
.preview-container { flex: 1; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.preview-container.hidden { display: none; }
.preview-toolbar {
  height: 34px;
  display: flex; align-items: center;
  padding: 0 14px; gap: 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
.preview-toolbar span { flex: 1; }
#previewFrame { flex: 1; border: none; background: #fff; }

/* ====== BOTTOM PANEL ====== */
.bottom-panel {
  height: var(--bottom-panel-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.bottom-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  flex-shrink: 0;
}
.bottom-tab {
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  font-weight: 500;
}
.bottom-tab:hover { color: var(--text-secondary); }
.bottom-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.bottom-tab-actions { margin-left: auto; display: flex; gap: 4px; }
.bottom-content { display: none; flex: 1; overflow: hidden; }
.bottom-content.active { display: flex; flex-direction: column; }

#bottom-terminal { overflow: hidden; }
.terminal-tabs {
  display: flex;
  gap: 4px;
  padding: 5px 10px;
  font-size: 11px;
  flex-shrink: 0;
}
.terminal-tab {
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 7px;
  font-size: 11px;
  transition: all var(--transition-fast);
}
.terminal-tab:hover { background: var(--bg-elevated); }
.terminal-tab.active {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-accent);
}
.terminal-tab .close-term { font-size: 10px; opacity: 0.4; }
.terminal-tab .close-term:hover { opacity: 1; }
#terminal { flex: 1; padding: 4px; }

#bottom-output, #bottom-problems { padding: 10px 14px; overflow-y: auto; }
#outputContent { font-family: var(--font-code); font-size: 12px; white-space: pre-wrap; }
#problemsList { font-size: 12px; }
.problem-item {
  padding: 4px 8px; display: flex; align-items: center; gap: 7px;
  cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.problem-item:hover { background: var(--bg-hover); }
.problem-error { color: var(--danger); }
.problem-warning { color: var(--warning); }

/* ====== STATUS BAR ====== */
#statusbar {
  height: var(--statusbar-height);
  background: var(--accent-gradient-h);
  color: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 11px;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  font-weight: 500;
}
.status-left, .status-right { display: flex; gap: 14px; }
.status-item {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.status-item:hover { opacity: 0.8; }

/* ====== CONTEXT MENU ====== */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 5px 0;
  z-index: 10000;
  min-width: 190px;
  backdrop-filter: blur(20px);
  animation: fadeIn 0.15s var(--ease-out);
}
.context-menu.hidden { display: none; }
.context-item {
  padding: 7px 18px;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
  display: flex; align-items: center; gap: 10px;
}
.context-item:hover { background: var(--accent); color: #fff; }
.context-separator { height: 1px; background: var(--border); margin: 4px 8px; }

/* Dropdown */
.dropdown-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 5px 0;
  z-index: 10000;
  min-width: 230px;
  backdrop-filter: blur(20px);
  animation: fadeIn 0.15s var(--ease-out);
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
  padding: 7px 18px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition-fast);
}
.dropdown-item:hover { background: var(--accent); color: #fff; }
.dropdown-item .shortcut { font-size: 11px; color: var(--text-muted); font-family: var(--font-code); }
.dropdown-item:hover .shortcut { color: rgba(255,255,255,0.6); }
.dropdown-separator { height: 1px; background: var(--border); margin: 4px 8px; }

/* ====== AI CHAT PANEL (Pinnable to Right) ====== */
.ai-panel {
  position: fixed;
  right: 0;
  top: var(--titlebar-height);
  bottom: var(--statusbar-height);
  width: 380px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-left: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4), 0 0 40px rgba(27, 58, 92, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), opacity 0.35s var(--ease-out), width 0.3s var(--ease-out);
}
.ai-panel.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}
.ai-panel.visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
/* Pinned state — docked flush to right edge */
.ai-panel.pinned {
  position: fixed;
  right: 0;
  top: var(--titlebar-height);
  bottom: var(--statusbar-height);
  border-radius: 0;
  border-left: 2px solid var(--accent-light);
  box-shadow: -4px 0 30px rgba(27, 58, 92, 0.15), 0 0 40px rgba(27, 58, 92, 0.08);
}
.ai-panel.pinned .ai-pin-btn {
  color: var(--accent-light);
  transform: rotate(45deg);
}
/* Pin button in header */
.ai-pin-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-pin-btn:hover {
  color: var(--accent-light);
  background: rgba(27, 58, 92, 0.2);
}

/* AI Panel Resize Handle */
.ai-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 510;
  background: transparent;
  transition: background 0.15s ease;
}
.ai-resize-handle:hover,
.ai-resize-handle.dragging {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
/* Disable transitions while resizing */
.ai-panel.resizing {
  transition: none !important;
}

/* Responsive AI Panel */
@media (max-width: 1200px) {
  .ai-panel { width: 340px; }
}
@media (max-width: 900px) {
  .ai-panel {
    width: 100%;
    max-width: 100vw;
    right: 0;
    border-left: none;
    border-top: 2px solid var(--accent);
    top: auto;
    bottom: var(--statusbar-height);
    height: 55vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .ai-panel.hidden {
    transform: translateY(100%);
  }
  .ai-panel.visible {
    transform: translateY(0);
  }
  .ai-panel.pinned {
    top: auto;
    bottom: var(--statusbar-height);
    height: 55vh;
    border-left: none;
    border-top: 2px solid var(--accent-light);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}
@media (max-width: 480px) {
  .ai-panel {
    height: 70vh;
  }
  .ai-panel .ai-msg-bubble { max-width: 95%; font-size: 12px; }
  .ai-panel-header { padding: 10px 12px; }
  .ai-input-area { padding: 8px 10px; }
  .ai-suggestions { padding: 8px 10px; }
}

.ai-panel-header {
  display: flex;
  align-items: center;
  padding: 3px 16px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  /* Match the editor's .tab-bar so the two stay visually aligned. The tab-bar uses
     `height: var(--tab-height)` with default content-box; mirror it exactly. */
  height: var(--tab-height);
}
.ai-panel-header .ai-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
  flex-shrink: 0;
  position: relative;
}
.ai-panel-header .ai-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: var(--accent-gradient);
  z-index: -1;
  opacity: 0.3;
  animation: pulse 2s infinite;
}
.ai-panel-header .ai-info { flex: 1; }
.ai-panel-header .ai-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-light);
  letter-spacing: -0.2px;
}
.ai-panel-header .ai-status {
  font-size: 11px;
  color: var(--success);
  display: flex; align-items: center; gap: 4px;
}
.ai-panel-header .ai-status::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
}
.ai-panel-actions { display: flex; gap: 4px; }

/* AI Context Chips */
.ai-context-bar {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.ai-context-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  background: var(--bg-active);
  border-radius: 20px;
  font-size: 11px;
  color: var(--accent-light);
  border: 1px solid var(--border-accent);
}
.ai-context-chip i { font-size: 10px; }
.ai-context-chip .remove-chip { cursor: pointer; opacity: 0.6; font-size: 10px; }
.ai-context-chip .remove-chip:hover { opacity: 1; }

/* AI Messages */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ai-msg {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s var(--ease-out);
}
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.ai-msg.assistant .ai-msg-avatar { background: var(--accent-gradient); color: #fff; }
.ai-msg.user .ai-msg-avatar {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.ai-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
}
.ai-msg.assistant .ai-msg-bubble {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.ai-msg.user .ai-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
}
.ai-msg-bubble code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-code);
  font-size: 12px;
}
.ai-msg-bubble pre {
  background: var(--bg-void);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.5;
}
.ai-msg-actions { display: flex; gap: 6px; margin-top: 8px; }
.ai-action-btn {
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  transition: all var(--transition-fast);
  display: flex; align-items: center; gap: 5px;
}
.ai-action-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

/* Typing Indicator */
.ai-typing { display: flex; gap: 4px; padding: 8px 14px; }
.ai-typing-dot {
  width: 6px; height: 6px;
  background: var(--accent-light);
  border-radius: 50%;
  animation: pulse 1.4s infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* AI Suggestions */
.ai-suggestions {
  display: flex;
  flex-wrap: nowrap;                          /* single row — never wrap */
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;                           /* scroll sideways if too narrow */
  scrollbar-width: none;                      /* Firefox: hide scrollbar */
}
.ai-suggestions::-webkit-scrollbar { display: none; }   /* Chrome/Edge */
.ai-suggestions::before {
  content: 'Try';
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #64748b);
  margin-right: 2px;
  flex-shrink: 0;
}
.ai-suggestion {
  padding: 2px 8px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.20);
  border-radius: 999px !important;            /* pill — defeat no-curves rule */
  font-size: 9.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  line-height: 1.6;
  flex-shrink: 0;
}
.ai-suggestion:hover {
  background: rgba(56, 189, 248, 0.15);
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.45);
}
.ai-suggestion i {
  color: var(--accent-light, #38bdf8);
  font-size: 8.5px;
}

/* AI Input Area */
.ai-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 6px;
  transition: all var(--transition-fast);
}
.ai-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.ai-input-field {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-ui);
  outline: none;
  resize: none;
  min-height: 32px;
  max-height: 120px;
  line-height: 1.5;
  padding: 6px 4px;
  display: block;
  align-self: center;
}
.ai-input-field::placeholder { color: var(--text-muted); line-height: 1.5; }
.ai-input-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  align-self: center;
  flex-shrink: 0;
}
.ai-send-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  padding: 0;
}
.ai-send-btn:hover { transform: scale(1.08); box-shadow: var(--shadow-glow); }
.ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.ai-attach-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  flex-shrink: 0;
  align-self: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.ai-attach-btn:hover { color: var(--accent-light); background: rgba(255, 255, 255, 0.05); }

/* Utility */
.hidden { display: none !important; }

/* Remote cursor */
.remote-cursor { position: absolute; width: 2px; z-index: 100; pointer-events: none; }
.remote-cursor-label {
  position: absolute; top: -18px; left: 0;
  font-size: 10px; padding: 1px 7px;
  border-radius: 4px; color: #fff;
  white-space: nowrap; pointer-events: none; font-weight: 600;
}

/* File icons */
.icon-js { color: #f7df1e; }
.icon-ts { color: #3178c6; }
.icon-py { color: #3572a5; }
.icon-rb { color: #cc342d; }
.icon-java { color: #b07219; }
.icon-c { color: #555555; }
.icon-cs { color: #178600; }
.icon-php { color: #4f5d95; }
.icon-go { color: #00add8; }
.icon-html { color: #e34c26; }
.icon-css { color: #1572b6; }
.icon-json { color: #f7df1e; }
.icon-md { color: #083fa1; }
.icon-folder { color: var(--accent-light); }
.icon-default { color: var(--text-muted); }

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 40px;
  right: 20px;
  z-index: 99999;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #fff;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  transition: all 0.35s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}
.toast.info { background: rgba(27, 58, 92, 0.95); }
.toast.success { background: rgba(34, 197, 94, 0.9); }
.toast.warning { background: rgba(245, 158, 11, 0.9); }
.toast.error { background: rgba(239, 68, 68, 0.9); }

/* Command Palette */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeIn 0.15s var(--ease-out);
}
.command-palette-overlay.hidden { display: none; }
.command-palette {
  width: 560px;
  max-height: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideInUp 0.2s var(--ease-out);
}
.command-palette-input {
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  font-family: var(--font-ui);
}
.command-palette-input::placeholder { color: var(--text-muted); }
.command-palette-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}
.command-palette-item {
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition-fast);
}
.command-palette-item:hover, .command-palette-item.selected { background: var(--bg-active); }
.command-palette-item i { width: 20px; text-align: center; color: var(--text-muted); }

/* ============================================================
   MODE SWITCHER & MODE STATES
   ============================================================ */

/* --- Mode Switcher in titlebar --- */
.mode-switcher {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.mode-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.mode-btn.active {
  background: var(--accent-gradient);
  color: var(--text-bright);
  box-shadow: var(--shadow-glow);
}
.mode-btn i { font-size: 11px; }

/* --- Mode visibility helpers --- */
.copilot-only, .autopilot-only, .autoagent-only { display: none !important; }
.mode-copilot .copilot-only { display: inline-flex !important; }
.mode-autopilot .autopilot-only { display: inline-flex !important; }
.mode-autoagent .autoagent-only { display: inline-flex !important; }

/* --- Mode badges in titlebar --- */
.mode-badge {
  display: none !important;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-approvals {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.badge-approvals i { font-size: 10px; }
.mode-autopilot .badge-approvals { display: inline-flex !important; }

.badge-ai-active {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.badge-ai-active i { font-size: 8px; animation: pulse 2s infinite; }
.mode-autoagent .badge-ai-active { display: inline-flex !important; }

/* --- Status bar mode indicator --- */
.status-center {
  display: flex;
  align-items: center;
  gap: 8px;
}
#statusMode {
  background: var(--accent-gradient);
  color: var(--text-bright);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* --- Status bar action buttons --- */
.status-action-btn {
  padding: 3px 14px;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}
.status-action-btn:not(.status-btn-danger) {
  background: rgba(99, 102, 241, 0.8);
  color: #fff;
}
.status-action-btn:not(.status-btn-danger):hover {
  background: rgba(99, 102, 241, 1);
}
.status-btn-danger {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
}
.status-btn-danger:hover {
  background: rgba(239, 68, 68, 1);
}

/* --- Mode overlay panels (prompt box only) --- */
.mode-overlay-panel {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  max-width: 90vw;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 800;
  overflow: hidden;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.mode-overlay-panel.panel-hide { display: none !important; }
.mode-overlay-panel.panel-show { display: block; animation: slideInUp 0.25s var(--ease-out); }

.overlay-panel-header {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.overlay-panel-header i { color: var(--accent-light); }
.overlay-close { margin-left: auto; }

.prompt-box-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.prompt-box-content textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-code);
  font-size: 13px;
  padding: 12px;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}
.prompt-box-content textarea:focus { border-color: var(--accent-light); }

/* ============================================================
   AUTOPILOT MODE — Flow Panel & Diff/Test View
   ============================================================ */

/* Panel sub-tabs (Flow / Code) */
.panel-sub-tabs {
  display: flex;
  gap: 0;
  width: 100%;
}
.panel-sub-tab {
  flex: 1;
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
  text-align: center;
}
.panel-sub-tab:hover { color: var(--text-secondary); }
.panel-sub-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* Autopilot flow content */
.autopilot-flow-content {
  padding: 16px 10px;
  overflow-y: auto;
  height: calc(100% - 40px);
}

/* Flow chart */
.flow-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.flow-node {
  padding: 8px 20px;
  border: 2px solid var(--border-light);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  min-width: 100px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.flow-terminal { border-radius: 20px; background: var(--bg-secondary); }
.flow-process { border-color: var(--border-light); }
.flow-success { border-color: #22c55e; color: #22c55e; }
.flow-error { border-color: #ef4444; color: #ef4444; }
.flow-arrow { color: var(--text-muted); font-size: 14px; padding: 2px 0; }
.flow-branch { display: flex; gap: 16px; padding: 4px 0; }
.flow-path { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.flow-label { font-size: 10px; font-style: italic; }
.flow-label.true { color: #22c55e; }
.flow-label.false { color: #ef4444; }

/* Autopilot editor view (Diff review & Tests) */
#autopilotEditorView {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.ap-view-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.ap-view-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}
.ap-view-tab:hover { color: var(--text-secondary); }
.ap-view-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

.ap-view-content {
  display: none;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.ap-view-content.active { display: flex; }

.ap-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Diff lines */
.diff-lines { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.diff-line {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid;
}
.diff-add {
  background: rgba(34, 197, 94, 0.08);
  border-left-color: #22c55e;
  color: #22c55e;
}
.diff-remove {
  background: rgba(239, 68, 68, 0.08);
  border-left-color: #ef4444;
  color: #ef4444;
}
.diff-sign { font-weight: 700; font-size: 15px; min-width: 14px; }

/* Accept / Reject buttons */
.ap-diff-actions { display: flex; gap: 10px; margin-bottom: 24px; }
.btn-ap-accept, .btn-ap-reject {
  padding: 8px 20px;
  border: 2px solid;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}
.btn-ap-accept {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}
.btn-ap-accept:hover { background: rgba(34, 197, 94, 0.2); }
.btn-ap-reject {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.btn-ap-reject:hover { background: rgba(239, 68, 68, 0.2); }

/* Test results */
.test-results-list { display: flex; flex-direction: column; gap: 8px; }
.test-result {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.test-pass { color: #22c55e; }
.test-pass i { color: #22c55e; }
.test-new { color: #f59e0b; }
.test-new i { color: #f59e0b; }

/* ============================================================
   AUTOAGENT MODE — Task Panel & Progress Timeline
   ============================================================ */

.autoagent-task-area {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.task-prompt-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.task-description {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 16px;
  font-weight: 500;
}
.btn-execute {
  background: #22c55e;
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
.btn-execute:hover { background: #16a34a; transform: translateY(-1px); }

/* Progress timeline */
.task-timeline {
  padding: 20px 20px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}
.timeline-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 0;
  border-left: 2px solid var(--border);
  margin-left: 0;
  padding-left: 24px;
  position: relative;
}
.timeline-step.completed { border-left-color: #22c55e; }
.timeline-step.running { border-left-color: #3b82f6; }

.step-number {
  position: absolute;
  left: -14px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.timeline-step.completed .step-number {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}
.timeline-step.running .step-number {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  animation: pulse 1.5s infinite;
}

.step-info { flex: 1; }
.step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.step-time {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 6px;
}
.step-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   BOTTOM PANEL — Integrated panels & mode tabs
   ============================================================ */

.integrated-panel-content {
  padding: 10px 14px;
  height: 100%;
  overflow-y: auto;
}
.approval-list { max-height: 100%; overflow-y: auto; }
.approval-empty, .audit-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.approval-empty i, .audit-empty i { font-size: 24px; opacity: 0.3; }

.audit-log-content {
  max-height: 100%;
  overflow-y: auto;
  font-family: var(--font-code);
  font-size: 12px;
}
.audit-entry {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
}
.audit-entry .audit-time { color: var(--text-muted); min-width: 70px; }
.audit-entry .audit-action { color: var(--accent-light); }

/* Mode tabs in bottom panel */
.bottom-tab.mode-tab {
  display: flex;
  align-items: center;
  gap: 5px;
}
.bottom-tab.mode-tab i { font-size: 10px; color: var(--accent-light); }

/* Agent overlay (kept for optional use) */
.agent-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.92);
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  animation: fadeIn 0.3s var(--ease-out);
}
.agent-overlay.active { display: flex; }
.agent-overlay i.overlay-icon {
  font-size: 48px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: float 3s ease-in-out infinite;
}
.agent-overlay h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.agent-overlay p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  text-align: center;
  line-height: 1.6;
}

/* ============================================================
   Modal — promise-based dialog system (replaces alert/prompt/confirm)
   ============================================================ */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 14, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ai-modal-overlay.open { opacity: 1; }
.ai-modal-overlay.closing { opacity: 0; }

.ai-modal {
  background: linear-gradient(180deg, var(--bg-elevated, #1e1f35), var(--bg-secondary, #13141f));
  border: 1px solid var(--border-light, rgba(255,255,255,0.1));
  border-radius: 16px;
  min-width: 380px;
  max-width: 520px;
  width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 80px rgba(27, 58, 92, 0.25);
  transform: translateY(12px) scale(0.97);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.18s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.ai-modal-overlay.open .ai-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.ai-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(27, 58, 92, 0.18), transparent 50%);
  pointer-events: none;
  border-radius: inherit;
}

.ai-modal-icon {
  font-size: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px auto 0;
  background: rgba(27, 58, 92, 0.18);
  color: var(--info, #38bdf8);
  box-shadow: 0 0 0 6px rgba(27, 58, 92, 0.08);
  position: relative;
  z-index: 1;
}
.ai-modal-success .ai-modal-icon { color: var(--success, #22c55e); background: rgba(34,197,94,0.15); box-shadow: 0 0 0 6px rgba(34,197,94,0.08); }
.ai-modal-warning .ai-modal-icon { color: var(--warning, #f59e0b); background: rgba(245,158,11,0.15); box-shadow: 0 0 0 6px rgba(245,158,11,0.08); }
.ai-modal-error   .ai-modal-icon { color: var(--danger, #ef4444);  background: rgba(239,68,68,0.15);  box-shadow: 0 0 0 6px rgba(239,68,68,0.08); }
.ai-modal-question .ai-modal-icon { color: var(--info, #38bdf8); }
.ai-modal-edit .ai-modal-icon    { color: #c084fc; background: rgba(192,132,252,0.15); box-shadow: 0 0 0 6px rgba(192,132,252,0.08); }

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 0;
  position: relative;
  z-index: 1;
}
.ai-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #e2e4f0);
  letter-spacing: -0.2px;
  text-align: center;
  flex: 1;
}
.ai-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted, #505370);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
}
.ai-modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #e2e4f0);
}

.ai-modal-body {
  padding: 16px 28px 4px;
  color: var(--text-secondary, #8b8fa8);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
  position: relative;
  z-index: 1;
  overflow-y: auto;
}
.ai-modal-message {
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-modal-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  text-align: left;
}
.ai-modal-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #8b8fa8);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-bottom: -6px;
}
.ai-modal-input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary, #e2e4f0);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}
.ai-modal-input::placeholder { color: var(--text-muted, #505370); }
.ai-modal-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-light, #2a5a8c);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.35);
}
.ai-modal-input.error {
  border-color: var(--danger, #ef4444);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
  animation: ai-modal-shake 0.35s ease;
}
.ai-modal-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  line-height: 1.5;
}

.ai-modal-actions {
  display: flex;
  gap: 10px;
  padding: 20px 24px 22px;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.ai-modal-btn {
  flex: 1;
  max-width: 180px;
  padding: 10px 20px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #e2e4f0);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.2px;
}
.ai-modal-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-light, rgba(255,255,255,0.16));
  transform: translateY(-1px);
}
.ai-modal-btn:active { transform: translateY(0); }
.ai-modal-btn.primary {
  background: var(--accent-gradient, linear-gradient(135deg, #0d2137, #2a5a8c));
  border-color: transparent;
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(27, 58, 92, 0.4);
}
.ai-modal-btn.primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 6px 20px rgba(27, 58, 92, 0.55);
}
.ai-modal-btn.danger {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.ai-modal-btn.danger:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
}
.ai-modal-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.5);
}

@keyframes ai-modal-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@media (max-width: 480px) {
  .ai-modal { min-width: 0; width: calc(100vw - 32px); }
  .ai-modal-actions { flex-direction: column-reverse; }
  .ai-modal-btn { max-width: none; }
}

/* -------- MCP Connector modal -------- */
.mcp-modal { width: 560px; max-width: calc(100vw - 32px); }
.mcp-modal .ai-modal-title i { margin-right: 6px; opacity: 0.85; }

.mcp-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
}
.mcp-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mcp-badge-ok   { background: rgba(34,197,94,0.15);  color: #4ade80; }
.mcp-badge-warn { background: rgba(245,158,11,0.15); color: #fbbf24; }
.mcp-badge-off  { background: rgba(148,163,184,0.15); color: #94a3b8; }
.mcp-project    { margin-left: auto; font-size: 12px; }
.mcp-project code { font-family: var(--font-mono, monospace); }

.mcp-row { margin-bottom: 14px; }
.mcp-row > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 4px;
}
.mcp-input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border, #2a3344);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-input, #0f1521);
}
.mcp-input-group input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text, #e2e8f0);
  padding: 8px 10px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12.5px;
  outline: none;
}
.mcp-icon-btn {
  background: rgba(255,255,255,0.04);
  border: 0;
  border-left: 1px solid var(--border, #2a3344);
  color: var(--text-secondary, #94a3b8);
  padding: 0 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mcp-icon-btn:hover  { background: rgba(255,255,255,0.08); color: var(--text, #e2e8f0); }
.mcp-icon-btn.copied { color: #4ade80; }

.mcp-help {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(148,163,184,0.08);
  font-size: 12.5px;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 14px;
  line-height: 1.5;
}
.mcp-help code { background: rgba(0,0,0,0.25); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.mcp-help-warn { background: rgba(245,158,11,0.10); color: #fbbf24; }
.mcp-help-warn code { background: rgba(0,0,0,0.3); color: #fde68a; }
.mcp-help-text { font-size: 12px; color: var(--text-secondary, #94a3b8); margin: 6px 0; }

.mcp-steps {
  margin: 12px 0 4px;
  padding-left: 22px;
  font-size: 13px;
  color: var(--text, #e2e8f0);
  line-height: 1.7;
}
.mcp-steps li { margin-bottom: 6px; }
.mcp-steps code {
  background: rgba(0,0,0,0.3);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.mcp-details { margin-top: 8px; }
.mcp-details summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary, #94a3b8);
  padding: 6px 0;
}
.mcp-details summary:hover { color: var(--text, #e2e8f0); }
.mcp-codeblock {
  position: relative;
  border: 1px solid var(--border, #2a3344);
  border-radius: 6px;
  background: var(--bg-input, #0f1521);
  margin-top: 6px;
}
.mcp-codeblock pre {
  margin: 0;
  padding: 10px 12px;
  max-height: 200px;
  overflow: auto;
  font-size: 12px;
}
.mcp-codeblock code { font-family: var(--font-mono, ui-monospace, monospace); color: var(--text, #e2e8f0); }
.mcp-codeblock-copy {
  position: absolute;
  top: 4px;
  right: 4px;
  border-left: 0 !important;
  background: rgba(0,0,0,0.4) !important;
  border-radius: 4px;
}

/* ============================================================
   AI Model Selector Bar
   ============================================================ */
.ai-model-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
}
.ai-model-bar > i {
  color: var(--accent-light, #2a5a8c);
  font-size: 12px;
}
.ai-model-select {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-primary, #e2e4f0);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  text-overflow: ellipsis;
  min-width: 0;
}
.ai-model-select:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-light, rgba(255,255,255,0.16));
}
.ai-model-select:focus {
  border-color: var(--accent-light, #2a5a8c);
  box-shadow: 0 0 0 2px rgba(27, 58, 92, 0.3);
}
.ai-model-select optgroup {
  background: var(--bg-secondary, #13141f);
  color: var(--text-secondary, #8b8fa8);
  font-style: normal;
  font-weight: 600;
}
.ai-model-select option {
  background: var(--bg-elevated, #1e1f35);
  color: var(--text-primary, #e2e4f0);
  padding: 4px;
}

/* ============================================================
   Project switcher (titlebar)
   ============================================================ */
.project-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  margin-left: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  height: 28px;
}
.project-switcher > i {
  color: var(--accent-light, #2a5a8c);
  font-size: 11px;
}
.project-select {
  background: transparent;
  border: none;
  color: var(--text-primary, #e2e4f0);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  max-width: 200px;
  text-overflow: ellipsis;
}
.project-select:focus { color: var(--text-bright, #ffffff); }
.project-select option {
  background: var(--bg-elevated, #1e1f35);
  color: var(--text-primary, #e2e4f0);
  padding: 4px;
}
#btnDeleteProject {
  font-size: 10px;
  opacity: 0.5;
  transition: all 0.15s ease;
}
#btnDeleteProject:hover {
  opacity: 1;
  color: var(--danger, #ef4444);
}

/* ============================================================
   Preview URL bar
   ============================================================ */
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary, #13141f);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}
.preview-url-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-primary, #e2e4f0);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  outline: none;
  transition: all 0.15s ease;
  min-width: 0;
}
.preview-url-input::placeholder { color: var(--text-muted, #505370); }
.preview-url-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-light, #2a5a8c);
  box-shadow: 0 0 0 2px rgba(27, 58, 92, 0.3);
}

/* ============================================================
   AI tool-call approval card
   ============================================================ */
.ai-approval-card .ai-msg-bubble {
  background: linear-gradient(180deg, rgba(192,132,252,0.10), rgba(56,189,248,0.06));
  border: 1px solid rgba(192,132,252,0.25);
  padding: 12px 14px;
  border-radius: 12px;
}
.ai-approval-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary, #8b8fa8);
  margin-bottom: 8px;
}
.ai-approval-head i { color: #c084fc; }
.ai-approval-head strong {
  color: var(--text-primary, #e2e4f0);
  font-weight: 600;
  font-size: 13px;
}
.ai-approval-head code {
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--info, #38bdf8);
}
.ai-approval-summary {
  font-size: 12px;
  color: var(--text-secondary, #8b8fa8);
  margin-bottom: 10px;
  line-height: 1.5;
}
.ai-approval-diff {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  padding: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  max-height: 240px;
  overflow: auto;
  margin-bottom: 12px;
}
.ai-diff-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 2px 4px;
  border-radius: 4px;
}
.ai-diff-row-old { background: rgba(239, 68, 68, 0.10); }
.ai-diff-row-new { background: rgba(34, 197, 94, 0.10); }
.ai-diff-row pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary, #e2e4f0);
  font-size: 12px;
  flex: 1;
}
.ai-diff-marker {
  font-weight: 700;
  width: 10px;
  flex: 0 0 auto;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}
.ai-diff-row-old .ai-diff-marker { color: var(--danger, #ef4444); }
.ai-diff-row-new .ai-diff-marker { color: var(--success, #22c55e); }
.ai-approval-write pre {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  max-height: 240px;
  overflow: auto;
  color: var(--text-primary, #e2e4f0);
  margin: 0 0 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-approval-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.ai-approval-actions .ai-modal-btn {
  flex: 0 0 auto;
  max-width: none;
  padding: 6px 14px;
  font-size: 12px;
}
.ai-approval-result {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ai-approval-result.approved {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success, #22c55e);
}
.ai-approval-result.rejected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger, #ef4444);
}

/* ============================================================
   AI thinking / loading — magical wand + cycling spell text
   ============================================================ */
.ai-wand-avatar {
  position: relative;
  background: radial-gradient(circle at 30% 30%, rgba(192,132,252,0.30), rgba(56,189,248,0.10) 70%);
  color: #c084fc;
  overflow: visible;
}
.ai-wand-avatar i {
  display: inline-block;
  animation: ai-wand-wave 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(192, 132, 252, 0.6));
}
@keyframes ai-wand-wave {
  0%, 100% { transform: rotate(-12deg) scale(1); }
  50%      { transform: rotate(18deg)  scale(1.08); }
}
.ai-spark {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #fde68a;
  box-shadow: 0 0 8px #fde68a, 0 0 16px rgba(192,132,252,0.5);
  opacity: 0;
  animation: ai-spark-pop 2.4s ease-in-out infinite;
}
.ai-spark-1 { top: 4px;  right: 6px;  animation-delay: 0s; }
.ai-spark-2 { bottom: 4px; right: 12px; animation-delay: 0.8s; }
.ai-spark-3 { top: 50%;  left: 4px;   animation-delay: 1.6s; background: #c084fc; }
@keyframes ai-spark-pop {
  0%, 100%   { opacity: 0; transform: scale(0.5); }
  10%, 30%   { opacity: 1; transform: scale(1.2); }
  60%        { opacity: 0; transform: scale(0.3) translateY(-8px); }
}

.ai-thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(120deg, rgba(192,132,252,0.10), rgba(56,189,248,0.08));
  border: 1px solid rgba(192,132,252,0.20);
}

/* Stacked thinking layout: orb on top, spell text underneath, centered.
   !important on flex-direction because the parent .ai-msg sets row layout. */
.ai-thinking-stacked {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 8px;
  padding: 8px 0 6px;
}
.ai-thinking-stacked .ai-thinking-orb {
  position: relative;
  width: 72px; height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  /* Outer halo: layered shadows for a soft, formal glow */
  box-shadow:
    0 0 0 1px rgba(192, 132, 252, 0.25),
    0 0 24px 4px rgba(139, 92, 246, 0.35),
    0 0 60px 12px rgba(139, 92, 246, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  /* Slow breathing pulse on the glow */
  animation: ai-orb-pulse 3.6s ease-in-out infinite;
}
.ai-thinking-stacked .ai-orb-img {
  width: 100%; height: 100%;
  object-fit: cover;          /* fill the circle edge-to-edge, no letterboxing */
  object-position: center;
  display: block;
  /* Float independently of the container's pulse so the motion feels alive */
  animation: ai-orb-float 4.2s ease-in-out infinite;
}
@keyframes ai-orb-float {
  0%, 100% { transform: translateY(0)    scale(1);    }
  50%      { transform: translateY(-3px) scale(1.02); }
}
@keyframes ai-orb-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(192, 132, 252, 0.25),
      0 0 24px 4px rgba(139, 92, 246, 0.35),
      0 0 60px 12px rgba(139, 92, 246, 0.18),
      inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(192, 132, 252, 0.45),
      0 0 32px 8px rgba(139, 92, 246, 0.55),
      0 0 80px 20px rgba(139, 92, 246, 0.28),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}
.ai-thinking-stacked .ai-thinking-bubble {
  background: transparent;
  border: 0;
  padding: 0;
}
.ai-thinking-text {
  font-size: 13px;
  color: var(--text-secondary, #8b8fa8);
  font-style: italic;
  letter-spacing: 0.2px;
  transition: opacity 0.18s ease;
  opacity: 1;
  background: linear-gradient(90deg, #c084fc, #38bdf8, #c084fc);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ai-shimmer 3s linear infinite;
}
.ai-thinking-text.ai-thinking-fading { opacity: 0; }
@keyframes ai-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.ai-thinking-dots {
  display: inline-flex;
  gap: 3px;
}
.ai-thinking-dots > span {
  width: 5px; height: 5px; border-radius: 50%;
  background: #c084fc;
  opacity: 0.25;
  animation: ai-tdot 1.2s infinite;
}
.ai-thinking-dots > span:nth-child(2) { animation-delay: 0.15s; }
.ai-thinking-dots > span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-tdot {
  0%,80%,100% { opacity: 0.25; transform: translateY(0); }
  40%         { opacity: 1;    transform: translateY(-4px); }
}

/* ============================================================
   AI markdown — readable code blocks, lists, headers, paragraphs
   ============================================================ */
.ai-msg-bubble {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.ai-msg.assistant .ai-msg-bubble {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary, #e2e4f0);
}
.ai-msg-bubble p {
  margin: 0 0 10px 0;
}
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble h1,
.ai-msg-bubble h2,
.ai-msg-bubble h3,
.ai-msg-bubble h4 {
  margin: 14px 0 8px 0;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-bright, #ffffff);
  line-height: 1.3;
}
.ai-msg-bubble h1 { font-size: 17px; }
.ai-msg-bubble h2 { font-size: 15px; }
.ai-msg-bubble h3 { font-size: 14px; color: #c084fc; }
.ai-msg-bubble h4 { font-size: 13px; color: #38bdf8; }
.ai-msg-bubble h1:first-child,
.ai-msg-bubble h2:first-child,
.ai-msg-bubble h3:first-child,
.ai-msg-bubble h4:first-child { margin-top: 0; }

.ai-msg-bubble ul,
.ai-msg-bubble ol {
  margin: 0 0 10px 0;
  padding-left: 22px;
}
.ai-msg-bubble li {
  margin: 3px 0;
  line-height: 1.5;
}
.ai-msg-bubble ul li::marker { color: var(--accent-light, #2a5a8c); }
.ai-msg-bubble ol li::marker { color: #c084fc; font-weight: 600; }

.ai-msg-bubble strong { color: var(--text-bright, #ffffff); font-weight: 600; }
.ai-msg-bubble em     { color: var(--text-secondary, #8b8fa8); }

.ai-msg-bubble a {
  color: #38bdf8;
  text-decoration: none;
  border-bottom: 1px dashed rgba(56,189,248,0.5);
}
.ai-msg-bubble a:hover { color: #7dd3fc; border-bottom-color: #7dd3fc; }

.ai-inline-code {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #fde68a;
  padding: 1px 6px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  white-space: nowrap;
}

.ai-code-block {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  margin: 10px 0;
  overflow: hidden;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.ai-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 4px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 10.5px;
}
.ai-code-lang {
  color: var(--text-muted, #505370);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.ai-code-copy {
  background: transparent;
  border: none;
  color: var(--text-muted, #505370);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  transition: all 0.15s ease;
}
.ai-code-copy:hover { color: var(--text-bright, #fff); background: rgba(255,255,255,0.06); }
.ai-code-copy.copied { color: var(--success, #22c55e); }
.ai-code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-primary, #e2e4f0);
  white-space: pre;
}
.ai-code-block pre code {
  background: transparent !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: pre !important;
  color: inherit !important;
}

/* ============================================================
   AI markdown tables
   ============================================================ */
.ai-msg-bubble .ai-table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 12.5px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.22);
}
.ai-msg-bubble .ai-table thead {
  background: linear-gradient(180deg, rgba(192,132,252,0.18), rgba(192,132,252,0.08));
}
.ai-msg-bubble .ai-table th {
  color: var(--text-bright, #ffffff);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  letter-spacing: 0.3px;
  border-bottom: 1px solid rgba(192, 132, 252, 0.25);
  white-space: nowrap;
}
.ai-msg-bubble .ai-table td {
  padding: 7px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #e2e4f0);
  vertical-align: top;
  line-height: 1.5;
}
.ai-msg-bubble .ai-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}
.ai-msg-bubble .ai-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.06);
}
.ai-msg-bubble .ai-table code,
.ai-msg-bubble .ai-table .ai-inline-code {
  font-size: 11.5px;
  padding: 0 4px;
  white-space: normal;
}

/* ============================================================
   Flat / squared design override — no curves anywhere
   ============================================================ */
*,
*::before,
*::after {
  border-radius: 0 !important;
}

/* Exception: every AI orb / avatar image stays circular (otherwise the
   global no-curves rule above would render them as hard-edged squares).
   Covers: thinking-state big orb, activity-bar button, titlebar toggle,
   and per-message assistant avatars. */
.ai-thinking-orb,
.ai-thinking-orb .ai-orb-img,
.ai-icon-img,
.ai-avatar,
.ai-msg-avatar,
.ai-wand-avatar {
  border-radius: 50% !important;
}

/* Ensure the small avatar containers actually clip their image to a circle */
.ai-avatar,
.ai-msg-avatar,
.ai-wand-avatar {
  overflow: hidden !important;
}

/* Exception: active activity-bar tile keeps rounded LEFT corners; the curve
   cutout pseudo-elements stay circular. Must override the earlier 12px rule
   AND the global no-curves wipe. */
.activity-btn.active {
  border-radius: 14px 0 0 14px !important;
}
.activity-btn.active::before,
.activity-btn.active::after {
  border-radius: 50% !important;
}

/* Make the activity-bar opaque (override the glassmorphism rule) and have
   the curve-cutout circles read from the same CSS variable as the bar so
   they always blend invisibly — across every theme (Dark, Midnight, Ocean,
   Forest, Purple, Pink). Each theme overrides --bg-secondary, so this
   automatically tracks the active theme. */
:root:not([data-theme="light"]) #activity-bar {
  background: var(--bg-secondary) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
:root:not([data-theme="light"]) .activity-btn.active::before,
:root:not([data-theme="light"]) .activity-btn.active::after {
  background: var(--bg-secondary) !important;
}

/* Hide tab-bar and breadcrumb when they have no real content. Defends against
   any code path that sets `style.display = ''` and would otherwise reveal an
   empty bar at the top of the editor area. */
#tabBar:not(:has(.tab)) { display: none !important; }
#breadcrumb:empty       { display: none !important; }

/* ============================================================
   Theme button + popover (titlebar, beside Copilot mode switcher)
   ============================================================ */
.theme-wrap { position: relative; margin-right: 8px; }
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--accent-light);
}
.theme-toggle-btn i { font-size: 13px; }
.theme-toggle-btn .theme-caret { font-size: 9px; opacity: 0.7; }
.theme-toggle-btn .theme-label { font-weight: 500; }

.theme-popover {
  position: fixed;                /* escape any parent stacking context */
  top: 48px;                      /* sit just below the titlebar */
  right: 12px;
  z-index: 99999;                 /* on top of everything — including modals */
  width: 290px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
  flex-direction: column;
  gap: 12px;
  display: none;                  /* hidden by default — JS adds .open to show */
}
.theme-popover.open { display: flex !important; }
.tp-section { display: flex; flex-direction: column; gap: 6px; }
.tp-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #94a3b8);
}
.tp-swatches { display: flex; flex-wrap: nowrap; gap: 5px; justify-content: space-between; }
.tp-swatch {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.tp-swatch:hover { transform: scale(1.08); border-color: var(--accent-light); }
.tp-swatch.active { border-color: var(--accent); border-width: 2px; }
.tp-swatch .tp-check {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  background: rgba(56, 189, 248, 0.95);
  color: #fff;
  font-size: 8px;
  display: none;
  align-items: center;
  justify-content: center;
}
.tp-swatch.active .tp-check { display: flex; }

.tp-sizes {
  display: flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  overflow: hidden;
}
.tp-size-btn {
  flex: 1;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.tp-size-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tp-size-btn.active { background: var(--accent); color: #fff; }

/* ============================================================
   Extra dark-variant themes (light theme is defined further below
   along with its chrome overrides).
   ============================================================ */
html[data-theme="midnight"] {
  --bg-void:      #0a0f1f;
  --bg-primary:   #0e1626;
  --bg-secondary: #131b2e;
  --bg-tertiary:  #1c2640;
}
html[data-theme="ocean"] {
  --bg-void:      #051c2e;
  --bg-primary:   #0a2942;
  --bg-secondary: #0e3050;
  --bg-tertiary:  #143e63;
}
html[data-theme="forest"] {
  --bg-void:      #0a1a0e;
  --bg-primary:   #122318;
  --bg-secondary: #142918;
  --bg-tertiary:  #1d3722;
}
html[data-theme="purple"] {
  --bg-void:      #110624;
  --bg-primary:   #1a0d2e;
  --bg-secondary: #1f1235;
  --bg-tertiary:  #2a1a47;
}
html[data-theme="pink"] {
  --bg-void:      #200a1a;
  --bg-primary:   #2a1020;
  --bg-secondary: #2d1426;
  --bg-tertiary:  #3a1a31;
}

/* Text-size variants — scale text app-wide via a CSS custom property. Avoids
   the layout-distortion that `zoom` causes (zoom shrinks the body box, leaving
   empty viewport corners). Trade-off: paddings/borders don't scale, only
   font-size — but the layout stays correct. */
:root { --ui-text-size: 13px; }
html[data-text-size="xs"] { --ui-text-size: 10px;   }
html[data-text-size="s"]  { --ui-text-size: 11.5px; }
html[data-text-size="m"]  { --ui-text-size: 13px;   }
html[data-text-size="l"]  { --ui-text-size: 14.5px; }
html[data-text-size="xl"] { --ui-text-size: 16.5px; }

/* Apply to elements that actually display user-facing text. Each selector
   uses !important so it wins over the original hardcoded px sizes. */
body,
.menu-item, .menu-dropdown-item,
.dropdown-menu, .dropdown-item,
.activity-btn, .activity-btn .label,
.panel-header, .file-tree, .file-tree-item,
.tab, .tabs, .breadcrumb,
.terminal-tab, .bottom-tab,
.git-changes, .git-branch, .search-results,
.project-select, .mode-btn,
.theme-toggle-btn, .tp-label, .tp-size-btn,
.ai-msg .ai-msg-bubble,
.ai-input,
input, button, select, textarea {
  font-size: var(--ui-text-size) !important;
}
.dropdown-item .shortcut { font-size: calc(var(--ui-text-size) - 1.5px) !important; }
.ai-msg-header   { font-size: calc(var(--ui-text-size) - 2.5px) !important; }
.ai-suggestion   { font-size: calc(var(--ui-text-size) - 3px)   !important; }
.ai-msg-time     { font-size: calc(var(--ui-text-size) - 3px)   !important; }

/* ============================================================
   Light theme — CSS variables + hardcoded-color overrides for the
   handful of places that bypass var() and would otherwise leave
   white-on-white or dark-on-dark text in light mode.
   ============================================================ */
html[data-theme="light"] {
  --bg-void:      #e5e7eb;
  --bg-primary:   #ffffff;
  --bg-secondary: #f1f5f9;
  --bg-tertiary:  #e2e8f0;
  --bg-input:     #ffffff;
  --bg-hover:     #cbd5e1;
  --bg-active:    #94a3b8;
  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #475569;
  --text-bright:    #000000;
  --border:        #cbd5e1;
  --border-accent: #0ea5e9;
}
/* Force readable colors on chrome that hardcoded dark backgrounds */
html[data-theme="light"] body,
html[data-theme="light"] #titlebar,
html[data-theme="light"] #activity-bar,
html[data-theme="light"] #sidebar,
html[data-theme="light"] .panel-header,
html[data-theme="light"] .tab-bar {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}
html[data-theme="light"] .welcome-screen {
  color: #475569;
}
html[data-theme="light"] .welcome-screen .welcome-logo {
  color: #0f172a;
}
html[data-theme="light"] kbd {
  background: #e2e8f0 !important;
  border-color: #94a3b8 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .menu-item        { color: #334155; }
html[data-theme="light"] .menu-item:hover  { color: #0f172a; background: #e2e8f0; }
html[data-theme="light"] .activity-btn        { color: #64748b; }
html[data-theme="light"] .activity-btn:hover  { color: #0f172a; background: #e2e8f0; }
/* Curved-nav stripe + cutouts re-tuned for the light theme so the cyan still pops */
html[data-theme="light"] #activity-bar::after { background: #0ea5e9; }
html[data-theme="light"] .activity-btn.active { background: #0ea5e9; color: #ffffff; }
html[data-theme="light"] .activity-btn.active::before {
  background: #f1f5f9;
  box-shadow: 4px 4px 0 #0ea5e9;
}
html[data-theme="light"] .activity-btn.active::after {
  background: #f1f5f9;
  box-shadow: 4px -4px 0 #0ea5e9;
}
html[data-theme="light"] .file-tree-item,
html[data-theme="light"] .tab               { color: #334155; }
html[data-theme="light"] .tab.active        { color: #0f172a; }

/* Chat panel: light surface with readable bubbles */
html[data-theme="light"] .ai-panel,
html[data-theme="light"] .ai-panel.pinned {
  background: #f8fafc;
  color: #0f172a;
}
html[data-theme="light"] .ai-msg .ai-msg-bubble {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}
html[data-theme="light"] .ai-msg.user .ai-msg-bubble {
  background: rgba(14, 165, 233, 0.12);
}
html[data-theme="light"] .ai-thinking-text { color: #334155 !important; }

/* Menu dropdown — bg + text contrast in light mode */
html[data-theme="light"] .dropdown-menu {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a;
}
html[data-theme="light"] .dropdown-item        { color: #0f172a; }
html[data-theme="light"] .dropdown-item:hover  { background: #0ea5e9; color: #ffffff; }
html[data-theme="light"] .dropdown-item .shortcut { color: #64748b; }
html[data-theme="light"] .dropdown-separator { background: #cbd5e1; }

/* Theme popover — same treatment so it reads on light backdrop */
html[data-theme="light"] .theme-popover {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a;
}
html[data-theme="light"] .tp-label       { color: #475569; }
html[data-theme="light"] .tp-size-btn    { color: #334155; }
html[data-theme="light"] .tp-size-btn.active { background: #0ea5e9; color: #ffffff; }
html[data-theme="light"] .tp-sizes       { background: #f1f5f9; border-color: #cbd5e1; }

/* (Chat-panel space reservation is handled by aiChat.js — it sets
   #main-layout's margin-right to the live panelWidth when the panel opens
   and during the resize drag. No CSS padding needed here.) */

/* ============================================================
   Apple-style glassmorphism (dark mode default).
   Body gets an ambient gradient so the backdrop-filter has color
   to refract; every chrome surface becomes semi-transparent + blurred.
   ============================================================ */
:root:not([data-theme="light"]) body {
  background:
    radial-gradient(ellipse 60% 50% at 12% 0%,  rgba(56,  189, 248, 0.14), transparent 60%),
    radial-gradient(ellipse 55% 45% at 88% 100%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(236, 72, 153, 0.05), transparent 70%),
    linear-gradient(140deg, #08101e 0%, #0c1424 50%, #0a131f 100%) !important;
  background-attachment: fixed;
}

/* All chrome surfaces — translucent + blurred. !important to defeat any
   hardcoded backgrounds. Skip for the light theme, which uses opaque surfaces. */
:root:not([data-theme="light"]) #titlebar,
:root:not([data-theme="light"]) #activity-bar,
:root:not([data-theme="light"]) #sidebar,
:root:not([data-theme="light"]) .tab-bar,
:root:not([data-theme="light"]) .bottom-panel,
:root:not([data-theme="light"]) .ai-panel,
:root:not([data-theme="light"]) .dropdown-menu,
:root:not([data-theme="light"]) .theme-popover,
:root:not([data-theme="light"]) .ai-modal,
:root:not([data-theme="light"]) .welcome-screen,
:root:not([data-theme="light"]) .preview-toolbar,
:root:not([data-theme="light"]) #statusbar {
  background: rgba(18, 26, 42, 0.55) !important;
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Surface tints per theme so each one still feels distinct under glass. */
html[data-theme="midnight"] body { background:
  radial-gradient(ellipse 60% 50% at 10% 0%, rgba(56, 189, 248, 0.18), transparent 60%),
  linear-gradient(140deg, #050b18 0%, #0b1730 100%) !important; }
html[data-theme="ocean"] body { background:
  radial-gradient(ellipse 60% 50% at 50% 0%, rgba(20, 184, 166, 0.18), transparent 60%),
  linear-gradient(140deg, #021526 0%, #06243c 100%) !important; }
html[data-theme="forest"] body { background:
  radial-gradient(ellipse 60% 50% at 50% 100%, rgba(34, 197, 94, 0.16), transparent 60%),
  linear-gradient(140deg, #04130a 0%, #0a1f12 100%) !important; }
html[data-theme="purple"] body { background:
  radial-gradient(ellipse 60% 50% at 50% 0%, rgba(168, 85, 247, 0.22), transparent 60%),
  radial-gradient(ellipse 50% 40% at 100% 100%, rgba(217, 70, 239, 0.14), transparent 60%),
  linear-gradient(140deg, #0d0418 0%, #1a0a30 100%) !important; }
html[data-theme="pink"] body { background:
  radial-gradient(ellipse 60% 50% at 50% 0%, rgba(236, 72, 153, 0.22), transparent 60%),
  radial-gradient(ellipse 50% 40% at 0% 100%, rgba(244, 114, 182, 0.14), transparent 60%),
  linear-gradient(140deg, #190612 0%, #2a0e21 100%) !important; }

/* Tabs, bubbles, inputs — slightly translucent for a layered feel */
:root:not([data-theme="light"]) .tab               { background: rgba(255,255,255,0.02); }
:root:not([data-theme="light"]) .tab.active        { background: rgba(255,255,255,0.06); }
:root:not([data-theme="light"]) .ai-msg-bubble     { background: rgba(255,255,255,0.05) !important; }
:root:not([data-theme="light"]) .ai-msg.user .ai-msg-bubble { background: rgba(56,189,248,0.12) !important; }
:root:not([data-theme="light"]) input[type="text"],
:root:not([data-theme="light"]) textarea,
:root:not([data-theme="light"]) select {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
}

/* Subtle inner highlight on bigger surfaces for the "polished glass" look */
:root:not([data-theme="light"]) .ai-panel,
:root:not([data-theme="light"]) .dropdown-menu,
:root:not([data-theme="light"]) .theme-popover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 16px 40px rgba(0,0,0,0.55);
}

/* Light theme keeps its opaque surfaces but gets a faint frost on the popover/modal
   so floating layers still feel layered. */
html[data-theme="light"] .dropdown-menu,
html[data-theme="light"] .theme-popover,
html[data-theme="light"] .ai-modal {
  background: rgba(255, 255, 255, 0.80) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

/* ============================================================
   Stacked chat bubbles — avatar on top edge, bubble below.
   Theme-matched (dark + cyan accent), no purple.
   ============================================================ */
.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 10px;             /* tighter spacing between messages */
}
.ai-msg.assistant {
  flex-direction: column !important;     /* defeat the old row-reverse rule */
  align-items: flex-start;
}
.ai-msg.user {
  flex-direction: column !important;     /* defeat the original .ai-msg.user row-reverse */
  align-items: flex-end;
}

/* Circular avatar floats above the bubble's top edge, slightly overlapping
   it so it visually "perches" on the bubble. */
.ai-msg .ai-msg-avatar {
  width: 32px !important;          /* smaller avatar = more text space */
  height: 32px !important;
  flex-shrink: 0;
  z-index: 2;
  margin-bottom: -8px;             /* lighter overlap (was -18px) */
  margin-left: -10px;              /* bleeds past the bubble's left edge */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--bg-secondary, #0f1521);   /* halo so the bubble shows behind avatar */
  background: var(--bg-secondary, #0f1521);
}
.ai-msg.user .ai-msg-avatar {
  margin-left: 0;
  margin-right: -10px;             /* mirror past the right edge */
}

/* Body holds the optional name/time header + the bubble */
.ai-msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 92%;
}
.ai-msg.user .ai-msg-body { align-items: flex-end; }

/* "Claude (Opus 4.7) says · now" header pill above bubble */
.ai-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 32px;          /* clear the overlapping avatar (-10 + 32 + breathing) */
  font-size: 10.5px;
  line-height: 1;
  margin-bottom: 1px;
}
.ai-msg.user .ai-msg-header {
  padding: 0 32px 0 14px;
  flex-direction: row-reverse;
}
.ai-msg-name {
  font-weight: 600;
  color: var(--text-primary, #e2e4f0);
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-msg-time {
  color: var(--text-secondary, #8b8fa8);
  font-size: 10.5px;
  flex-shrink: 0;
}

/* Bubble — dark, theme-matched, with a subtle accent border. Extra top
   padding to clear the overlapping avatar. */
.ai-msg .ai-msg-bubble {
  border-radius: 14px !important;
  padding: 10px 16px;              /* tighter — was 26px top, 12px bottom */
  font-size: 13.5px;
  line-height: 1.55;
  position: relative;
  background: var(--bg-tertiary, #161d2c);
  border: 1px solid var(--border, #2a3344);
  color: var(--text-primary, #e2e4f0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  max-width: 100%;
}
.ai-msg.assistant .ai-msg-bubble {
  border-color: rgba(56, 189, 248, 0.30);             /* cyan accent — "AI" */
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(56, 189, 248, 0.08) inset;
}
.ai-msg.user .ai-msg-bubble {
  border-color: rgba(148, 163, 184, 0.25);            /* neutral slate — "you" */
  background: rgba(56, 189, 248, 0.10);               /* faint cyan wash so it reads as user */
}

/* Code blocks / inline code stay squared so fenced code doesn't look weird
   inside a rounded pill. */
.ai-msg-bubble pre,
.ai-msg-bubble .ai-code-block,
.ai-msg-bubble code,
.ai-msg-bubble .ai-inline-code {
  border-radius: 0 !important;
}

/* Action buttons inside the bubble */
.ai-msg-bubble .ai-msg-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.ai-msg-bubble .ai-action-btn {
  border-radius: 999px !important;
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.30);
  color: var(--text-primary, #e2e4f0);
}
.ai-msg-bubble .ai-action-btn:hover {
  background: rgba(56, 189, 248, 0.20);
  border-color: rgba(56, 189, 248, 0.50);
}

/* Active state for the model-bar toggle in the AI panel header */
#btnAIModelBarToggle.active {
  color: var(--accent-light, #2a5a8c);
  background: rgba(56, 189, 248, 0.08);
}

/* Pasted-screenshot preview chips that appear above the chat input. */
.ai-pasted-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.04);
}
.ai-pasted-chip {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 6px !important;          /* defeat no-curves rule */
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.30);
  background: var(--bg-tertiary, #161d2c);
}
.ai-pasted-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ai-pasted-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50% !important;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.ai-pasted-remove:hover { background: rgba(239, 68, 68, 0.85); }

/* Active state for the IDE self-scan toggle — strong visual "ON" cue:
   bright cyan icon, cyan-tinted background, and a tiny pulsing dot in the
   top-right of the button so the user can see at a glance whether Eldar
   has IDE-source access. */
#btnAISelfScan { position: relative; }
#btnAISelfScan.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}
#btnAISelfScan.active::after {
  content: '';
  position: absolute;
  top: 4px; right: 4px;
  width: 6px; height: 6px;
  border-radius: 50% !important;       /* defeat global no-curves rule */
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  animation: ai-pulse 1.6s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 1;    transform: scale(1);    }
  50%      { opacity: 0.55; transform: scale(0.75); }
}

/* ============================================================
   AI assistant icon — image-based (replaces fa-wand-magic-sparkles)
   ============================================================ */
.ai-icon-img {
  width: 1em;
  height: 1em;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
}
/* Fill the avatar circle/square (32x32) without distortion */
.ai-avatar .ai-icon-img,
.ai-msg-avatar .ai-icon-img,
.ai-wand-avatar .ai-icon-img {
  width: 100%;
  height: 100%;
}
/* In the activity bar + titlebar, scale to ~22px (the icon-font size) */
#btnAIChat .ai-icon-img,
#btnAIChatToggle .ai-icon-img {
  width: 1.4em;
  height: 1.4em;
}
/* The avatar bubble background should not show through transparent PNG edges
   — kill the gradient backing when an image is rendered inside. */
.ai-avatar:has(.ai-icon-img),
.ai-msg-avatar:has(.ai-icon-img),
.ai-wand-avatar:has(.ai-icon-img) {
  background: transparent !important;
  box-shadow: none !important;
}

/* While resizing the AI panel, disable the smooth margin-right transition on
   #main-layout — otherwise the editor area lags ~350ms behind the cursor. */
body.resizing-ai-panel #main-layout,
body.resizing-ai-panel .ai-panel {
  transition: none !important;
}

/* ============================================================
   FINAL OVERRIDE — per-theme surface color.
   --surface is the canvas color used by #editor-area, #activity-bar,
   and the curve-cutout circles. Defining all three from the same
   variable guarantees they blend pixel-perfectly per theme (no more
   "ball" silhouettes from color mismatches).
   ============================================================ */
:root,
html[data-theme="dark"]     { --surface: #101523; }
html[data-theme="light"]    { --surface: #f1f5f9; }
html[data-theme="midnight"] { --surface: #101829; }
html[data-theme="ocean"]    { --surface: #0f2035; }
html[data-theme="forest"]   { --surface: #121e22; }
html[data-theme="purple"]   { --surface: #16142c; }
html[data-theme="pink"]     { --surface: #1c1526; }

#editor-area {
  background: var(--surface) !important;
}
html:not([data-theme="light"]) #activity-bar {
  background: var(--surface) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
:root:not([data-theme="light"]) .activity-btn.active::before,
:root:not([data-theme="light"]) .activity-btn.active::after {
  background: #10182800 !important;            /* fully transparent — no silhouette regardless of theme */
}
