/* =====================================================================
   mxblog-aoaa · 博客前端样式
   设计目标：中文长文阅读友好 + 移动端自适应
   要点：
     - 正文使用宋体系（衬线）字体，字号 18px、行高 1.95、首行缩进 2em
     - 全局留白用 clamp() 做流式缩放，小屏自动收紧
     - 目录在桌面端 sticky 常驻，在移动端变为抽屉
   ===================================================================== */

/* ------------------------------ 设计变量 ------------------------------ */
:root {
    --paper: #f7f4ee;
    --paper-deep: #efe9e0;
    --card: #fffdfa;
    --ink: #23201c;
    --ink-soft: #524c44;
    --ink-mute: #8b8378;
    --line: rgba(35, 32, 28, .10);
    --line-strong: rgba(35, 32, 28, .18);
    --accent: #a4442f;
    --accent-soft: rgba(164, 68, 47, .08);
    --accent-deep: #83341f;
    --gold: #b08d57;

    --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
    --read-font: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC",
    "SimSun", "Times New Roman", Georgia, serif;
    --mono-font: "JetBrains Mono", "Cascadia Code", Consolas, Menlo, Monaco, "Courier New", monospace;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(35, 32, 28, .05), 0 6px 18px -12px rgba(35, 32, 28, .25);
    --shadow-md: 0 2px 6px rgba(35, 32, 28, .06), 0 18px 40px -24px rgba(35, 32, 28, .35);
    --header-h: 60px;
    --shell: 1200px;
}

/* ------------------------------ 基础重置 ------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    /* 让锚点跳转时不被吸顶导航遮挡 */
    scroll-padding-top: calc(var(--header-h) + 18px);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background-color: var(--paper);
    background-image:
            radial-gradient(1200px 600px at 12% -8%, rgba(176, 141, 87, .10), transparent 60%),
            radial-gradient(900px 500px at 92% 4%, rgba(164, 68, 47, .06), transparent 60%);
    background-attachment: fixed;
    color: var(--ink);
    font-family: var(--ui-font);
    font-size: 16px;
    line-height: 1.85;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
}

/*
 * 必须放在所有组件样式之前，并带 !important。
 * 浏览器默认样式表里的 [hidden] { display: none } 优先级最低，
 * 任何写了 display 的组件规则都会把它覆盖掉——例如移动端目录遮罩
 * .toc-scrim { display: block; position: fixed; inset: 0 }，
 * 一旦覆盖就留下一层看不见却铺满全屏的遮罩，移动端所有点击都会被它吃掉。
 */
[hidden] {
    display: none !important;
}

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

a:hover {
    color: var(--accent-deep);
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.shell {
    width: 100%;
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
}

/* ------------------------------ 顶部导航 ------------------------------ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    background: rgba(247, 244, 238, .86);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color .25s ease, box-shadow .25s ease;
}

.site-header.is-stuck {
    border-bottom-color: var(--line);
    box-shadow: 0 8px 24px -22px rgba(35, 32, 28, .6);
}

.header-inner {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--accent), #c9734f);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand-text strong {
    font-size: 15px;
    letter-spacing: .02em;
}

.brand-text em {
    font-style: normal;
    font-size: 12px;
    color: var(--ink-mute);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 253, 250, .7);
    color: var(--ink-soft);
    font-size: 14px;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}

.ghost-btn:hover {
    background: var(--card);
    color: var(--accent);
    border-color: rgba(164, 68, 47, .35);
}

.ghost-btn:active {
    transform: scale(.97);
}

.ghost-btn svg {
    width: 16px;
    height: 16px;
}

.badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}

.toc-toggle {
    display: none;
}

.scroll-progress {
    height: 2px;
    background: transparent;
}

.scroll-progress i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--gold), var(--accent));
    transition: width .12s linear;
}

/* ------------------------------ 文章头部 ------------------------------ */
.hero {
    padding: clamp(36px, 7vw, 84px) 0 clamp(20px, 4vw, 36px);
}

.hero-inner {
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
}

.hero-eyebrow {
    display: inline-block;
    margin: 0 0 18px;
    padding: 4px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--gold);
    font-size: 12.5px;
    letter-spacing: .28em;
    text-indent: .28em;
}

.hero-title {
    margin: 0;
    font-family: var(--read-font);
    font-size: clamp(30px, 6.2vw, 54px);
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1.25;
}

