/* 「晴空自习室 · 蓝标题紫表格」阅读层：既有 Markdown 的排版映射。界面控件继续使用 kaopy.css。
   # → 章节题；## → 小节条；strong → 柠檬黄荧光笔；em → 沙杏色手写批注。
   结构、字号、间距、圆角、字体沿用晴空自习室，只换颜色：正文墨向产品墨靠拢；标题与小节条是压暗、降彩度的墨水蓝，
   色相从晴空的蓝青往 Kaopy 蓝挪一段；表格是更收敛的灰紫，只落在表头字、表头底和表线上；全页唯一的饱和色是加粗的黄；
   引用与批注的杏色退成沙杏，和黄同属暖色一侧。
   品牌蓝只留给可点的链接，状态色由产品层拥有。不补编号、不推断教学语义、不改正文或公式。 */
/* Times 只接管拉丁、希腊字母、上下标、箭头与数学符号；中文标点（U+2000–206F 的破折号、省略号、引号）交回中文字体。
   「——」连成一条，「……」居中，引号全宽。 */
@font-face { font-family: 'Kaopy Reading Latin'; font-style: normal; font-weight: 400; src: local('Times New Roman'), local('TimesNewRomanPSMT'), local('Times-Roman'); unicode-range: U+0000-02AF, U+0300-03FF, U+2070-209F, U+2100-22FF; }
@font-face { font-family: 'Kaopy Reading Latin'; font-style: normal; font-weight: 700; src: local('Times New Roman Bold'), local('TimesNewRomanPS-BoldMT'), local('Times-Bold'); unicode-range: U+0000-02AF, U+0300-03FF, U+2070-209F, U+2100-22FF; }
@font-face { font-family: 'Kaopy Reading Latin'; font-style: italic; font-weight: 400; src: local('Times New Roman Italic'), local('TimesNewRomanPS-ItalicMT'), local('Times-Italic'); unicode-range: U+0000-02AF, U+0300-03FF, U+2070-209F, U+2100-22FF; }
@font-face { font-family: 'Kaopy Reading Latin'; font-style: italic; font-weight: 700; src: local('Times New Roman Bold Italic'), local('TimesNewRomanPS-BoldItalicMT'), local('Times-BoldItalic'); unicode-range: U+0000-02AF, U+0300-03FF, U+2070-209F, U+2100-22FF; }
:root, [data-theme="light"] {
  --reading-book: 'Kaopy Reading Latin', 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --reading-hand: 'Kaiti SC', 'STKaiti', 'KaiTi', '楷体', serif;
  /* 冷色只管结构：正文墨、墨水蓝标题、灰紫表格同一条冷灰轴（色相 245–293，彩度都压在 .08 以下）；
     暖色只有两样：加粗的字脚黄、引用与批注的沙杏色。 */
  --reading-canvas: #E5E9EE;          /* 代码底：冷灰网底，对画布 1.12:1 */
  --reading-paper: #FFFFFF;
  --reading-ink: #2D343B;             /* 正文：oklch(.32 .016 250)，对画布 11.5:1 */
  --reading-ink-strong: #16191D;      /* 加粗、####：产品墨 */
  --reading-muted: #59626C;
  --reading-heading: #254F71;         /* 墨水蓝：oklch(.41 .074 245)，比产品链接蓝暗、彩度不到一半 */
  --reading-heading-soft: #E8EFF4;
  --reading-section: #254F71;
  --reading-section-soft: #E8EFF4;
  /* 产品页共用 --emphasis-marker；独立导出没有 kaopy.css 时回退到同一个明确值。 */
  --reading-key: var(--emphasis-marker, #F4E04F);
  --reading-marker: var(--emphasis-marker, #F4E04F);
  --reading-annotation: #7C5336;      /* 批注：沙杏色 */
  --reading-annotation-soft: #F5E9DD;
  --reading-rule: #D1D7DD;
  --reading-table-heading: #524B6F;   /* 灰紫：oklch(.435 .059 293) */
  --reading-table-heading-soft: #F0EFF6;
  --reading-table-rule: #CECCD6;
}
[data-theme="dark"] {
  --reading-canvas: #2E3439;
  --reading-paper: #242623;           /* 笔记纸 = 产品 surface（浅色的白纸同理），与笔记卡片同底 */
  --reading-ink: #E1E5E9;
  --reading-ink-strong: #F0F2F4;
  --reading-muted: #ABB3BA;
  --reading-heading: #B3D3E9;
  --reading-heading-soft: #34454F;
  --reading-section: #B3D3E9;
  --reading-section-soft: #34454F;
  /* 深色内容荧光笔：独立导出回退值与产品 token 相同，浅字对整块底仍为 4.75:1。 */
  --reading-key: var(--emphasis-marker, #6F6500);
  --reading-marker: var(--emphasis-marker, #6F6500);
  --reading-annotation: #D8B69A;
  --reading-annotation-soft: #3B342D;
  --reading-rule: #545C63;
  --reading-table-heading: #BEB8DC;
  --reading-table-heading-soft: #302F3A;
  --reading-table-rule: #5B5966;
}

/* --reading-ground：所在底色，深色加粗字的描边与宽表滚动提示用它；有底色的块各自改写。 */
:is(.msg-body, .aside-answer) { --reading-ground: var(--canvas); }
.cornell-rich-content { --reading-ground: var(--reading-paper); }
:is(.msg-body, .aside-answer, .cornell-rich-content) {
  min-width: 0;
  color: var(--reading-ink);
  font-family: var(--reading-book);
  font-size: 17px;
  line-height: 1.9;
  overflow-wrap: anywhere;
  white-space: normal;
}
.msg-body,
.msg-body.is-streaming .streaming-message-block { display: flex; flex-direction: column; gap: 14px; }
.msg-body { max-width: 40em; }
.msg-body.is-streaming .streaming-plain-text { white-space: pre-wrap; }
.msg-body > p { position: relative; }
:is(.aside-answer, .cornell-rich-content) > * + * { margin-top: .8em; }
:is(.msg-body, .aside-answer, .cornell-rich-content) p { margin-block: 0; }
:is(.aside-answer, .cornell-rich-content) p + p { margin-top: .7em; }
:is(.msg-body, .aside-answer, .cornell-rich-content) > :first-child { margin-top: 0; }
:is(.msg-body, .aside-answer, .cornell-rich-content) > :last-child { margin-bottom: 0; }

/* 标题保留无衬线骨架，与宋体正文形成稳定对照。
   字号阶 1.32 / 1.12 / 1.06 / 1：# 章节题明显大于 ## 小节条；### 是墨水蓝，#### 是与正文同大的墨黑，不再比正文弱。 */
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h1, h2, h3, h4, h5, h6) {
  font-family: 'Kaopy Reading Latin', var(--font-sans);
  font-weight: 600;
  line-height: 1.5;
  text-wrap: pretty;
  scroll-margin-top: 16px;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h1, h2) {
  margin: 1em 0 .25em;
  padding: 0;
  border: 0;
  color: var(--reading-ink);
  letter-spacing: .015em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) h1 {
  display: flex;
  align-items: center;
  gap: .55em;
  font-size: 1.38em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) h1::before {
  content: '';
  width: .72em;
  height: .72em;
  flex: none;
  border-radius: .28em;
  background: var(--reading-heading-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--reading-heading) 25%, transparent);
}
:is(.msg-body, .aside-answer, .cornell-rich-content) h2 {
  width: fit-content;
  padding-bottom: .18em;
  border-bottom: 1px solid var(--reading-rule);
  color: var(--reading-heading);
  font-size: 1.32em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) h3 {
  width: fit-content;
  margin: .9em 0 .2em;
  padding: .32em .8em;
  border: 0;
  border-radius: 8px;
  background: var(--reading-section-soft);
  color: var(--reading-section);
  font-size: 1.12em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h4, h5, h6) {
  margin: .75em 0 .1em;
  color: var(--reading-ink-strong);
  font-size: 1em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) h4 { color: var(--reading-heading); font-size: 1.06em; }

/* 荧光笔只垫在字的下半部，跨行各自延续，避免形成一串按钮。 */
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(strong, mark) {
  padding: 0 .08em;
  border-radius: 0;
  color: var(--reading-ink);
  background: linear-gradient(transparent 35%, var(--reading-marker) 35%, var(--reading-marker) 93%, transparent 93%);
  font-weight: 600;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h1, h2, h3, h4, h5, h6) strong {
  padding: 0;
  color: inherit;
  background: none;
}
/* 学生划重点：荧光底照常铺上，字保持阅读层的颜色（gxs 的 kp-mark 会把字统一压成产品墨） */
:is(.msg-body, .aside-answer, .cornell-rich-content) ::highlight(kp-mark) { color: var(--reading-ink); }
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h5, h6)::highlight(kp-mark) { color: var(--reading-ink-strong); }
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h2, h4, h2 *, h4 *)::highlight(kp-mark) { color: var(--reading-heading); }
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(h3, h3 *)::highlight(kp-mark) { color: var(--reading-section); }
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(th, th *)::highlight(kp-mark) { color: var(--reading-table-heading); }
:is(.msg-body, .aside-answer, .cornell-rich-content) em::highlight(kp-mark) { color: var(--reading-annotation); }

