/* ============================================================
   Mind — Knowledge Base CSS
   ============================================================ */
:root {
    --bg: #1e1e1e;
    --bg2: #252526;
    --bg3: #2d2d2d;
    --bg4: #333333;
    --sidebar-bg: #1a1a1a;
    --sidebar-width: 260px;
    --editor-bg: #1e1e1e;
    --preview-bg: #1e1e1e;
    --text: #d4d4d4;
    --text2: #999;
    --text3: #666;
    --accent: #6c8cff;
    --accent2: #5a7ae0;
    --accent-bg: rgba(108, 140, 255, 0.15);
    --border: #333;
    --danger: #e06c75;
    --success: #98c379;
    --warn: #d19a66;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --radius: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Light theme */
[data-theme="light"] {
    --bg: #ffffff;
    --bg2: #f6f8fa;
    --bg3: #eef1f5;
    --bg4: #e4e7eb;
    --sidebar-bg: #f6f8fa;
    --editor-bg: #ffffff;
    --preview-bg: #ffffff;
    --text: #24292f;
    --text2: #656d76;
    --text3: #8b949e;
    --accent: #4f6ef7;
    --accent2: #3b5de7;
    --accent-bg: rgba(79, 110, 247, 0.1);
    --border: #d0d7de;
    --danger: #cf222e;
    --success: #2da44e;
    --warn: #bf8700;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ============================================================
   Auth Pages
   ============================================================ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.auth-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    box-shadow: var(--shadow);
}

.auth-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
}

.auth-box .subtitle {
    color: var(--text2);
    text-align: center;
    margin-bottom: 28px;
    font-size: 14px;
}

.auth-box .form-group {
    margin-bottom: 16px;
}

.auth-box label {
    display: block;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 4px;
}

.auth-box input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

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

.auth-box .btn {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 15px;
    font-weight: 500;
    margin-top: 8px;
    transition: background 0.2s;
}

.auth-box .btn:hover {
    background: var(--accent2);
}

.auth-box .switch {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text2);
}

.auth-box .switch a {
    color: var(--accent);
    cursor: pointer;
}

.auth-box .error {
    background: rgba(224, 108, 117, 0.15);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.auth-box .error.show { display: block; }

/* ============================================================
   Main App Layout
   ============================================================ */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Unified top bar — same height across all columns */
.top-bar {
    display: flex;
    align-items: center;
    height: 36px;
    min-height: 36px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 6px;
    gap: 4px;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    flex-shrink: 0;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1px;
}

.top-actions button {
    background: none;
    border: none;
    color: var(--text2);
    padding: 4px 5px;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
}

.top-actions button:hover {
    background: var(--bg4);
    color: var(--text);
}

.top-bar-center {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

/* Tab bar inside top-bar-center */
.top-bar-center .tab-bar {
    display: flex;
    align-items: center;
    overflow-x: auto;
    height: 100%;
    gap: 0;
    flex: 1;
    border: none;
    background: transparent;
}

.top-bar-center .tab-bar::-webkit-scrollbar { height: 2px; }
.top-bar-center .tab-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.top-bar-center .tab {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--text2);
    cursor: pointer;
    border-right: 1px solid var(--border);
    white-space: nowrap;
    transition: all 0.1s;
    user-select: none;
    flex-shrink: 0;
    height: 100%;
}

.top-bar-center .tab:hover {
    background: var(--bg3);
    color: var(--text);
}

.top-bar-center .tab.active {
    background: var(--bg);
    color: var(--text);
    border-bottom: 2px solid var(--accent);
}

.top-bar-center .tab .tab-title {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-center .tab .tab-close {
    font-size: 13px;
    color: var(--text3);
    padding: 0 2px;
    border-radius: 2px;
    line-height: 1;
}

.top-bar-center .tab .tab-close:hover {
    background: var(--bg4);
    color: var(--text);
}

.top-bar-center .tab-placeholder {
    padding: 3px 10px;
    font-size: 11px;
    color: var(--text3);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.top-btn {
    background: none;
    border: none;
    color: var(--text2);
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
}

.top-btn:hover {
    background: var(--bg4);
    color: var(--text);
}

/* App body — below top bar, fills remaining height */
.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

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

.sidebar-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-search input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

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

/* Search input with clear button */
.search-input-wrap {
    display: flex;
    align-items: center;
    position: relative;
}

.search-input-wrap input {
    padding-right: 28px;
}

.search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text3);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}

.search-clear:hover {
    color: var(--text);
    background: var(--bg4);
}

.note-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.note-tree::-webkit-scrollbar {
    width: 4px;
}
.note-tree::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.note-item {
    display: flex;
    align-items: center;
    padding: 5px 12px 5px 8px;
    cursor: pointer;
    color: var(--text2);
    font-size: 13px;
    transition: all 0.1s;
    gap: 4px;
    border-left: 3px solid transparent;
}

.note-item:hover {
    background: var(--bg3);
    color: var(--text);
}

.note-item.active {
    background: var(--accent-bg);
    color: var(--accent);
    border-left-color: var(--accent);
}

.note-item.selected {
    background: rgba(108, 140, 255, 0.08);
    border-left-color: var(--accent);
}

.note-item.folder {
    font-weight: 600;
}

.note-item.folder-active {
    background: var(--accent-bg);
    border-left-color: var(--accent);
    color: var(--accent);
}

.note-item.folder-active .icon {
    color: var(--accent);
}

/* Drag-and-drop states */
.note-item.dragging {
    cursor: grabbing;
}

.note-item.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    background: var(--accent-bg);
    border-radius: 4px;
}

