/* === Variables === */
:root {
    --bg-color: #f9fafb; --text-color: #1f2937; --card-bg: #ffffff;
    --border-color: #e5e7eb; --link-color: #2563eb; --btn-hover: rgba(0,0,0,0.04);
    --secondary-text: #6b7280; --accent: #2563eb;
    --transition-fast: 0.2s ease; --transition-mid: 0.3s ease;
    --accent-soft: rgba(37,99,235,0.08); --accent-soft-border: rgba(37,99,235,0.2);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
                 "Noto Sans CJK SC", sans-serif;
    --font-title: "Noto Serif SC", "Songti SC", "SimSun", "Source Han Serif SC", Georgia, serif;
    --font-mono: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;

    --content-font-size: 16.5px;
    --content-line-height: 1.85;
}
[data-theme="dark"] {
    --bg-color: #0d1117; --text-color: #d1d5db; --card-bg: #161b22;
    --border-color: #30363d; --link-color: #60a5fa; --btn-hover: rgba(255,255,255,0.08);
    --secondary-text: #9ca3af; --accent: #60a5fa;
    --accent-soft: rgba(96,165,250,0.12); --accent-soft-border: rgba(96,165,250,0.25);
}

/* === Reset & Body === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { max-width: 100%; min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
body {
    background-color: var(--bg-color); color: var(--text-color);
    font-family: var(--font-sans); font-size: 15px; line-height: 1.6;
    transition: background-color 0.3s;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary-text); }

/* === Navbar === */
.navbar {
    position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
    width: calc(100% - 40px); max-width: 1200px; height: 60px;
    background-color: rgba(255,255,255,0.55); backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,0.35);
    border-radius: 30px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; z-index: 1000; box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
[data-theme="dark"] .navbar { background-color: rgba(22,27,34,0.7); border-color: rgba(255,255,255,0.08); }
.nav-left { display: flex; align-items: center; }
.logo-img { height: 42px; width: auto; object-fit: contain; }
.nav-right { display: flex; align-items: center; gap: 10px; }

.nav-btn {
    padding: 7px 15px; background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 8px; color: var(--text-color); text-decoration: none; font-size: 0.9rem;
    font-weight: 500; transition: all 0.2s; cursor: pointer;
}
.nav-btn:hover { border-color: var(--link-color); color: var(--link-color); }
.nav-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%; padding: 0;
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative; transition: all 0.3s;
}
.theme-toggle:hover { transform: scale(1.08); }
.theme-toggle svg { position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; transition: all 0.3s; }
.theme-toggle .icon-sun  { opacity: 0; transform: translate(-50%,-50%) scale(1); color: #f59e0b; }
.theme-toggle .icon-moon { opacity: 1; transform: translate(-50%,-50%) scale(0.5); }
[data-theme="dark"] .theme-toggle .icon-sun  { opacity: 1; transform: translate(-50%,-50%) scale(0.5); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: translate(-50%,-50%) scale(1); }

.hamburger {
    display: none; background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 8px; cursor: pointer; padding: 5px; color: var(--text-color); width: 36px; height: 36px;
}
.hamburger svg { width: 24px; height: 24px; stroke: currentColor; }
.mobile-menu {
    position: fixed; top: 80px; right: 20px; background-color: var(--card-bg);
    backdrop-filter: blur(10px); border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1); z-index: 1001; align-items: center;
    flex-direction: column; gap: 10px; transform: scaleY(0); transform-origin: top;
    opacity: 0; visibility: hidden; display: flex; padding: 10px 0; overflow: hidden; width: 62px;
    transition: transform var(--transition-fast), opacity var(--transition-fast), visibility var(--transition-fast);
}
.mobile-menu.active { transform: scaleY(1); opacity: 1; visibility: visible; }
.mobile-menu a {
    display: flex; align-items: center; justify-content: center; width: 40px;
    border: 1px solid var(--border-color); border-radius: 8px; padding: 6px;
    background: transparent; color: var(--text-color); text-decoration: none;
    font-size: 0.95rem; font-weight: 500; white-space: nowrap; flex-shrink: 0;
}
.mobile-menu a:hover { background: var(--btn-hover); }

