/* =====================================================================
   正文内容兜底净化样式（ylzncn 版）——文章 / 产品 / 页面 .content-body
   ---------------------------------------------------------------------
   挂载：functions.php ylzncn_scripts() → 依赖 ylzncn-style 之后加载（全站 CSS 最后一层）
   作用范围：body.single（文章详情/产品详情）与 body.page（关于我们等单页）的
   .content-body —— 即 template-parts/single/single-render.php:57/:104 与
   template-parts/page/page-render.php:45 的正文容器。
   index.php 无结果分支的 .content-body 只包搜索表单（body 类为 search/home），
   天然不在范围内；首页/列表/侧栏/后台不涉及。

   解决的问题：文员从 AI 对话、Word、微信公众号、网页等渠道粘贴文章/产品
   内容，自带大量行内样式与固定宽度（定宽图片、行内字号字体、margin:0 段落
   挤成一片、无符号列表、position:fixed 悬浮块、超宽表格、浮动图片贴死文字），
   导致正文排版混乱、撑破版心。（线上三站实测：cmlsx 变压器文 4 假空段、
   autoassy 自行车文 6 假空段 + electric-suv 6 零宽字符、标题 h2/h4 层级混用）

   与主题既有规则的关系（不重复、只补缺）：
   - 表格边框包（加强版 8 条：边框/表头底色/斑马纹/悬停/caption/单元格 p 修正/
     display:block 横向滚动）已于 2026-09 装在 style.css 229-239 —— 本文件不重复；
   - .content-body 基础行高/长词断行（style.css:229）、img/iframe/video
     max-width（style.css:230/239）已存在 —— 本文件只做 !important 硬兜底补充；
   - 全局 ul 无符号无缩进（style.css:45）→ 本文件在正文恢复列表符号；
   - pre/code 等宽字体（style.css:37）保留，本文件只归一字号行高。

   设计原则（与 ahlsx 主题 2026-11 第 9-11 轮同一套已验证方案）：
   1. 行内 style 优先级高，关键归一化属性一律 !important；
   2. 只强制"会破坏排版/层级"的属性（宽高/间距/标题层级/字体族/定位/列表符号）；
      颜色、对齐等可能出于作者意图的样式一律不动；
   3. 正文链接沿用主题全局规则（#333，hover #0d47ab），不重复定义；
   4. 标题阶梯与 ahlsx 版一致（20/18/16/15/14/13，正文基准 16px）；
      ylzncn 页面主标题 20px 常规蓝色（.content-title h1），正文 h1 20px 加粗
      黑色与其可区分，且线上实测正文几乎不出现 h1（三站 12 篇样本 0 个）。

   纯 CSS 兜底做不到的（由 inc/content-functions.php 过滤层接管）：
   假空段 <p>&nbsp;</p>、Word <o:p> 残留、零宽空格 —— 输出期轻过滤清除，
   表格逐字节保留（详见该文件头注释）。
   ===================================================================== */

