/* ==================================================================
   Markdown 正文排版
   ================================================================== */

.md { font-size: 15px; line-height: 1.75; word-wrap: break-word; overflow-wrap: anywhere; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }

.md p { margin: 0 0 14px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 24px 0 12px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -.2px;
}
.md h1 { font-size: 1.5em; }
.md h2 { font-size: 1.3em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 1.13em; }
.md h4 { font-size: 1em; }

.md ul, .md ol { margin: 0 0 14px; padding-left: 1.5em; }
.md li { margin: 4px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md li::marker { color: var(--muted); }

.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.md a:hover { border-bottom-color: currentColor; }

.md blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 15px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}

.md hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

.md img { max-width: 100%; border-radius: var(--r-md); }

.md strong { font-weight: 650; }

/* 行内代码 */
.md :not(pre) > code {
  font-family: var(--mono);
  font-size: .875em;
  padding: .15em .4em;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #b8395f;
  word-break: break-word;
}
[data-theme="dark"] .md :not(pre) > code { color: #ff9ab8; }

/* 代码块 */
.code-block {
  position: relative;
  margin: 0 0 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.code-block__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 6px 13px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: .3px;
}
.code-block__actions { display: flex; gap: 2px; }
.code-block__btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-family: var(--font);
  color: var(--text-2);
  transition: background .14s, color .14s;
}
.code-block__btn:hover { background: var(--surface-3); color: var(--text); }
.code-block__btn svg { width: 13px; height: 13px; }
.code-block__btn.is-done { color: var(--success); }

.code-block pre {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
  background: var(--surface);
}
.code-block pre code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.62;
  background: none;
  padding: 0;
  border: none;
  color: var(--text);
  white-space: pre;
}
.code-block.is-wrapped pre code { white-space: pre-wrap; word-break: break-word; }

/* 表格 */
.md .table-wrap { overflow-x: auto; margin: 0 0 15px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md th, .md td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.md th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

/* 任务列表 */
.md input[type="checkbox"] { margin-right: 6px; vertical-align: -2px; }

/* KaTeX */
.md .katex { font-size: 1.04em; }
.md .katex-display { margin: 16px 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* 思维链 / reasoning 折叠块 */
.reasoning {
  margin: 0 0 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  overflow: hidden;
}
.reasoning__head {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.reasoning__head:hover { color: var(--text-2); }
.reasoning__body {
  padding: 0 14px 12px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  max-height: 340px;
  overflow-y: auto;
}
