/* ==========================================================================
   富文本内容样式（前台正文 + 后台编辑器共用）
   说明：颜色 / 字号 / 字体 / 对齐统一用 class 表达，服务端保存时把内联样式
        收敛为这些类，因此前台无需放开 CSP 的 style-src。
   ========================================================================== */

/* ---------------------------- 正文排版 ------------------------------ */

.rich h2 { font-size: 22px; line-height: 1.45; font-weight: 700; margin: 32px 0 14px; letter-spacing: -.01em; }
.rich h3 { font-size: 18px; line-height: 1.5; font-weight: 700; margin: 26px 0 12px; }
.rich h4 { font-size: 16px; line-height: 1.6; font-weight: 700; margin: 22px 0 10px; }
.rich h2:first-child, .rich h3:first-child, .rich h4:first-child { margin-top: 0; }

.rich ul, .rich ol { margin: 0 0 18px; padding-left: 24px; }
.rich ul { list-style: disc; }
.rich ol { list-style: decimal; }
.rich li { margin: 7px 0; padding-left: 2px; }
.rich li > ul, .rich li > ol { margin: 7px 0 4px; }

.rich blockquote {
  margin: 20px 0; padding: 12px 20px; border-left: 3px solid currentColor;
  opacity: .92; background: rgba(11, 37, 69, .04); border-radius: 0 6px 6px 0;
}
.rich blockquote p:last-child { margin-bottom: 0; }

