/* ==========================================================================
   站点主题变量：明暗两套，通过 <html data-theme> 切换
   ========================================================================== */
:root {
    --bg: #ffffff;
    --bg-soft: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #1f2328;
    --text-muted: #6b7280;
    --text-faint: #9aa1ae;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: rgba(99, 102, 241, .12);
    --accent-contrast: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
    --radius: 14px;
    --radius-sm: 10px;
    --content-width: 760px;
    --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
    /* 代码高亮 token */
    --code-bg: #f6f8fa;
    --code-border: #e5e7eb;
    --tok-comment: #8b949e;
    --tok-keyword: #cf222e;
    --tok-string: #0a3069;
    --tok-number: #0550ae;
    --tok-function: #8250df;
    --tok-type: #953800;
    --tok-punct: #6e7781;
}

[data-theme="dark"] {
    --bg: #0f1116;
    --bg-soft: #14171d;
    --surface: #171a21;
    --surface-2: #1c2029;
    --border: #272b34;
    --border-strong: #363b46;
    --text: #e6e8ee;
    --text-muted: #9aa1ae;
    --text-faint: #6b7280;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: rgba(129, 140, 248, .16);
    --accent-contrast: #0f1116;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
    --code-bg: #151922;
    --code-border: #262b35;
    --tok-comment: #7d8590;
    --tok-keyword: #ff7b72;
    --tok-string: #a5d6ff;
    --tok-number: #79c0ff;
    --tok-function: #d2a8ff;
    --tok-type: #ffa657;
    --tok-punct: #8b949e;
}

/* ==========================================================================
   基础
   ========================================================================== */
* {
    box-sizing: border-box;
}

html {
    position: relative;
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color .2s ease, color .2s ease;
}

::selection {
    background: var(--accent-soft);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

    a:hover {
        color: var(--accent-hover);
    }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem var(--accent-soft);
}

/* ==========================================================================
   布局骨架
   ========================================================================== */
.site-main {
    flex: 1 0 auto;
    width: 100%;
}

.container-narrow {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 20px;
}

.container-wide {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================================
   顶部导航
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 60px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    letter-spacing: .2px;
}

    .brand:hover {
        color: var(--accent);
    }

.brand-mark {
    display: block;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #22d3ee);
    /* 图形用 currentColor 填充，这里给白色即可；圆底是恒定深色渐变，不随主题反色 */
    color: #fff;
    transition: transform .18s ease;
}

.brand:hover .brand-mark {
    transform: rotate(24deg);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-link {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    transition: color .16s ease, background-color .16s ease;
}

    .nav-link:hover {
        color: var(--text);
        background: var(--bg-soft);
    }

    .nav-link.active {
        color: var(--accent);
        background: var(--accent-soft);
        font-weight: 600;
    }

.nav-spacer {
    flex: 1;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 移动端汉堡按钮 */
.nav-toggle {
    display: none;
    width: 38px;
    height: 38px;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    transition: all .16s ease;
}

    .nav-toggle:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: var(--accent-soft);
    }

/* 图标按钮 */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    transition: all .16s ease;
}

    .icon-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: var(--accent-soft);
        transform: translateY(-1px);
    }

/* ==========================================================================
   首页 Hero
   ========================================================================== */
.hero {
    padding: 56px 0 32px;
}

.hero-title {
    margin: 0 0 10px;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -.5px;
    line-height: 1.3;
}

.hero-desc {
    margin: 0;
    color: var(--text-muted);
    font-size: 17px;
}

/* hero 不渲染时（站名/描述都留空）用于撑出顶部间距，避免内容贴住导航栏 */
.content-top {
    padding-top: 36px;
}

/* ==========================================================================
   文章卡片列表
   ========================================================================== */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0 0 40px;
    padding: 0;
    list-style: none;
}

.post-card {
    position: relative;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .18s ease;
}

    .post-card:hover {
        border-color: var(--accent);
    }

/* 整张卡片可点开：真正的可点区域是盖满卡片的 .post-card-link 透明层，
   这样正文里的链接、图片按钮仍然能点（链接按 z-index 抬到浮层之上）。
   用 .post-card-linked 限定，避免后台/其它复用 post-card 的地方被动生效 */
