/* 全局 Markdown 富文本编辑器 */
.rich-editor-shell,
.rich-editor-toolbar-host.rich-editor-shell {
  --xm-re-btn-size: 32px;
  --xm-re-icon-size: 18px;
  --xm-re-btn-radius: 8px;
}

.rich-editor-shell {
  position: relative;
  width: 100%;
  min-width: 0;
}

.rich-editor-shell .EasyMDEContainer {
  display: flex;
  flex-direction: column;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
  min-height: 0;
}

.rich-editor-shell .EasyMDEContainer .editor-toolbar {
  flex: 0 0 auto;
}

.rich-editor-shell .EasyMDEContainer .CodeMirror {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
}

.rich-editor-shell .EasyMDEContainer:focus-within {
  border-color: var(--td-primary, #1890ff);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.12);
}

/* 工具栏：ChatGPT 风格深色描边图标，容器内居中 */
.rich-editor-shell .editor-toolbar {
  position: relative;
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid #ececec;
  background: #fff;
  padding: 8px 10px;
  opacity: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 2px 1px;
  overflow: visible;
}

.rich-editor-shell .editor-toolbar button.preview,
.rich-editor-shell .editor-toolbar button.guide,
.rich-editor-shell .editor-toolbar button.xm-i-preview,
.rich-editor-shell .editor-toolbar button.xm-i-help {
  display: none !important;
}

.rich-editor-shell .editor-toolbar button.xm-re-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: var(--xm-re-btn-size) !important;
  height: var(--xm-re-btn-size) !important;
  min-width: var(--xm-re-btn-size) !important;
  margin: 0 1px;
  padding: 0 !important;
  color: #0d0d0d !important;
  border: 0 !important;
  border-radius: var(--xm-re-btn-radius) !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  font-size: 0 !important;
  line-height: 0 !important;
  vertical-align: middle;
}

.rich-editor-shell .editor-toolbar button.xm-re-fullscreen-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: var(--xm-re-btn-size) !important;
  height: var(--xm-re-btn-size) !important;
  min-width: var(--xm-re-btn-size) !important;
  padding: 0 !important;
  color: #0d0d0d !important;
  border: 0 !important;
  border-radius: var(--xm-re-btn-radius) !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  cursor: pointer;
}

.rich-editor-shell .editor-toolbar button {
  position: relative;
}

.rich-editor-shell .editor-toolbar button .xm-re-ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--xm-re-icon-size);
  height: var(--xm-re-icon-size);
  flex: 0 0 var(--xm-re-icon-size);
  pointer-events: none;
}

.rich-editor-shell .editor-toolbar button .xm-re-ic svg {
  display: block;
  width: var(--xm-re-icon-size);
  height: var(--xm-re-icon-size);
  color: inherit;
  stroke: currentColor;
  fill: none;
  shape-rendering: geometricPrecision;
}

.rich-editor-shell .editor-toolbar button .xm-re-ic svg [fill]:not([fill="none"]) {
  fill: currentColor;
  stroke: none;
}

.rich-editor-shell .editor-toolbar button .xm-re-ic svg .xm-tb-glyph,
.rich-editor-shell .editor-toolbar button .xm-re-ic svg .xm-quote-mark {
  fill: currentColor;
  stroke: none;
}

.rich-editor-shell .editor-toolbar button .xm-re-ic svg .xm-tb-accent {
  fill: #ff4d4f;
  stroke: none;
}

.rich-editor-shell .editor-toolbar button.attachment .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.emoji .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.ordered-list .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.bold .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.italic .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.strikethrough .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.text-color .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.inline-code .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.table .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.link .xm-re-ic svg,
.rich-editor-shell .editor-toolbar button.image .xm-re-ic svg {
  stroke: none;
}

.rich-editor-shell .editor-toolbar button.quote .xm-re-ic svg {
  stroke: none;
}

.rich-editor-shell .editor-toolbar button.quote .xm-re-ic svg .xm-quote-mark {
  fill: currentColor;
  stroke: none;
}

.rich-editor-shell .editor-toolbar button.xm-re-fullscreen-btn .xm-fs-svg {
  display: block;
  width: var(--xm-re-icon-size);
  height: var(--xm-re-icon-size);
  flex: 0 0 var(--xm-re-icon-size);
  color: inherit;
  shape-rendering: geometricPrecision;
}

.rich-editor-shell .editor-toolbar button.xm-re-fullscreen-btn .xm-fs-svg .xm-tb-glyph {
  fill: currentColor;
  stroke: none;
}

.rich-editor-shell .editor-toolbar button.xm-re-text-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 34px !important;
  height: var(--xm-re-btn-size) !important;
  padding: 0 10px !important;
  margin-right: 2px;
  font-size: 13px !important;
  line-height: 1 !important;
  font-weight: 600 !important;
  color: #0d0d0d !important;
  letter-spacing: .01em;
  border-radius: var(--xm-re-btn-radius) !important;
  background-color: transparent !important;
}

