/* ============================================================
   Personal Home · 文章与留言样式（pages/posts.css）
   仅文章列表 / 文章详情 / 留言板加载
   依赖 base.css 的设计令牌与通用组件
   ============================================================ */

/* ---------- 文章列表 ---------- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 8px;
}

.post-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--card-radius);
    box-shadow:
        inset 0 1px 0 var(--glass-hi),
        inset 0 -1px 0 var(--glass-lo),
        var(--card-shadow);
    transition: transform var(--dur-md) var(--ease-out),
                box-shadow var(--dur-md) var(--ease-out),
                background var(--dur-md) var(--ease-out);
}

.post-card-cover {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.post-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.post-card-body { padding: 18px 20px 20px; }

.post-card-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
}

/* 标签：文章列表与标签云共用（此前只在首页定义，文章页会丢失样式） */
.tech-tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--fg-2);
    text-decoration: none;
    background: var(--glass-strong);
    border: 1px solid var(--hairline);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    transition: color var(--dur-sm) var(--ease-out),
                background-color var(--dur-sm) var(--ease-out),
                border-color var(--dur-sm) var(--ease-out);
}

.tech-tag.is-active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: var(--accent);
}

.post-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.post-card-tags .tech-tag {
    padding: 2px 9px;
    font-size: 11.5px;
}

.post-card-title a {
    color: var(--fg);
    text-decoration: none;
}

/* 整卡可点：标题链接用伪元素铺满卡片，点击摘要 / 空白处也能进入详情 */
.post-card-title a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

/* 分类与标签是卡片内的独立链接，抬到遮罩之上保持可点 */
.post-card-cat,
.post-card-tags .tech-tag {
    position: relative;
    z-index: 2;
}

.post-card-summary {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--fg-2);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-meta,
.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--fg-3);
    font-variant-numeric: tabular-nums;
}

/* 元信息逐项不可断行，避免「2026-11-06」被拆成两行 */
.post-meta > a,
.post-meta > time,
.post-meta > span { white-space: nowrap; }

/* ---------- 文章分类：筛选标签与卡片 / 详情页标记 ---------- */
.cat-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
}

.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--hairline);
    background: var(--glass-strong);
    color: var(--fg-2);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    transition: color var(--dur-sm) var(--ease-out),
                background-color var(--dur-sm) var(--ease-out),
                border-color var(--dur-sm) var(--ease-out);
}

.cat-tab span {
    padding: 0 6px;
    border-radius: 999px;
    background: var(--hairline);
    color: var(--fg-3);
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.cat-tab:hover {
    color: var(--fg);
    border-color: var(--accent);
}

.cat-tab.is-active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: var(--accent);
}

.cat-tab.is-active span {
    color: var(--accent);
    background: var(--glass-hi);
}

.post-card-cat {
    display: inline-flex;
    align-self: flex-start;
    margin-bottom: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--hairline);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
    text-decoration: none;
}

.post-category {
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--hairline);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    text-decoration: none;
}

.post-category:hover { border-color: var(--accent); }

@media (max-width: 640px) {
    .cat-tabs { gap: 6px; margin-bottom: 14px; }
    .cat-tab { padding: 8px 12px; }
}

/* ---------- 文章详情：阅读列宽与区块节奏 ---------- */
/* 长文按约 760px 的舒适行长排版，超宽屏不铺满；标题 / 正文 / 评论共用同一列宽 */
.post-page {
    --post-read-width: 768px;
    --post-block-gap: 26px;
}

.post-page .page-head,
.post-page .post-cover,
.post-page .post-toc,
.post-page .post-content,
.post-page .post-nav,
.post-page .related-posts,
.post-page .comments {
    width: 100%;
    max-width: var(--post-read-width);
    margin-inline: auto;
}

.post-meta { margin-top: 10px; }

/* 标题区：长标题与长分类名不撑破列宽 */
.post-page .page-title {
    overflow-wrap: anywhere;
    letter-spacing: -0.01em;
}

.post-page .page-head { margin-bottom: var(--post-block-gap); }

/* 长分类名 / 长标签不撑破列宽 */
.post-page .post-category,
.post-page .tag-cloud .tech-tag {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.post-cover {
    margin: 0 auto var(--post-block-gap);
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-edge);
    background: var(--accent-soft);
}

.post-cover img {
    display: block;
    width: 100%;
    height: auto;
}

