/* ===== 主题变量 ===== */
:root {
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-header: #ffffff;
    --bg-footer: #ffffff;
    --bg-input: #ffffff;
    --bg-tag: #eff6ff;
    --bg-tag-hover: #dbeafe;
    --bg-badge-top: #fef3c7;
    --bg-blockquote: #f8f9ff;
    --bg-code-inline: #f1f5f9;
    --bg-code-block: #1e293b;
    --bg-table-head: #f8fafc;
    --bg-filter: #f3f4f6;
    --bg-pagination: #ffffff;
    --bg-archive-border: #e5e7eb;

    --text-primary: #111111;
    --text-body: #333333;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --text-code: #e11d48;
    --text-code-block: #e2e8f0;
    --text-badge-top: #92400e;
    --text-blockquote: #4b5563;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: rgba(37,99,235,0.1);

    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --border-input: #d1d5db;

    --shadow: rgba(0,0,0,0.06);
    --shadow-hover: rgba(0,0,0,0.1);
    --shadow-header: rgba(0,0,0,0.05);

    --nav-text: #374151;
    --toggle-bg: #e5e7eb;
    --toggle-icon: #f59e0b;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #253349;
    --bg-header: #1e293b;
    --bg-footer: #1e293b;
    --bg-input: #334155;
    --bg-tag: #1e3a5f;
    --bg-tag-hover: #1e4d7a;
    --bg-badge-top: #78350f;
    --bg-blockquote: #1e293b;
    --bg-code-inline: #334155;
    --bg-code-block: #0f172a;
    --bg-table-head: #334155;
    --bg-filter: #334155;
    --bg-pagination: #1e293b;
    --bg-archive-border: #334155;

    --text-primary: #f1f5f9;
    --text-body: #cbd5e1;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-faint: #475569;
    --text-code: #fb7185;
    --text-code-block: #e2e8f0;
    --text-badge-top: #fbbf24;
    --text-blockquote: #94a3b8;

    --accent: #60a5fa;
    --accent-hover: #93bbfd;
    --accent-light: rgba(96,165,250,0.15);

    --border: #334155;
    --border-light: #1e293b;
    --border-input: #475569;

    --shadow: rgba(0,0,0,0.2);
    --shadow-hover: rgba(0,0,0,0.35);
    --shadow-header: rgba(0,0,0,0.2);

    --nav-text: #cbd5e1;
    --toggle-bg: #475569;
    --toggle-icon: #60a5fa;
}

/* 基础重置 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    line-height: 1.7;
    color: var(--text-body);
    background: var(--bg);
    transition: background 0.3s, color 0.3s;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* 主题切换按钮 */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--toggle-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.3s, transform 0.3s;
    z-index: 101;
}
.theme-toggle:hover { transform: scale(1.1); }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }
:root .theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }

/* 头部 */
.site-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px var(--shadow-header);
    transition: background 0.3s, border-color 0.3s;
}

.site-title { font-size: 1.5rem; margin-bottom: 4px; }
.site-title a { color: var(--text-primary); }
.site-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px; }

.main-nav { display: flex; gap: 20px; margin-bottom: 12px; }
.main-nav a {
    color: var(--nav-text);
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover { border-bottom-color: var(--accent); color: var(--accent); }
.main-nav .nav-rss { font-size: 1.2rem; line-height: 1; }

.search-form { display: flex; gap: 8px; }
.search-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    background: var(--bg-input);
    color: var(--text-body);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.search-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.search-form input::placeholder { color: var(--text-faint); }
.search-form button {
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.search-form button:hover { background: var(--accent-hover); }

/* 主布局 */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 40px;
}

/* 文章卡片 */
.post-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px var(--shadow);
    position: relative;
    transition: box-shadow 0.2s, background 0.3s;
}
.post-card:hover { box-shadow: 0 4px 12px var(--shadow-hover); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.badge.top { background: var(--bg-badge-top); color: var(--text-badge-top); }

.post-cover img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; }

.post-title { font-size: 1.3rem; margin-bottom: 8px; }
.post-title a { color: var(--text-primary); }
.post-title a:hover { color: var(--accent); }

.post-meta {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.post-meta .category { color: var(--accent); }

.post-summary { color: var(--text-secondary); margin-bottom: 12px; }

.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--bg-tag);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.8rem;
}
.tag:hover { background: var(--bg-tag-hover); }

.read-more { font-size: 0.9rem; font-weight: 500; }

/* 分页 */
.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
}
.pagination a, .pagination .current {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}
.pagination a { background: var(--bg-pagination); border: 1px solid var(--border-input); color: var(--nav-text); }
.pagination a:hover { background: var(--bg-filter); border-color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border: 1px solid var(--accent); }