.hero-subtitle {
    margin: 18px auto 0;
    max-width: 34em;
    color: var(--ink-soft);
    font-size: clamp(14.5px, 2.4vw, 17px);
    line-height: 1.9;
}

/*
 * 文章信息（7 项）：作者 / 发布 / 更新 / 章节 / 字数 / 阅读 / 评论。
 *
 * 窄屏处理在文件末尾的响应式区。这里只定义基础（宽屏）形态。
 *
 * 关于 7 项带来的"末行落单"：六项时 3×2 与 2×3 都整齐，加到 7 项后
 * 3 列变成 3+3+1、2 列变成 2+2+2+1。曾考虑把两个日期合并成一项
 * （回到 6 项、网格整齐），实测合并后那一项需 226px，
 * 而窄屏每格最多只有 203px —— 会折行，反而更难看，因此放弃合并。
 * 末行只有 1 项时由 grid 居中，观感可以接受。
 */
.hero-meta {
    margin: 26px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
    list-style: none;
    color: var(--ink-mute);
    font-size: 13.5px;
}

.hero-meta li {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.hero-meta .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gold);
    opacity: .8;
    flex: none;
}

/* 数字用等宽数字，避免阅读量变化时整行轻微跳动 */
.hero-meta time {
    font-variant-numeric: tabular-nums;
    /* 日期是整体语义，绝不能被从中间折断（如 2026-10- / 10） */
    white-space: nowrap;
}

/* ------------------------------ 布局 ------------------------------ */
.layout {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: clamp(24px, 3.4vw, 52px);
    align-items: start;
    padding-bottom: clamp(40px, 7vw, 90px);
}

/* ------------------------------ 目录 ------------------------------ */
.toc {
    position: sticky;
    top: calc(var(--header-h) + 18px);
    align-self: start;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-h) - 40px);
    padding: 18px 6px 14px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 253, 250, .78);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.toc-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 12px 12px 0;
    border-bottom: 1px solid var(--line);
}

/* 目录标题是 h3：正文各章为 h2，这里不该同级 */
.toc-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .18em;
    color: var(--ink-soft);
}

.toc-count {
    font-size: 12px;
    color: var(--ink-mute);
}

/*
 * 目录列表：桌面端是 sticky 侧栏里的滚动区，移动端是抽屉里的滚动区。
 * 这里刻意把「滚动相关」的属性写全，避免在移动端出现"目录划不动"：
 *   - overflow-y: auto            建立滚动容器
 *   - -webkit-overflow-scrolling  让 iOS 用原生惯性滚动
 *     （抽屉祖先带 position:fixed + transform，缺这条时 iOS 经常判定为不可滚动）
 *   - touch-action: pan-y         明确允许纵向拖动，避免被当成页面手势
 *   - overscroll-behavior: contain 划到头不要把整页带着一起滚
 */
.toc-body {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 10px;
    padding-right: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.toc-body::-webkit-scrollbar {
    width: 6px;
}

.toc-body::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 3px;
}

.toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: chapter;
}

.toc-list li {
    margin: 1px 0;
}

