/* Flat Forum - 扁平话题流 · 直角 · 深色单配色 */
:root {
    color-scheme: dark;
    --bg: #0d1117;
    --bg-surface: #161b22;
    --bg-hover: #1c2128;
    --border: #30363d;
    --border-strong: #3a434d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-bg: rgba(88, 166, 255, 0.15);
    --accent-fg: #0d1117;
    --code-bg: #0a0c10;
    --warn: #d29922;
    --warn-bg: rgba(210, 153, 34, 0.12);
    --radius: 0;
    --font: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    /* 顶部导航整体尺寸（已按 1.2 倍放大，改这一个值即可整体缩放） */
    --topbar-h: 62px;
    --topbar-fs: 19px;
}

* { margin: 0; padding: 0; box-sizing: border-box; border-radius: var(--radius); }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    /* 页脚吸底：纵向排列，主体自动撑满剩余高度 */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶部导航 ===== */
#topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 19px;
    padding: 0 24px;
    height: var(--topbar-h);
}
.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 auto;
    min-width: 0;
    color: var(--text);
    font-size: var(--topbar-fs);
    font-weight: 600;
}
.logo:hover { text-decoration: none; }
.logo-img { display: block; width: 29px; height: 29px; flex-shrink: 0; }
.logo-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); }
.icon-btn svg { display: block; width: 19px; height: 19px; }
.menu-toggle { display: none; }

/* 顶栏右侧入口：桌面端常驻一行；窄屏由下方媒体查询收进汉堡抽屉 */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.page-quick {
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    padding: 4px 14px;
    font-size: 16px;
    white-space: nowrap;
}
.page-quick:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    border: 1px solid var(--accent);
    padding: 5px 17px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-primary:hover { text-decoration: none; opacity: 0.9; }
/* 顶栏「首页」按钮：房子图标 + 文字，单独加类避免影响评论/404 的纯文字按钮 */
.btn-home { display: inline-flex; align-items: center; gap: 6px; }
.btn-home svg { display: block; width: 16px; height: 16px; }

/* ===== 顶栏下方：搜索行（单独一行，带搜索按钮）===== */
.search-bar { background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.search-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 24px;
}
.search-form { display: flex; align-items: stretch; gap: 10px; }
.search-form input {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    padding: 8px 14px;
}
.search-form input:focus { border-color: var(--accent); outline: none; }
.search-form input::placeholder { color: var(--text-muted); }
.search-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    background: var(--accent);
    color: var(--accent-fg);
    border: 1px solid var(--accent);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    padding: 0 20px;
    cursor: pointer;
    white-space: nowrap;
}
.search-submit:hover { opacity: 0.9; }
.search-submit svg { display: block; width: 17px; height: 17px; }

/* ===== 面包屑 ===== */
.crumbs-bar { background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.crumbs-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 20px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }
.crumb-sep { margin: 0 6px; color: var(--border-strong); }
.crumb-current { color: var(--text); }

/* ===== 整体布局 ===== */
#layout {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 216px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
    flex: 1 0 auto;
}

