/* ==========================================
   CSS 变量及设计系统 (Design System)
   ========================================== */
:root[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-tertiary: #1f2430;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.15);
    --code-bg: #181b24;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --accent-light: rgba(79, 70, 229, 0.08);
    --code-bg: #f8fafc;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ==========================================
   页头 (Header)
   ========================================== */
.app-header {
    height: 60px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.brand i { color: var(--accent-color); }

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 10px;
    width: 16px;
    color: var(--text-muted);
}

.search-box input {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 12px 6px 34px;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s;
    width: 200px;
}

.search-box input:focus {
    width: 260px;
    border-color: var(--accent-color);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.theme-toggle:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* ==========================================
   核心三栏布局 (Three-column Layout)
   ========================================== */
.app-container {
    display: flex;
    height: calc(100vh - 60px);
    width: 100vw;
}

/* 左侧：文档导航 */
.sidebar-left {
    width: 280px;
    min-width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.doc-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.doc-item {
    padding: 10px 14px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s ease;
}

.doc-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.doc-item.active {
    background-color: var(--accent-light);
    color: var(--accent-color);
    font-weight: 600;
}

/* 中间：正文阅读区 */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px 60px;
    background-color: var(--bg-primary);
    scroll-behavior: smooth;
}

.markdown-body {
    max-width: 860px;
    margin: 0 auto;
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.75;
}

/* 右侧：文章 TOC */
.sidebar-right {
    width: 240px;
    min-width: 240px;
    background-color: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    padding: 24px 16px;
    overflow-y: auto;
}

.toc-header {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.toc-list { display: flex; flex-direction: column; gap: 6px; }

.toc-item {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 10px;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-item:hover { color: var(--text-primary); }
.toc-item.active { border-left-color: var(--accent-color); color: var(--accent-color); font-weight: 500; }
.toc-item.depth-3 { margin-left: 12px; }
.toc-item.depth-4 { margin-left: 24px; }
.toc-empty { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

/* ==========================================
   Markdown 内容排版与视觉样式
   ========================================== */
.markdown-body h1 { font-size: 2.2rem; margin-bottom: 1.5rem; font-weight: 800; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.markdown-body h2 { font-size: 1.6rem; margin: 2rem 0 1rem; font-weight: 700; }
.markdown-body h3 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; font-weight: 600; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 1rem; margin: 1rem 0 0.5rem; font-weight: 600; }
.markdown-body p { margin-bottom: 1.2rem; color: var(--text-secondary); }
.markdown-body ul, .markdown-body ol { margin-bottom: 1.2rem; padding-left: 1.5rem; color: var(--text-secondary); }
.markdown-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; border: 1px solid var(--border-color); }
.markdown-body hr { border: 0; height: 1px; background: var(--border-color); margin: 2rem 0; }

/* 表格样式 */
.markdown-body table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-color); padding: 10px 14px; font-size: 0.9rem; text-align: left; }
.markdown-body th { background-color: var(--bg-secondary); font-weight: 600; }

/* ==========================================
   Obsidian 风格 Callout 框定制
   ========================================== */
.callout {
    padding: 14px 16px;
    margin: 1.2rem 0;
    border-left: 4px solid var(--accent-color);
    border-radius: 0 6px 6px 0;
    background-color: var(--bg-secondary);
}

.callout-title {
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.callout-content { font-size: 0.92rem; color: var(--text-secondary); }
.callout-content p:last-child { margin-bottom: 0; }

/* Callout 类型拓展 */
.callout[data-type="info"] { border-left-color: #3b82f6; background-color: rgba(59, 130, 246, 0.08); }
.callout[data-type="info"] .callout-title { color: #3b82f6; }

.callout[data-type="note"] { border-left-color: #8b5cf6; background-color: rgba(139, 92, 246, 0.08); }
.callout[data-type="note"] .callout-title { color: #8b5cf6; }

.callout[data-type="tip"] { border-left-color: #10b981; background-color: rgba(16, 185, 129, 0.08); }
.callout[data-type="tip"] .callout-title { color: #10b981; }

.callout[data-type="warning"] { border-left-color: #f59e0b; background-color: rgba(245, 158, 11, 0.08); }
.callout[data-type="warning"] .callout-title { color: #f59e0b; }

.empty-state { text-align: center; padding: 100px 0; color: var(--text-muted); }
.empty-state i { width: 48px; height: 48px; margin-bottom: 16px; }