/* 长文阅读增强：顶部阅读进度条 */
.read-progress {
    position: fixed;
    inset: 0 0 auto;
    height: 3px;
    z-index: 60;
    pointer-events: none;
}

.read-progress span {
    display: block;
    height: 100%;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: var(--accent);
    transition: transform .12s linear;
}

/* 长文阅读增强：文内目录 */
.post-toc {
    margin-bottom: 22px;
    padding: 16px 20px;
    font-size: 13.5px;
}

.post-toc-title {
    margin: 0 0 8px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--fg-3);
}

.post-toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-toc-item a {
    display: block;
    padding: 3px 0;
    color: var(--fg-2);
    text-decoration: none;
    line-height: 1.6;
    border-radius: 4px;
    overflow-wrap: anywhere;
}

.post-toc-item a:hover { color: var(--accent); }

.post-toc-item.is-h3 { padding-left: 18px; }

.post-toc-item.is-h3 a { color: var(--fg-3); }

/* 长文阅读增强：文末相关阅读（桌面并排，窄屏横向滑动） */
.related-posts { margin: 0 0 26px; }

.related-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--fg);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.related-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    padding: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: var(--fg);
    transition: transform var(--dur-sm, .2s) ease, background-color var(--dur-sm, .2s) ease, border-color var(--dur-sm, .2s) ease;
}

/* 固定比例容器：有无封面都不会引起卡片高度跳动 */
.related-cover {
    display: block;
    flex: none;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 0;
    background: var(--accent-soft);
}

.related-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px 12px;
}

/* 推荐理由弱提示：低对比度小字，不抢标题层级 */
.related-card-reason {
    align-self: flex-start;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    line-height: 1.6;
    white-space: nowrap;
}

.related-card-title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/* 摘要固定一行，高度可预期 */
.related-card-desc {
    font-size: 12px;
    line-height: 1.5;
    color: var(--fg-3);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/* 中等宽度：两列并排，卡片不被压成窄条 */
@media (max-width: 900px) {
    .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 窄屏：改为横向滑动，露出下一张提示可拖，不再退化成竖排长列表 */
@media (max-width: 700px) {
    .related-grid {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-padding-inline-start: 2px;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .related-grid::-webkit-scrollbar { display: none; }

    /* 78% 宽：右侧固定露出下一张的一角作为滑动暗示 */
    .related-card {
        flex: 0 0 78%;
        max-width: 78%;
        scroll-snap-align: start;
    }

    .related-card-title { -webkit-line-clamp: 2; }
}

.post-content {
    padding: clamp(22px, 3.6vw, 40px) clamp(18px, 3.4vw, 40px);
    margin-bottom: var(--post-block-gap);
    font-size: clamp(16px, 1.6vw, 17.5px);
    line-height: 1.88;
    letter-spacing: 0.012em;
    color: var(--fg);
    overflow-wrap: break-word;
    hanging-punctuation: allow-end;
}

/* 补充正文里较少出现但必要的语义元素 */
.post-content hr {
    height: 1px;
    margin: 2em 0;
    border: 0;
    background: var(--hairline);
}

.post-content mark,
.post-content .post-mark {
    padding: 0 3px;
    border-radius: 4px;
    color: inherit;
    background: var(--accent-soft);
}

/* ---------- 图文混排 ---------- */
/* 图文容器：块级居中，与上下段落保持统一间距 */
.post-content .post-figure,
.post-content figure {
    margin: 1.55em 0;
    text-align: center;
}

.post-content .post-figure > .post-figure-link,
.post-content figure > a,
.post-content figure img {
    display: block;
}

/* 点击放大的链接：去掉正文链接的下划线，避免图片下出现横线 */
.post-content .post-figure-link {
    border-bottom: 0;
    text-decoration: none;
    padding: 0;
    cursor: zoom-in;
}

.post-content .post-figure-link.is-inline {
    display: inline-block;
    max-width: 100%;
    vertical-align: middle;
}

/* 正文图片：等比缩放，宽高都有上限，超宽 / 超长图都不撑破布局 */
/* 仅作用于经程序增强过、带 post-image 类的图片，避免影响文内广告素材 */
.post-content img {
    max-width: 100%;
    height: auto;
}

.post-content .post-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 72vh;
    margin: 0 auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-edge);
    background: var(--glass, rgba(127, 127, 127, 0.08));
    object-fit: contain;
}

.post-content .post-figure.is-wide img { max-height: 56vh; }
.post-content .post-figure.is-tall img { max-height: 76vh; }

.post-content .post-figcaption,
.post-content figcaption {
    display: block;
    margin-top: 10px;
    font-size: 12.5px;
    line-height: 1.6;
    text-align: center;
    color: var(--fg-3);
}

/* 图文环绕：给图片加 class="is-float-left / is-float-right" 即可 */
.post-content .post-figure.is-float-left {
    float: left;
    max-width: 46%;
    margin: 0.35em 1.1em 0.9em 0;
}

.post-content .post-figure.is-float-right {
    float: right;
    max-width: 46%;
    margin: 0.35em 0 0.9em 1.1em;
}

.post-content > *:first-child { margin-top: 0; }
.post-content > *:last-child { margin-bottom: 0; }

/* 段落：略大于行高的间距，长文连续阅读时层次更清楚 */
.post-content p,
.post-content ul,
.post-content ol,
.post-content dl,
.post-content blockquote,
.post-content figure { margin: 0 0 1.15em; }

.post-content p {
    text-wrap: pretty;
}

.post-content pre,
.post-content table { margin: 0 0 1.3em; }

.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5 {
    margin: 1.9em 0 0.7em;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.01em;
    scroll-margin-top: 84px;
}

.post-content h2:first-child,
.post-content h3:first-child { margin-top: 0; }

.post-content h2 { font-size: 24px; }
.post-content h3 { font-size: 20px; }
.post-content h4 { font-size: 17.5px; }

.post-content ul,
.post-content ol { padding-left: 1.4em; }

.post-content li { margin-bottom: 0.45em; }
.post-content li > ul,
.post-content li > ol { margin: 0.45em 0 0; }

.post-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-soft);
}