.rich-editor-shell .editor-toolbar button.xm-re-heading-trigger {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto !important;
  min-width: 72px !important;
  height: var(--xm-re-btn-size) !important;
  min-height: var(--xm-re-btn-size) !important;
  padding: 0 10px !important;
  margin-right: 2px;
  font-size: 13px !important;
  line-height: 1 !important;
  font-weight: 600 !important;
  color: #0d0d0d !important;
  border-radius: var(--xm-re-btn-radius) !important;
  background-color: transparent !important;
}

.rich-editor-shell .editor-toolbar button.xm-re-heading-trigger .xm-re-heading-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: #0d0d0d;
}

.rich-editor-shell .editor-toolbar button.xm-re-heading-trigger .xm-re-heading-chevron {
  width: 10px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%230d0d0d' stroke-width='2' stroke-linecap='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: .9;
}

.rich-editor-shell .editor-toolbar button.xm-re-heading-trigger.active,
.rich-editor-shell .editor-toolbar button.xm-re-heading-trigger:hover {
  color: #0d0d0d !important;
  background-color: rgba(0, 0, 0, 0.06) !important;
}

.rich-editor-shell .editor-toolbar button::before,
.rich-editor-shell .editor-toolbar button::after {
  display: none !important;
  content: none !important;
}

.rich-editor-shell .editor-toolbar button[data-tip]:hover::after,
.rich-editor-shell .editor-toolbar button[data-tip]:focus-visible::after {
  display: block !important;
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  z-index: 30;
  padding: 5px 9px;
  border-radius: 6px;
  color: #13243a;
  background: #fff;
  border: 1px solid #dbe7f6;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
  box-shadow: 0 6px 18px rgba(15, 35, 70, .12);
}

.rich-editor-shell .editor-toolbar button.xm-re-icon:hover,
.rich-editor-shell .editor-toolbar button.xm-re-icon:active,
.rich-editor-shell .editor-toolbar button.xm-re-fullscreen-btn:hover,
.rich-editor-shell .editor-toolbar button.xm-re-fullscreen-btn:active {
  background-color: rgba(0, 0, 0, 0.06) !important;
  color: #0d0d0d !important;
  border-color: transparent !important;
}

/* 格式图标不保留 EasyMDE 误加的 .active 高亮（斜体 * 会连带亮粗体） */
.rich-editor-shell .editor-toolbar button.xm-re-icon.active {
  background-color: transparent !important;
  color: #0d0d0d !important;
  border-color: transparent !important;
}

.rich-editor-shell .editor-toolbar i.separator {
  display: inline-block !important;
  align-self: center;
  flex: 0 0 auto;
  width: 1px;
  height: 20px;
  margin: 0 5px;
  border: 0;
  background: #e3e3e3;
  opacity: 1;
}

/* 隐藏 EasyMDE 默认 FontAwesome，保留自定义图标按钮 */
.rich-editor-shell .editor-toolbar button .fa {
  display: none !important;
}

/* 覆盖 EasyMDE 默认按钮边框与字重 */
.rich-editor-shell .editor-toolbar button {
  border: 0 !important;
  font-weight: 400 !important;
  white-space: nowrap;
}

.rich-editor-shell .editor-toolbar button.active {
  border: 0 !important;
}

.xm-re-toolbar-spacer {
  flex: 1 1 12px;
  width: auto;
  min-width: 8px;
  height: 1px;
  margin: 0 2px;
}

.rich-editor-shell .editor-toolbar .xm-re-fullscreen-btn {
  margin-left: 0;
}

