/* ==========================================================================
   print.css — 打印 / 导出 PDF 管线
   原则：纸上只出现 .sheet；A4 精确几何；色彩保真；条目不拦腰截断。
   ========================================================================== */

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html, body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  /* 隐藏全部编辑器 chrome */
  .topbar,
  .mobile-switch,
  .form-pane,
  .preview-toolbar,
  .guide-drawer,
  .scrim,
  .toast-host,
  .fold-flag,
  .sheet-measure {
    display: none !important;
  }

  /* 工作台归零，关闭缩放 */
  .app { height: auto !important; }
  .workbench {
    display: block !important;
    grid-template-columns: none !important;
  }
  .preview-pane { display: block !important; }
  .preview-pane::before { display: none !important; }
  .preview-stage {
    overflow: visible !important;
    padding: 0 !important;
    display: block !important;
  }
  .sheet-wrap {
    transform: none !important;
    width: auto !important;
    height: auto !important;
  }

  /* A4 几何：页边距由 .sheet 内部 --pad 控制，内容超出自然流到第 2 页 */
  .sheet {
    width: 210mm !important;
    height: auto !important;
    min-height: 296mm !important; /* 略小于 297mm 防浮点误差多出空白页 */
    overflow: visible !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  /* 色彩保真：双栏侧边底色 / 强调色块必须跟屏 */
  .sheet, .sheet * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 分页控制：条目/标题不被拦腰截断 */
  .r-entry,
  .r-paper,
  .r-honor,
  .r-honor-s,
  .r-cert {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .r-sec-title {
    break-after: avoid;
    page-break-after: avoid;
  }
  .r-bullets li { orphans: 2; widows: 2; }

  /* 双栏模板跨页时保持网格结构 */
  .tpl-classic .r-grid { min-height: 0 !important; }
  .sheet.tpl-classic { height: auto !important; }
}