/* === 列表页左右布局 === */
.page-wrapper { max-width: 1200px; margin: 0 auto; padding: 0 20px 40px; }

.main-container {
    position: relative;              /* 侧边栏以此为定位基准 */
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 40px;
}

/* 文章区决定整体高度，右侧留出侧边栏位置 (280 + 32) */
.post-section { flex: 1; min-width: 0; margin-right: 312px; }

.post-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    list-style: none; padding: 0; margin: 0; width: 100%;
    align-content: start;
    /* 3 行 × 300px + 2 × 24px 间距：最后一页或搜索结果少时高度也不变 */
    min-height: calc(300px * 3 + 24px * 2);
}

/* 侧边栏不参与撑高，上下边界贴齐文章区 */
.sidebar-section {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 280px;
    display: flex;
    flex-direction: column;
}

/* Widget */
.widget {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    flex-shrink: 0;
}
.widget-title {
    font-size: 1rem; font-weight: 700; margin-bottom: 16px; padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color); color: var(--text-color);
}

.stat-list { list-style: none; padding: 0; margin: 0; }
.stat-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-size: 0.9rem; color: var(--secondary-text); }
.stat-list li strong { color: var(--accent); font-size: 1.1rem; }
.stat-list li.stat-latest { border-top: 1px dashed var(--border-color); margin-top: 4px; padding-top: 12px; }
.stat-list li.stat-latest strong { font-size: 0.9rem; color: var(--text-color); font-family: var(--font-mono); }

.contact-info p { font-size: 0.85rem; color: var(--secondary-text); margin-bottom: 12px; line-height: 1.5; }
.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 0.88rem; }
.contact-list li a { color: var(--link-color); text-decoration: none; transition: opacity 0.2s; }
.contact-list li a:hover { opacity: 0.8; text-decoration: underline; }
.contact-list .icon { font-size: 1.1rem; }

