/* ═══════════════════════════════════════════════════════════
   ANTRA — Design System & Layout
   Palette: Volcanic Glass variant — deep IDE dark
   Fonts: Geist (UI) + JetBrains Mono (code)
═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  /* Backgrounds */
  --bg-base:        #0D0E11;
  --bg-surface:     #111318;
  --bg-elevated:    #161820;
  --bg-panel:       #13151A;
  --bg-hover:       #1C1F28;
  --bg-active:      #1F2230;
  --bg-selection:   #2A2D3E;

  /* Borders */
  --border:         #1E2130;
  --border-subtle:  #191C26;
  --border-focus:   #7C6FFF44;

  /* Text */
  --text-primary:   #E2E4EC;
  --text-secondary: #8B90A8;
  --text-muted:     #4E5368;
  --text-dim:       #363A4F;

  /* Accent */
  --accent:         #7C6FFF;
  --accent-dim:     #7C6FFF22;
  --accent-hover:   #9488FF;
  --accent-glow:    #7C6FFF33;

  /* Semantic */
  --green:          #4ADE80;
  --green-dim:      #4ADE8022;
  --red:            #F87171;
  --red-dim:        #F8717122;
  --yellow:         #FBBF24;
  --yellow-dim:     #FBBF2422;
  --blue:           #60A5FA;
  --blue-dim:       #60A5FA22;
  --cyan:           #22D3EE;

  /* Syntax */
  --syn-keyword:    #C084FC;
  --syn-string:     #86EFAC;
  --syn-number:     #FCA5A5;
  --syn-comment:    #4E5368;
  --syn-function:   #93C5FD;
  --syn-operator:   #94A3B8;
  --syn-type:       #67E8F9;

  /* Layout */
  --topbar-h:       44px;
  --mobile-nav-h:   58px;
  --files-w:        220px;
  --ai-w:           300px;
  --terminal-h:     200px;
  --resize-w:       4px;

  /* Typography */
  --font-ui:        'Geist', -apple-system, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  /* Radius */
  --r-sm:           4px;
  --r-md:           6px;
  --r-lg:           10px;

  /* Transitions */
  --t-fast:         120ms ease;
  --t-mid:          200ms ease;
  --t-slow:         300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

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

button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; outline: none; }
textarea { resize: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
::selection { background: var(--bg-selection); }

/* ═══════════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  z-index: 100;
  user-select: none;
}

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

.app-logo {
  display: flex;
  align-items: center;
  gap: 7px;
}

.app-name {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  background: linear-gradient(135deg, #E2E4EC 0%, #9488FF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.divider-v {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

.project-name-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
  color: var(--text-secondary);
}
.project-name-wrap:hover { background: var(--bg-hover); }

.project-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron { transition: transform var(--t-fast); }

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
}

.breadcrumb-file {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

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

.btn-icon {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  font-size: 12px;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.active { background: var(--accent-dim); color: var(--accent); }

.btn-label { font-size: 12px; }

.btn-run {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-run:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}
.btn-run:active { transform: scale(0.97); }
.btn-run.running { animation: pulse-run 1s ease infinite; }

@keyframes pulse-run {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow); }
}

/* ═══════════════════════════════════════════════
   WORKSPACE LAYOUT
═══════════════════════════════════════════════ */
.workspace {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  overflow: hidden;
}

/* ── Resize Handles ── */
.resize-handle {
  width: var(--resize-w);
  background: var(--border-subtle);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--t-fast);
  position: relative;
  z-index: 10;
}
.resize-handle:hover,
.resize-handle.dragging { background: var(--accent); }

.resize-handle-h {
  height: var(--resize-w);
  background: var(--border-subtle);
  cursor: row-resize;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.resize-handle-h:hover,
.resize-handle-h.dragging { background: var(--accent); }

/* ═══════════════════════════════════════════════
   PANELS — Base
═══════════════════════════════════════════════ */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  overflow: hidden;
  flex-shrink: 0;
}

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

.panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ═══════════════════════════════════════════════
   FILE MANAGER
═══════════════════════════════════════════════ */
.panel-files {
  width: var(--files-w);
  border-right: 1px solid var(--border);
}

.project-section { flex: 1; overflow-y: auto; padding: 6px 0; }

.project-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: background var(--t-fast);
  user-select: none;
}
.project-label:hover { background: var(--bg-hover); }
.project-label span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tree-arrow { transition: transform var(--t-fast); flex-shrink: 0; }
.tree-arrow.open { transform: rotate(0deg); }
.tree-arrow:not(.open) { transform: rotate(-90deg); }