.toc-list li a {
    display: block;
    padding: 7px 10px;
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.55;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.toc-list li a:hover {
    background: rgba(176, 141, 87, .10);
    color: var(--ink);
}

.toc-list li.toc-sub a {
    padding-left: 24px;
    font-size: 13px;
    color: var(--ink-mute);
}

.toc-list li a.is-active {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-weight: 600;
}

/*
 * 目录底部的「回到顶部」按钮，是抽屉里的最后一个 flex 项。
 * 它必须写 flex: 0 0 auto：
 * 抽屉给了确定高度（height: 100dvh）且 overflow: hidden，
 * 若允许收缩，浏览器会优先压缩它，按钮就会被挤出可见区域、点不到。
 * 同时给足高度作为触摸目标（移动端 44px 左右最合适）。
 */
.toc-top {
    flex: 0 0 auto;
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    padding: 10px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-top: 1px solid var(--line);
    background: none;
    color: var(--ink-mute);
    font-size: 13.5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .18s ease, background .18s ease;
}

.toc-top:hover {
    color: var(--accent);
}

.toc-top:active {
    color: var(--accent-deep);
    background: var(--accent-soft);
}

.toc-top svg {
    width: 15px;
    height: 15px;
}

.toc-scrim {
    display: none;
}

/* ------------------------------ 文章正文 ------------------------------ */
.article-wrap {
    min-width: 0;
}

.article {
    padding: clamp(22px, 3.4vw, 42px) clamp(18px, 3.6vw, 52px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.article-body {
    max-width: 44em;
    margin: 0 auto;
    font-family: var(--read-font);
    font-size: clamp(16.5px, 1.15vw + 14px, 18.5px);
    line-height: 1.98;
    color: var(--ink);
    letter-spacing: .012em;
    overflow-wrap: break-word;
    word-break: break-word;
}

.article-body > *:first-child {
    margin-top: 0;
}

/* 中文段落：首行缩进两格 */
.article-body p {
    margin: 0 0 1.05em;
    text-indent: 2em;
    text-align: justify;
    text-justify: inter-ideograph;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
    font-family: var(--ui-font);
    font-weight: 700;
    line-height: 1.45;
    color: var(--ink);
    scroll-margin-top: calc(var(--header-h) + 22px);
    text-indent: 0;
}

.article-body h1 {
    margin: 2em 0 1em;
    font-size: 1.6em;
    text-align: center;
}

/* 章节（H2）：左侧色条 + 楷体式标题感 */
.article-body h2 {
    position: relative;
    margin: 2.6em 0 1.2em;
    padding: 0 0 0 18px;
    font-size: 1.34em;
    letter-spacing: .05em;
}

.article-body h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: .18em;
    bottom: .18em;
    width: 4px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--accent), var(--gold));
}

.article-body h2::after {
    content: "";
    display: block;
    margin-top: .5em;
    height: 1px;
    background: linear-gradient(90deg, var(--line-strong), transparent 72%);
}

.article-body h3 {
    margin: 2em 0 .9em;
    padding-left: 14px;
    font-size: 1.16em;
    border-left: 3px solid var(--gold);
}

.article-body h4 {
    margin: 1.7em 0 .8em;
    font-size: 1.06em;
    color: var(--ink-soft);
}

.article-body h5,
.article-body h6 {
    margin: 1.5em 0 .7em;
    font-size: 1em;
    color: var(--ink-soft);
}

.article-body strong {
    font-weight: 700;
    color: #1b1815;
}

.article-body em {
    font-style: italic;
    color: var(--ink-soft);
}

.article-body a {
    color: var(--accent);
    border-bottom: 1px solid rgba(164, 68, 47, .35);
}

.article-body a:hover {
    border-bottom-color: var(--accent);
}

/* 引用：原文中的诗句 / 摘录 */
.article-body blockquote {
    margin: 1.6em 0;
    padding: .9em 1.3em;
    border-left: 3px solid var(--gold);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: rgba(176, 141, 87, .07);
    color: var(--ink-soft);
}

.article-body blockquote p {
    margin: 0 0 .4em;
    text-indent: 0;
    text-align: left;
}

.article-body blockquote p:last-child {
    margin-bottom: 0;
}

.article-body ul,
.article-body ol {
    margin: 1.1em 0;
    padding-left: 1.6em;
}

.article-body li {
    margin: .35em 0;
    text-indent: 0;
}

.article-body li::marker {
    color: var(--gold);
}

.article-body hr {
    margin: 2.4em auto;
    width: 42%;
    border: 0;
    border-top: 1px solid var(--line-strong);
    position: relative;
}

.article-body code {
    padding: .15em .42em;
    border-radius: 5px;
    background: rgba(35, 32, 28, .06);
    font-family: var(--mono-font);
    font-size: .88em;
    color: #8a3a29;
}

.article-body .article-pre {
    margin: 1.5em 0;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #2c2a27;
    color: #ece7df;
    overflow-x: auto;
    font-size: .88em;
    line-height: 1.7;
}

.article-body .article-pre code {
    padding: 0;
    background: none;
    color: inherit;
    font-size: 1em;
}

.article-body .article-table {
    width: 100%;
    margin: 1.5em 0;
    border-collapse: collapse;
    font-family: var(--ui-font);
    font-size: .92em;
    text-indent: 0;
    display: block;
    overflow-x: auto;
}

.article-body .article-table th,
.article-body .article-table td {
    padding: 9px 13px;
    border: 1px solid var(--line);
    text-align: left;
}

.article-body .article-table th {
    background: rgba(176, 141, 87, .10);
    font-weight: 600;
}

