/* =========================================================
   Rex - 极简高性能 Hugo 主题
   ========================================================= */

:root {
    --main: #007bff;
    --main-deep: #0069d9;
    --main-weak: rgba(0, 123, 255, .08);
    --text: #333333;
    --gray: #707070;
    --gray-2: #666666;
    --line: #f0f0f0;
    --bg: #f5f6f7;
    --card: #ffffff;
    --tint: #fafbfc;
    --radius: 6px;
    --maxw: 1280px;
}

[data-theme="dark"] {
    --text: #c9d1d9;
    --gray: #7d8690;
    --gray-2: #9aa4ad;
    --line: #1d2025;
    --bg: #0f1215;
    --card: #14181b;
    --tint: #1a1f26;
    --main-weak: rgba(0, 123, 255, .16);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar { background: var(--tint); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--gray); }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; height: 34px; }
.topbar-left { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 0; flex-wrap: nowrap; }
.topbar-left .hi { color: var(--gray-2); margin-right: 4px; }
.topbar-left a, .topbar-right a { position: relative; color: var(--gray); transition: color .2s ease; padding: 0 12px; line-height: 34px; }
.topbar-left a:first-of-type, .topbar-right a:first-of-type { padding-left: 0; }
.topbar-left a:hover, .topbar-right a:hover { color: var(--main); }
.topbar-left a:not(:last-of-type)::after,
.topbar-right a:not(:last-of-type)::after {
    content: ""; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    width: 1px; height: 12px; background: var(--line);
}
.theme-toggle {
    flex: 0 0 auto; width: 36px; height: 36px; border: 1px solid var(--line);
    background: var(--tint); color: var(--gray-2); border-radius: var(--radius);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px; line-height: 1; padding: 0;
}
.theme-toggle:hover { color: var(--main); border-color: var(--main); }

.header-main { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-title { font-size: 22px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand-title:hover { color: var(--main); }
.brand-logo img { height: 32px; width: auto; }

/* 顶栏右侧工具区：菜单 + 搜索图标 */
.header-tools { display: flex; align-items: center; gap: 18px; }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
    padding: 0 12px; line-height: 32px; color: var(--gray-2);
    font-size: 14px; white-space: nowrap; border-radius: 4px;
}
.site-nav a:hover, .site-nav a.current { color: var(--main-deep); background: var(--main-weak); }

/* 二级菜单（桌面：悬停展开） */
.nav-item.has-children { position: relative; display: flex; align-items: center; }
.nav-item.has-children > a { display: inline-flex; align-items: center; gap: 4px; }
.nav-caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid currentColor; }
.nav-sub {
    position: absolute; top: 100%; left: 0; min-width: 168px; margin: 0; padding: 6px 0;
    list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    display: none; z-index: 500;
}
.nav-item.has-children:hover > .nav-sub,
.nav-item.has-children:focus-within > .nav-sub { display: block; }
.nav-sub a { display: block; padding: 8px 16px; line-height: 1.5; color: var(--gray-2); border-radius: 0; white-space: nowrap; }
.nav-sub a:hover, .nav-sub a.current { color: var(--main-deep); background: var(--main-weak); }

/* 汉堡按钮（移动端显示） */
.nav-toggle {
    display: none; flex: 0 0 auto; width: 36px; height: 36px; border: 1px solid var(--line);
    background: var(--tint); color: var(--gray-2); border-radius: var(--radius);
    cursor: pointer; align-items: center; justify-content: center; padding: 0;
}
.nav-toggle:hover { color: var(--main); border-color: var(--main); }

.search-toggle {
    flex: 0 0 auto; width: 36px; height: 36px; border: 1px solid var(--line);
    background: var(--tint); color: var(--gray-2); border-radius: var(--radius);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.search-toggle:hover { color: var(--main); border-color: var(--main); }

/* 面包屑（顶栏第二行） */
.header-breadcrumb { padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--gray); }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.breadcrumb a { color: var(--gray); }
.breadcrumb a:hover { color: var(--main); }
.breadcrumb .sep { color: var(--gray); }
.breadcrumb .cur { color: var(--gray); }