/* 全屏按钮：工具栏最右侧（图2放大 / 图3缩小） */
.xm-re-heading-panel {
  display: grid;
  gap: 2px;
  min-width: 168px;
  padding: 6px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.xm-re-heading-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  color: #3d4f6f;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.xm-re-heading-item:hover,
.xm-re-heading-item.is-active {
  background: rgba(24, 144, 255, 0.1);
  color: #1677ff;
}
.xm-re-heading-item[data-level="1"] { font-size: 22px; font-weight: var(--weight-display); line-height: 1.2; }
.xm-re-heading-item[data-level="2"] { font-size: 18px; font-weight: var(--weight-display); line-height: 1.25; }
.xm-re-heading-item[data-level="3"] { font-size: 16px; font-weight: var(--weight-strong); line-height: 1.3; }
.xm-re-heading-item[data-level="4"] { font-size: 15px; font-weight: var(--weight-strong); line-height: 1.3; }
.xm-re-heading-item[data-level="5"] { font-size: 14px; font-weight: var(--weight-strong); line-height: 1.35; }
.xm-re-heading-item[data-level="6"] { font-size: 13px; font-weight: 600; line-height: 1.35; }

/* 编辑区：隐藏 Markdown 标记，呈现接近所见即所得的效果 */
.rich-editor-shell .CodeMirror,
.rich-editor-shell .CodeMirror pre.CodeMirror-line,
.rich-editor-shell .CodeMirror pre.CodeMirror-line-like {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif !important;
}

.rich-editor-shell .CodeMirror .cm-formatting-strong,
.rich-editor-shell .CodeMirror .cm-formatting-em,
.rich-editor-shell .CodeMirror .cm-formatting-strikethrough,
.rich-editor-shell .CodeMirror .cm-formatting.cm-strong,
.rich-editor-shell .CodeMirror .cm-formatting.cm-em,
.rich-editor-shell .CodeMirror .cm-formatting.cm-strikethrough,
.rich-editor-shell .CodeMirror .cm-formatting-code,
.rich-editor-shell .CodeMirror .cm-formatting-link,
.rich-editor-shell .CodeMirror .cm-formatting-url,
.rich-editor-shell .CodeMirror .cm-formatting-list,
.rich-editor-shell .CodeMirror .cm-formatting-list-ul,
.rich-editor-shell .CodeMirror .cm-formatting-header,
.rich-editor-shell .CodeMirror .cm-formatting.cm-formatting-strong {
  display: inline !important;
  width: 0 !important;
  max-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  color: transparent !important;
  font-size: 0 !important;
  vertical-align: baseline !important;
  pointer-events: none !important;
  user-select: none !important;
  text-decoration: none !important;
  font-style: normal !important;
  font-weight: inherit !important;
}

.rich-editor-shell .CodeMirror .cm-strong,
.rich-editor-shell .CodeMirror span.cm-strong {
  font-weight: var(--weight-strong) !important;
}

.rich-editor-shell .CodeMirror span.cm-header-1.cm-strong,
.rich-editor-shell .CodeMirror span.cm-header-2.cm-strong,
.rich-editor-shell .CodeMirror span.cm-header-3.cm-strong,
.rich-editor-shell .CodeMirror span.cm-header-4.cm-strong,
.rich-editor-shell .CodeMirror span.cm-header-5.cm-strong,
.rich-editor-shell .CodeMirror span.cm-header-6.cm-strong {
  font-weight: inherit !important;
}

.rich-editor-shell .CodeMirror .cm-em:not(.cm-formatting):not(.cm-formatting-em) {
  font-style: italic;
}

.rich-editor-shell .CodeMirror .cm-strikethrough:not(.cm-formatting-strikethrough):not(.cm-formatting) {
  text-decoration: line-through;
}

.rich-editor-shell .CodeMirror span.cm-comment {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace !important;
  font-size: 0.9em;
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: baseline;
}

.rich-editor-shell .CodeMirror .cm-link {
  color: var(--td-primary, #1677ff);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rich-editor-shell .CodeMirror .cm-url {
  display: inline !important;
  width: 0 !important;
  max-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  vertical-align: baseline !important;
  pointer-events: none !important;
}

/* 有序列表：保留并强化序号显示 */
.rich-editor-shell .CodeMirror .cm-formatting-list-ol {
  display: inline !important;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  margin: 0 4px 0 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  opacity: 1 !important;
  color: #111 !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 22px !important;
  vertical-align: middle !important;
  pointer-events: none !important;
}

.rich-editor-shell .CodeMirror-lines {
  padding: 8px 10px 6px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line {
  padding: 0;
  line-height: 22px;
  min-height: 22px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line > span[role="presentation"] {
  display: inline;
  padding: 0 !important;
  line-height: inherit;
  vertical-align: baseline;
  text-align: left;
}

.rich-editor-shell .CodeMirror-cursor {
  height: 22px !important;
  margin-top: 0 !important;
}

.rich-editor-shell .CodeMirror-selectedtext {
  vertical-align: baseline;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-1) {
  line-height: 34px;
  min-height: 34px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-2) {
  line-height: 30px;
  min-height: 30px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-3) {
  line-height: 26px;
  min-height: 26px;
  padding-top: 2px;
  padding-bottom: 2px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-4) {
  line-height: 24px;
  min-height: 24px;
  padding-top: 2px;
  padding-bottom: 2px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-5) {
  line-height: 22px;
  min-height: 22px;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-6) {
  line-height: 21px;
  min-height: 21px;
}

.rich-editor-shell .CodeMirror span.cm-header-1 {
  display: inline-block;
  font-size: 26px !important;
  font-weight: var(--weight-display) !important;
  line-height: 34px !important;
  vertical-align: middle;
}

.rich-editor-shell .CodeMirror span.cm-header-2 {
  display: inline-block;
  font-size: 22px !important;
  font-weight: var(--weight-display) !important;
  line-height: 30px !important;
  vertical-align: middle;
}

.rich-editor-shell .CodeMirror span.cm-header-3 {
  display: inline-block;
  font-size: 18px !important;
  font-weight: var(--weight-strong) !important;
  line-height: 26px !important;
  vertical-align: middle;
}

.rich-editor-shell .CodeMirror span.cm-header-4 {
  display: inline-block;
  font-size: 16px !important;
  font-weight: var(--weight-strong) !important;
  line-height: 24px !important;
  vertical-align: middle;
}

.rich-editor-shell .CodeMirror span.cm-header-5 {
  display: inline-block;
  font-size: 14px !important;
  font-weight: var(--weight-strong) !important;
  line-height: 22px !important;
  vertical-align: middle;
}

.rich-editor-shell .CodeMirror span.cm-header-6 {
  display: inline-block;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 21px !important;
  vertical-align: middle;
}

.xm-re-float-panel {
  position: fixed;
  z-index: 10180;
}

.xm-re-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 0 2px 4px;
}

.xm-re-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid #e8edf3;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
}

.xm-re-attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xm-re-attach-remove {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.xm-re-attach-remove:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #64748b;
}

.xm-re-link-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10200;
  background: rgba(3, 17, 32, 0.35);
}

.xm-re-link-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10210;
  display: grid;
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  padding: 20px 22px 18px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(4, 29, 58, 0.22);
  transform: translate(-50%, -50%);
}

