:root {
    --bg: #FAFAF9;
    --bg-secondary: #FFFFFF;
    --text: #1C1917;
    --text-secondary: #78716C;
    --text-tertiary: #A8A29E;
    --border: #E7E5E4;
    --accent: #EA580C;
    --accent-light: #FFF7ED;
    --accent-hover: #C2410C;
    --code-bg: #F5F5F4;
    --tag-bg: #F3F4F6;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 10px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg: #0C0A09;
    --bg-secondary: #1C1917;
    --text: #FAFAF9;
    --text-secondary: #A8A29E;
    --text-tertiary: #78716C;
    --border: #292524;
    --accent: #F97316;
    --accent-light: #1C1407;
    --accent-hover: #FB923C;
    --code-bg: #1C1917;
    --tag-bg: #292524;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-hover: 0 10px 40px rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    transition: background 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #F59E0B);
    z-index: 1001;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

.scroll-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
    z-index: 100;
}

.scroll-top.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-top:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.scroll-top:hover svg {
    stroke: white;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 250, 249, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

[data-theme="dark"] .header {
    background: rgba(12, 10, 9, 0.85);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

.nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    transition: var(--transition);
}

.nav a:hover {
    color: var(--text);
}

.nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    transition: width 0.3s ease;
}

.nav a:hover::after {
    width: 100%;
}

.nav a.active {
    color: var(--text);
}

.nav a.active::after {
    width: 100%;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-btn, .theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.search-btn:hover, .theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text);
    border-color: var(--text-tertiary);
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mobile-menu-btn span {
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: var(--transition);
}

.hero {
    padding: 80px 24px 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.08) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 16px;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
    opacity: 0;
    animation: fadeInUp 0.6s ease 0.1s forwards;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    opacity: 0;
    animation: fadeInUp 0.6s ease 0.2s forwards;
}

.stat {
    text-align: center;
}

.stat-num {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 80px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 48px;
}

.posts {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.post-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    opacity: 0;
    transform: translateY(30px);
}

.post-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.post-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
    border-color: transparent;
}