.article-body .article-img {
    display: block;
    margin: 1.6em auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

/* 章节之间的小装饰 */
.article-body h2 + p::first-letter {
    color: inherit;
}

/* 文章结尾 */
.article-end {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: clamp(30px, 5vw, 52px) 0 0;
    color: var(--ink-mute);
}

.article-end .end-line {
    flex: 1;
    max-width: 90px;
    height: 1px;
    background: var(--line-strong);
}

.article-end .end-text {
    font-size: 13px;
    letter-spacing: .3em;
    text-indent: .3em;
}

.article-cta {
    margin-top: 24px;
    text-align: center;
}

/* ------------------------------ 按钮 ------------------------------ */
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(140deg, var(--accent), #bf6244);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .04em;
    box-shadow: 0 10px 24px -14px rgba(164, 68, 47, .9);
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -14px rgba(164, 68, 47, .95);
}

.primary-btn:active {
    transform: translateY(0) scale(.99);
}

.primary-btn[disabled] {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.primary-btn svg {
    width: 17px;
    height: 17px;
}

.link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink-mute);
    font-size: 13.5px;
}

.link-btn:hover {
    color: var(--accent);
}

/* ------------------------------ 评论区 ------------------------------ */
.comments {
    margin-top: clamp(28px, 4.6vw, 56px);
    padding: clamp(22px, 3.4vw, 42px) clamp(18px, 3.6vw, 52px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow-sm);
    scroll-margin-top: calc(var(--header-h) + 18px);
}

/* 评论区标题同样是 h3，避免与正文各章抢 h2 */
.comments-head h3 {
    margin: 0;
    font-size: 20px;
    letter-spacing: .1em;
}

.comments-sub {
    margin: 8px 0 0;
    color: var(--ink-mute);
    font-size: 13.5px;
}

.comments-sub b {
    color: var(--accent);
}

