body {
  padding: 1rem;
  background: #ffffff;
  color: #1a1a1a;
  color-scheme: light dark;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.rich-text {
  color: #1a1a1a;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial,
    sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── 段落 ── */
.rich-text p {
  margin: 0 0 1.1em;
}

.rich-text p:last-child {
  margin-bottom: 0;
}

/* ── 标题 ── */
.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4,
.rich-text h5,
.rich-text h6 {
  font-weight: 600;
  line-height: 1.35;
  color: #111;
  margin: 1.6em 0 0.5em;
}

.rich-text h1:first-child,
.rich-text h2:first-child,
.rich-text h3:first-child {
  margin-top: 0;
}

.rich-text h1 {
  font-size: 2em;
  letter-spacing: -0.02em;
}
.rich-text h2 {
  font-size: 1.5em;
  letter-spacing: -0.01em;
}
.rich-text h3 {
  font-size: 1.25em;
}
.rich-text h4 {
  font-size: 1.1em;
}
.rich-text h5 {
  font-size: 1em;
}
.rich-text h6 {
  font-size: 0.9em;
  color: #555;
}

/* ── 强调 & 行内格式 ── */
.rich-text strong,
.rich-text b {
  font-weight: 600;
  color: inherit;
}

.rich-text em,
.rich-text i {
  font-style: italic;
}

.rich-text u {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rich-text s,
.rich-text del {
  text-decoration: line-through;
  color: #888;
}

.rich-text mark {
  background-color: #fff3a3;
  color: #1a1a1a;
  padding: 0.05em 0.2em;
  border-radius: 3px;
}

.rich-text sub {
  font-size: 0.75em;
  vertical-align: sub;
}

.rich-text sup {
  font-size: 0.75em;
  vertical-align: super;
}

/* ── 链接 ── */
.rich-text a {
  color: #1a6ed8;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition:
    color 0.15s ease,
    opacity 0.15s ease;
}

.rich-text a:hover {
  color: #0f50a8;
  opacity: 0.85;
}

/* ── 内联代码 ── */
.rich-text code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.875em;
  background: #f3f4f6;
  color: #c7254e;
  padding: 0.15em 0.42em;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

/* ── 代码块 ── */
.rich-text pre {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.875em;
  line-height: 1.65;
  background: #1e2027;
  color: #e2e8f0;
  padding: 1.1em 1.4em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.4em 0;
  -webkit-overflow-scrolling: touch;
}

.rich-text pre code {
  font-size: inherit;
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  border-radius: 0;
}

/* ── 引用块 ── */
.rich-text blockquote {
  margin: 1.4em 0;
  padding: 0.7em 1.2em;
  border-left: 3px solid #1a6ed8;
  background: #f7f9ff;
  border-radius: 0 6px 6px 0;
  color: #444;
  font-style: italic;
}

.rich-text blockquote p {
  margin: 0;
}

.rich-text blockquote p + p {
  margin-top: 0.6em;
}

/* ── 列表 ── */
.rich-text ul,
.rich-text ol {
  margin: 0.8em 0 1em;
  padding-left: 1.6em;
}

.rich-text li {
  margin: 0.3em 0;
  padding-left: 0.25em;
}

.rich-text ul {
  list-style-type: disc;
}

.rich-text ul ul {
  list-style-type: circle;
  margin: 0.25em 0;
}

.rich-text ul ul ul {
  list-style-type: square;
}

.rich-text ol {
  list-style-type: decimal;
}

.rich-text ol ol {
  list-style-type: lower-alpha;
  margin: 0.25em 0;
}

.rich-text ol ol ol {
  list-style-type: lower-roman;
}

/* ── 任务列表（TipTap / GitHub 风格） ── */
.rich-text ul[data-type="taskList"],
.rich-text ul.task-list {
  list-style: none;
  padding-left: 0.2em;
}

.rich-text ul[data-type="taskList"] li,
.rich-text ul.task-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  padding-left: 0;
}

.rich-text ul[data-type="taskList"] li input[type="checkbox"],
.rich-text ul.task-list li input[type="checkbox"] {
  margin-top: 0.3em;
  flex-shrink: 0;
  accent-color: #1a6ed8;
  width: 15px;
  height: 15px;
}

/* ── 分割线 ── */
.rich-text hr {
  border: none;
  border-top: 1.5px solid #e5e7eb;
  margin: 2em 0;
}

/* ── 表格 ── */
.rich-text table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925em;
  margin: 1.4em 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.rich-text th,
.rich-text td {
  padding: 0.6em 0.9em;
  text-align: left;
  border: 1px solid #e5e7eb;
  vertical-align: top;
}

.rich-text thead th {
  background: #f8f9fa;
  font-weight: 600;
  color: #333;
  font-size: 0.875em;
  letter-spacing: 0.01em;
  border-bottom: 2px solid #dee2e6;
}

.rich-text tbody tr:nth-child(even) {
  background: #fafafa;
}

.rich-text tbody tr:hover {
  background: #f1f5ff;
}

/* ── 图片 ── */
.rich-text img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  margin: 1.2em 0;
}

.rich-text figure {
  margin: 1.4em 0;
  text-align: center;
}

.rich-text figure img {
  margin: 0 auto;
}

.rich-text figcaption {
  margin-top: 0.5em;
  font-size: 0.85em;
  color: #888;
  font-style: italic;
}

/* ── 视频 / iframe 响应式容器 ── */
.rich-text .video-wrapper,
.rich-text .embed-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  margin: 1.4em 0;
}