/* 词云卡片：占满剩余高度，但不允许被内容撑大 */
.cloud-widget {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}
.tag-cloud {
    display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;                /* 放不下的由 JS 分到下一页 */
}
.tag-item {
    padding: 4px 12px; background: var(--bg-color); border: 1px solid var(--border-color);
    border-radius: 20px; font-size: 0.82rem; color: var(--secondary-text);
    cursor: pointer; transition: all 0.2s ease; height: fit-content;
}
.tag-item:hover, .tag-item.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 词云分页器：固定在卡片底部，高度恒定 */
.cloud-pagination {
    flex-shrink: 0;
    min-height: 41px;
    display: flex; justify-content: center; align-items: center; gap: 6px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
}
.cloud-page-btn {
    padding: 2px 8px; font-size: 0.75rem; border-radius: 4px;
    background: var(--bg-color); border: 1px solid var(--border-color);
    color: var(--secondary-text); cursor: pointer; transition: all 0.2s;
}
.cloud-page-btn:hover { border-color: var(--link-color); color: var(--link-color); }
.cloud-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === 卡片样式（固定高度 300px） === */
.post-item {
    background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border-color);
    overflow: hidden; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex; flex-direction: column; min-width: 0; width: 100%;
    height: 300px;
}
.post-item:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0,0,0,0.08); border-color: var(--link-color); }
.post-thumb { width: 100%; height: 180px; flex: none; object-fit: cover; background: var(--border-color); display: block; }
.post-info { padding: 18px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.post-title {
    font-size: 1.05rem; font-weight: 600; line-height: 1.4; color: var(--text-color); word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; width: 100%; }
.post-meta-time { font-size: 0.78rem; color: var(--secondary-text); }
.post-meta-category {
    font-size: 0.75rem; color: var(--link-color);
    background: var(--accent-soft); border: 1px solid var(--accent-soft-border);
    border-radius: 20px; padding: 4px 10px; font-weight: 500;
    display: inline-flex; align-items: center;
}

/* 文章分页器 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; width: 100%; }
.page-btn {
    display: flex; justify-content: center; align-items: center;
    width: 36px; height: 36px; border-radius: 8px;
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    color: var(--text-color); font-size: 0.95rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s ease;
}
.page-btn:hover { border-color: var(--link-color); color: var(--link-color); }
.page-btn.active { background-color: var(--accent); border-color: var(--accent); color: #fff; }

/* Search */
.search-group {
    display: flex; align-items: center; background: var(--card-bg);
    border: 1px solid var(--border-color); border-radius: 8px; height: 36px; transition: all 0.2s;
}
.search-group:focus-within { border-color: var(--link-color); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.search-input { border: none; background: transparent; padding: 0 12px; font-size: 14px; width: 120px; height: 100%; outline: none; color: var(--text-color); }
.search-input::placeholder { color: #9ca3af; }
.search-btn { border: none; background: transparent; padding: 0 10px; height: 100%; cursor: pointer; color: var(--text-color); display: flex; align-items: center; border-radius: 0 8px 8px 0; }
.search-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* Footer */
.footer {
    text-align: center; font-size: 0.85rem; color: var(--secondary-text);
    padding: 30px 20px; border-top: none; margin-top: 20px;
}
.footer-stats { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 10px; font-size: 0.9rem; }
.footer-stats .divider { color: var(--border-color); }

/* === 文章详情页样式（保留原样） === */
.post-layout { display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; min-height: 100dvh; padding: 20px; gap: 20px; width: 100%; }
.sidebar {
    position: sticky; top: 20px; width: 250px; flex-shrink: 0; max-height: calc(100vh - 40px); overflow-y: auto;
    background-color: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    padding: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); transition: all var(--transition-mid);
}
.sidebar h2 { margin-top: 0; font-size: 1.2em; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); color: var(--text-color); }
.toc ul { list-style: none; padding-left: 0; font-size: 0.95em; }
.toc a { display: block; padding: 10px 15px; color: var(--secondary-text); text-decoration: none; border-radius: 4px; transition: all 0.1s ease; }
.toc a.active { color: var(--link-color); font-weight: bold; }
.toc a:hover { color: var(--link-color); background-color: var(--btn-hover); }

.content-wrapper { flex: 1; max-width: 960px; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: 0; }
.content-wrapper > .controls { width: 100%; max-width: 960px; align-self: center; flex-shrink: 0; min-height: 48px; }
.controls {
    position: sticky; top: 20px; z-index: 1002; display: flex; align-items: center; justify-content: space-between;
    height: 48px; min-height: 48px; flex-shrink: 0; padding: 0 8px; margin-bottom: 20px;
    background-color: rgba(255,255,255,0.6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.4); border-radius: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: background-color var(--transition-mid), border-color var(--transition-mid);
}
[data-theme="dark"] .controls { background-color: rgba(22,27,34,0.65); border-color: rgba(255,255,255,0.08); }

.back-btn {
    display: flex; justify-content: center; align-items: center; width: 32px; height: 32px;
    padding: 0; border: 1px solid var(--border-color); border-radius: 50%;
    background-color: var(--card-bg); color: var(--text-color) !important;
    text-decoration: none !important; transition: all var(--transition-fast); cursor: pointer; flex-shrink: 0;
}
.back-btn svg { width: 16px; height: 16px; display: block; margin: 0; }
.back-btn:hover { background-color: var(--btn-hover); border-color: var(--link-color); color: var(--link-color) !important; }

.mobile-toc-toggle {
    display: none; align-items: center; justify-content: center; width: 32px; height: 32px;
    border: 1px solid var(--border-color); border-radius: 50%; background-color: var(--card-bg);
    cursor: pointer; transition: all var(--transition-fast); flex-shrink: 0;
}
.mobile-toc-toggle:hover { background-color: var(--btn-hover); border-color: var(--link-color); }
.mobile-toc-toggle svg { width: 16px; height: 16px; transition: transform var(--transition-mid); }
.mobile-toc-toggle.collapsed svg { transform: rotate(180deg); }
.controls .theme-toggle { width: 32px; height: 32px; margin-right: 0; flex-shrink: 0; }
.controls .theme-toggle svg { width: 32px; height: 32px; }

.markdown-body {
    background-color: var(--card-bg); color: var(--text-color) !important;
    padding: 48px 56px 64px 56px; border-radius: 36px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: background-color var(--transition-mid); width: 100%; max-width: 960px; min-width: 0; height: auto; margin: 0 auto;
    font-family: var(--font-sans); font-size: var(--content-font-size); line-height: var(--content-line-height);
    letter-spacing: 0.01em; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word;
}
.markdown-body > h1:first-child { text-align: center; font-family: var(--font-title); font-size: 2rem; line-height: 1.35; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.5em; border-bottom: none; }
.post-header-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5em; padding-bottom: 1em; border-bottom: 1px dashed var(--border-color); font-size: 0.9rem; }
.post-header-category { color: var(--link-color); background: var(--accent-soft); border: 1px solid var(--accent-soft-border); padding: 3px 12px; border-radius: 20px; font-weight: 500; }
.post-header-date { color: var(--secondary-text); font-family: var(--font-mono); }