.comment-form {
    margin: 22px 0 30px;
    padding: clamp(16px, 2.4vw, 24px);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(247, 244, 238, .6);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field {
    display: block;
    margin-bottom: 14px;
    position: relative;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 600;
}

/* 必填标记（*）用强调色 */
.field-label i {
    color: var(--accent);
    font-style: normal;
}

/*
 * 「选填」标记：它是"可以不填"的说明，不是必填警示，
 * 所以用弱化的灰色与小字号，避免比必填项还抢眼。
 */
.field-label i.is-optional {
    color: var(--ink-mute);
    font-size: 12px;
    font-weight: 400;
}

.field input,
.field textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.7;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.field textarea {
    resize: vertical;
    min-height: 118px;
}

.field input::placeholder,
.field textarea::placeholder {
    color: #b3aca1;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(164, 68, 47, .55);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field.is-invalid input,
.field.is-invalid textarea {
    border-color: #d2554a;
    box-shadow: 0 0 0 3px rgba(210, 85, 74, .12);
}

.field-counter {
    position: absolute;
    right: 10px;
    bottom: 8px;
    color: var(--ink-mute);
    font-size: 12px;
    pointer-events: none;
}

.form-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.reply-hint {
    margin: 0;
    color: var(--ink-mute);
    font-size: 13.5px;
}

.reply-hint b {
    color: var(--accent);
}

.reply-hint button {
    margin-left: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: 13px;
    text-decoration: underline;
}

.form-alert {
    margin: 12px 0 0;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    background: rgba(210, 85, 74, .10);
    color: #a8382c;
    font-size: 13.5px;
}

.form-alert.is-ok {
    background: rgba(90, 140, 90, .12);
    color: #3f6f43;
}

#submitComment.is-loading .btn-text {
    opacity: .75;
}

/* 评论列表 */
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comment {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.comment:last-child {
    border-bottom: 0;
}

.comment-avatar {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(140deg, rgba(176, 141, 87, .9), rgba(164, 68, 47, .85));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    user-select: none;
}

.comment-main {
    flex: 1 1 auto;
    min-width: 0;
}

.comment-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.comment-name {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--ink);
}

/*
 * 「博主」标识。
 * 只有服务端返回 blogger = true 的评论才会显示。
 * 路人不持有管理员会话，因此无法获得这个标识——这正是防冒充的关键：
 * 就算昵称写成「妙霄 」「妙霄\u200B」，没有标识也一眼可疑。
 */
.comment-blogger {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    border-radius: 999px;
    background: linear-gradient(140deg, var(--accent), #c9734f);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    line-height: 1;
    flex: none;
    user-select: none;
}

/* 博主本人登录时，表单顶部提示，避免忘记自己登着后台 */
.blogger-hint {
    margin: 0 0 14px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 13px;
}

/*
 * 「待审」标记。只出现在提交者自己刚发的那条评论上，
 * 用中性色 + 虚线边框，避免看起来像已经公开的身份标识。
 */
.comment-pending {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    border-radius: 999px;
    border: 1px dashed var(--line-strong);
    color: var(--ink-mute);
    font-size: 11px;
    letter-spacing: .06em;
    line-height: 1;
    flex: none;
    user-select: none;
}

/* 待审评论整条淡化，并附一句说明，避免访客误以为已公开 */
.comment.is-pending-self {
    background: rgba(176, 141, 87, .06);
    border-radius: var(--radius-sm);
    padding-left: 10px;
    padding-right: 10px;
    opacity: .85;
}

.comment.is-pending-self .comment-body::after {
    content: "（仅你自己可见，通过审核后其他人才能看到）";
    display: block;
    margin-top: 4px;
    color: var(--ink-mute);
    font-size: 12px;
}

.comment-replyto {
    color: var(--ink-mute);
    font-size: 13px;
}

.comment-replyto::before {
    content: "▸ ";
    color: var(--gold);
}

.comment-time {
    margin-left: auto;
    color: var(--ink-mute);
    font-size: 12.5px;
}

.comment-body {
    margin: 6px 0 0;
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.85;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}

.comment-foot {
    margin-top: 6px;
    display: flex;
    gap: 14px;
}

.comment-replies {
    margin-top: 12px;
    padding: 4px 0 0 14px;
    border-left: 2px solid var(--line);
    display: flex;
    flex-direction: column;
}

.comment-replies .comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.comment-replies .comment:last-child {
    border-bottom: 0;
}

.comment-replies .comment-avatar {
    width: 30px;
    height: 30px;
    font-size: 13px;
}

.comment-empty {
    padding: 26px 0;
    text-align: center;
    color: var(--ink-mute);
    font-size: 14px;
}

.load-more {
    display: block;
    width: 100%;
    margin-top: 18px;
    padding: 11px 0;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-soft);
    font-size: 14px;
    transition: background .18s ease, color .18s ease;
}

.load-more:hover {
    background: rgba(176, 141, 87, .08);
    color: var(--accent);
}

/* ------------------------------ 页脚 ------------------------------ */
.site-footer {
    border-top: 1px solid var(--line);
    background: rgba(239, 233, 224, .6);
}

.footer-inner {
    padding: 26px 0 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--ink-mute);
    font-size: 13px;
}

.footer-inner p {
    margin: 0;
}

/* 版权行：站名 · © 起始年–当前年 */
.footer-copyright {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}

.footer-inner .sep {
    margin: 0 6px;
    color: var(--gold);
}

.footer-copyright .years {
    color: var(--ink-mute);
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}

.footer-links a {
    color: var(--ink-mute);
    border-bottom: 1px solid var(--line-strong);
}

.footer-links a:hover {
    color: var(--accent);
}

/* ---- 备案信息 ----
 * 法定信息，单独占页脚底部一整行并居中；视觉上刻意比版权行更轻，
 * 用 --ink-mute 与更小的字号，避免和上面的博客标题抢注意力。
 * 两个备案分两行：各自都带超链接，挤在一行窄屏会连成一片难以点准。
 */
.footer-records {
    flex-basis: 100%;          /* 父级是 flex + wrap，这里强制换到新的一整行 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 12px;
    font-size: .92em;          /* 相对 .footer-inner 的 13px -> 约 12px */
    line-height: 1.65;
}

.footer-record {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-mute);
    text-align: center;
}

.footer-record:hover {
    color: var(--accent);
}

/* 公安徽标。高度由 CSS 定死，宽高比交给 height:auto，
 * 这样即使原图不是正方形也不会被压变形。
 * vertical-align 与 inline-flex 是给图片加载失败时兜底：
 * 那时 <img> 会退化成行内元素，位置仍然正常。 */
.record-badge {
    height: 15px;
    width: auto;
    vertical-align: middle;
    flex: none;
}

