:root {
    --electric-blue: #3E6AE1;
    --pure-white: #FFFFFF;
    --carbon-dark: #171A20;
    --graphite: #393C41;
    --pewter: #5C5E62;
    --silver-fog: #8E8E8E;
    --cloud-gray: #EEEEEE;
    --pale-silver: #D0D1D2;
    --light-ash: #F4F4F4;
    --frosted-glass: rgba(255, 255, 255, 0.75);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--graphite);
    background: var(--pure-white);
    line-height: 1.43;
    font-weight: 400;
    font-size: 14px;
}

/* Navigation */
nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1001; /* Highest layer: Nav covers Menu and Overlay */
    padding: max(16px, env(safe-area-inset-top)) 16px 16px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.33s cubic-bezier(0.5, 0, 0, 0.75);
    will-change: transform;
}
nav.scrolled { background: var(--frosted-glass); }
.nav-logo {
    font-size: 20px; font-weight: 700; color: var(--carbon-dark);
    letter-spacing: 0.1em; text-decoration: none;
}
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-links { display: flex; gap: 24px; }
.nav-link {
    font-size: 14px; font-weight: 500; color: var(--carbon-dark);
    text-decoration: none; padding: 8px 16px; border-radius: 4px;
    transition: color 0.33s, background-color 0.33s;
}
.nav-link:hover { color: var(--electric-blue); background: rgba(62, 106, 225, 0.05); }
.nav-link.active { color: var(--electric-blue); }

/* Search Trigger */
.search-trigger {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; border-radius: 4px; transition: background-color 0.33s; color: var(--carbon-dark);
}
.search-trigger:hover { background: rgba(0, 0, 0, 0.05); }

/* Search Overlay */
.search-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
    z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.33s;
}
.search-overlay.active { opacity: 1; pointer-events: all; }
.search-container {
    position: absolute; top: 15vh; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 640px; background: var(--pure-white);
    border-radius: 12px; overflow: hidden;
}
.search-input-wrap {
    display: flex; align-items: center; padding: 16px 20px;
    border-bottom: 1px solid var(--cloud-gray);
}
.search-icon { color: var(--silver-fog); margin-right: 12px; }
.search-input {
    flex: 1; border: none; outline: none; font-size: 16px;
    font-weight: 400; color: var(--carbon-dark); background: transparent;
}
.search-input::placeholder { color: var(--silver-fog); }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result-item {
    padding: 16px 20px; border-bottom: 1px solid var(--cloud-gray);
    cursor: pointer; transition: background-color 0.33s;
}
.search-result-item:hover { background: var(--light-ash); }
.search-result-title { font-size: 14px; font-weight: 500; color: var(--carbon-dark); margin-bottom: 4px; }
.search-result-excerpt { font-size: 13px; color: var(--pewter); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 32px 20px; text-align: center; color: var(--silver-fog); }

/* Hero Section */
.hero {
    height: 100vh; display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center;
    background: linear-gradient(180deg, var(--pure-white) 0%, var(--light-ash) 100%);
    padding: 0 32px;
}
.hero h1 { font-size: 40px; font-weight: 500; color: var(--carbon-dark); line-height: 1.2; margin-bottom: 16px; }
.hero p { font-size: 14px; font-weight: 400; color: var(--pewter); max-width: 600px; margin-bottom: 32px; }

