:root {
    --bg-base: #11121d;
    --bg-panel: #1a1b26;
    --bg-elevated: #24283b;
    --bg-hover: #2f334d;
    --bg-input: #1f2335;
    
    --text-main: #c0caf5;
    --text-dim: #a9b1d6;
    --text-muted: #565f89;
    
    --accent: #7aa2f7;
    --accent-glow: rgba(122, 162, 247, 0.15);
    --accent-hover: #89b4fa;
    
    --border: #2a2e42;
    --border-light: #363b54;
    
    --success: #9ece6a;
    --danger: #f7768e;
    --warning: #e0af68;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
    --bg-base: #f8f9fa;
    --bg-panel: #ffffff;
    --bg-elevated: #f1f3f5;
    --bg-hover: #e9ecef;
    --bg-input: #f1f3f5;
    --text-main: #212529;
    --text-dim: #495057;
    --text-muted: #868e96;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.1);
    --border: #dee2e6;
    --border-light: #ced4da;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; }
body { font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: var(--bg-base); color: var(--text-main); font-size: 14px; transition: background 0.3s; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg-base); }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

#app { display: flex; flex-direction: column; height: 100vh; width: 100vw; }

#titlebar { height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--bg-panel); border-bottom: 1px solid var(--border); z-index: 100; }
.title-left { display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; cursor: pointer; }
.dot.red { background: #f7768e; } .dot.yellow { background: #e0af68; } .dot.green { background: #9ece6a; }
.title-brand { margin-left: 16px; font-weight: 700; color: var(--text-main); opacity: 0.9; letter-spacing: 0.5px; }
.title-right { display: flex; gap: 8px; }

.btn-primary { background: var(--accent); color: #fff; padding: 6px 14px; border-radius: var(--radius-md); font-weight: 600; font-size: 13px; border: none; cursor: pointer; transition: var(--transition); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-dim); padding: 6px 14px; border-radius: var(--radius-md); font-weight: 500; font-size: 13px; border: 1px solid var(--border); cursor: pointer; transition: var(--transition); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-main); }
.btn-run { background: var(--success); color: #11121d; padding: 6px 14px; border-radius: var(--radius-md); font-weight: 700; font-size: 13px; border: none; cursor: pointer; transition: var(--transition); }
.btn-run:hover { opacity: 0.9; }

#body-container { flex: 1; display: flex; overflow: hidden; }

#activity-bar { width: 48px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px; background: var(--bg-panel); border-right: 1px solid var(--border); }
.act-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); cursor: pointer; background: none; border: none; color: var(--text-muted); transition: var(--transition); position: relative; }
.act-btn:hover { color: var(--text-main); background: var(--bg-hover); }
.act-btn.active { color: var(--accent); background: var(--accent-glow); }
.act-btn.active::before { content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--accent); border-radius: 0 4px 4px 0; }
.mt-auto { margin-top: auto; }

#sidebar { width: 240px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--bg-base); border-right: 1px solid var(--border); transition: width 0.2s; overflow: hidden; }
#sidebar.collapsed { width: 0 !important; border: none; }
.sidebar-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.explorer-actions { display: flex; gap: 4px; }
.explorer-actions button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; display: flex; align-items: center; }
.explorer-actions button:hover { color: var(--text-main); background: var(--bg-hover); }

.sidebar-content { flex: 1; overflow-y: auto; padding: 4px 8px; min-height: 0; }
.empty-state { color: var(--text-muted); font-size: 12px; padding: 16px; text-align: center; line-height: 1.5; }
.search-input { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text-main); outline: none; font-size: 13px; transition: var(--transition); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.search-options { display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--text-muted); }
.search-options label { display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.search-options input { accent-color: var(--accent); }
.search-result-item { padding: 6px 8px; cursor: pointer; border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted); margin: 2px 0; } 
.search-result-item:hover { background: var(--bg-hover); color: var(--text-main); }
.p-2 { padding: 10px; }

#main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#editor-area { flex: 1; display: flex; overflow: hidden; }
#editor-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-panel); overflow: hidden; }

#tabs-container { display: flex; background: var(--bg-base); border-bottom: 1px solid var(--border); overflow-x: auto; min-height: 36px; flex-shrink: 0; }
.tab-item { display: flex; align-items: center; padding: 8px 16px; border-right: 1px solid var(--border); cursor: pointer; flex-shrink: 0; transition: var(--transition); } 
.tab-item:hover { background: var(--bg-hover); }
.tab-item.active { background: var(--bg-panel); position: relative; } 
.tab-item.active::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--accent); }
.tab-name { font-size: 13px; margin-right: 12px; color: var(--text-dim); } 
.tab-item.active .tab-name { color: var(--text-main); font-weight: 500; }
.tab-close { font-size: 14px; color: var(--text-muted); cursor: pointer; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; border-radius: 4px; } 
.tab-close:hover { color: var(--danger); background: rgba(247, 118, 142, 0.1); }

#monaco-container { flex: 1; }