/* ------------------------------ 浮动按钮 ------------------------------ */
.float-actions {
    position: fixed;
    right: clamp(12px, 2.4vw, 26px);
    bottom: clamp(14px, 3vw, 30px);
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.float-btn {
    position: relative;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: rgba(255, 253, 250, .95);
    color: var(--ink-soft);
    box-shadow: var(--shadow-md);
    transition: transform .18s ease, color .18s ease;
}

.float-btn:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

.float-btn svg {
    width: 20px;
    height: 20px;
}

.float-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    box-shadow: 0 2px 6px rgba(164, 68, 47, .5);
}

/* ------------------------------ 响应式 ------------------------------ */

/* 中等屏幕：目录变窄 */
@media (max-width: 1080px) {
    .layout {
        grid-template-columns: 224px minmax(0, 1fr);
    }
}

/*
 * 文章信息改为网格的上界（唯一一处开启网格的地方）。
 *
 * 6 项横排实测总宽约 658px，加上 shell 左右 padding 约需 722px 视口。
 * 若沿用更小的断点（例如 640px），722px 以下会由 flex 自然换行，
 * 排成「4 + 2」这类形态——那正是要避免的。
 * 所以网格起点定在 760px（比所需多留约 38px 作为字体差异的余量），
 * 保证"要么整齐单行，要么整齐网格"。
 */
@media (max-width: 760px) {
    /*
     * 窄屏：6 项改网格，3 列 = 3+3，末行不落单。
     * 为什么不用自然换行：会排成「4 + 2」，两行不等长，不如网格整齐。
     * 用 grid 而非等宽 flex 是为了每列等宽——否则短项（「共 54 章」）与
     * 长项（「2021-06-22 发布」）会左右参差。
     * 圆点保留：在网格里它起"条目分隔"作用，去掉反而分不清。
     */
    .hero-meta {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px 12px;
        font-size: 13px;
    }

    /*
     * 圆点按列左对齐、文字居中：整项居中会让每列圆点随文字长短参差；
     * 固定圆点列宽后，同一列的圆点落在一条竖线上。
     * 圆点列取 8px 而不更大——它会直接从文字可用宽度里扣掉，
     * 太宽会把「2021-06-22 发布」挤到折行。
     */
    .hero-meta li {
        justify-content: flex-start;
        min-width: 0;
    }

    .hero-meta .dot {
        width: 8px;
        flex: none;
    }

    .hero-meta li > span {
        overflow-wrap: anywhere;
        min-width: 0;
        flex: 1 1 auto;
        text-align: center;
    }
}