/* 搜索弹层：满宽悬浮在顶栏正下方、跟顶栏同宽无圆角；输入框与按钮融成一条 */
.search-pop {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
    animation: rexSearchPopIn .2s ease;
    z-index: 1;
}
.search-pop[hidden] { display: none; }
.search-pop-form { display: flex; justify-content: center; align-items: stretch; padding: 12px 0; gap: 0; }
.search-pop-input {
    flex: 0 1 640px; min-width: 0; height: 48px;
    border: 1px solid var(--line); border-right: none;
    border-radius: 4px 0 0 4px;
    padding: 0 16px; background: var(--card); color: var(--text); font-size: 14px; outline: none;
    transition: border-color .2s ease;
}
.search-pop-input:focus { border-color: var(--main); }
.search-pop-btn {
    flex: 0 0 auto; height: 48px; width: 80px;
    border: none; border-radius: 0 4px 4px 0;
    background: var(--main); color: #fff; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color .2s ease;
}
.search-pop-btn:hover { background: #0069d9; }

@keyframes rexSearchPopIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- sticky header 滚动收窄（roll-up）---------- */
/* 平滑过渡（含尺寸/变换），因 JS 已加滞回阈值，toggle 不会频繁横跳，故不会呼吸 */
.site-header > .topbar,
.site-header > .header-main,
.site-header > .header-breadcrumb,
.site-header > .search-pop,
.site-header .brand-title,
.site-header .brand-logo img,
.site-header .header-tools,
.site-header .site-nav a,
.site-header .search-toggle {
    transition: max-height .3s ease, padding .3s ease, font-size .3s ease,
                line-height .3s ease, opacity .3s ease, gap .3s ease,
                background-color .3s ease, box-shadow .3s ease, color .3s ease, border-color .3s ease;
}

/* topbar / breadcrumb 收起：用 max-height + opacity 平滑收起，transform-origin 顶部更自然 */
.site-header > .topbar { max-height: 60px; overflow: hidden; opacity: 1; }
.site-header > .header-breadcrumb { max-height: 50px; overflow: hidden; opacity: 1; }

.site-header.is-scrolled { box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.site-header.is-scrolled .topbar { max-height: 0; opacity: 0; padding: 0; border-bottom-color: transparent; }
.site-header.is-scrolled .header-breadcrumb { max-height: 0; opacity: 0; padding: 0; border-top-color: transparent; }
.site-header.is-scrolled .header-main { padding: 10px 16px; }
.site-header.is-scrolled .brand-title { font-size: 19px; }
.site-header.is-scrolled .brand-logo img { height: 26px; width: auto; }
.site-header.is-scrolled .header-tools { gap: 12px; }
.site-header.is-scrolled .site-nav a { line-height: 28px; font-size: 13px; padding: 0 10px; }
.site-header.is-scrolled .search-toggle { width: 30px; height: 30px; }

/* ---------- layout ---------- */
.site-body { min-height: 60vh; }
.content-wrap { display: flex; gap: 30px; align-items: flex-start; padding: 24px 0; }
.content {
    flex: 1; min-width: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 20px 24px;
    overflow: hidden;
}

/* ---------- post list (post-card) ---------- */
.post-card { display: flex; gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.post-card:last-of-type { border-bottom: none; }
.post-card-thumb { flex: 0 0 180px; }
.post-card-thumb img {
    width: 100%; height: 123px; object-fit: cover;
    border-radius: var(--radius); background: var(--tint);
    border: 1px solid var(--line);
}
.post-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.post-card-title { font-size: 18px; line-height: 1.4; margin: 0 0 10px; font-weight: 600; }
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--main); }
.post-card-note {
    color: var(--gray); font-size: 13px; line-height: 1.7; margin: 0 0 12px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-meta { margin-top: auto; font-size: 12px; color: var(--gray); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.post-card-meta .meta-left, .post-card-meta .meta-right { display: flex; flex-wrap: wrap; gap: 12px; }
.post-card-meta a { color: var(--gray); }
.post-card-meta a:hover { color: var(--main); }

.archive-title {
    font-size: 16px; font-weight: 600; color: var(--text);
    padding: 20px 0 12px; margin: 0; border-bottom: 1px solid var(--line);
}
.empty-tip { padding: 40px 20px; text-align: center; color: var(--gray); }

/* ---------- single article ---------- */
.post { padding: 24px 0; }
.post-header { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 20px; }
.post-title { font-size: 24px; font-weight: 700; margin: 0 0 12px; color: var(--text); line-height: 1.4; }
.post-meta { font-size: 13px; color: var(--gray); display: flex; flex-wrap: wrap; gap: 14px; }
.post-meta a { color: var(--gray); }
.post-meta a:hover { color: var(--main); }

/* 更新时间徽章（列表置顶 + 彩色区分发布时间） */
.meta-updated { color: var(--main); }
.post-card-meta .meta-updated::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--main); margin-right: 5px; animation: updpulse 1.6s ease-in-out infinite; }
@keyframes updpulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .3; transform: scale(.75); } }
@media (prefers-reduced-motion: reduce) { .post-card-meta .meta-updated::before { animation: none; } }

