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

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-input: #1c2541;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --accent: #4fc3f7;
  --accent-hover: #29b6f6;
  --success: #66bb6a;
  --warning: #ffa726;
  --error: #ef5350;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --shadow: rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --radius-sm: 4px;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* ========== LOGIN PAGE ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.login-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

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

.login-form input {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 16px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}

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

.login-form button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #1a1a2e;
  font-size: 16px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  padding: 4px 0;
}

/* ========== MAIN APP ========== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ========== HEADER ========== */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

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

.header-left h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge.idle { background: #333; color: #888; }
.status-badge.connected { background: #1b5e20; color: #a5d6a7; }
.status-badge.running { background: #e65100; color: #ffcc80; }
.status-badge.error { background: #b71c1c; color: #ef9a9a; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

/* Model Selector */
.model-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.model-selector label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.model-selector select {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  max-width: 160px;
}

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

.model-selector select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Mode Selector (single vs multi-agent) */
.mode-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mode-selector label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mode-selector select {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  max-width: 120px;
}

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

.mode-selector select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Orchestration options */
.orch-options {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.orch-options label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.orch-options select {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
  max-width: 60px;
}

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

.orch-options select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.orch-options input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

.config-sep { color: var(--border-light); }

.message.orchestration .message-header {
  color: var(--accent);
  font-size: 11px;
}

.message.orchestration .message-body {
  background: rgba(79, 195, 247, 0.05);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  max-height: 200px;
}

.config-info {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

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

/* ========== SETTINGS PANEL ========== */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

.settings-header h3 {
  font-size: 16px;
  color: var(--text-primary);
}

.settings-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.setting-group input {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}

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

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #1a1a2e;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

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

.settings-status {
  font-size: 12px;
  color: var(--success);
  text-align: center;
  padding: 4px;
}

.settings-divider {
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.settings-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.btn-secondary:hover {
  background: var(--accent);
  color: #1a1a2e;
}

.btn-secondary:disabled {
  background: var(--border-light);
  color: var(--text-muted);
  border-color: var(--border-light);
  cursor: not-allowed;
}

/* ========== MAIN ========== */
#main {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

#chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

#chat-area::-webkit-scrollbar {
  width: 6px;
}

#chat-area::-webkit-scrollbar-track {
  background: transparent;
}

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

/* ========== WELCOME ========== */
.welcome {
  text-align: center;
  padding: 40px 20px;
  max-width: 600px;
  margin: auto;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.welcome h2 {
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.welcome p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.welcome-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tip {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tip code {
  background: var(--bg-tertiary);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ========== MESSAGES ========== */
#messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 90%;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message.tool_call,
.message.tool_result,
.message.tool_error {
  align-self: flex-start;
  max-width: 100%;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 0 4px;
}

.message.user .message-header { color: var(--accent); }
.message.assistant .message-header { color: var(--success); }
.message.tool_call .message-header { color: var(--warning); }
.message.tool_result .message-header { color: var(--text-secondary); }
.message.tool_error .message-header { color: var(--error); }

.message-body {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 500px;
}

.message.user .message-body {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.message.tool_result .message-body {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #0d1117;
  border-color: var(--border-light);
  color: #c9d1d9;
}

.message.tool_error .message-body {
  background: #2d1b1b;
  border-color: var(--error);
  color: #ffcdd2;
}

.message .tool-args {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 0 4px;
}

/* ========== MARKDOWN RENDERING ========== */
.markdown-body {
  line-height: 1.7;
  white-space: normal;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.markdown-body h1 { font-size: 20px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 16px; }
.markdown-body h4 { font-size: 15px; }
.markdown-body h5 { font-size: 14px; }
.markdown-body h6 { font-size: 13px; color: var(--text-secondary); }

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child { margin-top: 0; }

.markdown-body p {
  margin: 8px 0;
}

.markdown-body p:first-child { margin-top: 0; }
.markdown-body p:last-child { margin-bottom: 0; }

.markdown-body strong {
  color: var(--text-primary);
  font-weight: 700;
}

.markdown-body em {
  font-style: italic;
  color: var(--text-secondary);
}

.markdown-body code {
  background: var(--bg-tertiary);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.markdown-body pre {
  background: #0d1117;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: #c9d1d9;
  font-size: 12px;
  line-height: 1.5;
  tab-size: 2;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
  margin: 8px 0;
}

.markdown-body li {
  margin: 4px 0;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin: 2px 0;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 8px 0;
  background: rgba(79, 195, 247, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  transition: color 0.2s;
}

.markdown-body a:hover {
  color: var(--accent-hover);
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-body td {
  color: var(--text-secondary);
}

.markdown-body tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* ========== TOOL ARGS DETAIL ========== */
.tool-args-detail {
  background: #0d1117;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 8px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #c9d1d9;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre;
}

/* ========== LOADING ========== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 46, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-think {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 400px;
  text-align: center;
  line-height: 1.4;
}

/* ========== THINKING PANEL ========== */
.thinking-panel {
  flex-shrink: 0;
  max-height: 200px;
  overflow: hidden;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

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

.thinking-count {
  background: var(--bg-tertiary);
  color: var(--warning);
  padding: 0 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.thinking-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s;
}

.thinking-arrow.collapsed {
  transform: rotate(-90deg);
}

.thinking-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.thinking-content::-webkit-scrollbar {
  width: 4px;
}

.thinking-content::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.think-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  animation: fadeIn 0.2s ease;
}

.think-item.tool-call {
  color: var(--warning);
}

.think-item.tool-result {
  color: var(--text-secondary);
}

.think-item.tool-error {
  color: var(--error);
}

.think-item.info {
  color: var(--accent);
}

.think-timestamp {
  color: var(--text-muted);
  font-size: 10px;
  margin-right: 8px;
}

/* ========== INPUT ========== */
#input-area {
  flex-shrink: 0;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#prompt-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.4;
}

#prompt-input:focus {
  border-color: var(--accent);
}

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

#send-btn,
#stop-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #1a1a2e;
  transition: background 0.2s;
  flex-shrink: 0;
}

#send-btn:hover {
  background: var(--accent-hover);
}

#stop-btn {
  background: var(--error);
  color: white;
}

#stop-btn:hover {
  background: #e53935;
}

.input-hint {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 4px 0;
}

.hint-sep {
  color: var(--border-light);
}

/* ========== HISTORY SIDEBAR ========== */
.history-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  animation: slideInLeft 0.2s ease;
}

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

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

.history-header h3 {
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
}

.history-actions {
  display: flex;
  gap: 4px;
}

.icon-btn-sm {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 3px 6px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

.icon-btn-sm:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent);
}

.history-search {
  padding: 8px 16px;
  flex-shrink: 0;
}

.history-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}

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

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

.history-stats {
  padding: 4px 16px 8px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.history-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.history-item {
  position: relative;
  padding: 10px 12px;
  margin: 4px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.history-item-title {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.4;
  padding-right: 24px;
}

.history-item-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.history-item-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.2s;
  line-height: 1;
}

.history-item:hover .history-item-delete {
  opacity: 1;
}

.history-item-delete:hover {
  background: rgba(239, 83, 80, 0.2);
  color: var(--error);
}

/* ========== FILE TREE SIDEBAR ========== */
.filetree-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  animation: slideInLeft 0.2s ease;
}

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

.filetree-header h3 {
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
}

.filetree-actions {
  display: flex;
  gap: 4px;
}

.filetree-path {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  flex-shrink: 0;
  align-items: center;
}

.filetree-path input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
  font-family: var(--font-mono);
}

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

.filetree-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.filetree-content::-webkit-scrollbar {
  width: 4px;
}

.filetree-content::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.filetree-loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}

.filetree-entry {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  cursor: pointer;
  border-radius: 3px;
  color: var(--text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.filetree-entry.dir {
  color: var(--accent);
  font-weight: 500;
}

.filetree-entry.file {
  color: var(--text-secondary);
}

.filetree-entry .entry-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 11px;
}

.filetree-entry .entry-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filetree-entry .entry-size {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 4px;
}

.filetree-entry .entry-expand {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  width: 12px;
  text-align: center;
}

.filetree-children {
  padding-left: 16px;
}

/* File preview modal */
.file-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.file-preview-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 80vw;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

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

.file-preview-header h3 {
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #c9d1d9;
  background: #0d1117;
  white-space: pre-wrap;
  word-break: break-all;
}

.file-preview-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.file-preview-body::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

/* ========== CONVERSATION TOOLBAR ========== */
.conversation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.conv-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.conv-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.conv-id-badge {
  font-size: 11px;
  color: var(--accent);
  background: rgba(79, 195, 247, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.conv-title-input {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  min-width: 120px;
  max-width: 250px;
}

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

.conv-tags-input {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  min-width: 120px;
  max-width: 200px;
}

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

/* Tag badges in sidebar */
.history-item-tags {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.tag-badge {
  font-size: 10px;
  background: rgba(79, 195, 247, 0.15);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  #header {
    padding: 8px 12px;
  }

  .header-right {
    font-size: 11px;
  }

  .model-selector select {
    max-width: 120px;
    font-size: 11px;
  }

  #chat-area {
    padding: 12px;
  }

  .message {
    max-width: 100%;
  }

  #input-area {
    padding: 8px 12px;
  }

  .welcome {
    padding: 20px 12px;
  }

  .settings-panel {
    width: 100vw;
  }

  .history-sidebar {
    width: 100vw;
  }

  .filetree-sidebar {
    width: 100vw;
  }

  .login-card {
    padding: 24px;
  }
}