.post-card-linked {
    cursor: pointer;
}

.post-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

    /* 键盘 Tab 聚焦时给个明显轮廓，纯鼠标操作看不出来也没关系 */
    .post-card-link:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: -2px;
    }

.post-card-linked a:not(.post-card-link),
.post-card-linked button,
.post-card-linked .note-grid img {
    position: relative;
    z-index: 2;
}

.post-card-title {
    margin: 0 0 8px;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.4;
}

    .post-card-title a {
        color: var(--text);
    }

        .post-card-title a:hover {
            color: var(--accent);
        }

.post-card-summary {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.75;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    color: var(--text-faint);
    font-size: 13.5px;
}

.meta-dot::before {
    content: "·";
    margin-right: 12px;
}

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 600;
}

/* 状态徽章 */
.badge-status {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
}

.badge-draft {
    background: rgba(217, 119, 6, .14);
    color: var(--warning);
}

.badge-public {
    background: rgba(22, 163, 74, .14);
    color: var(--success);
}

.badge-circle {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-pin {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-pending {
    background: rgba(217, 119, 6, .14);
    color: var(--warning);
}

.badge-approved {
    background: rgba(22, 163, 74, .14);
    color: var(--success);
}

.badge-rejected {
    background: rgba(220, 38, 38, .14);
    color: var(--danger);
}

/* 空状态 */
.empty-state {
    padding: 64px 20px;
    text-align: center;
    color: var(--text-faint);
}

    .empty-state .empty-icon {
        font-size: 44px;
        display: block;
        margin-bottom: 12px;
        opacity: .5;
    }

/* ==========================================================================
   文章详情
   ========================================================================== */
.article {
    padding: 40px 0 20px;
}

.article-header {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.article-title {
    margin: 0 0 14px;
    font-size: 32px;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: -.4px;
}

.article-cover {
    width: 100%;
    max-height: 380px;
    object-fit: cover;
    border-radius: var(--radius);
    margin: 24px 0 0;
}

/* 阅读进度条 */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--accent), #22d3ee);
    transition: width .1s linear;
}

/* ==========================================================================
   Markdown 正文排版
   ========================================================================== */
.post-body {
    font-size: 16.5px;
    line-height: 1.85;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

    .post-body > *:first-child {
        margin-top: 0;
    }

    .post-body h1, .post-body h2, .post-body h3, .post-body h4 {
        margin: 1.9em 0 .8em;
        font-weight: 700;
        line-height: 1.4;
        scroll-margin-top: 80px;
    }

    .post-body h1 {
        font-size: 27px;
    }

    .post-body h2 {
        font-size: 23px;
        padding-bottom: .3em;
        border-bottom: 1px solid var(--border);
    }

    .post-body h3 {
        font-size: 19.5px;
    }

    .post-body h4 {
        font-size: 17px;
    }

    .post-body p {
        margin: 0 0 1.15em;
        text-align: justify;
        text-justify: inter-ideograph;
    }

    .post-body a {
        text-decoration: underline;
        text-underline-offset: 3px;
    }

    .post-body ul, .post-body ol {
        margin: 0 0 1.15em;
        padding-left: 1.6em;
    }

    .post-body li {
        margin: .35em 0;
    }

    .post-body blockquote {
        margin: 1.3em 0;
        padding: 2px 18px;
        border-left: 3px solid var(--accent);
        background: var(--accent-soft);
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
        color: var(--text-muted);
    }

        .post-body blockquote p:last-child {
            margin-bottom: 0;
        }

    .post-body img {
        max-width: 100%;
        height: auto;
        border-radius: var(--radius-sm);
        margin: .6em 0;
        cursor: zoom-in;
    }

    .post-body hr {
        margin: 2.4em 0;
        border: 0;
        border-top: 1px solid var(--border);
    }

    .post-body table {
        display: block;
        width: 100%;
        overflow-x: auto;
        border-collapse: collapse;
        margin: 1.3em 0;
        font-size: 15px;
    }

    .post-body th, .post-body td {
        padding: 9px 13px;
        border: 1px solid var(--border);
    }

    .post-body th {
        background: var(--bg-soft);
        font-weight: 600;
    }

    .post-body code {
        padding: .18em .4em;
        border-radius: 5px;
        background: var(--code-bg);
        border: 1px solid var(--code-border);
        font-family: var(--font-mono);
        font-size: .88em;
    }

    .post-body pre {
        position: relative;
        margin: 1.4em 0;
        padding: 16px 18px;
        overflow-x: auto;
        border: 1px solid var(--code-border);
        border-radius: var(--radius-sm);
        background: var(--code-bg);
        line-height: 1.65;
    }

        .post-body pre code {
            padding: 0;
            border: 0;
            background: none;
            font-size: 14px;
        }

    /* 复制代码按钮 */
    .code-copy {
        position: absolute;
        top: 8px;
        right: 8px;
        padding: 3px 9px;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: var(--surface);
        color: var(--text-faint);
        font-size: 12px;
        cursor: pointer;
        opacity: 0;
        transition: opacity .15s ease, color .15s ease;
    }

    .post-body pre:hover .code-copy {
        opacity: 1;
    }

    .code-copy:hover {
        color: var(--accent);
        border-color: var(--accent);
    }

/* ==========================================================================
   Prism 代码高亮 token 配色
   ========================================================================== */
.token.comment, .token.prolog, .token.doctype, .token.cdata {
    color: var(--tok-comment);
}

.token.punctuation {
    color: var(--tok-punct);
}

.token.tag, .token.keyword, .token.selector, .token.constant, .token.symbol, .token.deleted {
    color: var(--tok-keyword);
}

.token.attr-name, .token.function, .token.class-name {
    color: var(--tok-function);
}

.token.attr-value, .token.string, .token.char, .token.inserted {
    color: var(--tok-string);
}

.token.number, .token.boolean {
    color: var(--tok-number);
}

.token.property, .token.variable, .token.operator, .token.entity, .token.url {
    color: var(--tok-type);
}

/* ==========================================================================
   分页
   ========================================================================== */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px 0 48px;
}

.pager-btn {
    min-width: 38px;
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

    .pager-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

    .pager-btn.active {
        background: var(--accent);
        border-color: var(--accent);
        color: var(--accent-contrast);
        font-weight: 600;
    }

    .pager-btn.disabled {
        opacity: .45;
        pointer-events: none;
    }

/* ==========================================================================
   页脚
   ========================================================================== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    color: var(--text-faint);
    font-size: 13px;
    background: var(--bg-soft);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
    justify-content: center;
}

.footer-center {
    text-align: center;
}

/* 备案号：按监管要求放在页脚，配色比正文更淡，不抢视觉 */
.beian-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-faint);
    font-size: 13px;
    text-decoration: none;
}

    .beian-link:hover {
        color: var(--accent);
        text-decoration: none;
    }

    .beian-link:hover .beian-icon {
        fill: var(--accent);
    }