.file-tree { padding: 2px 0; }

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 24px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12.5px;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  position: relative;
  border-left: 2px solid transparent;
}
.file-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.file-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  border-left-color: var(--accent);
}
.file-item.modified .file-item-name::after {
  content: '●';
  font-size: 8px;
  color: var(--yellow);
  margin-left: 4px;
  vertical-align: middle;
}

.file-item-icon { flex-shrink: 0; }
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-item-actions {
  display: none;
  gap: 2px;
  margin-left: auto;
}
.file-item:hover .file-item-actions { display: flex; }

.file-ext-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-selection);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* File type colors */
.file-icon-js  { color: #F7DF1E; }
.file-icon-ts  { color: #3178C6; }
.file-icon-py  { color: #3572A5; }
.file-icon-html{ color: #E34C26; }
.file-icon-css { color: #563D7C; }
.file-icon-json{ color: #FBBF24; }
.file-icon-md  { color: #60A5FA; }
.file-icon-txt { color: #8B90A8; }
.file-icon-default { color: #6B7280; }

/* ═══════════════════════════════════════════════
   CENTER PANEL (Editor + Terminal)
═══════════════════════════════════════════════ */
.panel-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-base);
}

/* ── Editor Tabs ── */
.editor-tabs {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: 36px;
  flex-shrink: 0;
  overflow: hidden;
}

.tabs-list {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tabs-list::-webkit-scrollbar { display: none; }

.editor-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  flex-shrink: 0;
  user-select: none;
}
.editor-tab:hover { background: var(--bg-hover); color: var(--text-secondary); }
.editor-tab.active {
  background: var(--bg-base);
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
}
.editor-tab.modified .tab-name::after {
  content: '●';
  font-size: 8px;
  color: var(--yellow);
  margin-left: 4px;
}

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.editor-tab:hover .tab-close,
.editor-tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: var(--bg-selection); color: var(--text-primary); }

.tabs-actions {
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Editor Area ── */
.editor-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.editor-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
}

.welcome-icon { opacity: 0.5; }

.welcome-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #E2E4EC 0%, #7C6FFF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-sub {
  font-size: 13px;
  color: var(--text-dim);
}

.welcome-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  min-width: 28px;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.line-numbers {
  padding: 12px 0;
  min-width: 48px;
  text-align: right;
  padding-right: 12px;
  padding-left: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  user-select: none;
  overflow: hidden;
  flex-shrink: 0;
  white-space: pre;
}

.code-editor {
  flex: 1;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  caret-color: var(--accent);
  tab-size: 2;
  overflow: auto;
  white-space: pre;
}
.code-editor:focus { outline: none; }

/* ═══════════════════════════════════════════════
   TERMINAL PANEL
═══════════════════════════════════════════════ */
.terminal-panel {
  display: flex;
  flex-direction: column;
  height: var(--terminal-h);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  transition: height var(--t-slow);
}

.terminal-panel.collapsed { height: 36px; }

.terminal-tabs {
  display: flex;
  align-items: center;
  height: 36px;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  gap: 2px;
  flex-shrink: 0;
}

.term-tab {
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.term-tab:hover { color: var(--text-secondary); }
.term-tab.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

.term-spacer { flex: 1; }

.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 0;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
}

.term-line { display: block; }
.term-info  { color: var(--blue); }
.term-dim   { color: var(--text-dim); }
.term-success { color: var(--green); }
.term-error { color: var(--red); }
.term-warn  { color: var(--yellow); }
.term-output { color: var(--text-secondary); }
.term-cmd   { color: var(--accent); }

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 0;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.term-prompt {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12.5px;
  flex-shrink: 0;
}

.term-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  caret-color: var(--accent);
  background: none;
}
.term-input::placeholder { color: var(--text-dim); }

/* ═══════════════════════════════════════════════
   AI CHAT PANEL
═══════════════════════════════════════════════ */
.panel-ai {
  width: var(--ai-w);
  border-left: 1px solid var(--border);
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2.5s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--green); }
  50% { opacity: 0.6; box-shadow: 0 0 2px var(--green); }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  animation: msg-in var(--t-slow) both;
}

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

.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg.assistant .msg-avatar {
  background: var(--accent-dim);
  border: 1px solid var(--accent)33;
}

.chat-msg.user .msg-avatar {
  background: var(--bg-selection);
  border: 1px solid var(--border);
}

.msg-content { flex: 1; min-width: 0; }

.msg-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.chat-msg.user .msg-name { color: var(--accent); }

.msg-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  word-break: break-word;
}

.msg-text code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-selection);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--syn-function);
}

.msg-text pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-top: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.chat-msg.user .msg-text {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  color: var(--text-primary);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1.2s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Chat Input */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.chat-context-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11px;
}