:is(.msg-body, .aside-answer, .cornell-rich-content) em {
  padding: 0 .08em;
  color: var(--reading-annotation);
  font-family: 'Kaopy Reading Latin', var(--reading-hand);
  font-style: normal;
  background: linear-gradient(transparent 62%, var(--reading-annotation-soft) 62%);
  text-decoration: underline wavy;
  text-decoration-color: var(--reading-annotation);
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  text-decoration-skip-ink: auto;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(ul, ol) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .3em;
  margin-block: 0;
  padding-inline-start: 1.6em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) li { padding-inline-start: .12em; }
:is(.msg-body, .aside-answer, .cornell-rich-content) li::marker { color: var(--reading-heading); font-weight: 600; }
:is(.msg-body, .aside-answer, .cornell-rich-content) li > :is(ul, ol) {
  margin-top: .35em;
  padding-inline-start: 1.45em;
  border-inline-start: 1px solid var(--reading-rule);
}
:is(.msg-body, .aside-answer, .cornell-rich-content) li > p + p { margin-top: .55em; }
:is(.msg-body, .aside-answer, .cornell-rich-content) blockquote {
  display: grid;
  gap: .5em;
  margin: .35em 0;
  padding: .75em 1em;
  border: 0;
  border-radius: 5px 14px 14px 14px;
  background: var(--reading-annotation-soft);
  --reading-ground: var(--reading-annotation-soft);
  color: var(--reading-ink);
  font-size: .95em;
  font-weight: 400;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) blockquote > * { margin-block: 0; }