.post-content { font-size: 16px; line-height: 1.8; color: var(--text); word-wrap: break-word; overflow-wrap: break-word; }
.post-content img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; display: block; margin: 12px auto; }
/* 正文图片：中等宽度展示，点击灯箱看原图 */
.post-content .post-img { display: block; max-width: 640px; margin: 12px auto; cursor: zoom-in; }
.post-content .post-img img { margin: 0; }
.img-dialog { border: 0; padding: 0; background: transparent; }
.img-dialog::backdrop { background: rgba(0, 0, 0, .75); }
.img-dialog img { max-width: 92vw; max-height: 92vh; width: auto; height: auto; margin: 0; border: 0; }
.post-content a { color: var(--main); }
.post-content a:hover { text-decoration: underline; }
.post-content h2, .post-content h3, .post-content h4 {
    margin: 1.4em 0 .6em; padding-left: 10px; border-left: 4px solid var(--main); line-height: 1.4;
}
.post-content h2 { font-size: 19px; }
.post-content h3 { font-size: 16px; color: var(--gray-2); }
.post-content h4 { font-size: 15px; color: var(--gray-2); }
.post-content p { margin: .8em 0; }
.post-content pre {
    background: var(--tint); padding: 14px; border-radius: 6px; overflow: auto;
    font-size: 13px; line-height: 1.6; border: 1px solid var(--line);
}
.post-content code { background: var(--tint); padding: 2px 5px; border-radius: 3px; font-size: 13px; }
.post-content pre code { background: none; padding: 0; }
.post-content blockquote {
    border-left: 4px solid var(--main); margin: 1em 0; padding: 4px 14px;
    color: var(--gray-2); background: var(--tint);
}