#v-splitter { width: 4px; background: transparent; cursor: ew-resize; flex-shrink: 0; transition: background 0.2s; } 
#v-splitter:hover { background: var(--accent); }
#h-splitter { height: 4px; background: transparent; cursor: ns-resize; flex-shrink: 0; transition: background 0.2s; } 
#h-splitter:hover { background: var(--accent); }

#right-preview-panel { width: 40%; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--bg-panel); overflow: hidden; transition: width 0.2s; }
#right-preview-panel.collapsed { width: 0 !important; border: none; }
.preview-header { padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg-base); }

#bottom-panel { height: 240px; flex-shrink: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: var(--bg-base); }
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 12px; flex-shrink: 0; background: var(--bg-panel); }
.panel-tab { padding: 10px 16px; font-size: 12px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; background: none; border: none; transition: var(--transition); margin-bottom: -1px; } 
.panel-tab:hover { color: var(--text-dim); }
.panel-tab.active { color: var(--text-main); border-bottom: 2px solid var(--accent); }

#terminal-output { flex: 1; padding: 12px; font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; overflow-y: auto; color: var(--text-dim); min-height: 0; line-height: 1.6; }
#terminal-input-container { display: flex; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--bg-panel); }
.term-prompt { color: var(--success); margin-right: 8px; font-family: monospace; font-weight: bold; }
#terminal-input { flex: 1; background: none; border: none; color: var(--text-main); outline: none; font-family: monospace; font-size: 12px; }
#problems-panel { flex: 1; overflow-y: auto; padding: 12px; font-family: monospace; font-size: 12px; }
.problem-item { padding: 8px; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; color: var(--text-dim); }
.problem-item:hover { background: var(--bg-hover); }
.problem-icon { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; }
.problem-icon.error { background: var(--danger); } .problem-icon.warning { background: var(--warning); } .problem-icon.info { background: var(--accent); }
iframe { flex: 1; background: white; border: none; min-height: 0; }

#statusbar { height: 26px; flex-shrink: 0; background: var(--bg-panel); border-top: 1px solid var(--border); color: var(--text-main); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 12px; }
.status-right { display: flex; gap: 8px; align-items: center; }
.status-btn { background: none; border: 1px solid transparent; color: var(--text-dim); padding: 2px 8px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; transition: var(--transition); }
.status-btn:hover { background: var(--bg-hover); color: var(--text-main); }

.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-start; justify-content: center; padding-top: 100px; z-index: 10000; backdrop-filter: blur(4px); }
.modal-content { padding: 24px; border-radius: var(--radius-lg); width: 460px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); border: 1px solid var(--border-light); background: var(--bg-elevated); }
.modal-content h3 { margin-bottom: 12px; font-size: 18px; color: var(--text-main); } 
.modal-content input { width: 100%; padding: 12px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-main); border-radius: var(--radius-sm); outline: none; transition: var(--transition); font-size: 14px; }
.modal-content input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

#command-palette { padding-top: 80px; background: rgba(0, 0, 0, 0.4); }
.cmd-content { width: 600px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-light); box-shadow: 0 20px 50px rgba(0,0,0,0.5); background: var(--bg-elevated); }
#cmd-input { width: 100%; padding: 16px; background: var(--bg-input); border: none; border-bottom: 1px solid var(--border); color: var(--text-main); outline: none; font-size: 15px; font-family: 'Segoe UI', sans-serif; }
#cmd-results { max-height: 320px; overflow-y: auto; background: var(--bg-elevated); }
.cmd-item { padding: 12px 16px; cursor: pointer; font-size: 14px; color: var(--text-dim); border-bottom: 1px solid var(--border); transition: var(--transition); }
.cmd-item:hover { background: var(--accent); color: #fff; }

.snippet-item { padding: 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; cursor: pointer; }
.snippet-item:hover { border-color: var(--accent); }

#drop-zone { position: fixed; top: 16px; left: 16px; right: 16px; bottom: 16px; background: var(--accent-glow); backdrop-filter: blur(12px); display: none; align-items: center; justify-content: center; z-index: 9999; border: 4px dashed var(--accent); border-radius: var(--radius-lg); }
#drop-zone.active { display: flex; } 
.drop-content { text-align: center; color: var(--accent); }
.drop-content h2 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }

.tree-node { display: flex; flex-direction: column; }
.tree-item { display: flex; align-items: center; padding: 5px 10px; cursor: pointer; border-radius: var(--radius-sm); white-space: nowrap; transition: background 0.1s; position: relative; }
.tree-item:hover { background: var(--bg-hover); }
.tree-item.active { background: var(--accent-glow); }
.tree-icon { margin-right: 8px; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.tree-name { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; user-select: none; }
.tree-item:hover .tree-name { color: var(--text-main); }
.tree-children { display: flex; flex-direction: column; margin-left: 12px; border-left: 1px solid var(--border); padding-left: 4px; }

.ctx-menu { position: fixed; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 6px; z-index: 10000; box-shadow: 0 8px 30px rgba(0,0,0,0.5); min-width: 180px; }
.ctx-menu-item { padding: 8px 12px; cursor: pointer; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 10px; transition: background 0.1s; }
.ctx-menu-item:hover { background: var(--accent); color: #fff; }
.ctx-menu-item.danger:hover { background: var(--danger); color: #fff; }