/* 侧边栏 */
.sidebar { display: flex; flex-direction: column; gap: 20px; }

.widget {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px var(--shadow);
    transition: background 0.3s;
}
.widget-title {
    font-size: 1rem;
    color: var(--text-primary);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 12px;
}

.post-list { list-style: none; }
.post-list li { padding: 6px 0; font-size: 0.9rem; border-bottom: 1px dashed var(--border-light); }
.post-list li:last-child { border-bottom: none; }
.post-list .views, .post-list .count { color: var(--text-faint); font-size: 0.8rem; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

/* 文章详情 */
.post-detail {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 32px;
    box-shadow: 0 1px 3px var(--shadow);
    transition: background 0.3s;
}

.post-detail .post-title { font-size: 1.8rem; margin-bottom: 12px; }
.post-detail .post-meta { margin-bottom: 16px; }

.post-cover-detail img { width: 100%; max-height: 400px; object-fit: cover; border-radius: 8px; margin-bottom: 20px; }

.post-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-body);
}
.post-content p { margin-bottom: 1em; }
.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
    margin-top: 1.5em; margin-bottom: 0.5em; font-weight: 600; color: var(--text-primary);
}
.post-content h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.post-content h3 { font-size: 1.2rem; }
.post-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 12px 0; }
.post-content a { color: var(--accent); text-decoration: underline; }
.post-content blockquote {
    border-left: 4px solid #667eea; padding: 12px 20px;
    background: var(--bg-blockquote); margin: 16px 0; color: var(--text-blockquote);
    border-radius: 0 8px 8px 0;
}
.post-content pre {
    background: var(--bg-code-block); color: var(--text-code-block); padding: 16px 20px;
    border-radius: 8px; overflow-x: auto; margin: 16px 0;
    font-size: 0.9rem; line-height: 1.6;
}
.post-content code {
    background: var(--bg-code-inline); padding: 2px 6px; border-radius: 4px;
    font-size: 0.9em; color: var(--text-code);
}
.post-content pre code { background: none; padding: 0; color: inherit; }
.post-content table {
    width: 100%; border-collapse: collapse; margin: 16px 0;
}
.post-content th, .post-content td {
    border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.post-content th { background: var(--bg-table-head); font-weight: 600; color: var(--text-primary); }
.post-content ul, .post-content ol { margin: 12px 0; padding-left: 24px; }
.post-content li { margin-bottom: 4px; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.post-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    gap: 20px;
}
.post-nav a { font-size: 0.9rem; max-width: 45%; }

/* 评论区 */
.comments-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 24px;
    margin-top: 20px;
    box-shadow: 0 1px 3px var(--shadow);
    transition: background 0.3s;
}
.comments-section h3 { color: var(--text-primary); margin-bottom: 16px; }

.comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.comment-header { display: flex; gap: 12px; margin-bottom: 6px; }
.comment-header .date { color: var(--text-faint); font-size: 0.85rem; }

.comment-form { margin-top: 20px; }
.comment-form h4 { color: var(--text-primary); margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row input { flex: 1; }

.comment-form input, .comment-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-body);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.comment-form input:focus, .comment-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.btn {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-top: 8px;
}
.btn:hover { background: var(--accent-hover); }

/* 归档 */
.archive-group { margin-bottom: 24px; }
.archive-date { font-size: 1.1rem; color: var(--nav-text); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.archive-group ul { list-style: none; }
.archive-group li { padding: 6px 0; display: flex; gap: 12px; }
.archive-group .date { color: var(--text-faint); min-width: 50px; }

/* 页脚 */
.site-footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-faint);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--bg-footer);
    transition: background 0.3s, border-color 0.3s;
}

.friend-links {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.friend-links-label {
    color: var(--text-muted);
    font-weight: 500;
}
.friend-links a {
    color: var(--text-muted);
    margin: 0 8px;
    font-size: 0.85rem;
}
.friend-links a:hover { color: var(--accent); }

.footer-info p { margin-bottom: 6px; }
.footer-version {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-bottom: 8px !important;
}

.footer-filing {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 6px;
}
.footer-filing a {
    color: var(--text-faint);
    font-size: 0.8rem;
}
.footer-filing a:hover { color: var(--accent); }

.footer-code { margin-top: 8px; }

.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 1.4rem; color: var(--text-primary); }

.empty-state { text-align: center; padding: 40px; color: var(--text-faint); }
.no-comments { color: var(--text-faint); }