.xm-re-link-title {
  margin: 0;
  font-size: 16px;
  font-weight: var(--weight-strong);
  color: #13243a;
}

.xm-re-link-field {
  display: grid;
  gap: 6px;
}

.xm-re-link-label {
  font-size: 12px;
  font-weight: 600;
  color: #5c6b7e;
}

.xm-re-link-text,
.xm-re-link-url {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  color: #13243a;
  background: #fff;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  box-sizing: border-box;
}

.xm-re-link-text:focus,
.xm-re-link-url:focus {
  border-color: var(--td-primary, #1890ff);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.12);
}

.xm-re-link-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.xm-re-link-cancel,
.xm-re-link-confirm {
  min-width: 72px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.xm-re-link-cancel {
  border: 1px solid #dbe3ee;
  color: #4a5b70;
  background: #fff;
}

.xm-re-link-cancel:hover {
  border-color: #c5d2e0;
  background: #f7f9fc;
}

.xm-re-link-confirm {
  border: 0;
  color: #fff;
  background: var(--td-primary, #1677ff);
}

.xm-re-link-confirm:hover {
  background: #4096ff;
}

.xm-re-table-grid-panel {
  padding: 12px 14px;
  border: 1px solid #c8ddf8;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 35, 70, .18);
}

.xm-re-table-grid-preview {
  margin-bottom: 8px;
  color: #526173;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.xm-re-table-grid {
  display: grid;
  grid-template-columns: repeat(8, 22px);
  grid-template-rows: repeat(8, 22px);
  gap: 4px;
  padding: 4px;
  border: 1px dashed #dbe7f6;
  border-radius: 8px;
  background: #f8fbff;
}

.xm-re-table-grid-cell {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px dashed #9eb3cb;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: background .1s ease, border-color .1s ease, box-shadow .1s ease;
}

.xm-re-table-grid-cell.is-active {
  border-style: solid;
  border-color: #1677ff;
  background: rgba(22, 119, 255, .2);
  box-shadow: inset 0 0 0 1px rgba(22, 119, 255, .25);
}

/* 编辑器内图片预览 */
.xm-cm-image-ph {
  display: inline-block;
  width: 0;
  height: 0;
  overflow: hidden;
  font-size: 0;
  line-height: 0;
  vertical-align: top;
  pointer-events: none;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.xm-cm-image-ph) {
  line-height: 0;
  min-height: 0;
  max-height: 1px;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.rich-editor-shell .CodeMirror-widget .xm-cm-image-widget,
.rich-editor-shell .CodeMirror-linewidget .xm-cm-image-widget {
  display: block;
  margin: 4px 0 8px;
  max-width: 100%;
  pointer-events: auto;
}

.xm-cm-image-widget {
  display: block;
  margin: 4px 0 8px;
  max-width: 100%;
  pointer-events: auto;
}

.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.xm-cm-attachment-widget) {
  min-height: 1.6em;
}

.xm-cm-image-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}

.xm-cm-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, .72);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
}

.xm-cm-image-widget:hover .xm-cm-image-remove {
  display: block;
}

.xm-cm-image-remove:hover {
  background: #ef4444;
}

.xm-cm-image-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid #e5ebf3;
  background: #f8fafc;
  object-fit: contain;
}

.xm-cm-image-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #1677ff 50%);
  border-radius: 0 0 4px 0;
  opacity: 0.85;
}

/* 编辑器内真实 HTML 表格 */
.xm-cm-table-widget {
  display: block;
  margin: 8px 0;
  max-width: 100%;
  overflow-x: auto;
  pointer-events: auto;
  user-select: text;
}

.xm-cm-table-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  padding: 4px 6px;
  border: 1px solid #e5ebf3;
  border-radius: 6px;
  background: #f8fafc;
}

.xm-cm-table-tool {
  height: 26px;
  padding: 0 10px;
  border: 1px solid #d9e2ef;
  border-radius: 4px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.xm-cm-table-tool:hover {
  border-color: #1677ff;
  color: #1677ff;
  background: #f0f7ff;
}

.xm-cm-table-tool-sep {
  width: 1px;
  height: 16px;
  margin: 0 2px;
  background: #dbe3ef;
}

.xm-cm-table-tool-hint {
  margin-left: auto;
  color: #94a3b8;
  font-size: 11px;
  white-space: nowrap;
}

.xm-cm-table-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 4px;
}

.xm-cm-table-foot-label {
  color: #94a3b8;
  font-size: 11px;
  line-height: 24px;
  margin-right: 2px;
}

.xm-cm-table-foot-sep {
  width: 1px;
  height: 16px;
  margin: 0 2px;
  background: #dbe3ef;
}

