:root {
  --bg: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --border: #333;
  --text: #ececec;
  --text-muted: #888;
  --accent: #d97706;
  --accent-hover: #f59e0b;
  --accent-glow: rgba(217, 119, 6, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --sidebar-width: 260px;
  --preview-width: 400px;
  --radius: 12px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}

.logo-icon { font-size: 22px; }

.btn-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover { background: var(--border); }

.sidebar-section {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.2s;
}

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

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

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.2s;
}

.conv-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 1;
  transition: background 0.15s, color 0.15s;
}

.conv-item:hover .conv-delete,
.conv-item.active .conv-delete {
  opacity: 1;
}

.conv-delete:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.conv-item:hover, .conv-item.active {
  background: var(--bg-tertiary);
  color: var(--text);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--error); }

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view { display: none; flex-direction: column; height: 100%; }
.view.active { display: flex; }

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.chat-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.chat-site-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-site-label {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-domain-select {
  max-width: 280px;
}

.conv-meta {
  display: block;
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-main {
  flex: 1;
  min-width: 0;
}

.chat-header h2 { font-size: 16px; font-weight: 600; }

.chat-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle-label input { accent-color: var(--accent); }

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

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

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

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.message-content {
  line-height: 1.7;
  font-size: 15px;
}

.message.user .message-content {
  background: var(--accent-glow);
  border: 1px solid rgba(217, 119, 6, 0.3);
  padding: 12px 16px;
  border-radius: var(--radius);
}

.message.assistant .message-content { color: var(--text); }

.message-content pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

.message-content code {
  font-family: var(--mono);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message-content p { margin-bottom: 12px; }
.message-content h1, .message-content h2, .message-content h3 {
  margin: 16px 0 8px;
}

.search-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--success);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 8px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input */
.input-area {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 800px;
  margin: 0 auto;
  transition: border-color 0.2s;
}

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

#messageInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 200px;
  line-height: 1.5;
}

.send-btn {
  background: var(--accent);
  border: none;
  color: #000;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Panels */
.panel-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 18px; }

.files-panel, .deploy-panel, .mcp-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.file-item:hover { border-color: var(--accent); }

.file-icon { font-size: 20px; }
.file-name { font-family: var(--mono); font-size: 13px; flex: 1; }

.deploy-card, .mcp-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.deploy-card h3, .mcp-card h3 { margin-bottom: 8px; }
.deploy-card p, .mcp-card p { color: var(--text-muted); margin-bottom: 16px; font-size: 14px; }

.deploy-form, .mcp-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-field {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

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

.btn-primary {
  background: var(--accent);
  border: none;
  color: #000;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

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

.deploy-status, .mcp-status {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
}

.deploy-status.show, .mcp-status.show { display: block; }
.deploy-status.success, .mcp-status.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--success);
}

.deploy-status.error, .mcp-status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.mcp-info {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.mcp-info h4 { margin-bottom: 12px; font-size: 14px; }
.mcp-info ol { padding-left: 20px; color: var(--text-muted); font-size: 14px; line-height: 2; }
.mcp-info a { color: var(--accent); }

/* Preview Panel */
.preview-panel {
  width: 0;
  overflow: hidden;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s;
}

.preview-panel.open { width: var(--preview-width); }

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
}

.preview-code {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

/* Welcome */
.welcome {
  text-align: center;
  padding: 48px 24px;
  max-width: 600px;
  margin: auto;
}

.welcome h1 {
  font-size: 28px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome p { color: var(--text-muted); margin-bottom: 32px; line-height: 1.6; }

.prompt-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.suggestion {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.suggestion:hover {
  border-color: var(--accent);
  color: var(--text);
}

.suggestion strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 14px; }

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .logo-text, .sidebar-btn span:last-child, .sidebar-footer span { display: none; }
  .preview-panel.open { width: 100%; position: absolute; right: 0; top: 0; height: 100%; z-index: 10; }
}