/* 公安备案盾牌图标：仅描边，悬停时随文字一起变主题色 */
.beian-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    flex: none;
}

.footer-sep {
    opacity: .6;
}

/* ==========================================================================
   表单 / 后台
   ========================================================================== */
.form-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control, .form-select {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    padding: 9px 12px;
}

    .form-control:focus, .form-select:focus {
        border-color: var(--accent);
        background: var(--surface);
        color: var(--text);
        box-shadow: 0 0 0 .2rem var(--accent-soft);
    }

    .form-control::placeholder {
        color: var(--text-faint);
    }

.form-text {
    color: var(--text-faint);
    font-size: 13px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14.5px;
    line-height: 1.45;
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease,
                border-color .16s ease, color .16s ease;
}

    .btn:active {
        transform: translateY(0);
    }

.btn-accent {
    background: linear-gradient(180deg, var(--accent), var(--accent-hover));
    border-color: var(--accent-hover);
    color: var(--accent-contrast);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 6px 16px var(--accent-soft);
}

    .btn-accent:hover {
        color: var(--accent-contrast);
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(16, 24, 40, .1), 0 10px 22px var(--accent-soft);
    }

.btn-outline {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

    .btn-outline:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: var(--accent-soft);
        transform: translateY(-1px);
    }

/* 无边框的轻按钮，用在导航里 */
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
    padding: 7px 12px;
}

    .btn-ghost:hover {
        background: var(--bg-soft);
        color: var(--accent);
    }