.xm-cm-table-foot-btn {
  height: 24px;
  min-width: 24px;
  padding: 0 8px;
  border: 1px solid #d9e2ef;
  border-radius: 4px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.xm-cm-table-foot-btn:hover {
  border-color: #91caff;
  background: #f0f7ff;
  color: #1677ff;
}

.xm-cm-table-widget table,
.rich-content table.xm-md-table,
.rich-content .xm-md-table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

.xm-cm-table-widget table {
  min-width: 240px;
  width: max-content;
}

.xm-cm-table-widget th,
.xm-cm-table-widget td,
.rich-content table.xm-md-table th,
.rich-content table.xm-md-table td,
.rich-content .xm-md-table th,
.rich-content .xm-md-table td {
  border: 1px solid #d9e2ef;
  padding: 8px 10px;
  vertical-align: top;
  word-break: break-word;
  min-width: 72px;
  pointer-events: auto;
  user-select: text;
  cursor: text;
}

.xm-cm-table-widget th,
.rich-content table.xm-md-table th,
.rich-content .xm-md-table th {
  background: #f5f8fc;
  color: #1f2a37;
  font-weight: 600;
  text-align: left;
}

.xm-cm-table-widget td:empty::before,
.xm-cm-table-widget th:empty::before {
  content: "\00a0";
}

.xm-cm-table-widget td:focus,
.xm-cm-table-widget th:focus {
  outline: 2px solid rgba(24, 144, 255, 0.28);
  outline-offset: -2px;
  background: #fafcff;
}

.xm-cm-table-widget th.xm-cell-selected,
.xm-cm-table-widget td.xm-cell-selected {
  background: rgba(22, 119, 255, 0.12) !important;
  box-shadow: inset 0 0 0 2px rgba(22, 119, 255, 0.35);
}

.xm-cm-table-widget.is-drag-selecting th,
.xm-cm-table-widget.is-drag-selecting td {
  cursor: cell;
  user-select: none;
}

.xm-cm-table-widget th.xm-cell-align-center,
.xm-cm-table-widget td.xm-cell-align-center,
.rich-content table.xm-md-table th.xm-cell-align-center,
.rich-content table.xm-md-table td.xm-cell-align-center,
.rich-content .xm-md-table th.xm-cell-align-center,
.rich-content .xm-md-table td.xm-cell-align-center,
.td-desc.rich-content table.xm-md-table th.xm-cell-align-center,
.td-desc.rich-content table.xm-md-table td.xm-cell-align-center {
  text-align: center;
  vertical-align: middle;
}

.xm-cm-table-widget th.xm-cell-valign-middle,
.xm-cm-table-widget td.xm-cell-valign-middle,
.rich-content table.xm-md-table th.xm-cell-valign-middle,
.rich-content table.xm-md-table td.xm-cell-valign-middle,
.rich-content .xm-md-table th.xm-cell-valign-middle,
.rich-content .xm-md-table td.xm-cell-valign-middle,
.td-desc.rich-content table.xm-md-table th.xm-cell-valign-middle,
.td-desc.rich-content table.xm-md-table td.xm-cell-valign-middle {
  vertical-align: middle !important;
}

.rich-content table.xm-md-table,
.rich-content .xm-md-table {
  margin: 8px 0;
}

.xm-fs-svg {
  display: block;
  pointer-events: none;
}

/* 表情面板 */
.xm-re-emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 32px);
  gap: 4px;
  padding: 10px;
  border: 1px solid #c8ddf8;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 35, 70, .18);
}

.xm-re-emoji-item {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 18px;
  line-height: 32px;
  cursor: pointer;
}

.xm-re-emoji-item:hover {
  background: rgba(24, 144, 255, 0.1);
}

/* 编辑区 */
.rich-editor-shell .EasyMDEContainer .CodeMirror-wrap {
  flex: 1;
  min-height: 0;
}

.rich-editor-shell .EasyMDEContainer .CodeMirror {
  padding: 0 !important;
  box-sizing: border-box;
}

.rich-editor-shell .EasyMDEContainer .CodeMirror pre.CodeMirror-line,
.rich-editor-shell .EasyMDEContainer .CodeMirror pre.CodeMirror-line-like {
  padding: 0 !important;
}

.rich-editor-shell .CodeMirror {
  border: 0;
  min-height: 88px;
  height: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--td-text, rgba(0, 0, 0, 0.88));
  background: #fff;
  cursor: text;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

.rich-editor-shell .CodeMirror-placeholder {
  left: 10px !important;
  right: auto !important;
  width: calc(100% - 20px);
  max-width: calc(100% - 20px);
  top: 8px !important;
  padding: 0 !important;
  box-sizing: border-box;
  pointer-events: none;
  white-space: normal;
  overflow: hidden;
}

.rich-editor-shell .CodeMirror-placeholder .xm-ph-attach-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin: 0 1px;
  vertical-align: -2px;
  color: #b4b4b8;
}

.rich-editor-shell .CodeMirror-placeholder .xm-ph-attach-icon svg {
  display: block;
  width: 14px;
  height: 14px;
}

.rich-editor-shell .CodeMirror-placeholder .xm-ph-attach-icon svg .xm-tb-glyph {
  fill: currentColor;
  stroke: none;
}

.rich-editor-shell .CodeMirror,
.rich-editor-shell .CodeMirror-scroll {
  direction: ltr;
  text-align: left;
}

.rich-editor-shell .CodeMirror-sizer {
  min-width: 0 !important;
  margin-left: 0 !important;
}