:is(.msg-body, .aside-answer, .cornell-rich-content) hr {
  width: 100%;
  margin: .5em 0;
  border: 0;
  border-top: 1px solid var(--reading-rule);
}
:is(.msg-body, .aside-answer, .cornell-rich-content) a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: .2em;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) a:hover { text-decoration-thickness: 2px; }
:is(.msg-body, .aside-answer, .cornell-rich-content) a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* 公式：KaTeX 默认放大到 1.21em，比中文大一号；收到 1.1em，与正文字面齐平 */
:is(.msg-body, .aside-answer, .cornell-rich-content) .katex { font-size: 1.1em; }
:is(.msg-body, .aside-answer, .cornell-rich-content) img { display: block; width: auto; max-width: 100%; height: auto; margin: .7em auto; }
:is(.msg-body, .aside-answer, .cornell-rich-content) code { padding: .1em .3em; background: color-mix(in srgb, var(--reading-canvas) 48%, transparent); border-radius: 4px; font-family: var(--font-mono); font-size: .88em; }
:is(.msg-body, .aside-answer, .cornell-rich-content) pre { max-width: 100%; margin: .35em 0; padding: 14px; overflow: auto; background: color-mix(in srgb, var(--reading-canvas) 48%, transparent); border: 1px solid var(--reading-rule); border-radius: 10px; }
:is(.msg-body, .aside-answer, .cornell-rich-content) pre code { padding: 0; border: 0; background: transparent; white-space: pre; }

/* 横线组织行，留白组织列；宽表只在自身滚动，不挤宽正文。滚动没到头的一侧有一道淡影，提示还有列。 */
.markdown-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--reading-ground) 40%, transparent) left / 2em 100% no-repeat local,
    linear-gradient(to left, var(--reading-ground) 40%, transparent) right / 2em 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--reading-table-heading) 16%, transparent), transparent) left / .75em 100% no-repeat scroll,
    linear-gradient(to left, color-mix(in srgb, var(--reading-table-heading) 16%, transparent), transparent) right / .75em 100% no-repeat scroll;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) table {
  width: 100%;
  max-width: 100%;
  margin: .35em 0;
  border-collapse: collapse;
  border-block: 1.5px solid var(--reading-table-heading);
  font-size: .9em;
  line-height: 1.7;
}
:is(.msg-body, .aside-answer, .cornell-rich-content) :is(th, td) { padding: .55em .65em; border: 0; border-bottom: 1px solid var(--reading-table-rule); text-align: left; vertical-align: top; overflow-wrap: break-word; }
:is(.msg-body, .aside-answer, .cornell-rich-content) th { background: var(--reading-table-heading-soft); color: var(--reading-table-heading); font-family: 'Kaopy Reading Latin', var(--font-sans); font-weight: 600; }
:is(.msg-body, .aside-answer, .cornell-rich-content) tbody tr:last-child td { border-bottom: 0; }
/* 笔记里的表格没有滚动外框：按内容取列宽、词不从中间断开。窄栏里 6 列以上的表收紧字号和格距，
   8 列数字表在 255px 里放得下；万一仍放不下，整条笔记在纸内横向滚动，不被裁掉。 */
