:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-light: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --sidebar-width: 280px;
    --nav-height: 70px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --border: #334155;
    --primary-light: #1e3a8a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    transition: transform 0.3s;
}

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

.sidebar-content { padding: 1rem 0; }

.tree-item {
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.tree-item:hover { background: var(--bg); }
.tree-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.tree-notebook { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; color: var(--text-light); margin-top: 1rem; }
.tree-note { padding-left: 2.5rem; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.nav {
    height: var(--nav-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }

.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow);
}

.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-weight: 700; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-light); }
input, textarea, select { width: 100%; padding: 0.8rem; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text); font-size: 1rem; }

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-light);
    display: flex;
    align-items: center;
}
.icon-btn:hover { background: var(--border); color: var(--text); }

@media (max-width: 768px) {
    .sidebar { position: absolute; z-index: 1000; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
}

/* CodeMirror Dark Mode Overrides */
[data-theme="dark"] .CodeMirror {
    color: #f1f5f9 !important;
    background: #1e293b !important;
}

[data-theme="dark"] .CodeMirror-cursor {
    border-left: 2px solid #ffffff !important;
}

[data-theme="dark"] .cm-header { color: #38bdf8; font-weight: bold; }
[data-theme="dark"] .cm-quote { color: #94a3b8; font-style: italic; }
[data-theme="dark"] .cm-keyword { color: #f472b6; }
[data-theme="dark"] .cm-atom { color: #c084fc; }
[data-theme="dark"] .cm-number { color: #fbbf24; }
[data-theme="dark"] .cm-def { color: #38bdf8; }
[data-theme="dark"] .cm-variable { color: #f1f5f9; }
[data-theme="dark"] .cm-property { color: #38bdf8; }
[data-theme="dark"] .cm-operator { color: #f1f5f9; }
[data-theme="dark"] .cm-string { color: #4ade80; }
[data-theme="dark"] .cm-comment { color: #64748b; }
[data-theme="dark"] .cm-tag { color: #f472b6; }
[data-theme="dark"] .cm-attribute { color: #fbbf24; }
[data-theme="dark"] .cm-link { color: #2563eb; }
[data-theme="dark"] .cm-url { color: #94a3b8; }
[data-theme="dark"] .cm-strikethrough { text-decoration: line-through; }

/* Selection color */
[data-theme="dark"] .CodeMirror-selected {
    background: #334155 !important;
}
