/* Reading styles for AI replies. Tuned for long CJK + Latin mixed text. */
.md {
  font-size: var(--read-size); line-height: 1.78; color: var(--text);
  overflow-wrap: break-word; word-break: normal; line-break: auto;
  font-feature-settings: "palt" 0;
  min-width: 0;
}
.md > :first-child { margin-top: 0 !important; }
.md > :last-child { margin-bottom: 0 !important; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { line-height: 1.4; font-weight: 700; margin: 1.5em 0 .55em; letter-spacing: -.005em; overflow-wrap: anywhere; }
.md h1 { font-size: 1.42em; }
.md h2 { font-size: 1.24em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.1em; }
.md h4, .md h5, .md h6 { font-size: 1em; }
.md a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; overflow-wrap: anywhere; }
.md strong { font-weight: 700; }
.md em { font-style: italic; }
.md :lang(zh) em, .md em:lang(zh) { font-style: normal; text-emphasis: none; }
.md s { color: var(--text-3); }
.md hr { border: 0; height: 1px; background: var(--line); margin: 1.6em 0; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.45em; }
.md li { margin: .22em 0; }
.md li > ul, .md li > ol { margin: .2em 0 .3em; }
.md li > p { margin: 0 0 .4em; }
.md ul li::marker { color: var(--text-3); }
.md li:has(> .md-task) { list-style: none; margin-left: -1.2em; }
.md-task { color: var(--text-3); font-family: var(--mono); }
.md ol li::marker { color: var(--text-3); font-variant-numeric: tabular-nums; }
.md blockquote {
  margin: 0 0 .9em; padding: .55em 1em; border-left: 3px solid var(--line-2);
  background: var(--surface-2); border-radius: 0 10px 10px 0; color: var(--text-2);
}
.md blockquote > :last-child { margin-bottom: 0; }
.md code {
  font-family: var(--mono); font-size: .86em; padding: .12em .38em; border-radius: 5px;
  background: var(--surface-3); overflow-wrap: anywhere;
}

.md-code { margin: 0 0 1em; border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); overflow: hidden; min-width: 0; }
.md-code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 36px; padding: 0 4px 0 12px; border-bottom: 1px solid var(--line);
  font: 12px/1 var(--mono); color: var(--text-3);
}
.md-code-head button {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border-radius: 8px;
  font: 600 12.5px/1 var(--font); color: var(--text-2);
}
.md-code-head button svg { width: 14px; height: 14px; }
.md-code-head button[data-done] { color: var(--done); }
@media (hover: hover) { .md-code-head button:hover { background: var(--surface-3); } }
.md-code pre {
  margin: 0; padding: 12px 14px 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  font: 13px/1.62 var(--mono); tab-size: 2; white-space: pre; color: var(--text);
}
.md-code code { background: none; padding: 0; border-radius: 0; font-size: inherit; overflow-wrap: normal; }

.md-table-wrap {
  margin: 0 0 1em; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.md table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: .9em; line-height: 1.5; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; max-width: 22em; }
.md th { background: var(--surface-2); font-weight: 650; white-space: nowrap; color: var(--text-2); font-size: .95em; }
.md tr:last-child td { border-bottom: 0; }
.md td { font-variant-numeric: tabular-nums; }
.md th + th, .md td + td { border-left: 1px solid var(--line); }
.md [data-align="right"] { text-align: right; }
.md [data-align="center"] { text-align: center; }

.md-figure { margin: 0 0 1em; }
.md-figure img, .md img.md-inline-img {
  display: block; max-width: 100%; height: auto; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.md img.md-inline-img { display: inline-block; vertical-align: middle; max-height: 1.6em; border-radius: 4px; }
.md-figure figcaption { margin-top: 6px; font-size: .84em; color: var(--text-3); text-align: center; }
.md-img-fallback {
  display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 10px;
  border: 1px dashed var(--line-2); color: var(--text-3); font-size: .88em; line-height: 1.5;
}
.md-img-fallback svg { width: 20px; height: 20px; flex: none; }
.md-img-fallback b { color: var(--text-2); font-weight: 600; }
:root[data-theme="dark"] .md-figure img { filter: brightness(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .md-figure img { filter: brightness(.9); } }

.md-plain { white-space: pre-wrap; font-family: inherit; margin: 0; overflow-wrap: anywhere; }