.markdown-body p { margin: 0 0 1.4em; line-height: var(--content-line-height); }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body > h1:not(:first-child) { text-align: left; font-family: var(--font-title); font-size: 1.55rem; line-height: 1.4; margin: 2em 0 0.8em; }
.markdown-body h2 { font-family: var(--font-title); font-size: 1.35rem; line-height: 1.45; font-weight: 700; margin: 2.2em 0 0.8em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border-color); }
.markdown-body h3 { font-family: var(--font-title); font-size: 1.15rem; line-height: 1.5; font-weight: 600; margin: 1.8em 0 0.6em; }
.markdown-body h4 { font-family: var(--font-title); font-size: 1.02rem; font-weight: 600; margin: 1.5em 0 0.5em; }
.markdown-body ul, .markdown-body ol { margin: 0 0 1.4em; padding-left: 1.6em; }
.markdown-body li { margin: 0.45em 0; line-height: var(--content-line-height); }
.markdown-body li > p { margin: 0.3em 0; }
.markdown-body blockquote { margin: 1.5em 0; padding: 0.6em 1.2em; border-left: 3px solid var(--accent); background: var(--bg-color); color: var(--secondary-text); border-radius: 0 8px 8px 0; line-height: var(--content-line-height); }
.markdown-body blockquote p { margin: 0.4em 0; }
.markdown-body code { font-family: var(--font-mono); font-size: 0.9em; padding: 0.15em 0.4em; background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 4px; }
.markdown-body pre { font-family: var(--font-mono); font-size: 0.88em; line-height: 1.65; padding: 1.1em 1.3em; margin: 1.4em 0; background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; overflow-x: auto; max-width: 100%; }
.markdown-body pre code { padding: 0; border: none; background: none; font-size: inherit; }
.markdown-body img { display: block; max-width: 100%; width: auto; height: auto; margin: 1.8em auto; border-radius: 8px; object-fit: contain; cursor: zoom-in; box-shadow: 0 2px 12px rgba(0,0,0,0.06); background-color: var(--bg-color); }
.markdown-body hr { margin: 2.4em 0; border: none; border-top: 1px solid var(--border-color); }
.markdown-body a { color: var(--link-color); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; transition: opacity 0.15s; }
.markdown-body a:hover { opacity: 0.8; }
.markdown-body iframe, .markdown-body video, .markdown-body svg { max-width: 100%; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { scroll-margin-top: 90px; }

.giscus-container { margin-top: 3.5em; padding-top: 2em; border-top: 1px dashed var(--border-color); }
.giscus-frame { width: 100%; border: none; border-radius: 8px; background-color: transparent; }

[data-theme="light"] .markdown-body { color-scheme: light; }
[data-theme="dark"] .markdown-body { color-scheme: dark; }
.markdown-body ul.task-list { list-style: none; padding-left: 0; }
.markdown-body ul.task-list li { display: flex; align-items: center; margin: 6px 0; line-height: 1.6; }
.markdown-body ul.task-list li input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border: 2px solid var(--border-color) !important; border-radius: 4px; margin-right: 10px; background-color: var(--card-bg) !important; cursor: pointer; position: relative; top: -1px; transition: all 0.1s ease; vertical-align: middle; outline: none; pointer-events: auto; }
.markdown-body ul.task-list li input[type="checkbox"]:checked { background-color: var(--link-color) !important; border-color: var(--link-color) !important; }
.markdown-body ul.task-list li input[type="checkbox"]:checked::after { content: '✓'; color: white; font-weight: bold; font-size: 14px; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 0.95em; line-height: 1.6; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-color); padding: 12px 15px; text-align: left; background-color: var(--card-bg); white-space: normal; transition: background-color var(--transition-mid), color var(--transition-mid), border-color var(--transition-mid); }
.markdown-body th { font-weight: 600; color: var(--text-color); }
[data-theme="light"] .markdown-body tbody tr:nth-child(even) td { background-color: #f8f9fa !important; }
[data-theme="dark"] .markdown-body tbody tr:nth-child(even) td { background-color: #1c2128 !important; }

/* === 响应式 === */
@media (max-width: 900px) {
    .main-container { flex-direction: column; margin-bottom: 20px; }
    .post-section { width: 100%; margin-right: 0; }
    .post-grid { grid-template-columns: 1fr; min-height: 0; }
    .post-item { height: auto; }
    .sidebar-section {
        position: static; width: 100%; margin-top: 20px;
        display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    }
    .widget { margin-bottom: 0; }
    .cloud-widget { flex: none; }
    .tag-cloud { overflow: visible; }
    .page-btn { width: 40px; height: 40px; }
}
@media (max-width: 600px) {
    .sidebar-section { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .nav-btn:not(.hamburger) { display: none; }
    .hamburger { display: flex; align-items: center; justify-content: center; }
    .nav-right { gap: 12px; }
    .search-group { display: none; }
}

@media (max-width: 1100px) {
    .post-layout { display: flex; flex-direction: column; padding: 10px; width: 100%; min-height: 100vh; min-height: 100dvh; }
    .sidebar {
        position: fixed; top: 68px; left: 10px; right: 10px; width: auto; max-width: none; height: auto; max-height: 60vh; z-index: 1001;
        border-radius: 16px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
        transform: translateY(0); opacity: 1; transition: transform 0.3s ease, opacity 0.3s ease;
        background-color: var(--card-bg); border: 1px solid var(--border-color);
    }
    .sidebar.collapsed { transform: translateY(-20px); opacity: 0; pointer-events: none; }
    .content-wrapper { width: 100%; flex: 1; margin-top: 0; padding: 0; align-items: stretch; }
    .content-wrapper > .controls { width: 100%; max-width: 100%; top: 10px; }
    .markdown-body { width: 100%; max-width: 100%; padding: 24px 20px 48px 20px; border-radius: 24px; font-size: 16px; line-height: 1.8; margin: 0 auto; }
    .markdown-body > h1:first-child { font-size: 1.6rem; }
    .markdown-body h2 { font-size: 1.2rem; }
    .markdown-body h3 { font-size: 1.08rem; }
    .markdown-body p { margin-bottom: 1.2em; }
    .markdown-body img { margin: 1.2em auto; }
    .post-header-meta { margin-bottom: 1.8em; }
    .content-wrapper > .controls { min-height: 48px; }
    .mobile-toc-toggle { display: flex; }
    .controls { height: 48px; padding: 8px 8px; border-radius: 24px; margin-bottom: 10px; flex-wrap: nowrap; }
    .back-btn { order: 1; }
    .mobile-toc-toggle { order: 2; margin-left: auto; }
    .controls .theme-toggle { order: 3; margin-left: 8px; margin-right: 0; }
}
/* =====================================================================
   独立页面适配：about / categories / contact / info
   ===================================================================== */

/* 通用居中容器（about / categories / contact） */
.container { width: 100%; max-width: 900px; margin: 0 auto; padding: 0 20px; }

/* 页面标题条（categories / contact） */
.page-header { text-align: center; padding: 20px 20px 36px; max-width: 900px; margin: 0 auto; }
.page-header h1 { font-family: var(--font-title); font-size: 2.2rem; font-weight: 700; line-height: 1.3; }
.page-header p { margin-top: 10px; color: var(--secondary-text); font-size: 1rem; }

/* 带 stroke 图标的统一设置（模板里的 svg 没写 fill/stroke） */
.section-title-icon svg, .category-icon svg, .contact-card-icon svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- about ---------- */
.hero { text-align: center; padding: 30px 20px 40px; max-width: 900px; margin: 0 auto; }
.hero-avatar {
    width: 112px; height: 112px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--card-bg); background: var(--card-bg);
    box-shadow: 0 6px 24px rgba(0,0,0,0.12); margin-bottom: 18px;
}
.hero h1 { font-family: var(--font-title); font-size: 2.2rem; font-weight: 700; line-height: 1.3; }
.hero-tagline { margin-top: 8px; color: var(--secondary-text); font-size: 1.05rem; }
.hero-tags { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero-tag {
    padding: 4px 14px; font-size: 0.85rem; font-weight: 500; border-radius: 20px;
    color: var(--link-color); background: var(--accent-soft); border: 1px solid var(--accent-soft-border);
}

.section {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px;
    padding: 24px 28px; margin-bottom: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.section p { line-height: 1.85; color: var(--text-color); }
.section-title {
    display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700;
    margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-color);
}
.section-title-icon {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 32px; height: 32px; border-radius: 8px; color: var(--accent);
    background: var(--accent-soft);
}

.tech-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.tech-badge {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 0.88rem;
    background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 20px;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.tech-badge:hover { border-color: var(--link-color); transform: translateY(-2px); }
.tech-badge-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
    position: absolute; left: -26px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent); border: 2px solid var(--card-bg); box-shadow: 0 0 0 2px var(--accent);
}
.timeline-date { font-family: var(--font-mono); font-size: 0.8rem; color: var(--secondary-text); }
.timeline-title { font-weight: 600; margin: 2px 0 4px; }
.timeline-desc { font-size: 0.9rem; color: var(--secondary-text); line-height: 1.7; }

/* ---------- categories ---------- */
.category-block {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px;
    margin-bottom: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    transition: border-color var(--transition-fast);
}
.category-block:hover { border-color: var(--link-color); }
.category-header { width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; display: flex; align-items: center; gap: 12px; padding: 16px 20px; cursor: pointer; user-select: none; }
.category-header:hover { background: var(--btn-hover); }
.category-icon {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 36px; height: 36px; border-radius: 10px; color: var(--accent); background: var(--accent-soft);
}
.category-name { flex: 1; min-width: 0; font-size: 1.05rem; font-weight: 600; word-break: break-word; }
.category-count {
    font-size: 0.78rem; color: var(--secondary-text); padding: 2px 10px;
    background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 20px; white-space: nowrap;
}
.toggle-arrow { width: 18px; height: 18px; flex-shrink: 0; color: var(--secondary-text); transition: transform var(--transition-mid); }
.category-block.collapsed .toggle-arrow { transform: rotate(-90deg); }

.article-list { list-style: none; overflow: hidden; border-top: 1px dashed var(--border-color); transition: max-height var(--transition-mid), opacity var(--transition-mid); }
.category-block.collapsed .article-list { max-height: 0 !important; opacity: 0; border-top-color: transparent; }
.article-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 20px; transition: background var(--transition-fast); }
.article-item:hover { background: var(--btn-hover); }
.article-bullet { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.article-item a {
    flex: 1; min-width: 0; color: var(--text-color); text-decoration: none; font-size: 0.95rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color var(--transition-fast);
}
.article-item a:hover { color: var(--link-color); }
.article-arrow { color: var(--secondary-text); opacity: 0; transform: translateX(-6px); transition: all var(--transition-fast); }
.article-item:hover .article-arrow { opacity: 1; transform: translateX(0); color: var(--link-color); }

/* ---------- contact ---------- */
.contact-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 32px; }
.contact-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0;
    padding: 20px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px;
    color: inherit; text-decoration: none; box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.contact-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0,0,0,0.08); border-color: var(--link-color); }
