* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #1a1a2e; --bg2: #16213e; --bg3: #0f3460;
  --surface: #1e1e2e; --surface2: #252538; --surface3: #2d2d44;
  --border: #333355; --accent: #7c3aed; --accent2: #a78bfa;
  --text: #e2e8f0; --text2: #94a3b8; --text3: #64748b;
  --success: #22c55e; --error: #ef4444; --warn: #f59e0b;
  --radius: 8px; --shadow: 0 2px 8px rgba(0,0,0,0.3);
}
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* Top Nav */
.topnav { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 16px; height: 48px; flex-shrink: 0; }
.topnav-left { display: flex; align-items: center; gap: 8px; }
.topnav-right { display: flex; align-items: center; gap: 8px; }
.logo { font-weight: 700; font-size: 18px; color: var(--accent2); margin-right: 16px; }
.nav-btn { background: none; border: none; color: var(--text2); padding: 8px 16px; cursor: pointer; border-radius: var(--radius); font-size: 14px; transition: all 0.2s; }
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent); color: white; }
#agentSelect { background: var(--surface2); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: var(--radius); font-size: 13px; }

/* Views */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* Buttons */
.btn-sm { background: var(--accent); color: white; border: none; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.btn-sm:hover { background: var(--accent2); }
.btn-primary { background: var(--accent); color: white; border: none; padding: 10px 20px; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 600; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger { background: var(--error); color: white; border: none; padding: 4px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-icon { background: none; border: none; color: var(--text2); cursor: pointer; padding: 4px 8px; border-radius: 4px; font-size: 16px; }
.btn-icon:hover { color: var(--text); background: var(--surface3); }

/* Chat Layout */
.chat-layout { display: flex; flex: 1; overflow: hidden; }
.chat-sidebar { width: 280px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item { padding: 10px 12px; border-radius: var(--radius); cursor: pointer; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; transition: background 0.2s; }
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: var(--bg3); }
.conv-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conv-time { font-size: 11px; color: var(--text3); margin-left: 8px; }
.conv-del { opacity: 0; transition: opacity 0.2s; }
.conv-item:hover .conv-del { opacity: 1; }

/* Chat Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; word-wrap: break-word; }
.msg.user { background: var(--bg3); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--surface2); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.system { background: var(--surface3); align-self: center; font-size: 12px; color: var(--text2); }
.msg pre { background: #0d1117; padding: 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0; font-size: 13px; }
.msg code { background: var(--surface3); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.msg pre code { background: none; padding: 0; }
.msg p { margin: 6px 0; }
.msg ul, .msg ol { padding-left: 20px; margin: 6px 0; }
.msg h1, .msg h2, .msg h3 { margin: 12px 0 6px; color: var(--accent2); }
.msg a { color: var(--accent2); }

/* Chat Input */
.chat-input-area { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--surface); }
.chat-input-area textarea { flex: 1; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; resize: none; height: 44px; font-family: inherit; font-size: 14px; outline: none; }
.chat-input-area textarea:focus { border-color: var(--accent); }
.send-btn { background: var(--accent); color: white; border: none; border-radius: var(--radius); padding: 0 20px; cursor: pointer; font-size: 14px; font-weight: 600; }
.send-btn:hover { background: var(--accent2); }

/* Editor Layout */
.editor-layout { display: flex; flex: 1; overflow: hidden; }
.editor-sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.project-select { margin: 8px; padding: 8px; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; width: calc(100% - 16px); }
.file-tree { flex: 1; overflow-y: auto; padding: 8px 0; }
.tree-item { display: flex; align-items: center; padding: 5px 12px; cursor: pointer; font-size: 13px; transition: background 0.15s; }
.tree-item:hover { background: var(--surface2); }
.tree-item.active { background: var(--bg3); color: white; }
.tree-icon { margin-right: 6px; opacity: 0.6; font-size: 14px; }
.tree-children { padding-left: 16px; }
.tree-toggle { cursor: pointer; width: 16px; text-align: center; font-size: 10px; color: var(--text3); }

.editor-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.file-path { font-size: 13px; color: var(--text2); font-family: monospace; }
.editor-content { flex: 1; overflow: auto; background: #0d1117; }
.code-display { padding: 16px; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 13px; line-height: 1.6; color: #e6edf3; white-space: pre-wrap; word-wrap: break-word; min-height: 100%; margin: 0; }
.diff-content { flex: 1; display: flex; overflow: hidden; }
.diff-pane { flex: 1; overflow: auto; border-right: 1px solid var(--border); }
.diff-pane h4 { padding: 8px 12px; background: var(--surface); font-size: 12px; color: var(--text2); border-bottom: 1px solid var(--border); }
.history-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--border); font-size: 12px; color: var(--text2); }
.history-bar input[type="range"] { flex: 1; accent-color: var(--accent); }

/* Editor Chat */
.editor-chat { width: 320px; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }

/* Settings */
.settings-layout { flex: 1; overflow-y: auto; padding: 24px; max-width: 800px; margin: 0 auto; width: 100%; }
.settings-section { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; border: 1px solid var(--border); }
.settings-section h2 { font-size: 16px; margin-bottom: 16px; color: var(--accent2); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.form-input { width: 100%; padding: 10px 14px; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; outline: none; }
.form-input:focus { border-color: var(--accent); }
.assistants-list, .mcp-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.assistant-item, .mcp-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--surface2); border-radius: var(--radius); border: 1px solid var(--border); }
.assistant-info, .mcp-info { flex: 1; }
.assistant-name, .mcp-name { font-weight: 600; font-size: 14px; }
.assistant-desc, .mcp-desc { font-size: 12px; color: var(--text2); margin-top: 4px; }
.toggle-switch { position: relative; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--surface3); border-radius: 22px; transition: 0.3s; }
.toggle-slider:before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }
.stats-display { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface2); padding: 16px; border-radius: var(--radius); text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--accent2); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 8px; }
.toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Loading dots */
.loading::after { content: ''; animation: dots 1.5s infinite; }
@keyframes dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; min-width: 400px; max-width: 500px; }
.modal h3 { margin-bottom: 16px; }
.modal .form-input { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .btn-cancel { background: var(--surface3); color: var(--text); border: none; padding: 8px 16px; border-radius: var(--radius); cursor: pointer; }
