:root {
    --bg-editor:   #1e1e1e;
    --bg-sidebar:  #252526;
    --bg-inactive: #2d2d2d;
    --bg-hover:    #2a2d2e;
    --bg-selected: #094771;
    --text-primary:   #d4d4d4;
    --text-secondary: #abb2bf;
    --text-muted:     #858585;
    --border:  #3e3e3e;
    --accent:  #0078d4;
    --icon-folder: #dcb67a;
    --icon-json:   #9cdcfe;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-editor);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Title bar ───────────────────────────────────────────── */
#titlebar {
    height: 30px;
    background: #323233;
    border-bottom: 1px solid #111;
    display: flex;
    align-items: center;
    padding: 0 14px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-muted);
    gap: 8px;
}
#titlebar .app-name { color: var(--text-primary); font-weight: 500; }

/* ── Layout ──────────────────────────────────────────────── */
#workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
    width: 280px;
    min-width: 120px;
    max-width: 60vw;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

#sidebar-title {
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    flex-shrink: 0;
}

#search-wrap {
    padding: 0 8px 8px;
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    background: #3c3c3c;
    border: 1px solid #555;
    border-radius: 3px;
    color: var(--text-primary);
    font-size: 13px;
    padding: 5px 8px 5px 30px;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23858585'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 8px 50%;
    background-size: 14px 14px;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-muted); }

#file-tree {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1;
}
#file-tree::-webkit-scrollbar { width: 6px; }
#file-tree::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }
#file-tree::-webkit-scrollbar-track { background: transparent; }

/* ── Tree items ──────────────────────────────────────────── */
.t-item {
    display: flex;
    align-items: center;
    height: 22px;
    cursor: pointer;
    white-space: nowrap;
    padding-right: 8px;
    gap: 3px;
}
.t-item:hover    { background: var(--bg-hover); }
.t-item.selected { background: var(--bg-selected); }

.t-chevron {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-size: 9px;
    color: var(--text-muted);
    transition: transform 0.1s;
}
.t-icon   { flex-shrink: 0; font-size: 14px; width: 18px; text-align: center; }
.t-label  { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.t-item.folder .t-label { color: var(--text-primary); }
.t-item.file   .t-label { color: var(--icon-json); }

.t-children { display: none; }
.t-children.open { display: block; }

/* search result: show full path */
.t-item.flat-result .t-label {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    padding: 2px 0;
    height: auto;
}
.t-item.flat-result { height: auto; min-height: 22px; align-items: flex-start; padding-top: 3px; padding-bottom: 3px; }
.t-item.flat-result .t-filename { color: var(--icon-json); font-weight: 500; }
.t-item.flat-result .t-filepath { font-size: 11px; color: var(--text-muted); }
.t-item.flat-result mark { background: transparent; color: #e6b422; font-weight: 700; }

/* no-results / loading */
.tree-msg {
    padding: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Resizer ─────────────────────────────────────────────── */
#resizer {
    width: 4px;
    background: transparent;
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
}
#resizer:hover, #resizer.active { background: var(--accent); }

/* ── Editor area ─────────────────────────────────────────── */
#editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Tab bar */
#tabbar {
    height: 35px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
    overflow: hidden;
}
.tab {
    height: 35px;
    padding: 0 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-inactive);
    border-right: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
    max-width: 240px;
}
.tab.active {
    background: var(--bg-editor);
    color: var(--text-primary);
    border-top: 1px solid var(--accent);
    height: 36px;
}

/* Breadcrumb */
#breadcrumb {
    height: 22px;
    padding: 0 14px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-editor);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
    gap: 2px;
}
.bc-sep { opacity: 0.4; margin: 0 2px; }

/* Editor container */
#editor-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#monaco-editor {
    position: absolute;
    inset: 0;
    display: none;
}

/* Welcome */
#welcome {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
}
#welcome h2 {
    font-size: 22px;
    font-weight: 300;
    color: var(--text-secondary);
}
#welcome p { font-size: 13px; }

/* Status bar */
#statusbar {
    height: 22px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 12px;
    flex-shrink: 0;
    gap: 16px;
}
#status-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