/* -------------------------------------------------------------------
   1. 容器基础：正文基准 16px（长词断行已有 style.css:229，不重复）
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body {
	font-size: 16px;
}

/* -------------------------------------------------------------------
   2. 通用防溢出：任何后代不得超过版心宽度（行内写死 width:1200px 会被
      max-width 在"使用值"层面压回容器内），媒体类 !important 硬兜底
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body * {
	max-width: 100%;
	box-sizing: border-box;
}
body:is(.single, .page) .content-body img,
body:is(.single, .page) .content-body video,
body:is(.single, .page) .content-body canvas,
body:is(.single, .page) .content-body svg,
body:is(.single, .page) .content-body iframe,
body:is(.single, .page) .content-body embed,
body:is(.single, .page) .content-body object,
body:is(.single, .page) .content-body table {
	max-width: 100% !important;
}
body:is(.single, .page) .content-body img,
body:is(.single, .page) .content-body video {
	height: auto !important;
}
body:is(.single, .page) .content-body img {
	vertical-align: middle;
	border: 0;
}

/* -------------------------------------------------------------------
   3. 字体族归一：Word/网页/135 粘贴常自带 Calibri/宋体/Arial 等行内字体，
      统一继承站点字体；代码类元素恢复等宽字体（选择器优先级高于通配符）
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body * {
	font-family: inherit !important;
}
body:is(.single, .page) .content-body pre,
body:is(.single, .page) .content-body code,
body:is(.single, .page) .content-body kbd,
body:is(.single, .page) .content-body samp {
	font-family: Consolas, Monaco, "Courier New", monospace !important;
}

/* -------------------------------------------------------------------
   4. 标题层级归一：粘贴的 h1-h6 常带巨大/细体/行内字号（实测 h2 与 h4 混用），
      统一为站点正文标题阶梯
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body h1,
body:is(.single, .page) .content-body h2,
body:is(.single, .page) .content-body h3,
body:is(.single, .page) .content-body h4,
body:is(.single, .page) .content-body h5,
body:is(.single, .page) .content-body h6 {
	font-weight: 700 !important;
	line-height: 1.4 !important;
	margin: 1.4em 0 0.6em !important;
}
body:is(.single, .page) .content-body h1 { font-size: 20px !important; }
body:is(.single, .page) .content-body h2 { font-size: 18px !important; }
body:is(.single, .page) .content-body h3 { font-size: 16px !important; }
body:is(.single, .page) .content-body h4 { font-size: 15px !important; }
body:is(.single, .page) .content-body h5 { font-size: 14px !important; }
body:is(.single, .page) .content-body h6 { font-size: 13px !important; }

/* -------------------------------------------------------------------
   5. 段落与文本块：微信/135 粘贴常 margin:0 挤成一片、行内行高字号各异
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body p {
	margin: 0 0 1em !important;
	line-height: inherit !important;
	font-size: inherit !important;
}
body:is(.single, .page) .content-body section,
body:is(.single, .page) .content-body li {
	font-size: inherit !important;
}
body:is(.single, .page) .content-body p:empty {
	display: none !important;
}
body:is(.single, .page) .content-body > :first-child {
	margin-top: 0 !important;
}

/* -------------------------------------------------------------------
   5A. 行内元素与包裹层字号归一（字号真空所在）：
       段落里的 <span style="font-size:22px">、AI 导出的 div 包裹层。
       颜色/背景刻意不动（作者意图，如公众号彩色营销块）。
   表格豁免（表格粘贴来之不易，粘贴的表格原样保留）：
       :not(:is(table, thead, tbody, tfoot, tr, td, th) *) 精确排除表格
       后代——单元格里的任何行内字号（Word/Excel 紧凑表格 12px）原样生效。
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body :is(div, section, span, a, strong, b, em, i, u, font):not(:is(table, thead, tbody, tfoot, tr, td, th) *) {
	font-size: inherit !important;
	line-height: inherit !important;
}

/* -------------------------------------------------------------------
   6. 列表归一：主题全局 ul 无 padding 无符号（style.css:45），正文恢复
      缩进与项目符号，并对抗行内 list-style-type:none
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body ul,
body:is(.single, .page) .content-body ol {
	margin: 1em 0 !important;
	padding-left: 2em !important;
	list-style-position: outside !important;
}
body:is(.single, .page) .content-body ul { list-style-type: disc !important; }
body:is(.single, .page) .content-body ol { list-style-type: decimal !important; }
body:is(.single, .page) .content-body li > ul,
body:is(.single, .page) .content-body li > ol {
	margin: 0.3em 0 !important;
}

/* -------------------------------------------------------------------
   7. 引用 / 代码 / 术语列表（主题无既有规则，全量补齐）
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body blockquote {
	margin: 1.2em 0 !important;
	padding: 10px 16px !important;
	background-color: #f7f9fb;
	border-left: 4px solid #0d47ab;
	border-radius: 3px;
}
body:is(.single, .page) .content-body blockquote > :last-child {
	margin-bottom: 0 !important;
}
body:is(.single, .page) .content-body pre {
	margin: 1.2em 0 !important;
	padding: 12px 15px !important;
	background-color: #f6f8fa;
	border: 1px solid #e5e5e5;
	border-radius: 4px;
	overflow-x: auto;
	font-size: 13px !important;
	line-height: 1.6 !important;
	white-space: pre !important;
}
body:is(.single, .page) .content-body code {
	padding: 2px 6px;
	background-color: #f5f5f5;
	border-radius: 3px;
	font-size: 90%;
}
body:is(.single, .page) .content-body pre code {
	padding: 0 !important;
	background: none !important;
	font-size: inherit !important;
	border-radius: 0;
}
body:is(.single, .page) .content-body dl { margin: 1em 0 !important; }
body:is(.single, .page) .content-body dd { margin: 0 0 0.5em 2em !important; }
body:is(.single, .page) .content-body dt { font-weight: 700; }

/* -------------------------------------------------------------------
   8. figure / 图注 / 分隔线（style.css:6 figure margin 1em 40px 偏宽，归一）
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body figure { margin: 1em 0 !important; }
body:is(.single, .page) .content-body figcaption {
	margin-top: 0.5em;
	text-align: center;
	color: #999;
	font-size: 13px !important;
}
body:is(.single, .page) .content-body hr {
	height: 0 !important;
	border: 0 !important;
	border-top: 1px solid #ddd !important;
	margin: 1.5em 0 !important;
}

/* -------------------------------------------------------------------
   9. 表格兜底补充（边框/斑马纹/横滚已在 style.css 231-238，此处只补
      行内宽度兜底与表头加粗，不重复既有规则）
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body table {
	width: 100% !important;
	margin: 15px 0 !important;
}
body:is(.single, .page) .content-body th { font-weight: 700 !important; }

/* -------------------------------------------------------------------
   10. WP 编辑器对齐类与图注短代码（主题此前无对应样式，编辑器里设了
       对齐/图注前台一直不生效，按 WP 标准行为补齐）
   ------------------------------------------------------------------- */