/* Buttons */
.cta-group { display: flex; gap: 16px; }
.btn {
    padding: 12px 32px; font-size: 14px; font-weight: 500; border-radius: 4px;
    border: none; cursor: pointer; transition: background-color 0.33s, color 0.33s;
    text-decoration: none; min-height: 40px;
}
.btn-primary { background: var(--electric-blue); color: var(--pure-white); }
.btn-primary:hover { background: #2D5AD0; }
.btn-secondary { background: var(--pure-white); color: var(--graphite); border: 1px solid var(--pale-silver); }
.btn-secondary:hover { background: var(--light-ash); }

/* Categories Section */
.categories { padding: 64px 32px; max-width: 1200px; margin: 0 auto; }
.section-title { font-size: 24px; font-weight: 500; color: var(--carbon-dark); margin-bottom: 32px; text-align: center; }
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.category-card {
    position: relative; height: 200px; border-radius: 12px; overflow: hidden;
    background: var(--carbon-dark); cursor: pointer; transition: transform 0.33s;
}
.category-card:hover { transform: translateY(-2px); }
.category-card img { width: 100%; height: 100%; object-fit: cover; opacity: 0.7; }
.category-label { position: absolute; bottom: 24px; left: 24px; color: var(--pure-white); font-size: 17px; font-weight: 500; }
.category-count { position: absolute; bottom: 24px; right: 24px; color: var(--pure-white); font-size: 14px; font-weight: 400; opacity: 0.8; }

/* Articles Section */
.articles { padding: 64px 32px; max-width: 800px; margin: 0 auto; }
.article-item { padding: 24px 0; border-bottom: 1px solid var(--cloud-gray); }
.article-item:last-child { border-bottom: none; }
.article-meta { font-size: 14px; font-weight: 400; color: var(--silver-fog); margin-bottom: 8px; }
.article-title { font-size: 17px; font-weight: 500; color: var(--carbon-dark); margin-bottom: 8px; cursor: pointer; transition: color 0.33s; }
.article-title:hover { color: var(--electric-blue); }
.article-excerpt { font-size: 14px; font-weight: 400; color: var(--pewter); line-height: 1.43; }
.article-tags { display: flex; gap: 8px; margin-top: 12px; }
.tag {
    padding: 4px 12px; font-size: 12px; font-weight: 400; color: var(--pewter);
    background: var(--light-ash); border-radius: 4px; text-decoration: none;
}
.tag:hover { color: var(--carbon-dark); }

/* Article Content Page */
.article-page { padding: 120px 32px 64px; max-width: 800px; margin: 0 auto; }
.article-page h1 { font-size: 32px; font-weight: 500; color: var(--carbon-dark); margin-bottom: 16px; }
.article-page .meta { font-size: 14px; color: var(--silver-fog); margin-bottom: 32px; }
.article-page .content { font-size: 15px; line-height: 1.6; }
.article-page .content h2 { font-size: 22px; font-weight: 500; color: var(--carbon-dark); margin: 32px 0 16px; }
.article-page .content h3 { font-size: 18px; font-weight: 500; color: var(--carbon-dark); margin: 24px 0 12px; }
.article-page .content p { margin-bottom: 16px; }
.article-page .content ul, .article-page .content ol { margin-bottom: 16px; padding-left: 24px; }
.article-page .content li { margin-bottom: 8px; }
.article-page .content code { background: var(--light-ash); padding: 2px 6px; border-radius: 4px; font-family: monospace; color: var(--carbon-dark); }
.article-page .content pre { background: var(--light-ash); padding: 16px; border-radius: 8px; overflow-x: auto; margin-bottom: 16px; }
.article-page .content pre code { background: none; padding: 0; }
.article-page .content blockquote { border-left: 3px solid var(--electric-blue); padding-left: 16px; color: var(--pewter); margin-bottom: 16px; }
.article-page .content img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.article-page .content table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.article-page .content table th, .article-page .content table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--cloud-gray); }
.article-page .content table th { background: var(--light-ash); font-weight: 500; }

/* Footer */
footer { padding: 32px; text-align: center; color: var(--silver-fog); font-size: 14px; border-top: 1px solid var(--cloud-gray); }

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: max(32px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    background: var(--carbon-dark);
    color: var(--pure-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.33s, transform 0.33s, background-color 0.33s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    -webkit-tap-highlight-color: transparent;
}
.back-to-top.visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--electric-blue);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    width: 32px; height: 32px;
    cursor: pointer;
    margin-left: 12px;
    -webkit-tap-highlight-color: transparent;
}
.menu-toggle span {
    display: block; width: 20px; height: 2px;
    background: var(--carbon-dark); margin: 0;
    border-radius: 1px;
    transition: all 0.33s;
}
/* Adjusted animation for new centering */
.menu-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.menu-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Responsive */
@media (max-width: 768px) {
    nav { padding: max(16px, env(safe-area-inset-top)) 16px 16px 16px; }
    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
    }
    
    /* 移动端抽屉式导航 - 终极背景修复 */
    .nav-links { 
        position: fixed; top: 0; right: 0; bottom: 0; left: auto;
        width: 280px; max-width: 85%;
        height: 100vh; height: 100dvh; /* 适配动态地址栏 */
        background: transparent !important; /* 使用伪元素渲染背景 */
        flex-direction: column; gap: 0;
        padding: max(60px, env(safe-area-inset-top)) 0 32px;
        transform: translate3d(100%, 0, 0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -4px 0 12px rgba(0,0,0,0.15);
        z-index: 1000;
        display: flex;
    }
    .nav-links.active { transform: translate3d(0, 0, 0); }
    
    /* 强制背景层，独立于 transform 渲染 */
    .nav-links::before {
        content: "";
        position: absolute; top: 0; left: 0; right: 0; bottom: 0;
        background: #ffffff;
        z-index: -1;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .nav-link { 
        font-size: 16px; padding: 18px 24px; 
        color: #171A20; text-decoration: none;
        border-bottom: 1px solid #f0f0f0;
    }
    .nav-link:active { background: #f5f5f5; }
    .nav-link:last-child { border-bottom: none; }

    /* 汉堡按钮动画 */
    .menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
    .menu-toggle.active span:nth-child(2) { opacity: 0; }
    .menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

    /* Overlay background */
    .nav-overlay {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.3); z-index: 98;
        opacity: 0; pointer-events: none; transition: opacity 0.33s;
    }
    .nav-overlay.active { opacity: 1; pointer-events: all; }

    .category-grid { grid-template-columns: 1fr; }
    .hero { padding: 0 20px; }
    .hero h1 { font-size: 28px; }
    .cta-group { flex-direction: column; width: 100%; }
    .btn { width: 100%; text-align: center; }
    .articles { padding: 40px 20px; }
    
    /* 文章页阅读优化 */
    .article-page { padding: 100px 20px 40px; }
    .article-page h1 { font-size: 24px; }
    .article-page .content { font-size: 16px; line-height: 1.7; }
    .article-page .content pre { padding: 12px; font-size: 13px; }
}