/* 正文图片的尺寸 / 边框规则已在上方「图文混排」区块统一维护 */

.post-content blockquote {
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--fg-2);
    line-height: 1.75;
}

.post-content blockquote > *:last-child { margin-bottom: 0; }

.post-content code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--hairline);
    font-family: var(--font-mono);
    font-size: 0.88em;
}

.post-content pre {
    padding: 16px 18px;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--hairline);
    background: var(--glass-strong);
    -webkit-overflow-scrolling: touch;
}

.post-content pre code {
    padding: 0;
    background: none;
    font-size: 13px;
    line-height: 1.7;
}

.post-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 1.65;
}

.post-content th,
.post-content td {
    padding: 9px 12px;
    border: 1px solid var(--hairline);
    text-align: left;
}

.post-content th { background: var(--hairline); font-weight: 600; }

/* ---------- 上下篇导航 ---------- */
.post-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.post-nav-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 20px;
    text-decoration: none;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.post-nav-item.is-next { text-align: right; align-items: flex-end; }

.post-nav-label {
    font-size: 12.5px;
    color: var(--fg-3);
}

.post-nav-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--fg);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- 评论 / 留言 ---------- */
/* 与正文卡片保持同一列宽和圆角；收掉底部多余留白，避免与页脚间距翻倍 */
.comments {
    padding: clamp(20px, 3.4vw, 32px);
    margin: 4px 0 0;
}

.comments-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.comment {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--hairline);
    background: var(--glass-grad);
}

/* 首字头像：不依赖用户上传，也能让留言更容易辨认 */
.comment-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--hairline);
}

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

.comment.is-reply {
    margin-top: 12px;
    border-left: 3px solid var(--accent-soft);
}

.comment.is-reply .comment-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

/* 留言墙标题：与表单区拉开层级 */
.comment-wall-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 14px;
}

.comment-wall-head .comments-title { margin-bottom: 0; }

.comment-count {
    font-size: 12.5px;
    color: var(--fg-3);
    font-variant-numeric: tabular-nums;
}

.comment-form-hint {
    margin: 6px 0 14px;
    font-size: 13px;
    line-height: 1.65;
    color: var(--fg-3);
}

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

.comment-author {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--fg);
}

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

/* 评论 ↔ 会员身份：注册会员标识 */
.comment-badge {
    align-self: center;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11.5px;
    line-height: 1.6;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--hairline);
    white-space: nowrap;
}

.comment-identity {
    margin: 2px 0 14px;
    font-size: 13.5px;
    color: var(--fg-2);
}

.comment-identity strong { color: var(--fg); font-weight: 600; }

.comment-identity a {
    color: var(--accent);
    text-decoration: none;
    margin-left: 6px;
}

.comment-identity a:hover { text-decoration: underline; }