.note-item.drag-into {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: rgba(108, 140, 255, 0.12);
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px var(--accent);
}

.note-tree.drag-active .note-item {
    cursor: grab;
}

.note-tree.drag-root {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
    background: var(--accent-bg);
    border-radius: 6px;
    margin: 8px;
}

/* Browse mode tabs */
.browse-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.browse-tab {
    flex: 1;
    text-align: center;
    padding: 5px 0;
    font-size: 14px;
    cursor: pointer;
    color: var(--text3);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
}

.browse-tab:hover {
    color: var(--text);
    background: var(--bg3);
}

.browse-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Recent / tag list date groups */
.recent-group-label {
    padding: 6px 12px 2px;
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.recent-time {
    font-size: 11px;
    color: var(--text3);
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 8px;
}

/* Tag browser */
.tag-browser-chips {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.tag-chip.tag-active {
    background: var(--accent);
    color: #fff;
}

/* Root level drop zone at top of sidebar */
.tree-root-zone {
    font-size: 12px;
    color: var(--text3);
    border: 1px dashed transparent;
    border-radius: 4px;
    text-align: center;
    cursor: default;
    transition: all 0.15s;
}

.tree-root-zone.drag-hover {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
    cursor: grab;
}

.note-checkbox {
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent);
}

.note-item .icon {
    font-size: 14px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    cursor: pointer;
}

.note-item .title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    min-width: 0;
}

.note-item .tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Batch action bar */
.batch-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
    gap: 6px;
    flex-shrink: 0;
}

.batch-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.1s;
}

.batch-btn:hover {
    background: var(--bg4);
}

.batch-delete {
    background: rgba(224, 108, 117, 0.15);
    border-color: rgba(224, 108, 117, 0.3);
    color: var(--danger);
}

.batch-delete:hover {
    background: rgba(224, 108, 117, 0.25);
}

/* Tags section */
.sidebar-space {
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    flex-shrink: 0;
}

.sidebar-space select {
    width: 100%;
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 8px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.sidebar-space select:focus {
    border-color: var(--accent);
}

.tag-chip {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg3);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text2);
    margin: 2px 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.tag-chip:hover {
    background: var(--accent-bg);
    color: var(--accent);
}

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

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text3);
    gap: 12px;
}

.empty-state .big-icon {
    font-size: 48px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text2);
}

.empty-state p {
    font-size: 13px;
}

/* ============================================================
   Editor Area (Split View)
   ============================================================ */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-split {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-pane:only-child {
    border-right: none;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    min-height: 34px;
}

.editor-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.editor-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.editor-toolbar .note-title-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    outline: none;
    padding: 2px 0;
    min-width: 80px;
}

.editor-toolbar .note-title-input::placeholder {
    color: var(--text3);
}

.editor-toolbar .note-tags-input {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text2);
    font-size: 11px;
    padding: 2px 6px;
    outline: none;
    width: 120px;
}

.editor-toolbar .note-tags-input:focus {
    border-color: var(--accent);
    color: var(--text);
}

.editor-toolbar .toolbar-btn {
    background: none;
    border: none;
    color: var(--text2);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.15s;
    line-height: 1;
}

.editor-toolbar .toolbar-btn:hover {
    background: var(--bg4);
    color: var(--text);
}

.editor-toolbar .toolbar-btn.active {
    background: var(--accent-bg);
    color: var(--accent);
}

.editor-toolbar .toolbar-hint {
    font-size: 11px;
    color: var(--text3);
    min-width: 16px;
    text-align: center;
}

/* Tab bar — full width above the split panes */
/* Quick switcher & command palette */
.quick-switcher,
.cmd-palette {
    width: 480px;
    max-width: 90vw;
}

.qs-results {
    max-height: 320px;
    overflow-y: auto;
    margin: 8px 0;
}

.qs-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text);
    transition: background 0.1s;
}

.qs-item:hover,
.qs-item.qs-hover {
    background: var(--bg4);
}

.qs-item.qs-active {
    color: var(--accent);
    background: var(--accent-bg);
}

.editor-textarea {
    flex: 1;
    width: 100%;
    padding: 16px 20px;
    background: var(--editor-bg);
    border: none;
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.7;
    resize: none;
    outline: none;
    tab-size: 4;
}

