/**
 * 富文本正文共用样式：TinyMCE 编辑区 + 前台展示
 * 原则：尽量保留编辑器内联样式；前端只做安全兜底（图片不撑破、超宽可横滑）
 */
.yice-editor-html,
body.mce-content-body {
  font-family: Microsoft YaHei, PingFang SC, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  color: #333;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
}

.yice-editor-html :where(p, li, span, td, th, h1, h2, h3, h4, h5, h6, a, strong, em, div, blockquote, figcaption),
body.mce-content-body :where(p, li, span, td, th, h1, h2, h3, h4, h5, h6, a, strong, em, div, blockquote, figcaption) {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
}

/* 长 URL、连续无空格文本：仅前台展示强制断行；后台编辑器保持正常排版便于编辑 */
.yice-editor-html :where(p, a, li, td, th, span) {
  word-break: break-all;
}

.yice-editor-html a {
  color: var(--blue, #2c7af2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.yice-editor-html p,
body.mce-content-body p {
  margin: 0 0 0.85em;
}

.yice-editor-html h1,
.yice-editor-html h2,
.yice-editor-html h3,
.yice-editor-html h4,
.yice-editor-html h5,
.yice-editor-html h6,
body.mce-content-body h1,
body.mce-content-body h2,
body.mce-content-body h3,
body.mce-content-body h4,
body.mce-content-body h5,
body.mce-content-body h6 {
  margin: 1.1em 0 0.55em;
  line-height: 1.35;
  font-weight: 700;
  color: #222;
}

.yice-editor-html ul,
.yice-editor-html ol,
body.mce-content-body ul,
body.mce-content-body ol {
  margin: 0 0 0.85em;
  padding-left: 1.5em;
}

.yice-editor-html table,
body.mce-content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  table-layout: fixed;
  max-width: 100%;
}

.yice-editor-html table td,
.yice-editor-html table th,
body.mce-content-body table td,
body.mce-content-body table th {
  border: 1px solid #d0d7de;
  padding: 8px 10px;
  vertical-align: top;
  word-break: break-word;
  white-space: normal;
}

.yice-editor-html table th,
body.mce-content-body table th {
  background: #f5f7fa;
  font-weight: 700;
}

.yice-editor-html table tr:nth-child(even) td,
body.mce-content-body table tr:nth-child(even) td {
  background: #fafbfc;
}

.yice-editor-html img,
body.mce-content-body img {
  max-width: 100%;
  height: auto;
}

.yice-editor-html video,
body.mce-content-body video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px 0;
  background: #0f172a;
}

.yice-editor-html blockquote,
body.mce-content-body blockquote {
  margin: 0.85em 0;
  padding: 0.35em 0 0.35em 1em;
  border-left: 3px solid #d0d7de;
  color: #555;
}

/* 前台兜底：禁止整页横滑，在元素内断行 */
.yice-editor-html {
  overflow-x: clip;
  overflow-x: hidden;
}

/*
 * 抵消页面级「文章美化」对富文本的强制改写（nowrap / min-width / 强制通栏图等）
 * 内联 style 仍优先；这里只撤掉会破坏所见即所得的页面规则
 */
.yice-editor-html table,
.yice-editor-html .news-table,
.yice-editor-html .case-docx-table {
  min-width: 0 !important;
  height: auto !important;
}

.yice-editor-html table th,
.yice-editor-html table td {
  white-space: normal !important;
}

.yice-editor-html img {
  width: auto !important;
  max-width: 100% !important;
  border-radius: 0;
  box-shadow: none;
  margin: 0.5em 0;
}

.yice-editor-html .news-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 1rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.yice-editor-html iframe,
body.mce-content-body iframe {
  display: block;
  max-width: 100%;
  width: 100%;
  min-height: 200px;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  margin: 1rem 0;
}

.yice-editor-html pre,
.yice-editor-html code,
body.mce-content-body pre,
body.mce-content-body code {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.yice-editor-html figure,
.yice-editor-html section,
.yice-editor-html div,
body.mce-content-body figure,
body.mce-content-body section,
body.mce-content-body div {
  max-width: 100%;
  box-sizing: border-box;
}

/* Word / 旧稿：仅前台兜底，不改后台编辑器内联样式 */
.yice-editor-html [style*="width"] {
  max-width: 100% !important;
}

.yice-editor-html [style*="nowrap"],
.yice-editor-html [style*="white-space"] {
  white-space: normal !important;
}

.yice-editor-html [style*="min-width"] {
  min-width: 0 !important;
}

.yice-editor-html table[style],
.yice-editor-html .news-table[style],
.yice-editor-html .case-docx-table[style] {
  width: 100% !important;
}

/* —— 手机端：强制适配（覆盖编辑器内联宽度） —— */
@media (max-width: 768px) {
  .yice-editor-html {
    font-size: 15px;
    line-height: 1.75;
    overflow-x: hidden;
  }

  .yice-editor-html h1 {
    font-size: 1.45rem;
  }

  .yice-editor-html h2 {
    font-size: 1.3rem;
  }

  .yice-editor-html h3 {
    font-size: 1.15rem;
  }

  .yice-editor-html table,
  .yice-editor-html .news-table,
  .yice-editor-html .case-docx-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    font-size: 0.84rem;
  }

  .yice-editor-html table th,
  .yice-editor-html table td {
    padding: 6px 8px;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal !important;
  }

  .yice-editor-html .news-table-wrap {
    margin: 0.85rem 0;
  }

  .yice-editor-html img {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin-left: auto;
    margin-right: auto;
  }

  .yice-editor-html img.alignleft,
  .yice-editor-html img.alignright,
  .yice-editor-html .alignleft,
  .yice-editor-html .alignright {
    float: none !important;
    margin: 0.85rem auto !important;
  }

  .yice-editor-html table[style],
  .yice-editor-html .news-table[style],
  .yice-editor-html .case-docx-table[style] {
    width: 100% !important;
  }

  .yice-editor-html :where(p, a, li, span, td, th) {
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .yice-editor-html video,
  .yice-editor-html iframe {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0;
  }
}