.rich-text .video-wrapper iframe,
.rich-text .embed-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── 首字下沉（可选工具类） ── */
.rich-text .drop-cap::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: 0.85;
  font-weight: 700;
  margin: 0.05em 0.12em 0 0;
  color: #1a6ed8;
}

/* ── 文字对齐 ── */
.rich-text .ql-align-center,
.rich-text [style*="text-align: center"],
.rich-text [data-text-align="center"] {
  text-align: center;
}

.rich-text .ql-align-right,
.rich-text [style*="text-align: right"],
.rich-text [data-text-align="right"] {
  text-align: right;
}

.rich-text .ql-align-justify,
.rich-text [style*="text-align: justify"],
.rich-text [data-text-align="justify"] {
  text-align: justify;
  hyphens: auto;
}

/* ── 暗色模式支持 ── */
@media (prefers-color-scheme: dark) {
  body {
    background: #0b1220;
    color: #e2e8f0;
  }

  .rich-text {
    color: #e2e8f0;
  }

  .rich-text h1,
  .rich-text h2,
  .rich-text h3,
  .rich-text h4,
  .rich-text h5 {
    color: #f1f5f9;
  }

  .rich-text h6 {
    color: #94a3b8;
  }

  .rich-text a {
    color: #60a5fa;
  }

  .rich-text a:hover {
    color: #93c5fd;
  }

  .rich-text code {
    background: #1e2532;
    color: #f472b6;
    border-color: #2d3748;
  }

  .rich-text pre {
    background: #111827;
  }

  .rich-text blockquote {
    background: #1a2035;
    color: #94a3b8;
    border-left-color: #60a5fa;
  }

  .rich-text mark {
    background: #92400e;
    color: #fef9c3;
  }

  .rich-text hr {
    border-top-color: #2d3748;
  }

  .rich-text table {
    border-color: #2d3748;
  }

  .rich-text th,
  .rich-text td {
    border-color: #2d3748;
  }

  .rich-text thead th {
    background: #1e2532;
    color: #e2e8f0;
    border-bottom-color: #374151;
  }

  .rich-text tbody tr:nth-child(even) {
    background: #161d2d;
  }

  .rich-text tbody tr:hover {
    background: #1a2540;
  }
}

/* ── 响应式 ── */
@media (max-width: 640px) {
  .rich-text {
    font-size: 15px;
  }

  .rich-text h1 {
    font-size: 1.65em;
  }
  .rich-text h2 {
    font-size: 1.35em;
  }
  .rich-text h3 {
    font-size: 1.15em;
  }

  .rich-text table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .rich-text pre {
    font-size: 0.82em;
  }
}
