/* ═══════════════════════════════════════════════════════════════
   SAVA IDE WEB — Professional Dark Theme Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #1e1e2e;
  --bg-secondary: #181825;
  --bg-tertiary: #11111b;
  --bg-surface: #252535;
  --bg-hover: #2a2a3c;
  --bg-active: #313145;
  --bg-input: #1a1a2e;
  
  --text-primary: #cdd6f4;
  --text-secondary: #a6adc8;
  --text-muted: #6c7086;
  --text-accent: #89b4fa;
  
  --accent: #89b4fa;
  --accent-hover: #74c7ec;
  --accent-green: #a6e3a1;
  --accent-yellow: #f9e2af;
  --accent-red: #f38ba8;
  --accent-purple: #cba6f7;
  --accent-orange: #fab387;
  
  --border: #313244;
  --border-focus: #89b4fa;
  
  --sidebar-width: 240px;

/* ═══════════════════════════════════════════════════════════════
   AUTH OVERLAY
   ═══════════════════════════════════════════════════════════════ */

.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-tertiary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.auth-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-container {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.auth-logo {
  text-align: center;
  margin-bottom: 30px;
}

.auth-logo-img {
  height: 48px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.auth-form h2 {
  color: var(--text-primary);
  font-size: 20px;
  margin: 0 0 20px 0;
  text-align: center;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.auth-field input:focus {
  border-color: var(--accent);
}

.auth-field input::placeholder {
  color: var(--text-muted);
}

.auth-error {
  background: rgba(243, 139, 168, 0.1);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  border: none;
  border-radius: 8px;
  color: var(--bg-tertiary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.auth-btn:hover {
  opacity: 0.9;
}

.auth-btn:active {
  transform: scale(0.98);
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-footer p {
  color: var(--text-muted);
  font-size: 12px;
  margin: 4px 0;
}

.auth-powered {
  color: var(--text-muted);
  opacity: 0.6;
}

/* User badge in titlebar */
.user-badge {
  color: var(--accent-green);
  font-size: 12px;
  padding: 2px 8px;
  background: rgba(166, 227, 161, 0.1);
  border-radius: 4px;
  margin-right: 4px;
}

.storage-badge {
  color: var(--accent-yellow);
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(249, 226, 175, 0.1);
  border-radius: 4px;
  margin-right: 4px;
}
  --chat-width: 380px;
  --titlebar-height: 38px;
  --statusbar-height: 24px;
  --tab-height: 36px;
  --terminal-height: 220px;
  
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-size: 13px;
  --font-size-sm: 12px;
  --font-size-xs: 11px;
  
  --radius: 6px;
  --radius-sm: 4px;
  --transition: 150ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: var(--font-size);
  color: var(--text-primary);
  background: var(--bg-primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══ TITLEBAR ═══ */
#titlebar {
  height: var(--titlebar-height);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
  -webkit-app-region: drag;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-img {
  height: 22px;
  width: auto;
  vertical-align: middle;
}

.model-badge {
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--accent-green);
  border: 1px solid var(--border);
}

.titlebar-center {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.titlebar-right {
  display: flex;
  gap: 4px;
}

.tb-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 30px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background var(--transition);
  -webkit-app-region: no-drag;
}

.tb-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tb-btn.active { background: var(--bg-active); color: var(--accent); }

/* ═══ MAIN LAYOUT ═══ */
#mainLayout {
  display: flex;
  height: calc(100vh - var(--titlebar-height) - var(--statusbar-height));
}

/* ═══ SIDEBAR ═══ */
#sidebar {
  width: var(--sidebar-width);
  min-width: 160px;
  max-width: 400px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar.hidden { display: none; }

.sidebar-header {
  height: var(--tab-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* File Tree */
.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.tree-item.active { background: var(--bg-active); color: var(--accent); }

.tree-item .icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.tree-item .name { overflow: hidden; text-overflow: ellipsis; }

.tree-indent { display: inline-block; width: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.workspace-stats {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Index status indicator */
.index-status {
  padding: 4px 12px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  background: var(--surface1);
  border-bottom: 1px solid var(--surface2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.index-status.hidden { display: none; }
.index-status .index-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.index-status .index-badge.stale { background: var(--yellow); }
.index-status .index-badge.indexing {
  background: var(--blue);
  animation: pulse 1s infinite;
}

/* ═══ RESIZE HANDLES ═══ */
.resize-handle {
  background: transparent;
  transition: background var(--transition);
}

.resize-handle:hover,
.resize-handle.active { background: var(--accent); }

.resize-handle-v {
  width: 6px;
  cursor: col-resize;
  z-index: 10;
}

.resize-handle-h {
  height: 3px;
  cursor: row-resize;
}

/* ═══ CENTER PANEL ═══ */
#centerPanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 300px;
  overflow: hidden;
}

/* Tab bar */
#tabBar {
  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;
}

.tabs-container {
  display: flex;
  align-items: stretch;
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  min-width: 0;
  max-width: 200px;
  position: relative;
}

.tab:hover { background: var(--bg-hover); color: var(--text-secondary); }

.tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
}

.tab .tab-icon { font-size: 12px; flex-shrink: 0; }
.tab .tab-name { overflow: hidden; text-overflow: ellipsis; }

.tab .tab-close {
  margin-left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  transition: all var(--transition);
  background: none;
  border: none;
  cursor: pointer;
}

.tab:hover .tab-close { opacity: 1; }
.tab .tab-close:hover { background: var(--accent-red); color: white; opacity: 1; }

.tab.modified .tab-name::after {
  content: '●';
  margin-left: 4px;
  color: var(--accent-yellow);
  font-size: 10px;
}

/* ═══ EDITOR AREA ═══ */
#editorArea {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#editorContainer {
  width: 100%;
  height: 100%;
  overflow: auto;
}

#editorContainer.hidden { display: none; }

/* CodeMirror fallback textarea editor */
.code-editor {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 16px;
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

/* Line numbers container */
.editor-with-lines {
  display: flex;
  height: 100%;
  width: 100%;
}

.line-numbers {
  padding: 12px 8px 12px 12px;
  text-align: right;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  user-select: none;
  overflow: hidden;
  min-width: 48px;
  flex-shrink: 0;
}

.line-numbers .line-num {
  display: block;
}

.line-numbers .line-num.active-line {
  color: var(--text-primary);
}

.code-textarea {
  flex: 1;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 16px;
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  width: 100%;
}

/* Welcome screen */
#welcomeScreen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg-primary);
  overflow-y: auto;
}

#welcomeScreen.hidden { display: none; }

.welcome-content {
  max-width: 650px;
  text-align: center;
  padding: 20px 40px 40px;
}

.welcome-logo {
  width: 260px;
  max-width: 80%;
  height: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(137, 180, 250, 0.4)) brightness(1.15);
  animation: welcomePulse 3s ease-in-out infinite;
}

@keyframes welcomePulse {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(137, 180, 250, 0.4)) brightness(1.15); }
  50% { filter: drop-shadow(0 0 30px rgba(203, 166, 247, 0.6)) brightness(1.25); }
}

.welcome-content .subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.welcome-content .powered {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 20px;
}

.welcome-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.feature {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
}

.feature .feature-icon { font-size: 24px; display: block; margin-bottom: 8px; }
.feature strong { color: var(--text-primary); display: block; margin-bottom: 4px; }
.feature p { font-size: var(--font-size-sm); color: var(--text-muted); margin: 0; }

.welcome-hint {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
}

.welcome-hint p { margin-bottom: 8px; color: var(--text-secondary); }

.welcome-hint code {
  display: block;
  background: var(--bg-tertiary);
  color: var(--accent-green);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ═══ TERMINAL PANEL ═══ */
#terminalPanel {
  height: var(--terminal-height);
  min-height: 100px;
  max-height: 50vh;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

#terminalPanel.hidden { display: none; }

.terminal-header {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-output .cmd-line { color: var(--accent-green); }
.terminal-output .stdout { color: var(--text-primary); }
.terminal-output .stderr { color: var(--accent-red); }
.terminal-output .info { color: var(--text-muted); font-style: italic; }

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.prompt-symbol {
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-weight: 700;
}

#terminalInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

/* ═══ CHAT PANEL ═══ */
#chatPanel {
  width: var(--chat-width);
  min-width: 280px;
  max-width: 70vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
}

#chatPanel.hidden { display: none; }

.chat-header {
  height: var(--tab-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══ Chat History Drawer ═══ */
.chat-history-drawer {
  position: absolute;
  top: var(--tab-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  animation: slideDown 150ms ease;
}
.chat-history-drawer.hidden { display: none; }
.chat-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.chat-history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 12px;
  font-size: var(--font-size-sm);
}
.chat-history-item {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  margin-bottom: 4px;
  transition: background 150ms;
}
.chat-history-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.chat-history-item.active {
  background: var(--bg-surface);
  border-color: var(--accent-blue);
}
.chat-history-item-title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}
.chat-history-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.chat-history-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
  opacity: 0;
  transition: opacity 150ms;
}
.chat-history-item:hover .chat-history-delete { opacity: 1; }
.chat-history-delete:hover { color: var(--accent-red); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.model-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  padding: 2px 6px;
  outline: none;
  cursor: pointer;
}

.model-select:focus { border-color: var(--accent); }

.thinking-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  padding: 2px 6px;
  outline: none;
  cursor: pointer;
}
.thinking-select:focus { border-color: var(--accent-yellow); }

/* Thinking indicator in chat */
.thinking-block {
  background: rgba(249, 226, 175, 0.08);
  border-left: 3px solid var(--accent-yellow);
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  font-size: var(--font-size-xs);
  color: var(--accent-yellow);
  opacity: 0.85;
}
.thinking-block::before {
  content: '🧠 Pensando: ';
  font-weight: 600;
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.chat-welcome p { margin-bottom: 8px; font-size: var(--font-size-sm); color: var(--text-secondary); }
.chat-welcome .hint { color: var(--text-muted); font-style: italic; }

.chat-msg {
  display: flex;
  flex-direction: column;
  animation: fadeIn 200ms ease;
  padding: 8px 12px;
  border-radius: var(--radius);
}

.chat-msg.user {
  background: rgba(137, 180, 250, 0.08);
  border-left: 3px solid var(--accent);
}

.chat-msg.assistant {
  background: transparent;
  border-left: 3px solid var(--accent-purple);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg .bubble {
  flex: 1;
  min-width: 0;
}

.chat-msg .bubble .sender {
  font-size: var(--font-size-xs);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-msg.user .bubble .sender { color: var(--accent); }
.chat-msg.assistant .bubble .sender { color: var(--accent-purple); }

.chat-msg .bubble .content {
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Markdown in chat */
.chat-msg .bubble .content p { margin-bottom: 8px; }
.chat-msg .bubble .content p:last-child { margin-bottom: 0; }

.chat-msg .bubble .content code {
  background: var(--bg-tertiary);
  color: var(--accent-orange);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

.chat-msg .bubble .content pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 8px 0;
  overflow-x: auto;
  position: relative;
}

.chat-msg .bubble .content pre code {
  background: none;
  color: var(--text-primary);
  padding: 0;
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

.chat-msg .bubble .content pre .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  opacity: 0;
  transition: opacity var(--transition);
}

.chat-msg .bubble .content pre:hover .copy-btn { opacity: 1; }
.chat-msg .bubble .content pre .copy-btn:hover { background: var(--accent); color: var(--bg-primary); }

.chat-msg .bubble .content ul,
.chat-msg .bubble .content ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.chat-msg .bubble .content li { margin-bottom: 4px; }

.chat-msg .bubble .content strong { color: var(--accent); }

.chat-msg .bubble .content h1,
.chat-msg .bubble .content h2,
.chat-msg .bubble .content h3 {
  color: var(--text-primary);
  margin: 12px 0 6px;
  font-size: 14px;
}

.chat-msg .bubble .content h1 { font-size: 16px; }

.chat-msg .bubble .content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
}

/* Chat status */
.chat-status {
  padding: 6px 12px;
  font-size: var(--font-size-xs);
  color: var(--accent-yellow);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-status.hidden { display: none; }

.chat-status .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Agent Progress Panel */
.agent-progress {
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  max-height: 200px;
  overflow-y: auto;
  font-size: var(--font-size-xs);
  transition: max-height 0.2s ease;
}

.agent-progress.hidden { display: none; }

.agent-progress.minimized {
  max-height: 32px;
  overflow: hidden;
}

.agent-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  font-weight: 600;
  color: var(--accent);
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  z-index: 1;
  border-bottom: 1px solid var(--border);
}

.agent-progress-header .icon-btn {
  font-size: 10px;
  padding: 2px 6px;
}

.agent-steps {
  padding: 4px 8px;
}

.agent-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.agent-step:hover {
  background: var(--bg-secondary);
}

.agent-step-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.agent-step-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-step-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  flex-shrink: 0;
}

.agent-step.step-running { color: var(--accent-yellow); }
.agent-step.step-running .agent-step-icon { animation: pulse 1s infinite; }
.agent-step.step-success { color: var(--accent-green, #a6e3a1); }
.agent-step.step-error { color: var(--accent-red); }
.agent-step.step-plan { color: var(--accent-purple); }

.agent-step-badge.badge-success { background: rgba(166, 227, 161, 0.15); color: #a6e3a1; }
.agent-step-badge.badge-error { background: rgba(243, 139, 168, 0.15); color: var(--accent-red); }
.agent-step-badge.badge-running { background: rgba(249, 226, 175, 0.15); color: var(--accent-yellow); }
.agent-step-badge.badge-plan { background: rgba(203, 166, 247, 0.15); color: var(--accent-purple); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Diff View — Collapsible */
.diff-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 8px 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

.diff-container > summary {
  list-style: none;
  cursor: pointer;
}
.diff-container > summary::-webkit-details-marker { display: none; }
.diff-container > summary::before {
  content: '▸';
  margin-right: 6px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.diff-container[open] > summary::before {
  transform: rotate(90deg);
}

.diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-family);
  transition: background 0.15s;
}
.diff-header:hover {
  background: var(--bg-hover);
}

.diff-header .diff-filename { color: var(--accent); }
.diff-header .diff-stats { font-size: 10px; }
.diff-header .diff-stats .additions { color: #a6e3a1; }
.diff-header .diff-stats .deletions { color: var(--accent-red); }

.diff-body {
  max-height: 300px;
  overflow-y: auto;
}

.diff-line {
  display: flex;
  white-space: pre;
  line-height: 1.5;
  padding: 0 8px;
}

.diff-line-num {
  width: 40px;
  text-align: right;
  padding-right: 8px;
  color: var(--text-muted);
  user-select: none;
  flex-shrink: 0;
}

.diff-line-content {
  flex: 1;
  overflow-x: auto;
}

.diff-line.diff-add {
  background: rgba(166, 227, 161, 0.1);
  color: #a6e3a1;
}

.diff-line.diff-remove {
  background: rgba(243, 139, 168, 0.1);
  color: var(--accent-red);
}

.diff-line.diff-context {
  color: var(--text-secondary);
}

/* No credits banner */
.no-credits-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: #3d1212;
  color: #f87171;
  font-size: 12px;
  border-bottom: 1px solid #5c1a1a;
}
.no-credits-bar a {
  color: #60a5fa;
  text-decoration: underline;
  cursor: pointer;
}

/* Chat input */
.chat-input-area {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  transition: outline 0.15s;
}

.chat-input-wrapper {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.attach-btn {
  font-size: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.attach-btn:hover { opacity: 1; }

/* Attachment chips */
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.chat-attachments.hidden { display: none; }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
}
.attach-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-chip .chip-thumb {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}
.attach-chip .chip-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.attach-chip .chip-remove {
  cursor: pointer;
  opacity: 0.5;
  font-size: 12px;
  flex-shrink: 0;
  margin-left: 2px;
}
.attach-chip .chip-remove:hover { opacity: 1; color: var(--accent-red, #f38ba8); }

#chatInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  padding: 8px 12px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color var(--transition);
}

#chatInput:focus { border-color: var(--accent); }

#chatInput::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all var(--transition);
}

.send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.send-btn.stop-mode { background: #e64553; animation: pulse-stop 1.5s infinite; }
.send-btn.stop-mode:hover { background: #d20f39; transform: scale(1.1); }
@keyframes pulse-stop {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 69, 83, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(230, 69, 83, 0); }
}

/* ═══ STATUS BAR ═══ */
#statusBar {
  height: var(--statusbar-height);
  background: #16825d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: var(--font-size-xs);
  color: #ffffff;
  user-select: none;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-item { font-weight: 500; }
.status-clickable { cursor: pointer; opacity: 0.9; }
.status-clickable:hover { opacity: 1; text-decoration: underline; }
.status-brand { opacity: 0.7; font-style: italic; margin-left: 4px; }

/* ═══ WORKSPACE SELECTOR ═══ */
.workspace-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.ws-select {
  flex: 1;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: var(--font-size-xs);
  font-family: var(--font-ui);
  cursor: pointer;
  outline: none;
}
.ws-select:focus { border-color: var(--accent); }

.sidebar-header-actions {
  display: flex;
  gap: 2px;
}

/* ═══ CHAT EXPANDED MODE ═══ */
#chatPanel.expanded {
  position: fixed;
  left: 0;
  top: var(--titlebar-height);
  bottom: var(--statusbar-height);
  width: 100% !important;
  max-width: 100% !important;
  z-index: 200;
  border-left: none;
}

#chatPanel.expanded .chat-messages {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

#chatPanel.expanded .chat-input-area {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

#chatPanel.expanded ~ #centerPanel,
#chatPanel.expanded ~ #sidebar,
#chatPanel.expanded ~ .resize-handle {
  display: none;
}

/* ═══ TODO PANEL ═══ */
.todos-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  max-height: 300px;
  display: flex;
  flex-direction: column;
}

.todos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.todos-header div {
  display: flex;
  gap: 2px;
}

.todos-input-row {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.todos-input-row input {
  flex: 1;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: var(--font-size-sm);
  font-family: var(--font-ui);
  outline: none;
}
.todos-input-row input:focus { border-color: var(--accent); }

.todo-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.todo-item:hover { background: var(--bg-hover); }

.todo-item input[type="checkbox"] {
  accent-color: var(--accent-green);
  cursor: pointer;
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-text {
  flex: 1;
  color: var(--text-primary);
}

.todo-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--accent-red);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  transition: opacity var(--transition);
}
.todo-item:hover .todo-delete { opacity: 1; }

/* ═══ DOWNLOAD/EXPORT ACTION BUTTONS ═══ */
.action-btn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ═══ CONTEXT MENU (right-click on files) ═══ */
.context-menu {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  min-width: 160px;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.context-menu-item {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
}
.context-menu-item:hover {
  background: var(--accent);
  color: var(--bg-primary);
}

.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ═══ UTILITIES ═══ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   CODEMIRROR 6 — Editor Overrides
   ═══════════════════════════════════════════════════════════════ */

#editorContainer .cm-editor {
  height: 100%;
  font-size: 13px;
}

#editorContainer .cm-scroller {
  overflow: auto;
}

/* Ghost Text — Inline AI Completions */
.cm-ghost-text {
  color: #6c708688;
  font-style: italic;
  pointer-events: none;
  user-select: none;
}

.cm-ghost-more {
  color: #6c708655;
  font-size: 0.85em;
  margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   GITHUB MODAL
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.gh-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.gh-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.gh-modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.gh-connect {
  text-align: center;
  padding: 16px 0;
}

.gh-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 8px;
  outline: none;
}
.gh-input:focus {
  border-color: var(--accent);
}

.gh-btn {
  padding: 6px 16px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.2s;
}
.gh-btn:hover { opacity: 0.9; }

.gh-btn-sm {
  padding: 3px 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.gh-btn-sm:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.gh-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.gh-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.gh-login {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}

.gh-section {
  margin: 8px 0;
}

.gh-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 8px 0 4px;
  letter-spacing: 0.5px;
}

.gh-repo-list, .gh-pr-list {
  max-height: 250px;
  overflow-y: auto;
}

.gh-repo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}
.gh-repo-item:hover {
  background: var(--bg-hover);
}

.gh-repo-name {
  font-size: 12px;
  color: var(--text-primary);
}

.gh-repo-lang {
  font-size: 10px;
  color: var(--text-muted);
}

.gh-pr-item {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  background: var(--bg-surface);
}

.gh-pr-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}

.gh-pr-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.gh-pr-title {
  font-size: 12px;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.3;
}

.gh-pr-draft {
  font-size: 9px;
  background: var(--accent-yellow);
  color: var(--bg-primary);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.gh-pr-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.gh-label {
  font-size: 9px;
  background: var(--accent-purple);
  color: var(--bg-primary);
  padding: 1px 5px;
  border-radius: 3px;
}

.gh-pr-actions {
  display: flex;
  gap: 6px;
}

/* ═══ CREDITS MODAL ═══ */
.credits-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.credits-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.credits-modal-body {
  padding: 16px;
}

.credits-balance {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.credits-balance strong {
  color: var(--accent-yellow);
  font-size: 18px;
}

.credit-packages {
  display: grid;
  gap: 10px;
}

.credit-package {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.credit-package:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.credit-package-info {
  display: flex;
  flex-direction: column;
}

.credit-package-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.credit-package-credits {
  font-size: 11px;
  color: var(--text-muted);
}

.credit-package-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-green);
}

.credits-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 12px 0 8px;
}

.credits-powered {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}

/* ═══ SERVER PREVIEW PANEL ═══ */
.server-preview-panel {
  position: fixed;
  right: 16px;
  bottom: calc(var(--statusbar-height) + 12px);
  width: 480px;
  height: 380px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  min-width: 320px;
  min-height: 250px;
}
.server-preview-panel.expanded {
  width: 90vw;
  height: 80vh;
  right: 5vw;
  bottom: 10vh;
}
.server-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  cursor: move;
  flex-shrink: 0;
}
.server-preview-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.server-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  display: inline-block;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.server-preview-port {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 1px 6px;
  border-radius: 4px;
}
.server-preview-actions {
  display: flex;
  gap: 2px;
}
.server-preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* Server count badge on title bar button */
.server-count-badge {
  font-size: 9px;
  background: var(--accent-green);
  color: #000;
  border-radius: 8px;
  padding: 0 5px;
  margin-left: 2px;
  font-weight: 700;
  min-width: 14px;
  display: inline-block;
  text-align: center;
}
#btnServers.has-servers {
  color: var(--accent-green);
}

/* ═══ SERVER MANAGER MODAL ═══ */
.server-manager-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 440px;
  max-width: 90vw;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.server-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.server-manager-body {
  padding: 12px;
  overflow-y: auto;
  max-height: 50vh;
}
.server-manager-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  font-size: 13px;
}
.server-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.server-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.server-card-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.server-card-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.server-card-title .dot.running { background: var(--accent-green); }
.server-card-title .dot.stopped { background: var(--accent-red); }
.server-card-command {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}
.server-card-actions {
  display: flex;
  gap: 6px;
}
.server-card-actions button {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.server-card-actions button:hover {
  background: var(--border);
}
.server-card-actions .btn-preview {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.server-card-actions .btn-preview:hover {
  opacity: 0.85;
}
.server-card-actions .btn-stop {
  color: var(--accent-red);
  border-color: var(--accent-red);
}
.server-card-actions .btn-stop:hover {
  background: var(--accent-red);
  color: #fff;
}

/* ═══ AGENT STEP: Preview button inline ═══ */
.agent-step-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  margin-left: 6px;
  transition: opacity 0.15s;
}
.agent-step-preview-btn:hover {
  opacity: 0.8;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) {
  #sidebar { width: 200px; }
  #chatPanel { width: 300px; }
}

@media (max-width: 700px) {
  #sidebar { display: none; }
  #chatPanel { 
    position: fixed;
    right: 0;
    top: var(--titlebar-height);
    bottom: var(--statusbar-height);
    width: 100%;
    z-index: 100;
  }
}

/* ═══ SAVA MODAL (reusable) ═══ */
.sava-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: savaModalFadeIn 150ms ease;
}
.sava-modal-overlay.hidden { display: none; }

@keyframes savaModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sava-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 340px;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(137, 180, 250, 0.1);
  animation: savaModalSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes savaModalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.sava-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--accent);
}