/* 平板 / 手机：目录改为抽屉，单列布局 */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .toc-toggle {
        display: inline-flex;
    }

    .toc {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 90;
        width: min(84vw, 330px);
        /*
         * 抽屉高度要"确定"：
         *   - height: 100% 让它在 fixed 定位下撑满视口；
         *   - dvh 在移动端跟随地址栏收缩，100vh 作为兜底（老浏览器不认识 dvh 会忽略这行）；
         *   - max-height: none 覆盖桌面端 sticky 侧栏的限高。
         * 只有容器高度确定，里面的 .toc-body 才能真正变成可滚动区域。
         */
        height: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: 0;
        border-right: 1px solid var(--line);
        background: var(--card);
        padding: calc(var(--header-h) + 14px) 10px 18px 18px;
        transform: translateX(-102%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 24px 0 48px -32px rgba(35, 32, 28, .8);
    }

    .toc.is-open {
        transform: translateX(0);
    }

    .toc-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 80;
        background: rgba(35, 32, 28, .42);
        backdrop-filter: blur(2px);
        opacity: 0;
        /*
         * 双重保险：遮罩未打开时绝不接收指针事件。
         * 即便将来有人去掉 hidden 属性或改坏 [hidden] 规则，
         * 也不会再出现「看不见的遮罩吃掉整页点击」这种问题。
         */
        pointer-events: none;
        transition: opacity .28s ease;
    }

    .toc-scrim.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    .toc-list li a {
        padding: 10px 12px;
        font-size: 15px;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15.5px;
    }

    :root {
        --header-h: 56px;
    }

    .brand-text em {
        display: none;
    }

    .header-actions {
        gap: 6px;
    }

    .ghost-btn {
        height: 36px;
        padding: 0 11px;
        font-size: 13px;
    }

    .ghost-btn span {
        display: none;
    }

    .ghost-btn.toc-toggle span {
        display: inline;
    }

    /*
     * 文章头部保持居中：正文卡片虽然铺满屏幕，但标题区居中更稳，
     * 也避免"标题居中、下面信息网格居中，中间却插了一行左对齐"的割裂感。
     * 这里显式写出来是为了标明"这是有意的"，而不是漏掉了对齐。
     */
    .hero,
    .hero-inner {
        text-align: center;
    }

    .article,
    .comments {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        /* 手机端让卡片铺满屏幕，读起来更宽裕 */
        margin-left: calc(-1 * clamp(16px, 4vw, 32px));
        margin-right: calc(-1 * clamp(16px, 4vw, 32px));
    }

    .article-body {
        font-size: 16.5px;
        line-height: 1.95;
    }

    .article-body p {
        text-align: left;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-foot {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .form-foot .primary-btn {
        width: 100%;
    }

    .reply-hint {
        text-align: center;
    }

    .comment-time {
        margin-left: 0;
        width: 100%;
    }

    .float-actions {
        flex-direction: row;
        bottom: 14px;
    }

    /*
     * 页脚在窄屏改为纵向居中。
     * 原来这里是 align-items: flex-start（左对齐），页脚第一个子元素是版权行、
     * 第二个是「管理员登录」——纵向排开后两行各自贴左，右侧留一大片空白；
     * 加上备案行之后更明显（三行挤在左边）。改为居中。
     * 注意：这段必须留在本块内，别再另开一个 @media (max-width:640px) 块——
     * 两个同特异性块会让后写的那份悄悄覆盖这份（备案行当初就是这么被覆盖成左对齐的）。
     */
    .footer-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .footer-records {
        margin-top: 10px;
    }

    .article-cta .primary-btn {
        width: 100%;
    }
}

/*
 * 更窄（≤480px）：3 列时每格文字可用宽度会逼近最长项
 * （「更新 2026-10-10」需约 105px，480px 视口时只剩 124px/格），
 * 因此改为 2 列 3 行，给文字留出余量。
 * （六项横排的宽度测算见 README「文章信息行的顺序与窄屏排版」一节。）
 */
@media (max-width: 480px) {
    .hero-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 10px;
        font-size: 12.5px;
    }

    .hero-meta li {
        gap: 5px;
    }
}

/* 超小屏（≤380px）：正文与标题字号微调 */
@media (max-width: 380px) {
    .article-body {
        font-size: 16px;
    }

    .article-body h2 {
        font-size: 1.22em;
    }
}

/* 深色模式：跟随系统，仍保持纸感 */
@media (prefers-color-scheme: dark) {
    :root {
        --paper: #1b1a18;
        --paper-deep: #141312;
        --card: #232220;
        --ink: #ebe6dd;
        --ink-soft: #c3bcb0;
        --ink-mute: #948d82;
        --line: rgba(235, 230, 221, .12);
        --line-strong: rgba(235, 230, 221, .22);
        --accent: #e08363;
        --accent-soft: rgba(224, 131, 99, .12);
        --accent-deep: #f0a184;
        --gold: #d0ab74;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 18px 40px -24px rgba(0, 0, 0, .8);
    }

    body {
        background-image:
                radial-gradient(1200px 600px at 12% -8%, rgba(208, 171, 116, .07), transparent 60%),
                radial-gradient(900px 500px at 92% 4%, rgba(224, 131, 99, .05), transparent 60%);
    }

    .site-header {
        background: rgba(27, 26, 24, .88);
    }

    .ghost-btn,
    .float-btn,
    .toc {
        background: rgba(35, 34, 32, .92);
    }

    .article-body .article-pre {
        background: #12110f;
        color: #ded8cd;
    }

    .comment-form {
        background: rgba(20, 19, 18, .5);
    }

    .field input,
    .field textarea {
        background: #1b1a18;
        color: var(--ink);
    }

    .site-footer {
        background: rgba(20, 19, 18, .6);
    }
}

/* 打印：只保留正文 */
@media print {
    .site-header,
    .toc,
    .comments,
    .float-actions,
    .site-footer,
    .article-cta,
    .toc-scrim {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .layout {
        display: block;
    }

    .article {
        border: 0;
        box-shadow: none;
        padding: 0;
    }
}

/* 尊重「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
    }
}