.context-label { color: var(--text-dim); }
.context-file {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  transition: border-color var(--t-fast);
}
.chat-input-wrap:focus-within { border-color: var(--accent)66; }

.chat-input {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  caret-color: var(--accent);
}
.chat-input::placeholder { color: var(--text-dim); }

.chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
  transition: background var(--t-fast), transform var(--t-fast);
}
.chat-send:hover { background: var(--accent-hover); }
.chat-send:active { transform: scale(0.93); }
.chat-send:disabled { background: var(--bg-selection); color: var(--text-dim); cursor: not-allowed; }

.chat-hint {
  font-size: 10.5px;
  color: var(--text-dim);
  text-align: right;
}

/* ═══════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  transform: translateY(8px) scale(0.98);
  transition: transform var(--t-mid);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

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

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

.modal-body { padding: 16px 18px; }

.modal-label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.modal-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--t-fast);
}
.modal-input:focus { border-color: var(--accent)66; }

.modal-select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236B7280' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

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

.btn-ghost {
  padding: 7px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-primary {
  padding: 7px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  transition: background var(--t-fast);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red)33;
  transition: background var(--t-fast);
}
.btn-danger:hover { background: var(--red)22; }

/* Settings */
.settings-body { display: flex; flex-direction: column; gap: 14px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-label {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.setting-row .modal-input,
.setting-row .modal-select { max-width: 160px; }

.danger-row { padding-top: 8px; border-top: 1px solid var(--border); }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-selection);
  border-radius: 10px;
  transition: background var(--t-fast);
  border: 1px solid var(--border);
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--t-fast), background var(--t-fast);
}
.toggle input:checked + .toggle-track { background: var(--accent-dim); border-color: var(--accent)44; }
.toggle input:checked + .toggle-track::after { transform: translate(16px, -50%); background: var(--accent); }

/* ═══════════════════════════════════════════════
   CONTEXT MENU
═══════════════════════════════════════════════ */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  min-width: 140px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.context-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

.ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.ctx-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-item.ctx-danger { color: var(--red); }
.ctx-item.ctx-danger:hover { background: var(--red-dim); }

.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 72px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: toast-in 0.25s ease both;
  pointer-events: all;
  max-width: 280px;
}
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--accent); }
.toast.toast-out     { animation: toast-out 0.2s ease both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

/* ═══════════════════════════════════════════════
   MOBILE BOTTOM NAV
═══════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  border-radius: var(--r-md);
  transition: color var(--t-fast), background var(--t-fast);
  cursor: pointer;
}
.mobile-tab:hover { color: var(--text-secondary); }
.mobile-tab.active { color: var(--accent); }
.mobile-tab.active svg { filter: drop-shadow(0 0 4px var(--accent)66); }

/* ═══════════════════════════════════════════════
   RESPONSIVE — DESKTOP
═══════════════════════════════════════════════ */
@media (min-width: 769px) {
  .mobile-nav { display: none !important; }

  .workspace {
    bottom: 0;
  }

  .panel-files,
  .panel-ai,
  .panel-center { display: flex !important; }

  .resize-handle,
  .resize-handle-h { display: block !important; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — MOBILE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --topbar-h: 48px;
  }

  .mobile-nav {
    display: flex;
    align-items: stretch;
  }

  .workspace {
    bottom: var(--mobile-nav-h);
  }

  /* Hide all panels by default on mobile */
  .panel-files,
  .panel-ai,
  .panel-center { display: none; }

  /* Show active panel */
  .panel-files.mobile-active,
  .panel-ai.mobile-active,
  .panel-center.mobile-active {
    display: flex;
    flex: 1;
    width: 100%;
  }

  /* Terminal panel on mobile */
  .panel-center.mobile-active { flex-direction: column; }

  /* Hide resize handles on mobile */
  .resize-handle,
  .resize-handle-h { display: none !important; }

  /* Topbar adjustments */
  .topbar-center { display: none; }
  .btn-label { display: none; }
  .project-name { max-width: 80px; }

  /* File panel full width */
  .panel-files { width: 100%; border-right: none; }

  /* AI panel full width */
  .panel-ai { width: 100%; border-left: none; }

  /* Terminal always visible in editor panel on mobile */
  .terminal-panel { height: 200px; }

  /* Modal adjustments */
  .modal { width: calc(100vw - 32px); }
}

/* ═══════════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════════ */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Fade in animation for panels */
@keyframes panel-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.panel-files.mobile-active,
.panel-ai.mobile-active,
.panel-center.mobile-active {
  animation: panel-fade 0.15s ease both;
}

/* Save flash */
@keyframes save-flash {
  0%   { background: var(--green-dim); }
  100% { background: transparent; }
}
.save-flash { animation: save-flash 0.6s ease; }

/* Scrollbar for chat */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); }