/* ==================== CSS Variables ==================== */
:root {
    /* 浅色主题 */
    --bg-primary: #FFFFFF;
    --bg-secondary: #FAFAFA;
    --bg-tertiary: #F5F5F5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --accent-color: #2563EB;
    --accent-hover: #1D4ED8;
    --border-color: #E5E5E5;
    --code-bg: #1E1E1E;
    --code-text: #D4D4D4;
    --tag-bg: #EBF5FF;
    --tag-text: #2563EB;
    --shadow: rgba(0, 0, 0, 0.08);
    --toc-active: #2563EB;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #E8E8E8;
    --text-secondary: #B0B0B0;
    --text-tertiary: #707070;
    --border-color: #2D2D44;
    --code-bg: #0D1117;
    --tag-bg: #1E3A5F;
    --tag-text: #60A5FA;
    --shadow: rgba(0, 0, 0, 0.3);
    --toc-active: #60A5FA;
}

/* ==================== Base Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', Georgia, 'Songti SC', serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 16px;
    transition: background-color 0.3s, color 0.3s;
}

/* ==================== Reading Progress ==================== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent-color);
    z-index: 1001;
    transition: width 0.1s ease-out;
}

/* ==================== Theme Toggle ==================== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.sun-icon { display: block; }
.moon-icon { display: none; }

[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

/* ==================== Container ==================== */
.container {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 60px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ==================== Header ==================== */
.site-header {
    grid-column: 1 / -1;
    padding: 40px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.site-title {
    font-family: 'Inter', 'Source Han Sans CN', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.site-title:hover {
    color: var(--accent-color);
}

.main-nav {
    display: flex;
    gap: 32px;
}

.nav-link {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 0;
    position: relative;
    transition: color 0.2s;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.2s;
}

.nav-link:hover, .nav-link.active {
    color: var(--accent-color);
}

.nav-link.active::after, .nav-link:hover::after {
    width: 100%;
}

/* ==================== Main Content ==================== */
.main-content {
    min-height: calc(100vh - 200px);
}

/* ==================== Intro Section ==================== */
.intro-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 48px;
}

.intro-text h1 {
    font-family: 'Inter', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.intro-text p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 16px;
}

.intro-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.tag {
    display: inline-block;
    padding: 6px 16px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 20px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
}

/* ==================== Section Titles ==================== */
.section-title {
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

/* ==================== Search Box ==================== */
.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
}

.search-box input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.search-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.search-btn:hover svg {
    color: white;
}

/* ==================== Article List ==================== */
.article-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.article-card {
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--accent-color);
}

.article-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.article-card-date {
    font-size: 14px;
    color: var(--text-tertiary);
    font-family: 'Inter', sans-serif;
}

.article-card-category {
    padding: 4px 12px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

.article-card-title {
    font-family: 'Inter', 'Source Han Sans CN', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.article-card-title:hover {
    color: var(--accent-color);
}

.article-card-excerpt {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.article-card-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.article-tag {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

.read-more {
    font-size: 14px;
    color: var(--accent-color);
    font-family: 'Inter', sans-serif;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.read-more:hover {
    text-decoration: underline;
}

/* ==================== Article Detail ==================== */
.article-detail {
    max-width: 100%;
}

.article-header {
    margin-bottom: 40px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.article-date {
    font-size: 14px;
    color: var(--text-tertiary);
    font-family: 'Inter', sans-serif;
}

.article-category {
    padding: 4px 12px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

.article-title {
    font-family: 'Inter', 'Source Han Sans CN', sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 20px;
}

.article-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== Article TOC ==================== */
.article-toc {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.article-toc h3 {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.article-toc nav a {
    display: block;
    padding: 6px 0;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.article-toc nav a:hover, .article-toc nav a.active {
    color: var(--toc-active);
}

.article-toc nav a.level-2 {
    padding-left: 16px;
}

.article-toc nav a.level-3 {
    padding-left: 32px;
}

/* ==================== Article Content ==================== */
.article-content {
    font-size: 17px;
    line-height: 1.9;
}

.article-content h2 {
    font-family: 'Inter', 'Source Han Sans CN', sans-serif;
    font-size: 26px;
    font-weight: 600;
    margin: 48px 0 24px;
    color: var(--text-primary);
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.article-content h3 {
    font-family: 'Inter', 'Source Han Sans CN', sans-serif;
    font-size: 20px;
    font-weight: 600;
    margin: 36px 0 18px;
    color: var(--text-primary);
}

.article-content h4 {
    font-family: 'Inter', 'Source Han Sans CN', sans-serif;
    font-size: 18px;
    font-weight: 600;
    margin: 28px 0 14px;
    color: var(--text-primary);
}

.article-content p {
    margin-bottom: 20px;
}

.article-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.article-content a:hover {
    text-decoration: underline;
}

.article-content ul, .article-content ol {
    margin-bottom: 20px;
    padding-left: 28px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-content blockquote {
    margin: 24px 0;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.article-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 24px 0;
}

.article-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 40px 0;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
}

.article-content table th, .article-content table td {
    padding: 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.article-content table th {
    background: var(--bg-secondary);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

.article-content code:not(pre code) {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--accent-color);
}

/* ==================== Article Navigation ==================== */
.article-footer {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.prev-article, .next-article {
    flex: 1;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
}

.prev-article:hover, .next-article:hover {
    background: var(--bg-tertiary);
}

.article-nav span:first-child {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: 'Inter', sans-serif;
    margin-bottom: 8px;
}

.article-nav .article-nav-title {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.next-article {
    text-align: right;
}

/* ==================== Sidebar ==================== */
.sidebar {
    position: sticky;
    top: 24px;
    height: fit-content;
}

.sidebar-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.sidebar-title {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 8px;
}

.category-list a {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.category-list a:hover, .category-list a.active {
    background: var(--tag-bg);
    color: var(--tag-text);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.tag-item:hover, .tag-item.active {
    background: var(--tag-bg);
    color: var(--tag-text);
}

.recent-list {
    list-style: none;
}

.recent-list li {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.recent-list li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.recent-list a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.5;
    transition: color 0.2s;
}

.recent-list a:hover {
    color: var(--accent-color);
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.contact-link svg {
    width: 18px;
    height: 18px;
}

.contact-link:hover {
    color: var(--accent-color);
}

/* ==================== Footer ==================== */
.site-footer {
    grid-column: 1 / -1;
    padding: 40px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-content p {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-bottom: 8px;
}

.footer-content p:last-child {
    font-size: 12px;
}

/* ==================== Copy Toast ==================== */
.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    z-index: 1002;
    opacity: 0;
    transition: all 0.3s;
}

.copy-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr 240px;
        gap: 40px;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 0 16px;
    }

    .site-header {
        padding: 24px 0;
    }

    .header-content {
        flex-direction: column;
        gap: 20px;
    }

    .main-nav {
        gap: 20px;
    }

    .intro-section {
        padding: 24px;
    }

    .intro-text h1 {
        font-size: 24px;
    }

    .article-title {
        font-size: 28px;
    }

    .article-content {
        font-size: 16px;
    }

    .sidebar {
        display: none;
    }

    .theme-toggle {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }

    .article-nav {
        flex-direction: column;
    }

    .next-article {
        text-align: left;
    }
}

/* ==================== No Results ==================== */
.no-results {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-tertiary);
}

.no-results h3 {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    margin-bottom: 12px;
}

.no-results p {
font-size: 14px;
}