.contact-card-icon {
    display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    border-radius: 10px; margin-bottom: 6px; color: var(--accent); background: var(--accent-soft);
}
.contact-card-icon svg { width: 22px; height: 22px; }
.contact-card-title { font-weight: 600; }
.contact-card-value { font-size: 0.88rem; color: var(--secondary-text); font-family: var(--font-mono); max-width: 100%; overflow-wrap: anywhere; }

.form-section {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px;
    padding: 28px; box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.form-section h2 { font-family: var(--font-title); font-size: 1.35rem; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-color); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.form-group input, .form-group textarea {
    width: 100%; padding: 10px 14px; font-family: inherit; font-size: 0.95rem; color: var(--text-color);
    background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: #9ca3af; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--link-color); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-group textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.submit-btn {
    width: 100%; padding: 12px; font-size: 1rem; font-weight: 600; color: #fff; cursor: pointer;
    background: var(--accent); border: 1px solid var(--accent); border-radius: 8px;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.submit-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.submit-btn:active { transform: translateY(0); }
.form-note { margin-top: 10px; text-align: center; font-size: 0.8rem; color: var(--secondary-text); }

/* ---------- info（.container 内直接包含 .sidebar 的布局） ---------- */
.container:has(> .sidebar) { display: flex; align-items: flex-start; justify-content: center; gap: 20px; max-width: 1200px; padding: 20px; }
.container > .sidebar { top: 20px; }

/* ---------- 任务列表：兼容 mistune 2.x（ul.task-list）与 3.x（li.task-list-item） ---------- */
.markdown-body ul:has(> li.task-list-item) { list-style: none; padding-left: 0; }
.markdown-body li.task-list-item { display: flex; align-items: center; margin: 6px 0; line-height: 1.6; }
.markdown-body li.task-list-item input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; width: 20px; height: 20px; flex-shrink: 0;
    border: 2px solid var(--border-color) !important; border-radius: 4px; margin-right: 10px;
    background-color: var(--card-bg) !important; cursor: pointer; position: relative; top: -1px;
    transition: all 0.1s ease; vertical-align: middle; outline: none; pointer-events: auto;
}
.markdown-body li.task-list-item input[type="checkbox"]:checked { background-color: var(--link-color) !important; border-color: var(--link-color) !important; }
.markdown-body li.task-list-item input[type="checkbox"]:checked::after {
    content: '✓'; color: #fff; font-weight: bold; font-size: 14px; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
}

/* ---------- 独立页面响应式 ---------- */
@media (max-width: 1100px) {
    .container:has(> .sidebar) { flex-direction: column; align-items: stretch; padding: 10px; }
    .container > .sidebar { position: static; width: 100%; max-height: none; transform: none; opacity: 1; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
    .container > .content-wrapper { width: 100%; }
}
@media (max-width: 600px) {
    .page-header h1, .hero h1 { font-size: 1.7rem; }
    .section, .form-section { padding: 20px; }
    .contact-grid { grid-template-columns: 1fr; }
    .category-header { padding: 14px 16px; }
    .article-item { padding: 10px 16px; }
}
/* =====================================================================
   v2 新增：页面间距 / 无障碍 / 图片预览 / 代码高亮 / 减少动画
   ===================================================================== */
[hidden] { display: none !important; }

/* 原来写在各页面 <body style="..."> 里的内边距 */
body.with-nav { padding-top: 80px; padding-bottom: 60px; }
body.page-index { padding-top: 100px; padding-bottom: 20px; }

:focus-visible { outline: 2px solid var(--link-color); outline-offset: 2px; }
.search-input:focus-visible { outline: none; }

/* 代码高亮：背景统一用主题变量（配色由 pygments.css 提供） */
.markdown-body pre.highlight { background: var(--bg-color); }

/* 图片预览（原来全部是内联样式） */
.lightbox { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.95); }
.lb-stage { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden; cursor: zoom-in; touch-action: none; }
.lb-stage.zoomed { cursor: grab; }
.lb-stage.panning { cursor: grabbing; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform 0.1s ease-out; user-select: none; -webkit-user-drag: none; }
.lb-img.no-anim { transition: none; }
.lb-btn {
    position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center;
    width: 50px; height: 50px; font-size: 24px; color: #fff; cursor: pointer;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); border-radius: 50%;
}
.lb-btn:hover { background: rgba(255,255,255,0.25); }
.lb-prev { top: 50%; left: 30px; transform: translateY(-50%); }
.lb-next { top: 50%; right: 30px; transform: translateY(-50%); }
.lb-close { top: 20px; right: 30px; width: 44px; height: 44px; font-size: 28px; }
@media (max-width: 600px) { .lb-prev { left: 12px; } .lb-next { right: 12px; } .lb-close { right: 16px; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}