.comment-time {
    font-size: 12.5px;
    color: var(--fg-3);
}

.comment-body {
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--fg-2);
    overflow-wrap: break-word;
}

.comment-reply {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}

.comment-replies { margin-top: 4px; }

.comment-replying {
    margin: 4px 0 14px;
    font-size: 13.5px;
    color: var(--fg-2);
}

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

.comment-form { margin-top: 8px; }

.comment-form h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

/* 独立留言表单（.glass.comment-form）自带内边距 */
.glass.comment-form { padding: clamp(20px, 3.4vw, 30px); margin-bottom: 30px; }

.glass.comment-form label,
.comment-form label {
    display: block;
    margin: 14px 0 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--fg-2);
}

.glass.comment-form input,
.glass.comment-form textarea,
.comment-form input,
.comment-form textarea {
    width: 100%;
    min-height: var(--touch);
    padding: 11px 14px;
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-sm);
    background: var(--glass-grad);
    color: var(--fg);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

.glass.comment-form textarea,
.comment-form textarea { min-height: 96px; resize: vertical; line-height: 1.7; }

/* 蜜罐字段：移出视口且不可交互，正常用户不可见 */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.glass.comment-form input:focus,
.glass.comment-form textarea:focus,
.comment-form input:focus,
.comment-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 交互增强（指针精细设备）：文章与评论 ---------- */
@media (hover: hover) and (pointer: fine) {
    .post-card:hover {
        transform: translateY(-5px);
        background: var(--glass-grad-hover);
        box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), var(--card-shadow-hover);
    }
    .post-card:hover .post-card-cover img { transform: scale(1.04); }
    .post-card-title a:hover { color: var(--accent); }
    .tech-tag:hover {
        color: var(--accent);
        background: var(--accent-soft);
        border-color: var(--accent);
    }
    .post-nav-item:hover { transform: translateY(-3px); background: var(--glass-grad-hover); }
    .comment-reply:hover,
    .post-content a:hover { color: var(--accent-2); }
    .comment-author a:hover { color: var(--accent-2); }
}

/* ---------- 交互增强（触摸设备）：文章卡片 ---------- */
@media (hover: none) {
    .post-card { touch-action: manipulation; }
    .post-card:active { transform: scale(0.985); }
}

/* ---------- 响应式：上下篇单列 ---------- */
@media (max-width: 760px) {
    .post-nav { grid-template-columns: minmax(0, 1fr); }
    .post-nav-item.is-next { text-align: left; align-items: flex-start; }
}