.editor-textarea::placeholder {
    color: var(--text3);
}

/* Preview Pane */
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--preview-bg);
    min-width: 0;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.preview-pane .markdown-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    max-width: 800px;
    margin: 0 auto;
}

.preview-pane::-webkit-scrollbar {
    width: 6px;
}

.preview-pane::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ============================================================
   Live Preview Styles
   ============================================================ */
.live-preview {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--editor-bg);
}

.live-loading {
    color: var(--text3);
    font-size: 14px;
    padding: 40px 0;
    text-align: center;
}

.live-empty {
    color: var(--text3);
    font-size: 14px;
    padding: 40px 0;
    text-align: center;
}

.live-block {
    padding: 4px 8px;
    margin: 2px -8px;
    border-radius: 4px;
    transition: background 0.1s;
    cursor: text;
    position: relative;
}

.live-block:hover {
    background: var(--bg3);
}

.live-block.live-editing {
    background: transparent;
    margin: 0;
    padding: 0;
    border-radius: 0;
}

.live-block.live-editing:hover {
    background: transparent;
}

.live-edit-textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    background: var(--bg2);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}

.live-edit-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ============================================================
   Markdown Preview Styles
   ============================================================ */
.markdown-body {
    line-height: 1.7;
    color: var(--text);
    font-size: 15px;
}

.markdown-body h1 { font-size: 28px; margin: 24px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 22px; margin: 20px 0 10px; }
.markdown-body h3 { font-size: 18px; margin: 16px 0 8px; }
.markdown-body h4 { font-size: 16px; margin: 12px 0 6px; }
.markdown-body p { margin: 8px 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0; padding-left: 24px; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 12px 0;
    background: var(--bg3);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text2);
}
.markdown-body code {
    background: var(--bg3);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 13px;
}
.markdown-body pre {
    background: var(--bg3);
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 12px 0;
}
.markdown-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}
.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius);
}
.markdown-body .table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
    min-width: 400px;
}
.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    min-width: 80px;
}
.markdown-body th {
    background: var(--bg3);
    font-weight: 600;
    position: sticky;
    top: 0;
}
.markdown-body tbody tr:nth-child(even) {
    background: var(--bg2);
}
.markdown-body tbody tr:hover {
    background: var(--accent-bg);
}
.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}
.markdown-body .wiki-link {
    color: var(--accent);
    cursor: pointer;
    border-bottom: 1px dashed var(--accent);
    padding: 0 2px;
    transition: all 0.15s;
}
.markdown-body .wiki-link:hover {
    background: var(--accent-bg);
    text-decoration: none;
}
.markdown-body .wiki-link.missing {
    color: var(--danger);
    border-bottom-color: var(--danger);
}

/* ============================================================
   Right Panel (Backlinks & Properties)
   ============================================================ */
.right-panel {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.right-panel.hidden { display: none; }

.right-panel-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.right-panel-section h4 {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.backlink-item {
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text2);
    transition: all 0.1s;
    margin-bottom: 2px;
}

.backlink-item:hover {
    background: var(--bg3);
    color: var(--text);
}

/* Property panel select */
.prop-select {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 12px;
    padding: 3px 6px;
    outline: none;
}

.prop-select:focus {
    border-color: var(--accent);
}

/* ============================================================
   Graph View
   ============================================================ */
.graph-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 100;
    display: none;
    flex-direction: column;
}

.graph-overlay.open { display: flex; }

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

.graph-header h3 {
    font-size: 16px;
}

.graph-header button {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    transition: all 0.15s;
}

.graph-header button:hover {
    background: var(--bg4);
}

.graph-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.graph-canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.graph-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text2);
}

/* ============================================================
   Search results
   ============================================================ */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow);
    display: none;
}

.search-results.show { display: block; }

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg3); }

.search-result-item h4 {
    font-size: 14px;
    margin-bottom: 2px;
}

.search-result-item p {
    font-size: 12px;
    color: var(--text3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}

.modal-box h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.modal-box .form-group {
    margin-bottom: 14px;
}

.modal-box label {
    display: block;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 4px;
}

.modal-box input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

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

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-actions .btn {
    padding: 8px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    border: none;
    transition: all 0.15s;
}

.modal-actions .btn-primary {
    background: var(--accent);
    color: white;
}

.modal-actions .btn-primary:hover { background: var(--accent2); }

.modal-actions .btn-secondary {
    background: var(--bg3);
    color: var(--text2);
    border: 1px solid var(--border);
}

.modal-actions .btn-secondary:hover { background: var(--bg4); }

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast.info { background: var(--accent); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.success { background: var(--success); color: #1e1e1e; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Loading
   ============================================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text3);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .right-panel { display: none; }
    .editor-container { flex-direction: column; }
    .editor-pane { border-right: none; border-bottom: 1px solid var(--border); }
}