.alert {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.card-panel {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   登录页
   ========================================================================== */
.auth-wrap {
    display: grid;
    place-items: center;
    padding: 60px 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* ==========================================================================
   后台表格
   ========================================================================== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
}

    .admin-table th, .admin-table td {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
        text-align: left;
        vertical-align: middle;
    }

    .admin-table th {
        color: var(--text-muted);
        font-weight: 600;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: .4px;
        background: var(--bg-soft);
    }

    .admin-table tbody tr:hover {
        background: var(--bg-soft);
    }

.table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* ==========================================================================
   编辑器（Quill 富文本）
   ========================================================================== */
.editor-shell {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.editor-shell .ql-toolbar {
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    padding: 8px 12px;
}

.editor-shell .ql-container {
    border: 0;
    font-family: var(--font-sans);
    font-size: 16px;
}

.editor-shell .ql-editor {
    min-height: 480px;
    line-height: 1.8;
}

.editor-shell .ql-editor.ql-blank::before {
    color: var(--text-faint);
    font-style: normal;
}

/* Quill 工具栏图标与下拉适配明暗主题 */
.editor-shell .ql-toolbar .ql-stroke { stroke: var(--text-muted); }
.editor-shell .ql-toolbar .ql-fill { fill: var(--text-muted); }
.editor-shell .ql-toolbar .ql-picker { color: var(--text-muted); }
.editor-shell .ql-toolbar button:hover .ql-stroke,
.editor-shell .ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
.editor-shell .ql-toolbar button:hover .ql-fill,
.editor-shell .ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }
.editor-shell .ql-picker-options {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.editor-shell .ql-picker.ql-expanded .ql-picker-label { color: var(--accent); border-color: var(--accent); }
.editor-shell .ql-toolbar .ql-picker-item:hover,
.editor-shell .ql-toolbar .ql-picker-item.ql-selected { color: var(--accent); }

/* ==========================================================================
   附件库
   ========================================================================== */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.attachment-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.attachment-thumb {
    display: grid;
    place-items: center;
    height: 120px;
    background: var(--bg-soft);
    overflow: hidden;
}

    .attachment-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.attachment-thumb .file-icon {
    font-size: 34px;
    color: var(--text-faint);
}

.attachment-info {
    padding: 9px 11px;
    font-size: 13px;
}

.attachment-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.attachment-sub {
    color: var(--text-faint);
    font-size: 12px;
}

/* ==========================================================================
   图片灯箱
   ========================================================================== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, .82);
    cursor: zoom-out;
}

    .lightbox.show {
        display: grid;
    }

    .lightbox img {
        max-width: 92vw;
        max-height: 92vh;
        border-radius: 8px;
    }

/* ==========================================================================
   文章正文 + 目录（长文导航）
   ========================================================================== */
.article-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 36px;
    padding: 0 20px;
}

.article-main {
    width: 100%;
    max-width: var(--content-width);
}

.toc {
    display: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px 9px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .5px;
}

.toc.collapsed .toc-list {
    display: none;
}

.toc-toggle {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-faint);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: all .15s ease;
}

    .toc-toggle:hover {
        background: var(--accent-soft);
        color: var(--accent);
    }

.toc-list {
    margin: 0;
    padding: 8px 0;
    list-style: none;
}

    .toc-list a {
        display: block;
        padding: 5px 14px;
        border-left: 2px solid transparent;
        color: var(--text-muted);
        font-size: 13.5px;
        line-height: 1.55;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

        .toc-list a:hover {
            color: var(--accent);
            background: var(--accent-soft);
        }

        .toc-list a.active {
            color: var(--accent);
            border-left-color: var(--accent);
            background: var(--accent-soft);
            font-weight: 600;
        }

.toc-lv2 a {
    padding-left: 26px;
}

.toc-lv3 a {
    padding-left: 38px;
    font-size: 13px;
}

/* 宽屏：目录吸附在右侧 */
@media (min-width: 1280px) {
    .toc {
        display: block;
        position: sticky;
        top: 84px;
        width: 230px;
        flex: 0 0 230px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* 窄屏：目录移到正文上方，默认折叠 */
@media (max-width: 1279px) {
    .article-wrap {
        flex-direction: column;
        align-items: center;
    }

    .toc {
        display: block;
        order: -1;
        width: 100%;
        max-width: var(--content-width);
        margin-bottom: 20px;
    }
}

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 900px) {
    .nav-toggle {
        display: grid;
        place-items: center;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 10px 20px 14px;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }

        .nav-links.open {
            display: flex;
        }

    .nav-link {
        border-radius: 10px;
        padding: 10px 14px;
    }
}

@media (max-width: 640px) {
    .hero {
        padding: 36px 0 22px;
    }

    .hero-title {
        font-size: 26px;
    }

    .hero-desc {
        font-size: 15.5px;
    }

    .article {
        padding: 24px 0 12px;
    }

    .article-title {
        font-size: 24px;
    }

    .article-cover {
        max-height: 260px;
    }

    .post-body {
        font-size: 16px;
        line-height: 1.8;
    }

    .post-body h1 {
        font-size: 23px;
    }

    .post-body h2 {
        font-size: 20px;
    }

    .post-body h3 {
        font-size: 17.5px;
    }

    .post-body h4 {
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .container-narrow,
    .container-wide {
        padding: 0 16px;
    }

    .hero-title {
        font-size: 24px;
    }

    .article-title {
        font-size: 22px;
    }

    .post-card {
        padding: 18px;
    }

    .post-card-title {
        font-size: 19px;
    }
}

/* ==========================================================================
   Quill 富文本正文（编辑器产出 HTML 的排版适配）
   ========================================================================== */
.post-body .ql-align-center { text-align: center; }
.post-body .ql-align-right { text-align: right; }
.post-body .ql-align-justify { text-align: justify; }
.post-body .ql-indent-1 { padding-left: 3em; }
.post-body .ql-indent-2 { padding-left: 6em; }
.post-body .ql-indent-3 { padding-left: 9em; }
.post-body pre.ql-syntax {
    font-family: var(--font-mono);
    font-size: 14px;
}

/* ==========================================================================
   文章配图九宫格 + 附件（朋友圈式，正文下方）
   ========================================================================== */

/* 前台：正文下方九宫格，固定 3 列（朋友圈风格） */
.post-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 24px 0 8px;
}

.post-gallery-item {
    margin: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--surface-2);
    border: 1px solid transparent;
    transition: border-color .18s ease;
}

    .post-gallery-item img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        cursor: zoom-in;
    }

    .post-gallery-item:hover {
        border-color: var(--accent);
    }

/* 随笔配图更小巧：限制整体宽度（朋友圈式靠左） */
.article-note .post-gallery {
    max-width: 480px;
}

/* 前台：附件下载列表 */
.post-attachments {
    margin: 20px 0 8px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.post-attachments-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.post-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    transition: background-color .15s ease;
}

    .post-attachment:hover {
        background: var(--bg-soft);
        color: var(--text);
    }

.post-attachment-icon {
    flex-shrink: 0;
}

.post-attachment-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent);
}

