/* ==========================================================================
   学法减分 · 后台富文本编辑器样式
   前缀 re- (rich editor)，与 admin.css 共用 :root 变量
   ========================================================================== */

.re-wrap {
  position: relative;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.re-wrap:focus-within { border-color: #b9cdf0; box-shadow: 0 0 0 3px rgba(47, 127, 243, .08); }

/* 全屏 */
.re-wrap.re-full {
  position: fixed;
  inset: 0;
  z-index: 9998;
  border-radius: 0;
  border: none;
}

.re-wrap.re-full .re-body,
.re-wrap.re-full .re-src { flex: 1; max-height: none !important; }

/* ---------------- 工具栏 ---------------- */
.re-tb {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 8px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border, #e6eaf0);
  user-select: none;
}
.re-tb-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 30px;
}
.re-tb-row + .re-tb-row {
  padding-top: 4px;
  border-top: 1px solid #f0f3f8;
}
.re-tb .re-sep {
  width: 1px;
  height: 18px;
  background: var(--border, #e6eaf0);
  margin: 0 5px;
  flex: none;
}

.re-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: #46536a;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  flex: none;
  transition: background .12s, color .12s, border-color .12s;
}
.re-btn:hover { background: #eef2f8; color: var(--text, #2b3445); }
.re-btn:active { background: #e3eaf5; }
.re-btn.on,
.re-btn.active { background: #e6f0ff; color: var(--primary, #2f7ff3); border-color: #c9ddfb; }
.re-btn:disabled { opacity: .35; cursor: default; background: none; }
.re-btn svg { width: 16px; height: 16px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.re-btn.re-btn-text { width: auto; padding: 0 8px; font-weight: 600; letter-spacing: .3px; }

/* 颜色按钮底部色条 */
.re-btn.re-color-btn { position: relative; flex-direction: column; gap: 1px; }
.re-btn.re-color-btn .re-cbar {
  width: 15px;
  height: 4px;
  border-radius: 1px;
  background: #e74c3c;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

/* 下拉 */
.re-sel {
  height: 30px;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 5px;
  background: #fff;
  color: #46536a;
  font-size: 12.5px;
  padding: 0 4px;
  margin: 0 2px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.re-sel:hover { border-color: #cbd6e6; }
.re-sel:focus { border-color: var(--primary, #2f7ff3); }
.re-sel.re-sel-font { width: 96px; }
.re-sel.re-sel-size { width: 72px; }
.re-sel.re-sel-block { width: 84px; }
.re-sel.re-sel-line { width: 76px; }

/* ---------------- 编辑区 ---------------- */
.re-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  outline: none;
  font-size: 15px;
  line-height: 1.75;
  color: #2b3445;
  word-break: break-word;
  background: #fff;
}
.re-body:empty::before,
.re-body.re-empty::before {
  content: attr(data-placeholder);
  color: #b6c0cd;
  pointer-events: none;
}
.re-body p { margin: 0 0 12px; }
.re-body h1 { font-size: 26px; margin: 20px 0 12px; line-height: 1.35; }
.re-body h2 { font-size: 22px; margin: 18px 0 10px; line-height: 1.35; }
.re-body h3 { font-size: 19px; margin: 16px 0 10px; line-height: 1.4; }
.re-body h4 { font-size: 17px; margin: 14px 0 8px; }
.re-body h5 { font-size: 15.5px; margin: 12px 0 8px; }
.re-body h6 { font-size: 14px; margin: 12px 0 8px; color: #6b7787; }
.re-body ul, .re-body ol { margin: 0 0 12px; padding-left: 24px; }
.re-body li { margin: 4px 0; }
.re-body blockquote {
  margin: 0 0 12px;
  padding: 10px 16px;
  border-left: 3px solid #c9ddfb;
  background: #f7faff;
  color: #55637a;
}
.re-body pre {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #f5f7fa;
  border: 1px solid #e9eef5;
  border-radius: 6px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
}
.re-body code { background: #f2f5f9; padding: 1px 5px; border-radius: 3px; font-family: Consolas, Monaco, monospace; font-size: .92em; color: #c7254e; }
.re-body pre code { background: none; padding: 0; color: inherit; }
.re-body a { color: #2f7ff3; text-decoration: underline; }
.re-body img { max-width: 100%; height: auto; border-radius: 4px; vertical-align: middle; }
.re-body img.re-selected { outline: 2px solid var(--primary, #2f7ff3); outline-offset: 2px; }

/* 视频：编辑区里直接可播，宽度由「视频设置」控制 */
.re-body video {
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  border-radius: 6px;
  background: #0b0f14;
  display: block;
  cursor: pointer;
}
.re-body video:hover { outline: 2px solid rgba(47, 127, 243, .45); outline-offset: 2px; }
.re-body p:has(> video) { margin: 0; }

.re-body hr { border: none; border-top: 1px solid #e2e8f0; margin: 20px 0; }
.re-body table { border-collapse: collapse; width: 100%; margin: 0 0 14px; }
.re-body table th, .re-body table td {
  border: 1px solid #dbe3ee;
  padding: 8px 12px;
  min-width: 40px;
  vertical-align: top;
}
.re-body table th { background: #f5f8fd; font-weight: 600; }
.re-body table.re-stripe tbody tr:nth-child(even) { background: #fafcff; }

/* ---------------- 源码模式 ---------------- */
.re-src {
  display: none;
  flex: 1;
  width: 100%;
  min-height: 260px;
  border: none;
  outline: none;
  resize: none;
  padding: 16px 18px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #2b3445;
  background: #fcfdfe;
  white-space: pre;
  overflow: auto;
}
.re-wrap.re-source .re-body { display: none; }
.re-wrap.re-source .re-src { display: block; }

/* ---------------- 底部状态栏 ---------------- */
.re-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  border-top: 1px solid var(--border, #e6eaf0);
  background: #fafbfc;
  font-size: 12px;
  color: var(--text-3, #9aa5b4);
}
.re-foot .re-stat b { font-weight: 600; color: var(--text-2, #6b7787); }

/* ---------------- 弹出面板（颜色 / 表格 / 链接） ---------------- */
.re-pop {
  position: absolute;
  z-index: 9999;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(20, 32, 51, .14);
  padding: 10px;
  min-width: 196px;
}
.re-pop-title { font-size: 12px; color: var(--text-3, #9aa5b4); margin-bottom: 8px; }
.re-swatches {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  gap: 6px;
}
.re-sw {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, .08);
  transition: transform .1s;
}
.re-sw:hover { transform: scale(1.14); box-shadow: 0 0 0 2px #dce8fb; }
.re-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #f0f3f7;
  font-size: 12px;
  color: var(--text-2, #6b7787);
}
.re-custom input[type="color"] {
  width: 30px;
  height: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0;
  background: none;
  cursor: pointer;
}
.re-pop input.re-inp {
  width: 100%;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 0 9px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.re-pop input.re-inp:focus { border-color: var(--primary, #2f7ff3); }
.re-pop .re-pop-foot { display: flex; gap: 8px; margin-top: 10px; }
.re-pop .re-pop-foot button {
  flex: 1;
  height: 30px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
}
.re-pop .re-pop-foot button.re-ok { background: var(--primary, #2f7ff3); border-color: var(--primary, #2f7ff3); color: #fff; }
.re-pop .re-pop-foot button:hover { filter: brightness(.96); }

/* 表格网格选择器 */
.re-grid-pick { display: grid; gap: 3px; margin-top: 2px; }
.re-grid-pick i {
  width: 16px;
  height: 16px;
  border: 1px solid #d5dee9;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  display: block;
}
.re-grid-pick i.hot { background: #d9e8ff; border-color: #a9c8f5; }

/* ---------------- 上传进度遮罩 ---------------- */
.re-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  font-size: 13px;
  color: var(--text-2, #6b7787);
  gap: 10px;
}
.re-loading .re-spin {
  width: 18px;
  height: 18px;
  border: 2px solid #d8e2f0;
  border-top-color: var(--primary, #2f7ff3);
  border-radius: 50%;
  animation: re-rotate .8s linear infinite;
}
@keyframes re-rotate { to { transform: rotate(360deg); } }

/* 小屏幕 */
@media (max-width: 900px) {
  .re-btn { width: 28px; height: 28px; }
  .re-body { padding: 14px; }
}