.rich-editor-shell .CodeMirror-empty .CodeMirror-line {
  min-width: 0;
}

.rich-editor-shell .CodeMirror-empty pre.CodeMirror-line > span[role="presentation"] {
  display: inline-block;
  width: 0;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  vertical-align: top;
  text-align: left;
}

.rich-editor-shell .CodeMirror:not(.CodeMirror-empty) pre.CodeMirror-line > span[role="presentation"] {
  display: inline;
  width: auto;
  min-width: 0;
}

.rich-editor-shell textarea.rich-editor-bound {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

.rich-editor-shell .CodeMirror-scroll {
  min-height: 88px;
  padding-bottom: 0 !important;
  resize: none;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  box-sizing: border-box;
}

/* 带底栏的编写区：工具栏顶、正文滚动、底栏固定 */
.rich-editor-compose {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rich-editor-compose > .create-textarea-wrap.rich-editor-shell,
.rich-editor-compose > .create-textarea-wrap.rich-editor-field {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.rich-editor-compose > .rich-compose-footer,
.rich-editor-compose > .create-mention-actions,
.rich-editor-compose > .sheet-compose-footer {
  flex: 0 0 auto;
}

.rich-editor-in-compose.rich-editor-shell.is-ready .EasyMDEContainer {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}

.rich-editor-in-compose.rich-editor-shell.is-ready .editor-toolbar {
  flex: 0 0 auto;
}

.rich-editor-shell .CodeMirror-vscrollbar,
.rich-editor-shell .CodeMirror-hscrollbar,
.rich-editor-shell .CodeMirror-scrollbar-filler {
  display: none !important;
}

.rich-editor-shell .editor-preview,
.rich-editor-shell .editor-preview-side {
  display: none !important;
}

.rich-editor-shell .editor-statusbar { display: none; }

/* 放大输入区：A4 纸浮窗，卡片内浅灰衬底；外层透明不遮罩系统 */
.xm-re-enlarge-overlay {
  --xm-re-page-w: 840px;
  --xm-re-card-w: 880px;
  --xm-re-a4-h: calc(var(--xm-re-page-w) * 297 / 210);
  position: fixed;
  inset: 0;
  z-index: 10090;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  box-sizing: border-box;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

/* 任务操作侧栏打开时，放大浮窗靠左排布，避免挡住侧栏底部「取消/提交」 */
body.has-task-action-panel .xm-re-enlarge-overlay.is-visible {
  --xm-re-card-w: min(880px, calc(100vw - var(--task-drawer-compact-width, 320px) - var(--task-action-panel-width, var(--panel-width, 420px)) - 48px));
  --xm-re-page-w: min(840px, calc(var(--xm-re-card-w) - 40px));
  justify-content: flex-start;
  align-items: center;
  padding-left: 24px;
  padding-right: calc(var(--task-drawer-compact-width, 320px) + var(--task-action-panel-width, var(--panel-width, 420px)) + 16px);
}

body.has-task-action-panel .xm-re-enlarge-overlay.is-visible .xm-re-enlarge-footer .create-mention-actions {
  max-width: 100%;
}

.xm-re-enlarge-overlay.is-visible {
  opacity: 1;
  pointer-events: none;
}

.xm-re-enlarge-shell {
  display: flex;
  flex-direction: column;
  width: min(var(--xm-re-card-w), calc(100vw - 48px));
  max-width: 100%;
  height: min(96vh, calc(var(--xm-re-a4-h) + 168px));
  max-height: 96vh;
  min-height: min(92vh, calc(var(--xm-re-a4-h) + 148px));
  margin: 0;
  border: 1px solid #dfe3e8;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 56px rgba(15, 35, 62, .16), 0 6px 20px rgba(15, 35, 62, .1);
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: auto;
}

.xm-re-enlarge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid #eceef2;
  background: #fff;
}

.xm-re-enlarge-title {
  color: #161823;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xm-re-enlarge-close {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  color: rgba(0, 0, 0, .75);
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.xm-re-enlarge-close:hover {
  color: #1677ff;
  border-color: #91caff;
  background: #f0f7ff;
}

.xm-re-enlarge-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 4px 16px 6px;
  border-bottom: 1px solid #ececec;
  background: #fff;
  overflow: visible;
}

.rich-editor-toolbar-host.rich-editor-shell {
  display: block;
  width: min(var(--xm-re-page-w), 100%);
  min-width: 0;
  margin: 0 auto;
  position: static;
  border: 0;
  padding: 0;
  background: transparent;
  overflow: visible;
}

.xm-re-enlarge-toolbar .editor-toolbar {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 2px 4px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: #fff !important;
  cursor: default;
  user-select: none;
  flex-wrap: wrap;
  overflow: visible;
}

.xm-re-enlarge-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 16px;
  background: #eef0f3;
  -webkit-overflow-scrolling: touch;
}

.xm-re-enlarge-paper {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: min(var(--xm-re-page-w), 100%);
  min-height: var(--xm-re-a4-h);
  margin: 0 auto;
  padding: 36px 48px 40px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 35, 62, .06), 0 6px 20px rgba(15, 35, 62, .08);
  box-sizing: border-box;
}

.xm-re-enlarge-footer {
  flex: 0 0 auto;
  border-top: 1px solid #eceef2;
  background: #fff;
}

.xm-re-enlarge-footer:not([hidden]) {
  display: flex;
  justify-content: center;
  padding: 8px 16px 10px;
}

.xm-re-enlarge-footer .rich-compose-footer,
.xm-re-enlarge-footer .create-mention-actions,
.xm-re-enlarge-footer .create-desc-toolbar,
.xm-re-enlarge-footer .create-desc-preview {
  width: min(var(--xm-re-page-w), 100%);
  max-width: 100%;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
}

.xm-re-enlarge-footer .rich-compose-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 0;
  padding-bottom: 0;
}