/* ===== 左侧分类导航 ===== */
#sidebar { position: sticky; top: 72px; align-self: start; }
.side-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-bottom: none;
}
.side-icon { flex: 0 0 auto; width: 14px; height: 14px; opacity: 0.85; }
.side-title-gap { margin-top: 16px; }
/* 侧栏第一个块不再额外留白，保证与右侧列表顶部对齐 */
#sidebar > .side-title:first-child { margin-top: 0; }
.cat-nav { list-style: none; }
.cat-nav li { border: 1px solid var(--border); border-top: none; }
.cat-nav li:last-child { border-bottom: 1px solid var(--border); }
.cat-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    padding: 8px 10px;
    font-size: 13px;
    background: var(--bg-surface);
}
.cat-nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.cat-nav a.current {
    color: var(--accent);
    background: var(--accent-bg);
    border-left: 2px solid var(--accent);
    padding-left: 8px;
}
.cat-nav em { font-style: normal; font-size: 12px; color: var(--text-muted); }

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: none;
}
.tag-cloud a {
    font-size: 12px;
    padding: 2px 8px;
    color: var(--tag-tone, var(--text-muted));
    background: var(--tag-bg, var(--bg));
    border: 1px solid var(--tag-line, var(--border));
}
.tag-cloud a:hover {
    color: var(--bg);
    background: var(--tag-tone, var(--accent));
    border-color: var(--tag-tone, var(--accent));
    text-decoration: none;
}
.tag-cloud em { font-style: normal; font-size: 11px; margin-left: 4px; opacity: 0.72; }
/* 七彩随机：颜色由模板按标签 slug 哈希分配（同一标签颜色恒定，刷新不跳变） */
.tag-cloud a.tag-t1 { --tag-tone: #ff7b72; --tag-line: rgba(255, 123, 114, 0.45); --tag-bg: rgba(255, 123, 114, 0.12); }
.tag-cloud a.tag-t2 { --tag-tone: #ffa657; --tag-line: rgba(255, 166, 87, 0.45); --tag-bg: rgba(255, 166, 87, 0.12); }
.tag-cloud a.tag-t3 { --tag-tone: #e3b341; --tag-line: rgba(227, 179, 65, 0.45); --tag-bg: rgba(227, 179, 65, 0.12); }
.tag-cloud a.tag-t4 { --tag-tone: #7ee787; --tag-line: rgba(126, 231, 135, 0.45); --tag-bg: rgba(126, 231, 135, 0.12); }
.tag-cloud a.tag-t5 { --tag-tone: #79c0ff; --tag-line: rgba(121, 192, 255, 0.45); --tag-bg: rgba(121, 192, 255, 0.12); }
.tag-cloud a.tag-t6 { --tag-tone: #b69cff; --tag-line: rgba(182, 156, 255, 0.45); --tag-bg: rgba(182, 156, 255, 0.12); }
.tag-cloud a.tag-t7 { --tag-tone: #ff9ec7; --tag-line: rgba(255, 158, 199, 0.45); --tag-bg: rgba(255, 158, 199, 0.12); }

/* ===== 侧栏：联系方式（QQ） ===== */
.contact-card {
    padding: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
.contact-card + .side-title { margin-top: 16px; }
.side-title + .contact-card { border-top: none; }
.contact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: inherit;
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
}
.contact-row + .contact-row { margin-top: 6px; }
.contact-row:hover { border-color: var(--accent); background: var(--bg-hover); }
.contact-face { position: relative; width: 30px; height: 30px; flex-shrink: 0; }
.contact-face-fallback, .contact-face-img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.contact-face-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-fg);
    background: var(--accent);
}
.contact-face-img { display: block; object-fit: cover; border: 1px solid var(--border); }
.contact-info { flex: 1; min-width: 0; }
.contact-info em { display: block; font-style: normal; font-size: 11px; color: var(--text-muted); }
.contact-info b {
    display: block;
    margin-top: 1px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.contact-copy {
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1.5;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    padding: 1px 5px;
}
.contact-row:hover .contact-copy { color: var(--accent); border-color: var(--accent); }
.contact-qr { margin-top: 10px; text-align: center; }
.contact-qr img {
    display: block;
    width: 100%;
    max-width: 148px;
    margin: 0 auto;
    padding: 4px;
    background: #ffffff;
    border: 1px solid var(--border);
}
.contact-qr span { display: block; margin-top: 6px; font-size: 11px; color: var(--text-muted); }

/* ===== 侧栏：图片超链接 ===== */
.side-ads { margin-top: 16px; }
.side-ad { display: block; }
.side-ad + .side-ad { margin-top: 8px; }
.side-ad img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
}
.side-ad:hover img { border-color: var(--accent); }

/* ===== 首页：每日毒鸡汤（只有正文，无标题与日期） ===== */
.soup-card {
    padding: 12px 12px 10px;
    margin-bottom: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
.soup-text { font-size: 13px; line-height: 1.8; color: var(--text); word-break: break-word; }
.soup-text::before { content: "\201C"; color: var(--accent); }
.soup-text::after { content: "\201D"; color: var(--accent); }

/* ===== Banner 图片块区 ===== */
.banner { margin-bottom: 16px; border: 1px solid var(--border); overflow: hidden; }
.banner img { display: block; width: 100%; height: auto; max-height: 200px; object-fit: cover; }

/* ===== 首页图片位（一行最多 5 个，超出换行；每格宽度按图片自身宽度决定） ===== */
.home-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}
.home-gallery-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.home-gallery-item {
    position: relative;
    display: block;
    /* 槽位＝行宽的 1/5，一行最多 5 个；--iw 是图片原始宽度，图片比槽位窄时按图片自身宽度显示 */
    flex: 0 0 auto;
    width: min(var(--iw, calc((100% - 48px) / 5)), calc((100% - 48px) / 5));
    /* --ar 由脚本按图片实际宽高比写入；写入前按正方形占位，避免加载时抖动 */
    aspect-ratio: var(--ar, 1);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    overflow: hidden;
}
.home-gallery-item:hover { border-color: var(--accent); text-decoration: none; }
.home-gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 5px 8px;
    font-size: 12px;
    color: var(--text);
    background: rgba(13, 17, 23, 0.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== 区块标题 ===== */
.block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
.block-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.sticky-block { margin-bottom: 16px; }
.sticky-block .block-head { border-bottom: 1px solid var(--border); }
.sticky-block .topic-list { border-top: none; }

/* ===== 通用列表区块（首页「最新话题」、独立页「全部主题」）===== */
.list-block { margin-bottom: 16px; }
.list-block .block-head { border-bottom: 1px solid var(--border); }
.list-block .topic-list { border-top: none; }
.block-count { flex-shrink: 0; font-size: 12px; color: var(--text-muted); }
.list-more { text-align: center; }
.list-more a {
    display: block;
    padding: 9px 0;
    font-size: 13px;
    color: var(--accent);
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
.list-more a:hover { border-color: var(--accent); text-decoration: none; }
.list-more a.is-loading,
.list-more a.is-done {
    cursor: default;
    color: var(--text-muted);
}
.list-more a.is-loading { border-color: var(--border); }
.list-more a.is-done { border-style: dashed; }

/* ===== 首页底部：友情链接（横跨整页的文字条） ===== */
.home-links-bar {
    flex-shrink: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.home-links-bar + #footer { margin-top: 0; }
.home-links-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 14px;
}
.home-links-label {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.home-links-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 13px;
}
.home-links-list a,
.home-links-list span { color: var(--text-muted); }
.home-links-list a:hover { color: var(--accent); text-decoration: none; }

/* ===== 话题列表（单行） ===== */
.topic-list { border: 1px solid var(--border); }
.topic-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}
.topic-row:last-child { border-bottom: none; }
.topic-row:hover { background: var(--bg-hover); }
.topic-row-sticky { border-left: 2px solid var(--accent); }
.topic-title {
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topic-title:hover { color: var(--accent); text-decoration: none; }
.topic-cat {
    flex-shrink: 0;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 2px 10px;
    font-size: 12px;
}
.topic-date, .topic-views {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.topic-views { min-width: 46px; }
.topic-empty { padding: 40px; text-align: center; color: var(--text-muted); }

/* 徽章 */
.badge {
    flex-shrink: 0;
    font-size: 11px;
    line-height: 1.4;
    padding: 1px 6px;
    border: 1px solid;
}
.badge-sticky { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.badge-featured { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }

/* ===== 分页 ===== */
.pager { margin-top: 16px; text-align: center; }
.page-nav span, .page-nav a {
    display: inline-block;
    padding: 5px 12px;
    margin: 0 3px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 13px;
}
.page-nav a:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.page-nav .current { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ===== 文章页 ===== */
.post-single {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 24px;
}
.post-title { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.post-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 13px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.meta-cat { color: var(--accent); }
.post-content { color: var(--text); word-wrap: break-word; }
.post-content p { margin-bottom: 14px; }
.post-content img { max-width: 100%; }
.post-content ul, .post-content ol { margin: 0 0 14px 22px; }
.post-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    padding: 14px;
    overflow-x: auto;
    font-size: 13px;
    margin-bottom: 14px;
}
.post-content code { font-family: "Consolas", "Courier New", monospace; }
.post-content blockquote {
    border-left: 3px solid var(--border-strong);
    padding: 2px 0 2px 14px;
    margin-bottom: 14px;
    color: var(--text-muted);
}
.post-content table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.post-content th { background: var(--bg-hover); }
.post-content h1, .post-content h2, .post-content h3, .post-content h4 { margin: 20px 0 12px; color: var(--text); }
.post-content a { text-decoration: underline; }
.post-tags { margin-top: 16px; color: var(--text-muted); font-size: 13px; }
.post-tags a { margin-right: 8px; }

/* ===== 全宽独立页（无侧栏 · 无评论） ===== */
#layout.layout-full { grid-template-columns: minmax(0, 1fr); }
.page-full {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 34px 40px 44px;
}
.page-full-head { margin-bottom: 26px; }
.page-full-title {
    font-size: 27px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}
.page-full-title::after {
    content: "";
    display: block;
    width: 52px;
    height: 3px;
    margin-top: 16px;
    background: var(--accent);
}
.page-full-body { font-size: 15px; line-height: 1.85; }
.page-full-body p { margin-bottom: 16px; }
.page-full-body h2 { font-size: 20px; }
.page-full-body h3 { font-size: 17px; }

/* 上一篇/下一篇 */
.post-near {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}
.post-near > div {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 站点统计 / 友链 ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.stat-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 14px 10px;
    text-align: center;
}
.stat-item em { display: block; font-style: normal; font-size: 22px; font-weight: 600; color: var(--accent); }
.stat-item span { font-size: 12px; color: var(--text-muted); }

.link-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.link-card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 14px;
}
.link-card:hover { border-color: var(--accent); text-decoration: none; }
.link-name { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.link-desc { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.link-host { display: block; font-size: 12px; color: var(--accent); margin-top: 6px; }

/* ===== 404 ===== */
.error-404 { text-align: center; padding: 60px 20px; }
.error-404 h1 { font-size: 64px; color: var(--accent); }
.error-404 p { color: var(--text-muted); margin: 10px 0 20px; }
.search-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    padding: 8px 12px;
    font-size: 14px;
    width: 260px;
    margin-right: 8px;
}

/* ===== 评论 ===== */
#comments { margin-top: 16px; }
.comments-title, .respond-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}
.comment-list { list-style: none; }
.comment-list .comment-body {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 14px;
    margin-bottom: 10px;
}
.comment-list .comment-author { color: var(--accent); font-weight: 600; }
.comment-list .comment-meta { color: var(--text-muted); font-size: 12px; margin: 4px 0 8px; }
.comment-list .comment-content { color: var(--text); }
.comment-list .comment-children { margin: 10px 0 0 20px; list-style: none; }
.comment-list .comment-reply { font-size: 12px; }
.respond {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 16px;
}
.comment-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
#comment-form input, #comment-form textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    font-size: 14px;
    width: 100%;
    font-family: var(--font);
}
#comment-form input:focus, #comment-form textarea:focus { border-color: var(--accent); outline: none; }
#comment-form textarea { margin-bottom: 10px; }
.cancel-reply { margin-bottom: 8px; }
.comments-closed { color: var(--text-muted); }

/* ===== 页脚 ===== */
#footer {
    border-top: 1px solid var(--border);
    margin-top: 30px;
    background: var(--bg-surface);
    flex-shrink: 0;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}
.footer-extra { margin-top: 8px; font-size: 12px; line-height: 1.8; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    #layout { grid-template-columns: 1fr; padding: 12px; align-content: start; }
    #sidebar { position: static; }
    /* 窄屏一行 3 个，超出同样换行 */
    .home-gallery { gap: 8px; }
    .home-gallery-row { flex-wrap: wrap; gap: 8px; }
    .home-gallery-item { width: min(var(--iw, calc((100% - 32px) / 3)), calc((100% - 32px) / 3)); }
    .topbar-inner { gap: 10px; padding: 0 14px; }
    .menu-toggle { display: inline-flex; }
    .logo { gap: 7px; font-size: 18px; }
    .logo-img { width: 24px; height: 24px; }

    /* 窄屏：页面入口收进汉堡抽屉，避免顶栏被撑出横向溢出 */
    .topbar-right {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: var(--topbar-h);
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        z-index: 25;
    }
    .topbar-right.open { display: flex; }
    .page-quick { border: 0; border-bottom: 1px solid var(--border); padding: 13px 14px; font-size: 16px; }
    .btn-home { display: flex; justify-content: flex-start; padding: 13px 14px; }

    .search-bar-inner { padding: 8px 12px; }
    .search-form { gap: 8px; }
    .search-form input { font-size: 15px; padding: 7px 10px; }
    .search-submit { font-size: 15px; padding: 0 12px; gap: 5px; }
    .search-submit svg { width: 15px; height: 15px; }

    .crumbs-inner { padding: 8px 12px; }
    .topic-row { flex-wrap: wrap; gap: 6px 10px; padding: 11px 12px; }
    .topic-title { flex: 1 1 100%; white-space: normal; }
    .topic-views { min-width: 0; }
    .comment-fields { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-input { width: 100%; margin: 0 0 8px; }
    .post-single { padding: 16px; }
    .page-full { padding: 20px 16px 26px; }
    .page-full-head { margin-bottom: 18px; }
    .page-full-title { font-size: 21px; }
    .page-full-body { font-size: 14px; }
}

/* ===== 右下角「返回顶端」 ===== */
.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease,
        color .15s ease, border-color .15s ease, background .15s ease;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.back-to-top:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-hover); }
.back-to-top svg { display: block; width: 16px; height: 16px; }

@media (max-width: 768px) {
    .back-to-top { right: 12px; bottom: 12px; width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
    .back-to-top { transition: none; }
}
