* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
a {
    text-decoration: none;
}
:root {
    --bg: #f7f8fa;
    --card: #ffffff;
    --text: #333;
    --text-light: #666;
    --text-gray: #999;
    --shadow: 0 2px 10px rgba(0,0,0,0.06);
    --nav: #fff;
    --border: #eee;
    --accent: #0066cc;
}

[data-theme="dark"] {
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e0e0e0;
    --text-light: #b0b0b0;
    --text-gray: #777;
    --shadow: 0 2px 10px rgba(0,0,0,0.3);
    --nav: #1a1a1a;
    --border: #333;
    --accent: #4285e4;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    transition: background 0.3s, color 0.3s;
}

.navbar {
    background: var(--nav);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 99;
}
.nav-container {
    max-width: 1200px;
    margin: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}
.logo {
    font-weight: bold;
    font-size: 20px;
    color: #0066cc;
    text-decoration: none;
}
.nav-links {
    display: flex;
    gap: 24px;
}
.nav-links a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 15px;
}
.nav-links a:hover {
    color: var(--accent);
}
.theme-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text);
}

.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    gap: 30px;
    position: relative;
}

/* ========= 左侧目录 ========= */
.toc-container {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 10px;
    z-index: 90;
}
.toc-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.toc-list {
    list-style: none;
}
.toc-item {
    margin-bottom: 10px;
}
.toc-link {
    color: var(--text-light);
    text-decoration: none;
    font-size: 14px;
    display: block;
    padding: 4px 0;
    transition: color 0.2s;
}
.toc-link:hover,
.toc-link.active {
    color: var(--accent);
    font-weight: 500;
}
.toc-item-h2 { padding-left: 0; font-weight: 500; }
.toc-item-h3 { padding-left: 12px; font-size: 13px; }

/* ========= 手机端目录最小化核心 ========= */
@media (max-width: 1024px) {
    .toc-container {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        background: var(--card);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        padding: 20px;
        z-index: 999;
    }
    .toc-container.show {
        transform: translateX(0);
    }

    /* 手机端展开按钮 */
    .toc-mobile-btn {
        position: fixed;
        bottom: 30px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: var(--accent);
        color: #fff;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
        z-index: 998;
    }

    .page-wrapper {
        display: block;
    }
}

/* 电脑端隐藏按钮 */
@media (min-width: 1025px) {
    .toc-mobile-btn {
        display: none !important;
    }
}

.article-container {
    flex: 1;
    max-width: 860px;
}
.article-header { margin: 30px 0 24px; }
.article-title { font-size: 26px; font-weight: 700; line-height: 1.4; margin-bottom: 12px; }
.article-meta { font-size: 14px; color: var(--text-gray); display: flex; gap: 16px; }
.article-cover { width: 100%; border-radius: 12px; margin: 20px 0 30px; box-shadow: var(--shadow); }

.article-content { font-size: 16px; line-height: 1.9; }
.article-content p { margin-bottom: 18px; }
.article-content h2 { font-size: 20px; margin: 30px 0 14px; scroll-margin-top: 100px; }
.article-content h3 { font-size: 18px; margin: 24px 0 12px; scroll-margin-top: 100px; }
.article-content ul, .article-content ol { margin: 0 0 18px 22px; }
.article-content li { margin-bottom: 8px; }
.article-content strong { font-weight: 600; }

.divider { height: 1px; background: var(--border); margin: 40px 0; }
.recommend { margin-top: 20px; }
.recommend h3 { margin-bottom: 16px; }
.recommend-list { display: flex; flex-direction: column; gap: 12px; }
.recommend-item a { color: var(--accent); text-decoration: none; font-size: 15px; }
.recommend-item a:hover { text-decoration: underline; }

footer {
    text-align: center;
    padding: 40px 0;
    margin-top: 50px;
    color: var(--text-gray);
    font-size: 14px;
    border-top: 1px solid var(--border);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}