body:is(.single, .page) .content-body .aligncenter {
	display: block !important;
	float: none !important;
	margin-left: auto !important;
	margin-right: auto !important;
}
body:is(.single, .page) .content-body .alignleft {
	float: left !important;
	margin: 5px 20px 8px 0 !important;
}
body:is(.single, .page) .content-body .alignright {
	float: right !important;
	margin: 5px 0 8px 20px !important;
}
/* 经典编辑器图注：<dl class="wp-caption" style="width:510px">，width 已含
   两侧 padding，恢复 content-box 计宽并取消上面 dd 的缩进 */
body:is(.single, .page) .content-body dl.wp-caption {
	box-sizing: content-box;
	padding: 5px 5px 0;
	text-align: center;
}
body:is(.single, .page) .content-body dd.wp-caption-text {
	margin: 5px 0 0 !important;
	text-align: center;
	font-size: 13px;
	color: #999;
}

/* -------------------------------------------------------------------
   11. 粘贴垃圾修正
   ------------------------------------------------------------------- */
/* 粘贴产生的 position:fixed/absolute 悬浮块会飘出正文压住页面，按静态处理
   （兼容带/不带空格两种行内写法） */
body:is(.single, .page) .content-body [style*="position:fixed"],
body:is(.single, .page) .content-body [style*="position: fixed"],
body:is(.single, .page) .content-body [style*="position:absolute"],
body:is(.single, .page) .content-body [style*="position: absolute"] {
	position: static !important;
}
/* Word/135 编辑器粘贴的浮动图片常无外边距，文字贴死图片，补安全间距 */
body:is(.single, .page) .content-body img[style*="float:left"],
body:is(.single, .page) .content-body img[style*="float: left"] {
	float: left !important;
	margin: 5px 20px 8px 0 !important;
}
body:is(.single, .page) .content-body img[style*="float:right"],
body:is(.single, .page) .content-body img[style*="float: right"] {
	float: right !important;
	margin: 5px 0 8px 20px !important;
}
