/* ==========================================================================
   paper.css — A4 纸张与文档排版
   单位策略：文档区一律使用 pt（1pt = 1/72in），与 Word 内部单位一致，
   保证「屏幕上看到的字号」== 「导出 docx 里的字号」，实现真正 WYSIWYG。
   ========================================================================== */

.canvas-scroll {
  padding-bottom: 40px;
}

.paper {
  width: var(--tz-paper-w);
  min-height: var(--tz-paper-h);
  padding: var(--tz-paper-pad) 76px;
  background: #fff;
  box-shadow: var(--tz-shadow-paper);
  outline: 1px solid rgba(15, 23, 42, 0.05);
  outline-offset: -1px;
  transition: box-shadow 0.2s;
}
.paper:focus-within {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 16px 44px rgba(37, 99, 235, 0.14);
}

/* ─────────────────── 文档根 ─────────────────── */

.doc {
  min-height: calc(var(--tz-paper-h) - var(--tz-paper-pad) * 2);
  outline: none;
  color: #1a1a1a;
  font-family: Calibri, -apple-system, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 11pt;
  line-height: 1.5;
  caret-color: var(--tz-accent);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.doc.is-empty::before {
  content: attr(data-placeholder);
  display: block;
  color: #b8c0cc;
  pointer-events: none;
  user-select: none;
}

.doc ::selection { background: rgba(37, 99, 235, 0.2); }

/* ─────────────────── 段落 ─────────────────── */

.doc p {
  margin: 0 0 8pt;
  min-height: 1em;
}

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

/* 空段落（Word 里用来占位的空行）保持可见高度 */
.doc p:empty::after { content: ""; display: inline-block; }

/* ─────────────────── 标题（对齐 Word 2016+ 默认主题） ─────────────────── */

.doc h1, .doc h2, .doc h3,
.doc h4, .doc h5, .doc h6 {
  margin: 18pt 0 6pt;
  font-family: Calibri, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 600;
  line-height: 1.28;
  color: #2f5496;
  page-break-after: avoid;
}
.doc h1 { font-size: 16pt; margin-top: 0; }
.doc h2 { font-size: 13pt; }
.doc h3 { font-size: 12pt; }
.doc h4 { font-size: 11pt; font-style: italic; }
.doc h5 { font-size: 11pt; color: #1a1a1a; }
.doc h6 { font-size: 11pt; color: #1a1a1a; font-weight: 400; }

/* ─────────────────── 行内元素 ─────────────────── */

.doc b, .doc strong { font-weight: 700; }
.doc i, .doc em { font-style: italic; }
.doc u { text-decoration: underline; }
.doc s, .doc strike, .doc del { text-decoration: line-through; }
.doc sup { vertical-align: super; font-size: 0.75em; }
.doc sub { vertical-align: sub; font-size: 0.75em; }
.doc a {
  color: #0563c1;
  text-decoration: underline;
  cursor: pointer;
}
.doc code, .doc kbd, .doc samp {
  padding: 0.1em 0.36em;
  border-radius: 4px;
  background: #f1f5f9;
  font-family: var(--tz-mono);
  font-size: 0.92em;
  color: #0f172a;
}
.doc mark { background: #fef08a; color: inherit; }

/* ─────────────────── 列表 ─────────────────── */

.doc ul, .doc ol {
  margin: 0 0 8pt;
  padding-left: 1.75em;
}
.doc li { margin-bottom: 3pt; }
.doc li>ul, .doc li>ol { margin: 3pt 0 0; }
.doc ul { list-style-type: disc; }
.doc ul ul { list-style-type: circle; }
.doc ul ul ul { list-style-type: square; }
.doc ol { list-style-type: decimal; }
.doc ol ol { list-style-type: lower-alpha; }
.doc ol ol ol { list-style-type: lower-roman; }
.doc li::marker { color: #1a1a1a; }

/* ─────────────────── 引用 / 分隔线 ─────────────────── */

.doc blockquote {
  margin: 8pt 0;
  padding: 6pt 0 6pt 14pt;
  border-left: 3px solid #93c5fd;
  background: #f8fafc;
  color: #475569;
}

.doc hr {
  height: 0;
  margin: 12pt 0;
  border: 0;
  border-top: 1px solid #cbd5e1;
}

/* ─────────────────── 表格 ─────────────────── */

.doc table {
  width: 100%;
  margin: 8pt 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10.5pt;
}
.doc th, .doc td {
  padding: 5pt 7pt;
  border: 1px solid #a6b1c2;
  vertical-align: top;
  text-align: left;
  word-break: break-word;
}
.doc th {
  background: #eef2f9;
  font-weight: 700;
}
.doc table p { margin: 0; }

/* ─────────────────── 图片 ─────────────────── */

.doc img {
  max-width: 100%;
  height: auto;
  vertical-align: bottom;
  border-radius: 2px;
}
.doc img.is-selected {
  outline: 2px solid var(--tz-accent);
  outline-offset: 1px;
}
.doc p[data-image-only] { text-align: center; }

/* ─────────────────── 分页符 ─────────────────── */

.doc .wb-pagebreak {
  position: relative;
  height: 0;
  margin: 18pt 0;
  border-top: 1px dashed #bfdbfe;
  user-select: none;
}
.doc .wb-pagebreak::after {
  content: "分页符";
  position: absolute;
  top: -7pt;
  right: 0;
  padding: 0 5pt;
  border-radius: 999px;
  background: #eff6ff;
  color: #60a5fa;
  font-family: var(--tz-font);
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 14pt;
}

/* ─────────────────── 表格交互 ─────────────────── */

.doc td, .doc th { position: relative; }
.doc td:focus, .doc th:focus { outline: 2px solid var(--tz-accent-soft); outline-offset: -2px; }
.doc table:focus-within { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08); }

/* ─────────────────── 打印 / 导出 PDF ─────────────────── */

@page {
  size: A4;
  margin: 19mm 20mm;
}

@media print {
  html, body {
    height: auto;
    overflow: visible;
    background: #fff;
  }
  .topbar, .ribbon, .sidebar, .statusbar, .side-toggle,
  .toast-stack, .busy, .modal-backdrop, .empty-state { display: none !important; }

  .app { display: block; height: auto; }
  .workspace { display: block; }
  .canvas {
    display: block;
    padding: 0;
    overflow: visible;
    background: #fff;
  }
  .canvas-inner { display: block; width: auto; }
  .zoom-wrap { transform: none !important; }

  .paper {
    width: auto;
    min-height: 0;
    padding: 0;
    box-shadow: none;
    outline: 0;
  }
  .doc { min-height: 0; font-size: 11pt; }

  .doc a { color: #0563c1; }
  .doc .wb-pagebreak {
    margin: 0;
    border: 0;
    break-after: page;
    page-break-after: always;
  }
  .doc .wb-pagebreak::after { content: none; }
  .doc h1, .doc h2, .doc h3 { page-break-after: avoid; }
  .doc table, .doc img, .doc blockquote { page-break-inside: avoid; }
  .doc tr { page-break-inside: avoid; }
  mark.find-hit { background: transparent !important; }
}