.rich a { color: #0f766e; text-decoration: underline; text-underline-offset: 2px; }
.rich a:hover { color: #0b2545; }

.rich img.rt-img {
  display: block; max-width: 100%; height: auto; margin: 20px 0;
  border-radius: 6px; background: #f4f7fa;
}
.rich hr { border: 0; height: 1px; margin: 28px 0; background: currentColor; opacity: .16; }
.rich sup, .rich sub { font-size: 72%; line-height: 0; }
.rich div { margin: 0 0 16px; }
.rich div:last-child { margin-bottom: 0; }

/* ---------------------------- 颜色 / 高亮 ---------------------------
   使用 :is(.rich, .rt-area) 提升特异性并配 !important，
   确保优先于前台正文的默认颜色与字号（如 .detail-main .rich p）。 */

:is(.rich, .rt-area) .rt-c-ink { color: #1a1a1a !important; }
:is(.rich, .rt-area) .rt-c-gray { color: #5b6b7c !important; }
:is(.rich, .rt-area) .rt-c-red { color: #c8102e !important; }
:is(.rich, .rt-area) .rt-c-orange { color: #c8690a !important; }
:is(.rich, .rt-area) .rt-c-gold { color: #b8860b !important; }
:is(.rich, .rt-area) .rt-c-green { color: #0f7b4f !important; }
:is(.rich, .rt-area) .rt-c-teal { color: #0f766e !important; }
:is(.rich, .rt-area) .rt-c-blue { color: #1d4ed8 !important; }
:is(.rich, .rt-area) .rt-c-white { color: #ffffff !important; }

.rt-hl-ink { background: rgba(26, 26, 26, .12); }
.rt-hl-gray { background: rgba(91, 107, 124, .14); }
.rt-hl-red { background: rgba(200, 16, 46, .12); }
.rt-hl-orange { background: rgba(200, 105, 10, .14); }
.rt-hl-gold { background: rgba(184, 134, 11, .16); }
.rt-hl-green { background: rgba(15, 123, 79, .13); }
.rt-hl-teal { background: rgba(15, 118, 110, .13); }
.rt-hl-blue { background: rgba(29, 78, 216, .12); }

/* ------------------------------ 字号 ------------------------------- */

:is(.rich, .rt-area) .rt-s-1 { font-size: 13px !important; }
:is(.rich, .rt-area) .rt-s-2 { font-size: 15px !important; }
:is(.rich, .rt-area) .rt-s-3 { font-size: 16.5px !important; }
:is(.rich, .rt-area) .rt-s-4 { font-size: 18px !important; }
:is(.rich, .rt-area) .rt-s-5 { font-size: 22px !important; }
:is(.rich, .rt-area) .rt-s-6 { font-size: 28px !important; }

/* ------------------------------ 字体 ------------------------------- */

:is(.rich, .rt-area) .rt-f-song { font-family: "Songti SC", "SimSun", "STSong", "Noto Serif SC", serif !important; }
:is(.rich, .rt-area) .rt-f-hei { font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif !important; }
:is(.rich, .rt-area) .rt-f-kai { font-family: "KaiTi", "STKaiti", "Kaiti SC", serif !important; }
:is(.rich, .rt-area) .rt-f-mono { font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace !important; }

/* ------------------------------ 字形 ------------------------------- */

:is(.rich, .rt-area) .rt-b { font-weight: 700 !important; }
:is(.rich, .rt-area) .rt-i { font-style: italic !important; }
:is(.rich, .rt-area) .rt-u { text-decoration: underline !important; text-underline-offset: 2px; }

/* ------------------------------ 对齐 ------------------------------- */

:is(.rich, .rt-area) .rt-a-c { text-align: center !important; }
:is(.rich, .rt-area) .rt-a-r { text-align: right !important; }
:is(.rich, .rt-area) .rt-a-j { text-align: justify !important; }

/* ==========================================================================
   后台编辑器外壳（仅 /admin 页面出现）
   ========================================================================== */

.field--richtext { grid-column: 1 / -1; }

.rt {
  border: 1px solid #d8e1e9; border-radius: 10px; background: #fff;
  overflow: hidden; transition: border-color .16s, box-shadow .16s;
}
.rt:focus-within { border-color: #9fc4dc; box-shadow: 0 0 0 3px rgba(15, 139, 132, .08); }

.rt-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  padding: 7px 9px; background: #f6f9fc; border-bottom: 1px solid #e3e9ef;
}
.rt-btn {
  min-width: 30px; height: 29px; padding: 0 8px; line-height: 1;
  border: 1px solid transparent; border-radius: 5px; background: transparent;
  font-size: 12.5px; color: #2b3a4a; cursor: pointer; white-space: nowrap;
}
.rt-btn:hover { background: #e7eff6; border-color: #cfdde8; }
.rt-btn:active { background: #d9e7f1; }
.rt-btn b, .rt-btn i, .rt-btn u, .rt-btn s { font-size: 13px; }

.rt-sel {
  height: 29px; padding: 0 4px; border: 1px solid #cfdde8; border-radius: 5px;
  background: #fff; font-size: 12.5px; color: #2b3a4a; max-width: 118px;
}
.rt-sel--sm { max-width: 84px; }

.rt-sep { width: 1px; height: 17px; margin: 0 5px; background: #dbe5ee; flex: none; }

.rt-colors { display: flex; align-items: center; gap: 3px; }
.rt-dot {
  width: 17px; height: 17px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(11, 37, 69, .22); cursor: pointer;
}
.rt-dot:hover { transform: scale(1.12); }
.rt-dot--ink { background: #1a1a1a; }
.rt-dot--gray { background: #5b6b7c; }
.rt-dot--red { background: #c8102e; }
.rt-dot--orange { background: #c8690a; }
.rt-dot--gold { background: #b8860b; }
.rt-dot--green { background: #0f7b4f; }
.rt-dot--teal { background: #0f766e; }
.rt-dot--blue { background: #1d4ed8; }
.rt-dot--white { background: #fff; }

.rt-area {
  min-height: 280px; max-height: 620px; overflow-y: auto;
  padding: 18px 20px; outline: none;
  font-size: 15px; line-height: 1.85; color: #22313f;
}
.rt-area:empty::before {
  content: "在此输入正文，可设置字体、字号、颜色，插入图片与列表…";
  color: #9aa9b6; pointer-events: none;
}
.rt-area h2 { font-size: 22px; margin: 26px 0 12px; }
.rt-area h3 { font-size: 18px; margin: 22px 0 10px; }
.rt-area h4 { font-size: 16px; margin: 18px 0 8px; }
.rt-area p { margin: 0 0 14px; }
.rt-area ul, .rt-area ol { margin: 0 0 14px; padding-left: 24px; }
.rt-area ul { list-style: disc; }
.rt-area ol { list-style: decimal; }
.rt-area blockquote {
  margin: 16px 0; padding: 10px 16px; border-left: 3px solid #0f8b84;
  background: rgba(15, 139, 132, .06); color: #33475a;
}
.rt-area a { color: #0f766e; text-decoration: underline; }
.rt-area img.rt-img { display: block; max-width: 100%; height: auto; margin: 16px 0; border-radius: 6px; }
.rt-area hr { border: 0; height: 1px; background: #dbe5ee; margin: 22px 0; }

.rt-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 12px; border-top: 1px solid #eef3f8; background: #fbfdfe;
  font-size: 11.5px; color: #8b9aa8;
}
.rt-foot-tip { color: #9aa9b6; }

@media (max-width: 720px) {
  .rt-bar { padding: 6px; }
  .rt-btn { min-width: 28px; padding: 0 6px; }
  .rt-area { min-height: 220px; padding: 14px; }
  .rt-foot-tip { display: none; }
}
