:root {
    /* 浅色模式变量 */
    --bg-color: #ffffff;
    --text-color: #333333;
    --sidebar-bg: #f5f5f5;
    --sidebar-hover: #e0e0e0;
    --sidebar-active: #d0d0d0;
    --border-color: #dddddd;
    --code-bg: #f6f8fa;
    --link-color: #0366d6;
    --accent-color: #005cc5;
}

[data-theme="dark"] {
    /* 深色模式变量 */
    --bg-color: #1e1e1e;
    --text-color: #c9d1d9;
    --sidebar-bg: #252526;
    --sidebar-hover: #2a2d2f;
    --sidebar-active: #37373d;
    --border-color: #30363d;
    --code-bg: #161b22;
    --link-color: #58a6ff;
    --accent-color: #79c0ff;
}

* {
    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-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* 布局 */
.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    flex-shrink: 0;
    transition: background-color 0.3s, border-color 0.3s;
    height: 100vh;
    overflow-y: auto;
    position: sticky;
    top: 0;
}

.sidebar h2 {
    padding: 0 20px 15px;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.group-header {
    padding: 15px 20px 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    padding: 10px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

.sidebar li:hover {
    background-color: var(--sidebar-hover);
}

.sidebar li.active {
    background-color: var(--sidebar-active);
    border-left: 4px solid var(--accent-color);
    padding-left: 16px;
}

/* 主内容区 */
.content {
    flex-grow: 1;
    padding: 40px;
    max-width: 900px;
    margin: 0 auto;
    overflow-y: auto;
}

/* Markdown 样式 */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.25em; }

.markdown-body p, .markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: var(--code-bg);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
}

.markdown-body strong {
    font-weight: 600;
    color: var(--accent-color);
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* 移动端菜单切换按钮 */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 响应式布局 */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .container {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -250px;
        height: 100vh;
        width: 250px;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        transition: left 0.3s ease;
        overflow-y: auto;
        padding-top: 70px; /* 为汉堡菜单留出空间 */
    }

    .sidebar.open {
        left: 0;
    }
    
    .sidebar h2 {
        display: none; /* 移动端隐藏标题，节省空间 */
    }
    
    .sidebar ul {
        display: block;
        padding: 0;
    }
    
    .sidebar li {
        padding: 12px 20px;
        margin: 0;
        border-radius: 0;
        border-left: 4px solid transparent;
    }
    
    .sidebar li.active {
        border-left: 4px solid var(--accent-color);
        padding-left: 16px;
        background-color: var(--sidebar-active);
        color: var(--text-color);
    }
    
    .content {
        padding: 70px 20px 20px; /* 顶部留出按钮空间 */
        width: 100%;
    }
}