/* richtext.js 产出的元素的样式。根元素是 .rt；里面的类名都以 rt- 开头。
   颜色、圆角全部用 theme.css 的变量，深色模式跟着变量自动成立。
   theme.css 里还没有的变量（字号、行内代码的小圆角、公式用的衬线字体）写成 var(--名字, 回退值)，
   清单见 richtext.md；以后在 theme.css 里统一定义后，这里不用改。
   要放在 chat.css 之后引入：.rt 把 .msg.assistant 的 pre-wrap 改回 normal，代码块里的 code 去掉行内代码的底色。 */

.rt { white-space: normal; overflow-wrap: anywhere; line-height: var(--lh-relaxed, 1.85); }
.rt > :first-child { margin-top: 0; }
.rt > :last-child { margin-bottom: 0; }
/* 很长的回答（richtext.js 的 LONG_TEXT）：屏幕外的块不做布局与绘制，高度先按 8em 估、渲染过一次后浏览器记住真实高度。搜索、选择、复制照常可用。 */
.rt[data-long] > * { content-visibility: auto; contain-intrinsic-size: auto 8em; }

/* —— 段落与标题 —— */
.rt p { margin: 0 0 .8em; }
.rt h1, .rt h2, .rt h3, .rt h4, .rt h5, .rt h6 { margin: 1.15em 0 .45em; font-weight: 600; line-height: 1.4; }
.rt h1 { font-size: var(--fs-h1, 1.35em); }
.rt h2 { font-size: var(--fs-h2, 1.2em); }
.rt h3 { font-size: var(--fs-h3, 1.07em); }
.rt h4, .rt h5, .rt h6 { font-size: var(--fs-h4, 1em); }
.rt h5, .rt h6 { color: var(--dim); }

/* —— 行内 —— */
.rt strong { font-weight: 600; }
.rt del { color: var(--dim); }
.rt a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.rt a:hover { text-decoration-thickness: 2px; }
.rt a:focus-visible, .rt-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.rt code { font-family: var(--mono); font-size: var(--fs-code); padding: 1px var(--sp-1); border-radius: var(--r-code); background: var(--fill); }
.rt sup, .rt sub { line-height: 0; font-size: var(--fs-script, .72em); }
.rt-pending { color: var(--accent); }

/* —— 列表、引用、分隔线 —— */
.rt ul, .rt ol { margin: 0 0 .7em; padding-left: 1.5em; }
.rt li { margin: .2em 0; }
.rt li > p { margin: 0; }
.rt li > p + p { margin-top: .45em; }
.rt li > ul, .rt li > ol { margin: .2em 0 0; }
.rt li > .rt-code, .rt li > .rt-table { margin: .4em 0; }
.rt li::marker { color: var(--dim); }
.rt li.rt-task { position: relative; list-style: none; }
.rt li.rt-task > input { position: absolute; left: -1.45em; top: .36em; margin: 0; accent-color: var(--accent); }
.rt blockquote { margin: 0 0 .7em; padding: 1px 0 1px var(--sp-3); border-left: 3px solid var(--fill-2); color: var(--dim); }
.rt blockquote > :first-child { margin-top: 0; }
.rt blockquote > :last-child { margin-bottom: 0; }
.rt hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--sep); }

/* —— 表格：论文里的三线表——顶线、表头线、底线，没有竖线，行与行之间不画线；数字右对齐由 Markdown 的对齐标记决定。
   对话回复、文档预览、报告正文用的是同一份。窄屏放不下时整张表在容器里横向滚动。—— */
.rt-table { margin: 0 0 .8em; overflow-x: auto; }
.rt table { width: 100%; border-collapse: collapse; border-top: 1.5px solid var(--fg); border-bottom: 1.5px solid var(--fg); font-size: var(--fs-table, .93em); font-variant-numeric: tabular-nums; overflow-wrap: normal; }
.rt th, .rt td { padding: var(--sp-1) var(--sp-3); border: 0; text-align: left; vertical-align: top; }
.rt th { color: var(--fg); font-weight: var(--fw-semibold); border-bottom: 1px solid var(--fg); white-space: nowrap; }
.rt tbody tr:hover { background: var(--hover); }
.rt td.rt-right, .rt td.rt-center { white-space: nowrap; }      /* 数字与居中的短项不折行（1.2e-08 不能断成两截）；左对齐的文字照常换行 */
.rt .rt-left { text-align: left; }
.rt .rt-right { text-align: right; }
.rt .rt-center { text-align: center; }