@media (max-width: 640px) {
    .post-card-body { padding: 16px 16px 18px; }
    .post-card-title { font-size: 17px; }

    /* 标签多时横向滚动，避免把列表页顶得很高 */
    .tag-cloud {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        margin-bottom: 18px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .tag-cloud::-webkit-scrollbar { display: none; }
    .tag-cloud .tech-tag { flex: 0 0 auto; }

    .comment { gap: 10px; padding: 14px 14px; }
    .comment-avatar { width: 32px; height: 32px; font-size: 13px; }
    .comment.is-reply { padding: 12px 12px; }

    /* 移动端单列：图片不环绕、边距收紧，避免竖图占满整屏 */
    .post-content .post-figure { margin: 1.25em 0; }
    .post-content .post-figure.is-float-left,
    .post-content .post-figure.is-float-right {
        float: none;
        max-width: 100%;
        margin: 1.25em auto;
    }
    .post-content .post-image { max-height: 64vh; }
    .post-content .post-figure.is-tall img { max-height: 70vh; }

    /* 详情页：窄屏收边距，标题与元信息按「标题 → 分类 → 时间 → 其他」自然换行 */
    .post-page .page-head,
    .post-page .post-content,
    .post-page .comments { max-width: 100%; }

    .post-page .page-title {
        font-size: clamp(22px, 6.2vw, 28px);
        line-height: 1.28;
    }
    .post-page .page-head { margin-bottom: 20px; }

    .post-meta { gap: 4px 10px; margin-top: 10px; }
    .post-meta > span[aria-hidden="true"] { display: none; }

    .post-content {
        padding: 20px 16px;
        margin-bottom: 20px;
        font-size: 16px;
        line-height: 1.85;
    }

    .post-cover { margin-bottom: 20px; border-radius: var(--radius-md); }
    .post-toc { padding: 14px 16px; margin-bottom: 18px; }
    .post-nav { gap: 12px; margin-bottom: 20px; }
    .post-nav-item { padding: 14px 16px; }
    .related-posts { margin-bottom: 20px; }
    .comments { padding: 18px 16px; }
}

/* 极窄屏：卡片略收窄，保证露出更多下一张，滑动目标更明确 */
@media (max-width: 520px) {
    .related-card { flex-basis: 84%; max-width: 84%; }
    .related-card-body { padding: 9px 11px 11px; }
}

/* ---------- 动效降级：文章与评论 ---------- */
@media (prefers-reduced-motion: reduce) {
    .post-card, .post-nav-item, .related-card { transition: none; }
    .post-card-cover img { transition: none; }
    /* 尊重系统设置：关闭平滑滚动与惯性吸附动画 */
    .related-grid { scroll-behavior: auto; }
}

/* ---------- 返回列表 + 管理员快捷入口（普通访客只渲染返回） ---------- */
/* 返回入口收进文章头部第一行，与标题同处一个视觉区块，不再作为独立段落悬空 */
.post-back { margin: 0; }

.post-back a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 13px;
    border: 1px solid var(--glass-edge);
    border-radius: 999px;
    background: var(--glass);
    color: var(--fg-2);
    font-size: 12.5px;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.post-back a:hover,
.post-back a:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.post-head-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.post-head-bar .post-back { margin-bottom: 0; }

.post-admin {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.post-admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--glass-edge);
    border-radius: 999px;
    background: var(--glass-grad);
    color: var(--fg-2);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.post-admin-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

@media (max-width: 640px) {
    /* 返回入口：移动端放大到 40px 触控高度，留出安全区，不与悬浮导航重叠 */
    .post-back a { min-height: 40px; padding: 0 15px; font-size: 13px; }
    .post-head-bar { align-items: flex-start; margin-bottom: 12px; }
    .post-admin { width: 100%; margin-left: 0; }
    .post-admin-link { flex: 1 1 auto; min-height: 42px; padding: 0 16px; font-size: 13.5px; }
}

/* ---------- 广告位（文章内 / go 位共用展示规则） ---------- */
.ad-slot { margin: 0; }

.ad-slot-list {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.4vw, 14px);
}

/* 整卡可点；min-height 保证超宽图也有 ≥44px 触控热区 */
.ad-slot-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    min-height: 44px;
    max-height: clamp(160px, 30vh, 280px);
    margin-inline: auto;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-edge);
    background: var(--glass-strong);
    touch-action: manipulation;
    transition: border-color 0.2s ease, opacity 0.2s ease;
}

.ad-slot-link:hover { border-color: var(--accent); }
.ad-slot-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 图片按真实比例缩放；竖图/超宽图都不会撑破阅读列 */
.ad-slot-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: clamp(160px, 30vh, 280px);
    object-fit: contain;
}

/* 图片损坏时由 ads.js 隐藏碎图，卡片保留占位底与「广告」标识 */
.ad-slot-link.is-broken { width: 100%; min-height: 56px; }
.ad-slot-link.is-broken .ad-slot-img { visibility: hidden; }

/* 标识浮在图片上：固定深色胶囊 + 白字，深浅模式与任意素材下对比度都稳定 */
.ad-slot-tag {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.6;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    pointer-events: none;
}

/* 文内广告位于 .post-content 内，覆盖正文对 a / img 的通用样式，避免出现下划线或额外外边距 */
.post-content .ad-slot-link {
    color: inherit;
    border: 1px solid var(--glass-edge);
    border-bottom-color: var(--glass-edge);
    text-decoration: none;
}
.post-content .ad-slot-img { margin: 0; }

/* 正文中段广告：上下留白对齐正文段落节奏（1.15em），不额外撑开版面 */
.post-ad {
    margin: 1.15em 0;
}

/* 与紧邻引用/代码块合并间距，避免“广告 + 引用”叠成一大块 */
.post-ad + blockquote,
.post-ad + pre,
.post-ad + figure { margin-top: 0; }

/* 平板 */
@media (max-width: 1024px) {
    .ad-slot-link,
    .ad-slot-img { max-height: clamp(150px, 26vh, 230px); }
}

/* 手机：高度更保守，宽度不越出正文（左右安全区由页面级 body 内边距统一处理） */
@media (max-width: 768px) {
    .ad-slot-link,
    .ad-slot-img { max-height: clamp(140px, 24vh, 200px); }
    .ad-slot-tag { right: 6px; bottom: 6px; }
}