.rich-editor-shell.is-enlarge-window {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.rich-editor-shell.is-enlarge-window .EasyMDEContainer {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden;
}

.rich-editor-shell.is-enlarge-window .EasyMDEContainer:focus-within {
  border: 0 !important;
  box-shadow: none !important;
}

.rich-editor-shell.is-enlarge-window .CodeMirror {
  flex: 1 1 auto;
  min-height: 0 !important;
  height: auto !important;
  background: transparent !important;
}

.rich-editor-shell.is-enlarge-window .CodeMirror-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.rich-editor-shell.is-enlarge-window .CodeMirror-lines {
  padding: 0 !important;
}

.rich-editor-shell.is-enlarge-window .CodeMirror pre.CodeMirror-line {
  color: #161823;
  font-size: 15px;
  line-height: 1.75;
}

.rich-editor-shell.is-enlarge-window .CodeMirror-placeholder {
  left: 0 !important;
  right: 0 !important;
  color: #b4b4b8 !important;
  font-size: 15px !important;
  line-height: 1.75 !important;
}

@media (max-width: 720px) {
  .xm-re-enlarge-overlay {
    padding: 12px 10px;
  }
  .xm-re-enlarge-shell {
    width: 100%;
    height: min(94vh, calc(var(--xm-re-a4-h) + 140px));
    min-height: min(88vh, 640px);
  }
  .xm-re-enlarge-stage {
    padding: 10px;
  }
  .xm-re-enlarge-paper {
    min-height: calc(100vw * 297 / 210);
    padding: 24px 20px 28px;
  }
}

.rich-editor-shell.is-compact .CodeMirror,
.rich-editor-shell.is-compact .CodeMirror-scroll {
  min-height: 88px;
}

.create-textarea-wrap > .rich-editor-shell + .create-desc-toolbar,
.td-compose-field > .rich-editor-shell + .create-mention-actions,
.td-compose-field > .EasyMDEContainer + .create-mention-actions,
.td-compose-field > .rich-editor-shell + .create-mention-picker,
.td-compose-field > .rich-editor-shell + .td-compose-toolbar {
  margin-top: 8px;
}

/* Markdown 展示 */
.rich-content {
  color: rgba(0, 0, 0, 0.65);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.rich-content > :first-child { margin-top: 0; }
.rich-content > :last-child { margin-bottom: 0; }

.rich-content p,
.rich-content ul,
.rich-content ol,
.rich-content pre,
.rich-content blockquote {
  margin: 0 0 8px;
}

.rich-content ul,
.rich-content ol {
  padding-left: 1.4em;
}

.rich-content blockquote {
  padding: 4px 10px;
  border-left: 3px solid #d6e4ff;
  color: rgba(0, 0, 0, 0.55);
  background: #fafcff;
}

.rich-content pre {
  padding: 8px 10px;
  border-radius: 4px;
  background: #f5f7fa;
  overflow-x: auto;
}

.rich-content code {
  padding: 1px 4px;
  border-radius: 3px;
  background: #f5f7fa;
  font-size: 12px;
}

.rich-content pre code {
  padding: 0;
  background: transparent;
}

.rich-content a {
  color: var(--td-primary, #1890ff);
  text-decoration: none;
}

.rich-content a:hover { text-decoration: underline; }

.rich-content img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

.rich-content img.xm-md-image {
  max-height: none;
}

.rich-content .xm-md-image-fallback {
  color: rgba(0, 0, 0, 0.45);
  font-size: 12px;
}

.td-comment-txt.rich-content,
.td-desc.rich-content {
  margin: 0;
}

/* 任务评论编辑器：排版对齐发布后 .dy-comment-content */
.td-comment-editor-wrap.rich-editor-shell .CodeMirror {
  font-size: 15px;
  line-height: 1.55;
  color: #161823;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror-lines {
  padding: 0 2px;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line-like {
  line-height: 1.55;
  min-height: calc(15px * 1.55);
  padding: 0;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line > span[role="presentation"] {
  line-height: 1.55;
  vertical-align: baseline;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror-cursor {
  height: calc(15px * 1.55) !important;
  margin-top: 0 !important;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror .cm-strong,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror .cm-em:not(.cm-formatting):not(.cm-formatting-em),
.td-comment-editor-wrap.rich-editor-shell .CodeMirror .cm-strikethrough:not(.cm-formatting-strikethrough):not(.cm-formatting) {
  font-size: inherit;
  line-height: inherit;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror-selectedtext {
  line-height: inherit;
  vertical-align: baseline;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror span.cm-header-1,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror span.cm-header-2,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror span.cm-header-3,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror span.cm-header-4,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror span.cm-header-5,
.td-comment-editor-wrap.rich-editor-shell .CodeMirror span.cm-header-6 {
  line-height: inherit !important;
}

.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-1),
.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-2),
.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-3),
.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-4),
.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-5),
.td-comment-editor-wrap.rich-editor-shell .CodeMirror pre.CodeMirror-line:has(.cm-header-6) {
  line-height: inherit;
  min-height: calc(15px * 1.55);
  padding-top: 0;
  padding-bottom: 0;
}

/* 文字颜色面板 */
.xm-re-color-panel {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  gap: 6px;
  padding: 8px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.xm-re-color-item {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: var(--xm-re-color, linear-gradient(135deg, #fff 45%, #e5e7eb 55%));
  cursor: pointer;
}

.xm-re-color-item:hover {
  transform: scale(1.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.xm-re-color-item[data-color=""] {
  background: linear-gradient(135deg, #fff 45%, #e5e7eb 55%);
}

/* 编辑器右键菜单 */
.xm-re-context-menu {
  position: fixed;
  z-index: 10320;
  min-width: 168px;
  padding: 6px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
  pointer-events: auto;
}

.xm-re-context-menu hr {
  margin: 4px 0;
  border: 0;
  border-top: 1px solid #eef2f7;
}

.xm-re-context-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #334155;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
}

.xm-re-context-item:hover:not(:disabled) {
  background: rgba(24, 144, 255, 0.08);
  color: #1677ff;
}

.xm-re-context-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.task-drawer-sheet-body .rich-editor-shell .CodeMirror,
.task-drawer-sheet-body .rich-editor-shell .CodeMirror-scroll {
  min-height: 88px;
}

.task-drawer-sheet-body .rich-editor-shell .editor-toolbar {
  position: relative;
  z-index: 4;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.task-drawer-sheet-body .rich-editor-shell .editor-toolbar::-webkit-scrollbar {
  display: none;
}

.task-drawer-sheet-body .sheet-mention-host.rich-editor-shell .CodeMirror,
.task-drawer-sheet-body .sheet-mention-host.rich-editor-shell .CodeMirror-scroll {
  min-height: 72px;
}

.task-drawer-sheet-body .sheet-mention-host.rich-editor-shell .CodeMirror-lines {
  padding: 8px 10px 6px;
}

.wf-snippet-editor-host.rich-editor-shell .CodeMirror,
.wf-snippet-editor-host.rich-editor-shell .CodeMirror-scroll {
  min-height: 180px !important;
}

.wf-snippet-editor-host.rich-editor-shell .CodeMirror-lines {
  padding: 10px 10px 8px;
}

/* 编辑器内彩色文字 widget */
.xm-cm-color-widget {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  font: inherit;
  line-height: inherit;
  white-space: inherit;
  word-break: inherit;
  vertical-align: baseline;
}

.rich-editor-shell .CodeMirror-line .CodeMirror-widget:has(.xm-cm-color-widget) {
  vertical-align: baseline;
  line-height: inherit;
}

/* 编辑器内附件 widget（只读预览入口） */
button.xm-cm-attachment-widget {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(100%, 320px);
  margin: 2px 0;
  padding: 4px 8px 4px 4px;
  border: 1px solid #e3ebf5;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  vertical-align: middle;
}

button.xm-cm-attachment-widget:hover {
  border-color: #91caff;
  background: #eef6ff;
  box-shadow: 0 2px 10px rgba(22, 119, 255, 0.12);
}

button.xm-cm-attachment-widget img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #eef2f7;
}

button.xm-cm-attachment-widget > i {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: #1677ff;
  font-style: normal;
  font-size: 11px;
  font-weight: var(--weight-display);
}

button.xm-cm-attachment-widget.kind-pdf > i { background: #ff5151; }
button.xm-cm-attachment-widget.kind-xls > i { background: #52c41a; }
button.xm-cm-attachment-widget.kind-doc > i { background: #5b8def; }
button.xm-cm-attachment-widget.kind-txt > i { background: #8b9cb0; }

button.xm-cm-attachment-widget > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

button.xm-cm-attachment-widget > em {
  flex: 0 0 auto;
  color: #1677ff;
  font-style: normal;
  font-size: 11px;
}

/* 详情页富文本内嵌附件（在线查看，不可编辑） */
.rich-content .xm-md-attachment {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
  vertical-align: middle;
}

.rich-content .xm-md-attachment-preview {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.rich-content .xm-md-attachment-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1677ff;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rich-content .xm-md-attachment-link:hover {
  color: #0958d9;
}

.rich-content .xm-md-attachment-name,
.rich-content .xm-md-attachment-hint {
  font-size: 12px;
  color: #64748b;
}

.rich-content .xm-md-attachment-hint {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1677ff;
}

.rich-editor-char-counter {
  margin: 6px 2px 0;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #8b98a8;
  text-align: right;
}

.rich-editor-char-counter.is-warn {
  color: #d48806;
}

.rich-editor-char-counter.is-over {
  color: #cf1322;
  font-weight: 600;
}