.sava-modal-header .icon-btn {
  color: var(--text-muted);
  font-size: 14px;
}

.sava-modal-body {
  padding: 18px;
}

.sava-modal-body p {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
}

.sava-modal-input {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 150ms;
}

.sava-modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.15);
}

.sava-modal-input.hidden { display: none; }

.sava-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.sava-modal-btn {
  padding: 7px 18px;
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 150ms;
  font-family: var(--font-ui);
}

.sava-modal-btn.secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.sava-modal-btn.secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sava-modal-btn.primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}
.sava-modal-btn.primary:hover {
  filter: brightness(1.15);
}

.sava-modal-btn.danger {
  background: var(--accent-red);
  color: var(--bg-primary);
  border-color: var(--accent-red);
}
.sava-modal-btn.danger:hover {
  filter: brightness(1.15);
}

.sava-modal-btn.success {
  background: var(--accent-green);
  color: var(--bg-primary);
  border-color: var(--accent-green);
}
.sava-modal-btn.success:hover {
  filter: brightness(1.15);
}

/* ═══ APPS PANEL ═══ */
.apps-panel-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 60px;
}
.apps-panel-overlay.hidden { display: none; }
.apps-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(600px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: savaModalSlide 0.2s ease-out;
}
.apps-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
}
.apps-panel-body {
  padding: 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.app-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  transition: border-color 0.15s;
}
.app-card:hover { border-color: var(--accent); }
.app-card.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--bg-primary)); }
.app-card.coming-soon { opacity: 0.6; }
.app-card.coming-soon:hover { border-color: var(--border); }
.app-card-icon {
  flex-shrink: 0;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 10px;
}
.app-card-info { flex: 1; min-width: 0; }
.app-card-info h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.app-card-info p { margin: 0 0 6px; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.app-card-status { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-dot.active { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.available { background: #89b4fa; }
.status-dot.soon { background: var(--text-muted); }
.app-card-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.app-btn {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none; text-align: center; white-space: nowrap;
  transition: filter 0.15s;
}
.app-btn:hover { filter: brightness(1.15); }
.app-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.app-btn.secondary {
  background: transparent; color: var(--text-muted); border-color: var(--border);
}
.app-btn.secondary:hover { border-color: var(--text-muted); color: var(--text-primary); }
.apps-account-info {
  margin-top: 4px; padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 8px;
  font-size: 12px; color: var(--text-muted);
  text-align: center;
}

/* ═══ MANUAL MODAL ═══ */
.manual-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(800px, 94vw);
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: savaModalSlide 0.2s ease-out;
}
.manual-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
}
.manual-modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 13px; line-height: 1.7;
  color: var(--text-primary);
}
.manual-modal-body h2 {
  font-size: 18px; margin: 24px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border); color: var(--accent);
}
.manual-modal-body h2:first-child { margin-top: 0; }
.manual-modal-body h3 { font-size: 14px; margin: 16px 0 6px; color: var(--text-primary); }
.manual-modal-body p { margin: 0 0 10px; }
.manual-modal-body ul, .manual-modal-body ol { margin: 0 0 12px; padding-left: 22px; }
.manual-modal-body li { margin-bottom: 4px; }
.manual-modal-body code {
  background: var(--bg-primary); padding: 2px 6px; border-radius: 4px;
  font-size: 12px; color: var(--accent);
}
.manual-modal-body kbd {
  background: var(--bg-primary); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px; font-size: 11px; font-family: inherit;
}
.manual-modal-body .manual-section {
  margin-bottom: 20px; padding: 14px;
  background: var(--bg-primary); border-radius: 8px;
  border: 1px solid var(--border);
}
.manual-modal-body .tip {
  padding: 10px 14px; border-radius: 6px; margin: 10px 0;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-left: 3px solid var(--accent);
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   PROFESSIONAL TOOLTIPS
   ═══════════════════════════════════════════════════════════════ */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 10000;
}
[data-tooltip]::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  padding: 5px 10px;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e2e8f0;
  border: 1px solid #3b3b5c;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  letter-spacing: 0.01em;
}
[data-tooltip]::after {
  content: '';
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: #3b3b5c;
}
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Tooltip bottom position */
[data-tooltip-pos="bottom"]::before {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
}
[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #3b3b5c;
  transform: translateX(-50%) translateY(-4px);
}
[data-tooltip-pos="bottom"]:hover::before,
[data-tooltip-pos="bottom"]:hover::after {
  transform: translateX(-50%) translateY(0);
}
/* Tooltip left position */
[data-tooltip-pos="left"]::before {
  bottom: auto;
  left: auto;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
}
[data-tooltip-pos="left"]::after {
  bottom: auto;
  left: auto;
  right: calc(100% + 2px);
  top: 50%;
  border-top-color: transparent;
  border-right-color: transparent;
  border-left-color: #3b3b5c;
  transform: translateY(-50%) translateX(4px);
}
[data-tooltip-pos="left"]:hover::before,
[data-tooltip-pos="left"]:hover::after {
  transform: translateY(-50%) translateX(0);
}
/* Prevent tooltip cut-off on edge buttons */
.titlebar-right [data-tooltip]::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
}
.titlebar-right [data-tooltip]::after {
  left: auto;
  right: 12px;
  transform: translateX(0) translateY(4px);
}
.titlebar-right [data-tooltip]:hover::before,
.titlebar-right [data-tooltip]:hover::after {
  transform: translateX(0) translateY(0);
}
/* Keyboard shortcut styling inside tooltip */
[data-tooltip] .kbd {
  font-size: 9px;
  opacity: .7;
}
