/* ═══════════════════════════════════════════════════════════════
   文档排版（doc-style）
   写作页（编辑器）与阅读页共用同一套 .doc-sheet / .doc-body 样式，
   保证「写的样子 = 读的样子」。
   ═══════════════════════════════════════════════════════════════ */

/* ─── A4 纸面 ─── */
.doc-sheet {
    background: var(--t-paper, #fffdfa);
    color: var(--t-ink, #3a3238);
    max-width: 820px;
    margin: 0 auto;
    padding: 56px 64px 64px;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(var(--t-shadow-rgb, 0, 0, 0), .16), 0 2px 10px rgba(var(--t-shadow-rgb, 0, 0, 0), .07);
}

/* ─── 正文排版（编辑器与阅读页同款） ─── */
.doc-body {
    font-family: "Georgia", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
    font-size: 1.08rem;
    line-height: 2;
    outline: none;
    word-break: break-word;
    caret-color: var(--t-accent, #e8608a);
}

    .doc-body ::selection {
        background: rgba(var(--t-accent-rgb, 232, 96, 138), .22);
    }

    .doc-body > *:first-child { margin-top: 0; }
    .doc-body > *:last-child { margin-bottom: 0; }

    .doc-body p { margin: .45em 0; }

    .doc-body h2, .doc-body h3 {
        font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
        font-weight: 700;
        line-height: 1.5;
        margin: 1.4em 0 .5em;
        color: var(--t-ink, #3a3238);
    }

    .doc-body h2 {
        font-size: 1.3rem;
        padding-left: .65em;
        border-left: 4px solid var(--t-accent, #e8608a);
        letter-spacing: .02em;
    }

    .doc-body h3 {
        font-size: 1.1rem;
        color: var(--t-accent-deep, #b3476f);
    }

    .doc-body a {
        color: var(--t-accent-deep, #b3476f);
        text-decoration: underline;
        text-decoration-style: dotted;
        text-underline-offset: 3px;
    }

    .doc-body blockquote {
        margin: .9em 0;
        padding: .55em 1.1em;
        border-left: 3px solid var(--t-accent, #e8608a);
        border-radius: 0 12px 12px 0;
        background: rgba(var(--t-accent-rgb, 232, 96, 138), .07);
        color: var(--t-ink-soft, #8a7a82);
    }

        .doc-body blockquote p { margin: .2em 0; }

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

    .doc-body li { margin: .28em 0; }
        .doc-body li p { margin: .18em 0; }

    .doc-body ul li::marker { color: var(--t-accent, #e8608a); }
    .doc-body ol li::marker { color: var(--t-accent, #e8608a); font-weight: 600; }

    .doc-body hr {
        border: none;
        height: 2px;
        margin: 1.8em auto;
        width: 62%;
        border-radius: 2px;
        background: linear-gradient(90deg, transparent, rgba(var(--t-accent-rgb, 232, 96, 138), .55), transparent);
    }

    .doc-body code {
        font-family: Consolas, "JetBrains Mono", monospace;
        font-size: .88em;
        padding: .12em .45em;
        border-radius: 6px;
        background: rgba(var(--t-accent-rgb, 232, 96, 138), .1);
        color: var(--t-accent-deep, #b3476f);
    }

    .doc-body pre {
        margin: 1em 0;
        padding: 1em 1.2em;
        border-radius: 12px;
        background: #2d2a2e;
        color: #f3eef0;
        overflow-x: auto;
        font-size: .88rem;
        line-height: 1.7;
    }

        .doc-body pre code { background: none; color: inherit; padding: 0; }

    /* ─── 表格：日程/清单 ─── */
    .doc-body table {
        width: 100%;
        margin: 1em 0;
        border-collapse: collapse;
        font-size: .95rem;
        overflow: hidden;
        border-radius: 10px;
    }

    .doc-body th, .doc-body td {
        border: 1px solid var(--t-line, #eadfe3);
        padding: .5em .8em;
        text-align: left;
        vertical-align: top;
        line-height: 1.7;
    }

    .doc-body th {
        font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
        font-weight: 600;
        background: rgba(var(--t-accent-rgb, 232, 96, 138), .1);
        color: var(--t-accent-deep, #b3476f);
        white-space: nowrap;
    }

    .doc-body .selectedCell:after {
        content: "";
        position: absolute;
        inset: 0;
        background: rgba(var(--t-accent-rgb, 232, 96, 138), .12);
        pointer-events: none;
    }

    .doc-body td, .doc-body th { position: relative; }

    .doc-body .column-resize-handle {
        position: absolute;
        right: -2px;
        top: 0;
        bottom: 0;
        width: 4px;
        background: var(--t-accent, #e8608a);
    }

    /* ─── 图片与图注 ─── */
    .doc-body img {
        max-width: 100%;
        height: auto;
        border-radius: 12px;
        display: block;
        box-shadow: 0 6px 20px rgba(var(--t-shadow-rgb, 0, 0, 0), .12);
    }

    .doc-body figure[data-doc-figure] {
        width: 72%;
        margin: 1.4rem auto;
        position: relative;
    }

    .doc-body figure[data-doc-figure][data-align="left"] { margin-left: 0; }

    .doc-body figure[data-doc-figure] img { width: 100%; cursor: pointer; }

    /* 选中图片的高亮：用 PM 自己维护的 selectednode 类（会随选区自动增删） */
    .doc-body img.ProseMirror-selectednode {
        outline: 3px solid var(--t-accent, #e8608a);
        outline-offset: 2px;
    }

    .doc-body figcaption {
        text-align: center;
        font-size: .86em;
        color: var(--t-ink-soft, #8a7a82);
        margin-top: .55em;
        line-height: 1.6;
    }

        .doc-body figcaption:empty { display: none; }
        .doc-body figcaption.is-empty:empty { display: block; }

    /* ─── 编辑器占位符（TipTap Placeholder） ─── */
    .doc-body p.is-empty:first-child::before,
    .doc-body h2.is-empty::before,
    .doc-body h3.is-empty::before,
    .doc-body figcaption.is-empty::before {
        content: attr(data-placeholder);
        color: rgba(var(--t-shadow-rgb, 0, 0, 0), .42);
        float: left;
        height: 0;
        pointer-events: none;
    }

    .doc-body .ProseMirror-gapcursor:after { border-top-color: var(--t-accent, #e8608a); }

/* ─── 编辑器工作区（灰底 + 白纸） ─── */
.doc-workspace {
    background: rgba(var(--t-shadow-rgb, 0, 0, 0), .05);
    border: 1px solid var(--t-glass-border, rgba(0,0,0,.06));
    border-radius: 18px;
    padding: 22px clamp(10px, 3vw, 34px) 30px;
    position: relative;
}

.doc-shell { position: relative; }

/* ─── 图片悬浮工具条 ─── */
.doc-figpop {
    position: absolute;
    z-index: 30;
    display: none;
    gap: 2px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 12px;
    background: var(--t-panel, #fff);
    border: 1px solid var(--t-glass-border, rgba(0,0,0,.08));
    box-shadow: 0 8px 24px rgba(var(--t-shadow-rgb, 0, 0, 0), .18);
}

    .doc-figpop button {
        border: none;
        background: none;
        cursor: pointer;
        font-size: .78rem;
        padding: 4px 8px;
        border-radius: 8px;
        color: var(--t-ink, #3a3238);
        white-space: nowrap;
    }

        .doc-figpop button:hover { background: rgba(var(--t-accent-rgb, 232, 96, 138), .12); }
        .doc-figpop button.is-active { background: var(--t-accent, #e8608a); color: #fff; }

/* ─── 表格操作小菜单（编辑时） ─── */
.doc-body table .ProseMirror-selectednode { outline: none; }

/* ─── 打印：只留纸面 ─── */
@media print {
    .doc-sheet {
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        background: #fff;
    }

    .doc-body h2 { border-left-color: #b3476f; }
    .doc-body img, .doc-body figure[data-doc-figure] img { box-shadow: none; }
    .doc-workspace { background: none; border: none; padding: 0; }
}

/* ─── 全站打印规则：打印文章时只留纸面正文 ─── */
@media print {
    .sidebar, .corner-clock, .theme-wallpaper, .reconnect, .reload, .dismiss,
    .no-print, .comments, .post-actions, .post-foot, .print-bar,
    .pose-hero, .hero-badges, .filter-bar, .pager {
        display: none !important;
    }

    .page, .content { display: block !important; padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
    .theme-root { background: #fff !important; }
    .post-paper, .panel {
        background: #fff !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    body { background: #fff !important; }

    .doc-body { font-size: 11.5pt; }
    .doc-body h2 { break-after: avoid; }
    .doc-body figure[data-doc-figure], .doc-body img { break-inside: avoid; }
    .doc-body table { break-inside: auto; }
}