.post-attachment-size {
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-faint);
}

/* 编辑页：配图九宫格 */
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.media-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: grab;
}

    .media-item:active {
        cursor: grabbing;
    }

    .media-item.dragging {
        opacity: .5;
    }

    .media-item img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        cursor: zoom-in;
    }

.media-item-del {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

    .media-item:hover .media-item-del {
        opacity: 1;
    }

.media-add {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 26px;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}

    .media-add:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

/* 编辑页：附件列表 */
.media-files {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: grab;
}

    .file-item:active {
        cursor: grabbing;
    }

    .file-item.dragging {
        opacity: .5;
    }

.file-item-icon {
    flex-shrink: 0;
    font-size: 18px;
}

.file-item-info {
    flex: 1;
    min-width: 0;
}

.file-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.file-item-size {
    font-size: 12.5px;
    color: var(--text-faint);
}

.file-item-del {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease;
}

    .file-item-del:hover {
        color: var(--danger);
        background: var(--bg-soft);
    }

.file-add {
    padding: 10px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, color .15s ease;
}

    .file-add:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

/* ==========================================================================
   随笔（朋友圈式）
   与文章共用 post-card 外壳，但内部结构不同：没有标题，正文直接展示，配图走九宫格。
   ========================================================================== */
.note-text {
    display: block;
    font-size: 15.5px;
    line-height: 1.85;
    color: var(--text);
    /* 保留正文里的换行（服务端已转成纯文本带 \n） */
    white-space: pre-line;
    /* 列表里最多 6 行，超出截断，避免长随笔把列表撑散 */
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

    .note-text:hover {
        color: var(--text);
    }

.note-grid {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    /* 固定列宽 120px 而非 1fr：1/2/3 列三种情况的缩略图大小完全一致，
       不会出现"一张图占满一整行、下一张突然变小"的割裂感。
       列数由 notegridColumns() 根据图片数量算好，这里只负责尺寸 */
    grid-auto-columns: 120px;
    /* 单图/两图时不占满整行，观感更接近朋友圈 */
    max-width: 420px;
}

.note-grid-1 {
    grid-template-columns: repeat(1, 120px);
}

.note-grid-2 {
    grid-template-columns: repeat(2, 120px);
}

.note-grid-3 {
    grid-template-columns: repeat(3, 120px);
}

.note-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

/* 单图不再拉成 4:3 宽幅，保持方形，和两图/三图大小一致 */
.note-grid-1 img {
    aspect-ratio: 1;
}

/* 随笔详情页：去掉正文首行的顶部留白，紧贴 meta 行 */
.article-note .note-header {
    margin-bottom: 12px;
}

.article-note .post-body {
    font-size: 16px;
    line-height: 1.9;
}

/* 后台列表：文章 / 随笔 标记 */
.badge-article {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-note {
    background: var(--bg-soft);
    color: var(--text-muted);
}

/* 编辑页：随笔只有"谁可以看 / 置顶"两个小控件，用一行 flex 排开，
   不套 Bootstrap 栅格（栅格会把卡片撑高且右侧留大片空白） */
.note-meta-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 14px 20px;
}

.note-meta-item {
    flex: 0 0 auto;
}

    .note-meta-item .form-select {
        min-width: 200px;
    }

.note-meta-hint {
    flex: 1 1 200px;
    font-size: 13px;
    color: var(--text-faint);
    text-align: right;
}

/* ==========================================================================
   个人中心
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.dashboard-profile {
    padding: 24px;
    text-align: center;
}

.dashboard-avatar {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #22d3ee);
    color: #fff;
    font-size: 30px;
    font-weight: 700;
}

.dashboard-name {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 2px;
}

.dashboard-username {
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
    margin-bottom: 12px;
}

.dashboard-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.dashboard-stat {
    padding: 18px 12px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.dashboard-stat .stat-num {
    font-size: 26px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
}

.dashboard-stat .stat-label {
    font-size: 12.5px;
    color: var(--text-faint);
}

.dashboard-links {
    display: grid;
    /* 固定四列：附件库 / 修改密码 / 导航管理 / 账号管理 排成一排 */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.dashboard-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

    .dashboard-link:hover {
        transform: translateY(-2px);
        border-color: var(--accent);
        box-shadow: var(--shadow);
        color: var(--text);
    }

.dashboard-link .link-icon {
    font-size: 22px;
    color: var(--accent);
}

.dashboard-link .link-title {
    font-weight: 600;
}

.dashboard-link .link-desc {
    font-size: 13px;
    color: var(--text-muted);
}

@media (max-width: 860px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-stat-row {
        grid-template-columns: repeat(3, 1fr);
    }

    /* 窄屏放不下四个卡片，退成两列（再窄就是单列） */
    .dashboard-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .dashboard-links {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Toast 轻提示（右上角弹出后自动消失）
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

/* 黑底白字：不跟随明暗主题，浅色页面/深色页面上都能一眼看清 */
.toast-item {
    min-width: 180px;
    max-width: 320px;
    padding: 11px 16px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--radius-sm);
    background: rgba(20, 20, 20, .92);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-16px);
    transition: opacity .45s ease, transform .45s ease;
}

    .toast-item.show {
        opacity: 1;
        transform: translateY(0);
    }

    /* 淡出更慢一点：消失时不"啪"地一下断掉 */
    .toast-item.hide {
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity .6s ease, transform .6s ease;
    }

/* 类型只用于无障碍标注，不再染色 —— 提示统一纯黑，避免一条彩色边造成视觉噪音 */