.cornell-rich-content :is(th, td) { padding: .45em .55em; }
.cornell-workspace__note { overflow-x: auto; }
@container (max-width: 40rem) {
  .cornell-rich-content table:has(tr > :nth-child(6)) { font-size: .8em; }
  .cornell-rich-content table:has(tr > :nth-child(6)) :is(th, td) { padding-inline: .3em; }
}

/* 复用 Cornell 已有页边栏，不从正文猜出「提示」或重新排序内容。 */
.board-doc, .notes-preview { --board-paper: var(--reading-paper); --board-border: var(--reading-rule); }
.board-doc .cornell-workspace, .notes-preview, .notes-print {
  --note-blue: var(--reading-heading);
  --note-green: var(--reading-heading);
  --note-violet: var(--reading-section);
  --note-amber: var(--reading-annotation);
  --note-red: var(--reading-annotation);
}
.cornell-rich-content :is(.note-definition, .note-derivation) { --note-tint: var(--reading-heading-soft); --reading-ground: var(--reading-heading-soft); }
/* 提示框的竖线与标签跟底色同一族：沙杏底配沙杏线，蓝底配墨水蓝线（原先交叉，出现蓝底棕线、杏底蓝线） */
.cornell-rich-content :is(.note-example, .note-tip, .note-annotation) { --note-accent: var(--reading-annotation); background: var(--reading-annotation-soft); --reading-ground: var(--reading-annotation-soft); }
.cornell-rich-content :is(.note-warning, .note-clue, .note-weakness) { --note-accent: var(--reading-heading); background: var(--reading-heading-soft); --reading-ground: var(--reading-heading-soft); }
/* 模型写在 span 上的提示框：整块成框，竖线贯穿全高，不按行参差 */
.cornell-rich-content span:is(.note-definition, .note-derivation, .note-example, .note-tip, .note-annotation, .note-question, .note-warning, .note-clue, .note-weakness) { display: inline-block; max-width: 100%; vertical-align: top; }
:is(.board-doc, .notes-preview, .notes-print) .cornell-workspace__page-title { font-family: 'Kaopy Reading Latin', var(--font-sans); color: var(--reading-heading); letter-spacing: .025em; }
.cornell-main > .cornell-workspace__section-title {
  width: fit-content;
  padding: 3px 14px 3px 10px;
  border-inline-start: 5px solid var(--reading-section);
  background: var(--reading-section-soft);
  color: var(--reading-section);
}
.cornell-sidebar :is(.cornell-workspace__section-title, .note-label) {
  width: fit-content;
  padding: 1px 6px;
  border-inline-start: 3px solid var(--reading-heading);
  background: var(--reading-heading-soft);
  color: var(--reading-heading);
  font-family: 'Kaopy Reading Latin', var(--font-sans);
  font-size: 13px;
}
.cornell-sidebar { border-right-style: dashed; }
.cornell-sidebar .cornell-rich-content { font-size: 15px; line-height: 1.8; }
.cornell-sidebar :is(.note-tip, .note-annotation, .note-question, .note-clue, .note-warning, .note-weakness) { padding: 0; border: 0; border-radius: 0; background: transparent; --reading-ground: var(--reading-paper); }
.cornell-sidebar .note-annotation { color: var(--reading-annotation); font-family: 'Kaopy Reading Latin', var(--reading-hand); }
/* 「本页总结」：标题原是产品链接蓝、每条的左线原是产品标记黄，两者都不表示可点或标记，换成阅读层的墨水蓝与细线 */
.cornell-summary > .cornell-workspace__section-title { color: var(--reading-heading); }
.cornell-summary > .cornell-workspace__list > li { border-left-color: var(--reading-rule); }
.aside-answer { font-size: 16px; }
.cornell-summary .cornell-rich-content { font-size: 16px; }

@media (max-width: 600px) {
  .msg-body { font-size: 16px; line-height: 1.85; }
  .cornell-rich-content { font-size: 16px; }
}
@media (forced-colors: active) {
  :is(.msg-body, .aside-answer, .cornell-rich-content) :is(strong, mark) { background: none; text-decoration: underline; }
}