/* ---------- 提示框 alert（后台编辑器一键插入） ---------- */
.alert {
    position: relative; margin: 1.2em 0; padding: 12px 14px 12px 16px;
    border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius);
    background: var(--tint); color: var(--text); font-size: 14px; line-height: 1.8;
}
.post-content .alert > :first-child { margin-top: 0; }
.post-content .alert > :last-child { margin-bottom: 0; }
.alert-tip     { border-left-color: #007bff; background: rgba(0, 123, 255, .06); }
.alert-success { border-left-color: #2e9c4a; background: rgba(46, 156, 74, .07); }
.alert-warning { border-left-color: #e6a23c; background: rgba(230, 162, 60, .08); }
.alert-danger  { border-left-color: #e2554f; background: rgba(226, 85, 79, .07); }

/* ---------- 折叠块 details（长列表收纳，后台编辑器插入） ---------- */
.post-content details { margin: 1.2em 0; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--tint); }
.post-content summary { margin: 0 -14px; padding: 10px 14px; cursor: pointer; font-weight: 500; user-select: none; }
.post-content details[open] summary { border-bottom: 1px solid var(--line); }
.post-content details > :last-child { margin-bottom: 0; }

/* 表格：table-layout:auto 让列宽按内容自适应（避免两列对半分导致短列右侧大片空白）；
   th/td 的 overflow-wrap:anywhere + word-break:break-word 保证长文件名/哈希在格内断行，不撑出容器。 */
.post-content table { width: auto; max-width: 100%; border-collapse: collapse; margin: 1em 0; table-layout: auto; }
.post-content th, .post-content td { border: 1px solid var(--line); padding: 8px 10px; overflow-wrap: anywhere; word-break: break-word; }

.post-tags { margin-top: 24px; font-size: 13px; color: var(--gray); }
.post-tags a {
    display: inline-block; padding: 3px 12px; margin: 0 6px 6px 0;
    background: var(--main-deep); color: #fff; border-radius: 20px; font-size: 12px;
}
.post-tags a:hover { opacity: .85; }

/* ---------- 文章底部免责声明 ---------- */
.post-disclaimer {
    margin-top: 24px; padding: 16px 18px;
    border: 1px solid var(--line); border-left: 4px solid var(--main);
    border-radius: var(--radius); background: var(--tint);
    font-size: 13px; line-height: 1.8; color: var(--gray-2);
}
.post-disclaimer-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--text); }
.post-disclaimer-content p { margin: .4em 0; }
.post-disclaimer-content a { color: var(--main); }
.post-disclaimer-content a:hover { text-decoration: underline; }

.post-nav {
    display: flex; justify-content: space-between; gap: 16px;
    margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px;
}
.post-nav a { color: var(--gray-2); }
.post-nav a:hover { color: var(--main); }
.post-nav .nav-next { text-align: right; }

/* ---------- sidebar ---------- */
.sidebar { flex: 0 0 320px; width: 320px; position: sticky; top: 84px; align-self: flex-start; }
.widget {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; margin-bottom: 20px;
}
.widget-title {
    font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 14px;
    padding-left: 10px; border-left: 4px solid var(--main); line-height: 1.2;
}
.widget-list { margin: 0; padding: 0; }
.widget-list li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.widget-list li:last-child { border-bottom: none; }
.widget-list li a { color: var(--gray-2); }
.widget-list li a:hover { color: var(--main); }
.tag-cloud a {
    display: inline-block; padding: 4px 10px; margin: 0 6px 8px 0;
    background: var(--tint); border-radius: 4px; font-size: 13px; color: var(--gray-2);
}
.tag-cloud a:hover { background: var(--main); color: #fff; }

/* ---------- 文章目录（TOC）---------- */
.widget-toc .toc-list { margin: 0; padding: 0; list-style: none; position: relative; }
/* 左侧总竖线 */
.widget-toc .toc-list::before {
    content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px;
    width: 1px; background: var(--line);
}
.widget-toc .toc-list li { position: relative; padding: 7px 0 7px 24px; }
/* 圆点 */
.widget-toc .toc-list li::before {
    content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--main);
    background: var(--card); box-sizing: border-box; z-index: 1;
}
/* 圆点与竖线之间的连线 */
.widget-toc .toc-list li::after {
    content: ""; position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
    width: 12px; height: 1px; background: var(--line); z-index: 0;
}
.widget-toc .toc-list a { color: var(--gray-2); font-size: 14px; }
.widget-toc .toc-list a:hover { color: var(--main); }
/* 激活态 */
.widget-toc .toc-list li.is-active::before { background: var(--main); }
.widget-toc .toc-list li.is-active::after { background: var(--main); }
.widget-toc .toc-list li.is-active a { color: var(--main); font-weight: 600; }

/* ---------- 热门文章 ---------- */
.hot-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.hot-item { display: flex; gap: 10px; align-items: flex-start; }
.hot-thumb {
    flex: 0 0 100px; width: 100px; height: 68px; border-radius: var(--radius);
    overflow: hidden; background: var(--bg); border: 1px solid var(--line);
}
.hot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hot-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hot-title {
    color: var(--text); font-size: 14px; line-height: 1.45; font-weight: 500;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hot-title:hover { color: var(--main); }
.hot-date { color: var(--gray-2); font-size: 12px; }



/* 文章列表/归档分页：输出 .pagenav */
.pagenav { margin: 24px 0; padding: 0; list-style: none; text-align: center; }
.pagenav li { display: inline-block; margin: 0 4px; }
.pagenav a, .pagenav span {
    display: inline-block; min-width: 34px; padding: 7px 11px;
    border: 1px solid transparent; border-radius: 6px; color: var(--gray-2);
    font-size: 13px; background: var(--tint);
}
.pagenav a:hover { background: var(--tint); color: var(--main); border-color: var(--main); }
.pagenav .current a, .pagenav .current span {
    background: var(--main); color: #fff; border-color: var(--main); font-weight: 500;
}
.pagenav .prev a, .pagenav .next a { min-width: auto; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: 20px; }
.footer-inner { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--gray); }
.footer-inner a { color: var(--gray-2); text-decoration: underline; }
.footer-inner a:hover { color: var(--main); }
.footer-extra { margin-top: 6px; }

/* ---------- back to top ---------- */
.back-top {
    position: fixed; right: 24px; bottom: 30px; width: 42px; height: 42px;
    border-radius: 50%; background: var(--main); color: #fff; border: none; cursor: pointer;
    font-size: 18px; display: none; z-index: 200; box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.back-top.show { display: block; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .content-wrap { flex-direction: column; }
    .content { width: 100%; }
    .sidebar { width: 100%; flex: none; }
    .post-card-thumb { flex: 0 0 140px; }
    .post-card-thumb img { height: 96px; }
}
@media (max-width: 768px) {
    .topbar { display: none; }
    .sidebar { display: none; }
    .nav-toggle { display: inline-flex; order: 1; margin: 0; }
    .header-main { flex-wrap: nowrap; gap: 12px; padding: 12px 16px; }
    .brand { order: 2; flex: 1 1 auto; justify-content: center; }
    .brand-title { font-size: 18px; }
    .header-tools { order: 3; flex: 0 0 auto; gap: 12px; }
    .site-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px; z-index: 500;
    }
    .site-nav.open { display: flex; }
    .site-nav > a, .nav-item.has-children { width: 100%; }
    .site-nav > a { padding: 11px 12px; line-height: 1.5; }
    .nav-item.has-children { flex-direction: column; align-items: stretch; }
    /* 移动端二级菜单内联展开，不再悬停浮层 */
    .nav-sub { position: static; display: block; min-width: 0; border: none; border-radius: 0; padding: 0 0 4px 14px; }
    .nav-sub a { padding: 9px 12px; }
}
@media (max-width: 560px) {
    .post-card { flex-direction: row; align-items: flex-start; gap: 12px; padding: 14px 0; }
    .post-card-thumb { flex: 0 0 112px; width: 112px; }
    .post-card-thumb img { height: 80px; border-radius: var(--radius); }
    .post-card-title { font-size: 13px; font-weight: 600; line-height: 1.45; margin: 0 0 6px;
        display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    .post-card-note { display: none; }
    .post-card-meta { font-size: 12px; gap: 10px; }
    .post-title { font-size: 20px; }
    .post-content { font-size: 15px; line-height: 1.75; }
    .post-nav { flex-direction: column; gap: 8px; }
    .post-nav .nav-next { text-align: left; }
}

/* ---------- 搜索页 ---------- */
.search-page { padding: 20px 0; }
.search-tip { color: var(--gray); font-size: 12px; margin: 4px 0 12px; }
.search-page .widget-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.search-page .search-date { flex: 0 0 auto; color: var(--gray); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- 404 ---------- */
.notfound { padding: 80px 20px; text-align: center; }
.notfound-code { font-size: 72px; font-weight: 700; color: var(--main); line-height: 1; }
.notfound-text { color: var(--gray); margin: 16px 0 24px; }
.notfound-search { display: flex; justify-content: center; gap: 0; margin-bottom: 20px; }
.notfound-search input {
    flex: 0 1 360px; min-width: 0; height: 42px; border: 1px solid var(--line); border-right: none;
    border-radius: 4px 0 0 4px; padding: 0 14px; background: var(--card); color: var(--text); outline: none;
}
.notfound-search input:focus { border-color: var(--main); }
.notfound-search button {
    height: 42px; padding: 0 22px; border: none; border-radius: 0 4px 4px 0;
    background: var(--main); color: #fff; cursor: pointer;
}
.notfound-search button:hover { opacity: .9; }
.notfound-home { display: inline-block; color: var(--gray-2); border: 1px solid var(--line); padding: 8px 22px; border-radius: var(--radius); }
.notfound-home:hover { color: var(--main); border-color: var(--main); }

/* ---------- 阅读进度条（顶部细线，零依赖） ---------- */
.reading-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 999; background: transparent; pointer-events: none; }
.reading-progress > span { display: block; height: 100%; width: 0; background: var(--main); transition: width .1s linear; }

/* ---------- 代码块复制按钮（hover 显现，无 JS 时隐藏） ---------- */
.post-content pre { position: relative; }
.code-copy {
    position: absolute; top: 8px; right: 8px; z-index: 1;
    font-size: 12px; line-height: 1; padding: 4px 8px;
    border: 1px solid var(--line); border-radius: 4px;
    background: var(--card); color: var(--gray-2); cursor: pointer;
    opacity: 0; transition: opacity .2s ease;
}
.post-content pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--main); border-color: var(--main); }