/* 文件下载页 */
.file-filter {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
}
.filter-btn {
    padding: 6px 16px; border-radius: 20px; font-size: 0.85rem;
    background: var(--bg-filter); color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
}
.filter-btn.active, .filter-btn:hover {
    background: var(--accent); color: #fff;
}

.file-card {
    display: flex; align-items: center; gap: 16px;
    background: var(--bg-card); border-radius: 10px; padding: 16px 20px;
    margin-bottom: 12px; box-shadow: 0 1px 3px var(--shadow);
    transition: box-shadow 0.2s, background 0.3s;
}
.file-card:hover { box-shadow: 0 4px 12px var(--shadow-hover); }

.file-icon { font-size: 2rem; min-width: 48px; text-align: center; }
.file-info { flex: 1; min-width: 0; }
.file-name {
    font-size: 0.95rem; margin-bottom: 4px; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; }
.file-meta { display: flex; gap: 12px; font-size: 0.8rem; color: var(--text-faint); }

.btn-download {
    padding: 8px 20px; border-radius: 6px; font-size: 0.85rem;
    background: var(--accent); color: #fff; font-weight: 500; white-space: nowrap;
}
.btn-download:hover { background: var(--accent-hover); color: #fff; }

/* 响应式 */
@media (max-width: 768px) {
    .main-layout { grid-template-columns: 1fr; }
    .post-detail { padding: 20px; }
    .form-row { flex-direction: column; }
    .post-nav { flex-direction: column; }
    .post-nav a { max-width: 100%; }
    .theme-toggle { top: 14px; right: 14px; width: 36px; height: 36px; font-size: 1rem; }
    .post-body-wrapper { grid-template-columns: 1fr; }
    .post-toc { display: none; }
}

/* 阅读时间 */
.reading-time { color: var(--text-faint); font-size: 0.82rem; }

/* 文章目录 TOC */
.post-body-wrapper {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 30px;
}
.post-content {
    min-width: 0;
    order: -1;
}
.post-toc {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-left: 2px solid var(--border);
    padding-left: 12px;
    align-self: start;
}
.post-toc h4 {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.post-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.post-toc li {
    margin-bottom: 6px;
    line-height: 1.4;
}
.post-toc .toc-level-3 {
    padding-left: 12px;
    font-size: 0.78rem;
}
.post-toc a {
    color: var(--text-muted);
    transition: color 0.2s;
}
.post-toc a:hover { color: var(--accent); }

/* 评论楼层回复 */
.comment .reply-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2px 10px;
    cursor: pointer;
    margin-top: 4px;
    transition: border-color 0.2s, color 0.2s;
}
.comment .reply-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.comment.reply {
    margin-left: 24px;
    margin-top: 8px;
    padding: 10px 14px;
    background: var(--bg-filter);
    border-radius: 8px;
    border: none;
}
.reply-to {
    font-size: 0.8rem;
    color: var(--text-faint);
    margin-left: 8px;
}
.reply-form {
    margin-top: 8px;
    padding: 12px 14px;
    background: var(--bg-filter);
    border-radius: 8px;
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
    z-index: 99;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* 面包屑导航 */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-faint);
    margin-bottom: 16px;
}
.breadcrumb a {
    color: var(--text-muted);
    transition: color 0.2s;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-faint); }
.breadcrumb .current { color: var(--text-secondary); }

/* 社交分享按钮 */
.share-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.share-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.share-btn {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #fff;
    transition: opacity 0.2s;
}
.share-btn:hover { opacity: 0.85; color: #fff; }
.share-btn.weibo { background: #e6162d; }
.share-btn.qq { background: #12b7f5; }
.share-btn.copy { background: var(--text-muted); }

/* 文章附件下载栏 */
.post-attachments {
    margin: 28px 0;
    padding: 20px;
    background: var(--bg-card, var(--bg-main));
    border: 1px solid var(--border);
    border-radius: 10px;
}
.attachments-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--text-title);
}
.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-main, #fff);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.2s;
}
.attachment-item:hover {
    border-color: var(--accent);
}
.attachment-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.attachment-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-title);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--text-faint);
}
.attachment-size,
.attachment-count {
    white-space: nowrap;
}
.attachment-download-btn {
    display: inline-block;
    padding: 5px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.attachment-download-btn:hover {
    opacity: 0.85;
    color: #fff;
}
@media (max-width: 600px) {
    .attachment-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .attachment-meta {
        width: 100%;
        justify-content: space-between;
    }
}

/* 错误页面 */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
    color: var(--text-body);
}
.error-code {
    font-size: 8rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 16px;
    opacity: 0.8;
}
.error-page h1 {
    font-size: 1.6rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.error-page p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 1rem;
}
.error-page .btn {
    margin-top: 0;
}