/* —— 代码块：浅底圆角，右上角一个“复制” —— */
.rt-code { margin: 0 0 .8em; border-radius: var(--r-item); background: var(--fill); overflow: hidden; }
.rt-code-bar { display: flex; align-items: center; justify-content: space-between; min-height: 24px; padding: var(--sp-1) var(--sp-1) 0 var(--sp-3); font-size: var(--fs-small, 12px); color: var(--faint); }
.rt-copy { padding: var(--sp-0) var(--sp-2); border: 0; border-radius: var(--r-pill); background: transparent; color: var(--dim); font-size: inherit; line-height: 1.5; cursor: pointer; }
.rt-copy:hover { background: var(--hover); color: var(--fg); }
.rt-copy:active { background: var(--press); }
/* —— 推荐问题：回答末尾的几个小按钮，点一下填进输入框 —— */
.rt-followups { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0 .4em; }
.rt-followups-label { color: var(--faint); font-size: var(--fs-small, 12px); }
.rt-followup { padding: var(--sp-1) var(--sp-3); border: 1px solid var(--edge); border-radius: var(--r-pill); background: transparent; color: var(--dim); font: inherit; font-size: var(--fs-small, 13px); line-height: 1.5; text-align: left; cursor: pointer; }
.rt-followup:hover { background: var(--hover); color: var(--fg); }
.rt-followup:active { background: var(--press); }
.rt-followup:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.rt .rt-code pre { margin: 0; padding: var(--sp-1) var(--sp-3) var(--sp-3); overflow-x: auto; white-space: pre; overflow-wrap: normal; }
.rt .rt-code pre code { padding: 0; border-radius: 0; background: none; font-size: var(--fs-code); line-height: 1.7; }
.rt-c { color: var(--dim); }
.rt-s { color: var(--ok); }
.rt-k { color: var(--accent); }
.rt-n { color: var(--warn); }
.rt-t { color: var(--ft-purple); }      /* 名称：YAML / INI 的键与段名、C 的预处理行 */

/* —— 公式 —— */
.rt-math { font-family: var(--serif, "STIX Two Text", "Times New Roman", "Noto Serif", "Songti SC", "Noto Serif CJK SC", serif); font-size: var(--fs-math, 1.08em); line-height: 1.2; white-space: nowrap; }
.rt-math-block { display: block; margin: .7em 0 .9em; padding: 2px 0; line-height: 2; text-align: center; overflow-x: auto; overflow-y: hidden; }
.rt-var { font-style: italic; }
.rt-rm, .rt-rm .rt-var, .rt-bf .rt-var, .rt-tt .rt-var { font-style: normal; }
.rt-bf { font-weight: 700; }
.rt-tt { font-family: var(--mono); }
.rt-rel { margin: 0 .28em; }
.rt-fn { margin: 0 .14em 0 .1em; }
.rt-frac { display: inline-flex; flex-direction: column; align-items: center; margin: 0 .15em; vertical-align: middle; line-height: 1.25; }
.rt-math:not(.rt-math-block) .rt-frac, .rt-frac .rt-frac { font-size: var(--fs-frac, .85em); }
.rt-num { align-self: stretch; padding: 0 .25em 1px; border-bottom: 1px solid currentColor; text-align: center; }
.rt-den { padding: 1px .25em 0; }
.rt-radicand { display: inline-block; margin-left: -.04em; padding: 0 .15em 0 .1em; border-top: 1px solid currentColor; }
.rt-root-index { margin-right: -.45em; font-size: var(--fs-root, .6em); vertical-align: .9em; }
/* 上下标：一上一下叠在一起；只有一个时把它推上去或拉下来 */
.rt-scripts { display: inline-flex; flex-direction: column; margin-left: .05em; vertical-align: middle; font-size: var(--fs-script, .72em); line-height: 1.05; }
.rt-scripts > sup, .rt-scripts > sub { position: relative; font-size: inherit; line-height: inherit; vertical-align: baseline; }
.rt-scripts > sup { order: 0; }
.rt-scripts > sub { order: 1; }
.rt-scripts > sup:only-child { top: -.5em; }
.rt-scripts > sub:only-child { top: .42em; }

/* —— 化学式 —— */
.rt-chem { white-space: nowrap; }