/* ---------- 相关文章推荐 ---------- */
.related-posts { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.related-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.related-item { display: flex; gap: 12px; align-items: flex-start; }
.related-thumb { flex: 0 0 120px; width: 120px; height: 80px; border-radius: var(--radius); overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.related-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.related-title { color: var(--text); font-size: 14px; line-height: 1.45; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.related-title:hover { color: var(--main); }
.related-meta { color: var(--gray-2); font-size: 12px; display: flex; gap: 12px; }
@media (max-width: 560px) {
    .related-list { grid-template-columns: 1fr; }
    .related-thumb { flex-basis: 100px; width: 100px; height: 68px; }
}

/* ---------- 移动端 TOC（文首内联目录） ---------- */
/* 默认隐藏，窄屏显示文首目录并隐藏侧栏 TOC（避免重复） */
.toc-mobile { display: none; }
@media (max-width: 900px) {
    .sidebar .widget-toc { display: none; }
    .toc-mobile {
        display: block; margin: 0 0 20px; padding: 14px 16px;
        background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius);
    }
    .toc-mobile-title {
        font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 10px;
        padding-left: 10px; border-left: 4px solid var(--main);
    }
    .toc-mobile .toc-list { margin: 0; padding: 0; list-style: none; }
    .toc-mobile .toc-list li { padding: 5px 0; }
    .toc-mobile .toc-list a { color: var(--gray-2); font-size: 14px; }
    .toc-mobile .toc-list a:hover { color: var(--main); }
}


/* ---------- 打印样式 ---------- */
@media print {
    .site-header, .sidebar, .reading-progress, .back-top,
    .post-nav, .related-posts, #comments .respond,
    .search-pop, .theme-toggle, .search-toggle, .header-breadcrumb {
        display: none !important;
    }
    html, body { background: #fff !important; color: #000 !important; }
    .content-wrap { display: block; }
    .content { border: none; box-shadow: none; padding: 0; }
    .post-content { font-size: 12pt; line-height: 1.6; }
    .post-content img { max-width: 100%; page-break-inside: avoid; }
    .post-content a { color: #000; text-decoration: underline; }
    .post-content a[href]::after {
        content: " (" attr(href) ")"; font-size: 10pt; color: #555; word-break: break-all;
    }
    .post-tags { display: none; }
}