.post-cover {
    width: 100%;
    height: 240px;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.post-card:hover .post-cover {
    transform: scale(1.03);
}

.post-cover-wrapper {
    overflow: hidden;
}

.post-content {
    padding: 28px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.post-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    background: var(--accent-light);
    border-radius: 6px;
}

.post-date {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.post-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
    letter-spacing: -0.3px;
}

.post-title a {
    color: var(--text);
    text-decoration: none;
    transition: var(--transition);
}

.post-title a:hover {
    color: var(--accent);
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 20px;
}

.post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.post-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.post-tags a {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    background: var(--tag-bg);
    padding: 4px 10px;
    border-radius: 6px;
    transition: var(--transition);
    text-decoration: none;
}

.post-tags a:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.read-more {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.read-more svg {
    transition: transform 0.3s ease;
}

.read-more:hover svg {
    transform: translateX(4px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.widget {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    transition: var(--transition);
}

.widget-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.author-card {
    text-align: center;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 16px;
    overflow: hidden;
    border: 3px solid var(--accent-light);
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.author-bio {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.social-link {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.social-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: translateY(-2px);
}

.toc-list {
    list-style: none;
    font-size: 0.85rem;
}

.toc-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.toc-list li:last-child {
    border-bottom: none;
}

.toc-list a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-list a::before {
    content: '→';
    color: var(--text-tertiary);
    transition: var(--transition);
}

.toc-list a:hover {
    color: var(--accent);
}

.toc-list a:hover::before {
    color: var(--accent);
    transform: translateX(2px);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--tag-bg);
    padding: 6px 12px;
    border-radius: 20px;
    text-decoration: none;
    transition: var(--transition);
}

.tag-item:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
}

.archive-list {
    list-style: none;
}

.archive-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.archive-list li:last-child {
    border-bottom: none;
}

.archive-list a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.archive-list a:hover {
    color: var(--accent);
}

.archive-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--tag-bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.search-box {
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 24px;
    width: 90%;
    max-width: 560px;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.search-modal.active .search-box {
    transform: translateY(0);
}

.search-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

.search-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-hint kbd {
    background: var(--tag-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    min-width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: translateY(-2px);
}

.pagination a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.pagination a.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination a.disabled:hover {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transform: none;
}

.footer {
    border-top: 1px solid var(--border);
    padding: 48px 24px;
    text-align: center;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-copyright {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 150;
    padding: 80px 24px 24px;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu.open {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu a {
    display: block;
    padding: 12px 0;
    color: var(--text);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.mobile-menu a:hover {
    color: var(--accent);
    padding-left: 8px;
}

.mobile-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.post-detail-body {
    font-size: 1.05rem;
    line-height: 1.9;
    margin-top: 24px;
}

.post-detail-body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 40px 0 16px;
    padding-left: 16px;
    border-left: 4px solid var(--accent);
}

.post-detail-body h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 32px 0 12px;
}

.post-detail-body p {
    margin-bottom: 20px;
    color: var(--text);
}

.post-detail-body blockquote {
    border-left: 4px solid var(--accent);
    background: var(--accent-light);
    padding: 20px 24px;
    margin: 24px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.post-detail-body img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 24px 0;
}

/* ===== 代码块防溢出修复（替换原 .post-detail-body pre 相关样式） ===== */
.post-detail-body pre,
.post-detail-body code,
.post-detail-body pre code {
    /* 🔑 核心：允许长字符串换行 */
    white-space: pre-wrap !important;      /* 保留格式 + 允许自动换行 */
    word-wrap: break-word !important;      /* 长单词强制断行 */
    word-break: break-all !important;      /* 任意字符处可断行（URL 必备） */
    
    /* 🔑 限制宽度 + 滚动 */
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    box-sizing: border-box;
    
    /* 基础样式保留 */
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: var(--text);
}

.post-detail-body pre {
    padding: 20px;
    margin: 16px 0;
    display: block;                        /* 确保块级元素 */
}

.post-detail-body pre code {
    padding: 0;
    border: none;
    background: none;
    display: inline;                       /* 避免 code 独占一行 */
}

/* 移动端适配：小屏幕字体略小 + 触摸滚动优化 */
@media (max-width: 768px) {
    .post-detail-body pre,
    .post-detail-body code {
        font-size: 0.85em;
        padding: 16px;
        -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
    }
}

.post-detail-body ul, .post-detail-body ol {
    margin: 16px 0;
    padding-left: 24px;
}

.post-detail-body li {
    margin-bottom: 8px;
}

@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .widget.author-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .nav {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .hero {
        padding: 48px 24px 32px;
    }

    .hero-stats {
        gap: 24px;
    }

    .main {
        padding: 0 16px 48px;
        gap: 24px;
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .post-content {
        padding: 20px;
    }

    .post-cover {
        height: 180px;
    }

    .footer-links {
        flex-wrap: wrap;
    }

    .scroll-top {
        bottom: 16px;
        right: 16px;
    }
}

@media (max-width: 480px) {
 .header-inner {
 padding: 0 16px;
 }

 .hero-stats {
 /* ✅ 保持横向排列，允许自动换行 */
 flex-direction: row !important;
 flex-wrap: wrap;
 justify-content: center;  /* 换行后居中对齐 */
 gap: 16px 24px;           /* 行间距 16px，列间距 24px */
 }

 /* 可选：略微缩小字体适配超窄屏 */
 .stat-num {
 font-size: 1.5rem;
 }
 .stat-label {
 font-size: 0.75rem;
 }
}

.post-detail-body pre {
    position: relative;
}
.post-detail-body pre::after {
    content: '📋 复制';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--accent);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.post-detail-body pre:hover::after {
    opacity: 1;
}