/*
 * 阅读页三栏 —— 章节栏贴左、本页目录贴右、正文居中限宽
 *
 * 【Workspace 上限 1600】整层 width:100% + max-width:1600px，超宽后水平居中。
 * 窗口更窄时仍铺满侧栏右侧。左右栏 270、正文 --kb-read-max、1099/999 断点都不看这个上限。
 *
 * 【--kb-toolbar-h 由 reader.js 量出来写回】这里的值只是 JS 没跑起来时的兜底。
 * 章节栏 / 目录栏的 sticky top 与 max-height 都依赖它，写歪了会「滚到底最后一条点不到」。
 * 宽屏顶栏是 display:none（返回/搜索已进左栏），量出来会是 0，这是预期。
 */
.mytheme-kb-reader {
  /*
   * 【别在这里定义 --kb-primary】设置页的主色是靠 wp_head 输出 :root{--kb-primary:…}
   * 生效的（见 includes/enqueue.php）。在 .mytheme-kb-reader 上再写一遍，对本子树来说
   * 它比 :root 更近，会把用户设的颜色整个盖掉——取色器看着能存，前台永远是默认红。
   * 用到的地方一律 var(--kb-primary, #e03030) 自带兜底。
   */
  /*
   * 左右栏定 270：大屏三栏对齐（左章节 / 正文 / 右目录）。窗口变窄时不要靠把
   * 两栏再压细来硬撑三栏——1099 收掉右栏、999 收成抽屉，正文才不会被挤成细条
   * （2026-08-06 定宽 240+200 却没断点、窗口 1100~1300 时正文只剩四百来像素）。
   */
  --kb-nav-w: 270px;
  --kb-toc-w: 270px;
  /* 贴边留白：窄屏收到 1rem，宽屏最多 2rem，不做到 0，否则字直接顶着视口边 */
  --kb-gutter: clamp(1rem, 2.2vw, 2rem);
  /* 正文块最大宽度：行长收在约四十来个汉字内，再宽读起来要甩头 */
  --kb-read-max: 800px;
  /* 正文块与两侧分隔线之间至少留这么多（中列吃紧时按 vw 自动收窄）
   * 下限 1.5rem=24px：对齐合集/知识库阅读页边（390 宽屏净宽约 327～342） */
  --kb-read-inset: clamp(1.5rem, 1.8vw, 2.5rem);
  --kb-toolbar-h: 0px;
  /* 三栏共用顶距：左栏从回书架圆钮起算 */
  --kb-col-pad-top: 1.25rem;
  /*
   * 回书架圆钮那一行（钮高 + 跟搜索框的空隙）。
   * 中列标题、右栏「本页目录」要跟搜索框顶齐，得把这一行垫过去——
   * 三条顶线是：搜索框 / 章节标题 / 本页目录，不是返回钮那条。
   */
  --kb-back-size: 40px;
  --kb-back-gap: 0.65rem;
  --kb-back-row-h: calc(var(--kb-back-size) + var(--kb-back-gap));
  --kb-align-top: calc(var(--kb-col-pad-top) + var(--kb-back-row-h));
  width: 100%;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
  min-height: calc(100vh - 4rem);
}

.mytheme-kb-reader-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem var(--kb-gutter);
  /*
   * 窄屏才看得见这条：宽屏顶栏收掉了。吸顶时正文会滚到它下面，留一条极淡的线。
   */
  border-bottom: 1px solid #f5f5f5;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

/* 圆钮 pill：theme/assets/css/chrome-back.css（.mytheme-kb-back） */

.mytheme-kb-reader-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 500;
}

/* 章节页里书名是回概括页的链接，但不要长得像链接：旁边圆钮也回概括页 */
.mytheme-kb-reader-title a {
  color: inherit;
  text-decoration: none;
}

.mytheme-kb-reader-title a:hover {
  color: var(--kb-primary, #e03030);
}

/* 章节抽屉开关：宽屏用不上（章节栏就在左边），只在收成抽屉的宽度出现 */
.mytheme-kb-nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: #666;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.mytheme-kb-nav-toggle:hover {
  background: #f5f5f5;
  color: #222;
}

.mytheme-kb-reader-grid {
  display: grid;
  grid-template-columns: var(--kb-nav-w) minmax(0, 1fr) var(--kb-toc-w);
  /* 栏间不留 gap：分隔线正好落在栏边界上，空档由各栏自己的 padding 给 */
  column-gap: 0;
  align-items: start;
  width: 100%;
}

/*
 * 【不要给两侧栏加分隔线】2026-08-06 明确要求：三栏之间、正文四周一条线都不要，
 * 全靠留白分区（参考站就是纯白平铺）。别再「为了分区更清楚」把 border 加回来。
 */
.mytheme-kb-chapter-nav {
  display: flex;
  flex-direction: column;
  /* 左内边距 = gutter：章节栏贴到壳的左缘 */
  padding: var(--kb-col-pad-top) 1.25rem 2.5rem var(--kb-gutter);
  /* 栏高等于视口，返回/搜索钉在顶上，章节列表自己滚 */
  height: calc(100vh - var(--kb-toolbar-h));
  max-height: calc(100vh - var(--kb-toolbar-h));
  /*
   * 滚动交给里面的 .mytheme-kb-nav-scroll，外层 overflow:visible 才不会把
   * 搜索下拉结果裁掉（下拉要比这一列更宽，铺到正文上面）。
   *
   * sticky 本身会建层叠上下文；不写 z-index 时左栏和中列按 DOM 顺序画，
   * 正文里的视频会盖住溢出到中列的搜索结果。抬一层，下拉才能压在视频上。
   * 窄屏抽屉另有 z-index:40，这里只覆盖宽屏三栏。
   */
  overflow: visible;
  position: sticky;
  top: var(--kb-toolbar-h);
  z-index: 2;
}

.mytheme-kb-nav-tools {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

.mytheme-kb-nav-tools .mytheme-kb-back {
  display: inline-flex;
  margin-bottom: var(--kb-back-gap);
}

.mytheme-kb-nav-search {
  position: relative;
}

.mytheme-kb-nav-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 36px;
  padding: 0 0.65rem;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  cursor: text;
}

.mytheme-kb-nav-search-bar:focus-within {
  border-color: #111;
}

.mytheme-kb-nav-search-icon {
  display: flex;
  flex-shrink: 0;
  color: #999;
}

.mytheme-kb-nav-search-icon svg {
  width: 16px;
  height: 16px;
}

.mytheme-kb-nav-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0.45rem 0;
  /* 窄屏抽屉里必须 ≥16，避免 iOS 聚焦整页放大；宽屏用 caption 14 */
  font-size: 16px;
  color: #222;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.mytheme-kb-nav-search-input::-webkit-search-decoration,
.mytheme-kb-nav-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.mytheme-kb-nav-search-input::placeholder {
  color: #999;
}

.mytheme-kb-nav-search-input:focus {
  outline: none;
}

.mytheme-kb-nav-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, 72vw);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid #eee;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  z-index: 50;
  max-height: 360px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.5rem;
}

.mytheme-kb-nav-search-results a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  color: #222;
  text-decoration: none;
}

.mytheme-kb-nav-search-results a:hover {
  background: #f9fafb;
}

.mytheme-kb-nav-search-results strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
}

.mytheme-kb-search-book {
  margin-top: 0.15rem;
  font-size: 13px;
  color: #999;
}

.mytheme-kb-nav-search-results a > div:last-child {
  margin-top: 0.2rem;
  font-size: 13px;
  color: #666;
}

.mytheme-kb-nav-search-results mark {
  background: rgba(240, 48, 48, 0.15);
  color: var(--kb-primary, #e03030);
}

.mytheme-kb-search-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0.25rem;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  line-height: 1.4;
}

.mytheme-kb-search-divider::before,
.mytheme-kb-search-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.mytheme-kb-search-divider span {
  flex-shrink: 0;
}

.mytheme-kb-nav-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.mytheme-kb-nav-root,
.mytheme-kb-nav-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mytheme-kb-nav-children {
  padding-left: 0.75rem;
}

/* 「介绍」跟章节不是一类东西，靠一点留白隔开就够（这一栏不用分隔线） */
.mytheme-kb-nav-intro {
  margin-bottom: 0.5rem;
}

.mytheme-kb-nav-root a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: #666;
  text-decoration: none;
  /* caption 14 / 400 / 20：左右栏同一档，比正文 16/28 更紧，方便扫目录 */
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  /* 栏宽就这么宽：短的一行放下，长的到边就省略，不要折成两行把列表撑高 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mytheme-kb-nav-root a:hover {
  background: #f7f7f7;
  color: #222;
}

.mytheme-kb-nav-root li.is-active > a {
  background: rgba(240, 48, 48, 0.08);
  color: var(--kb-primary, #e03030);
}

/* 分组只是名字：加粗不可点，和上下组分得开一点 */
.mytheme-kb-nav-group {
  margin: 1rem 0 0.2rem;
  padding: 0.15rem 0.6rem 0.35rem;
  pointer-events: none;
  user-select: none;
}

.mytheme-kb-nav-intro + .mytheme-kb-nav-group {
  margin-top: 0.75rem;
}

.mytheme-kb-nav-group span {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: #222;
}

/*
 * 正文块：在中列里居中并限宽。中列本身很宽（吃掉两栏之外的全部空间），
 * 靠 justify-self:center + width:min() 让左右留白自动对称——参考站量出来的
 * 「章节栏→正文」与「正文→目录」间距是相等的。
 */
.mytheme-kb-content {
  /*
   * 减掉 inset*2：既保证窄屏时文字不顶到视口边，也让宽屏时左右留白对称。
   * 不再套 .card，也不要加左右 padding——行宽就等于 --kb-read-max，多一层 padding
   * 会让实际行宽莫名比设定值窄一截。
   */
  width: min(100% - var(--kb-read-inset) * 2, var(--kb-read-max));
  justify-self: center;
  margin-block: 0 4rem;
  /* 跟左栏搜索框、右栏「本页目录」同一条顶线，不跟「← 书架」齐 */
  padding-top: var(--kb-align-top);
}

/*
 * 章节标题用阅读档页面 H1：28 / 600 / 36。
 * 顶线跟搜索框对齐；不再用 display 40，也不再跟正文 H2 同号。
 */
.mytheme-kb-content-header {
  margin: 0;
}

/*
 * 章节封面：可选，16:9。坐在标题前面，跟正文同一行宽。
 * 用 cover 裁切，避免竖图把阅读栏撑得过长。
 */
.mytheme-kb-chapter-cover {
  margin: 0 0 20px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #f3f4f6;
}

.mytheme-kb-chapter-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mytheme-kb-content-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 20px;
}

.mytheme-kb-chapter-cover + .mytheme-kb-content-header h1 {
  margin-top: 0;
}

.mytheme-kb-content-header h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 36px;
  letter-spacing: -0.02em;
  color: #222;
  margin: 0;
}

.mytheme-kb-content-header + .mytheme-membership-gate {
  margin-top: 0;
}

/* AI 摘要插在 H1 与正文之间，去掉卡片自带的大上边距，避免和标题 20px 叠出空洞 */
.mytheme-kb-content-header:has(+ .aas-summary-card) .mytheme-kb-content-title {
  margin-bottom: 16px;
}

.mytheme-kb-content-header + .aas-summary-card {
  margin-top: 0;
  margin-bottom: 20px;
}

.mytheme-kb-content .mytheme-kb-entry-content > :first-child,
.mytheme-kb-content .mytheme-kb-entry-content .entry-content > :first-child {
  margin-top: 0;
}

/*
 * 标题下第一块若是视频：不要再叠视频自己的 20px 上边距。
 * 视频后面的 H2 已经把 36px 清成 0，只留视频下边距 20px——上下要同一档。
 * :has(+ 视频) 那条是给「分段器仍吐出开头空行」的旧 HTML / 整页缓存兜底。
 */
.mytheme-kb-content-header + .mytheme-kb-entry-content > .entry-content:first-child:has(> .mytb-coll-segment-gap:only-child),
.mytheme-kb-content-header + .aas-summary-card + .mytheme-kb-entry-content > .entry-content:first-child:has(> .mytb-coll-segment-gap:only-child) {
  display: none;
}

.mytheme-kb-content-header + .mytheme-kb-entry-content > .mytb-coll-video-block:first-child,
.mytheme-kb-content-header + .mytheme-kb-entry-content > .entry-content:first-child:has(> .mytb-coll-segment-gap:only-child) + .mytb-coll-video-block,
.mytheme-kb-content-header + .aas-summary-card + .mytheme-kb-entry-content > .mytb-coll-video-block:first-child,
.mytheme-kb-content-header + .aas-summary-card + .mytheme-kb-entry-content > .entry-content:first-child:has(> .mytb-coll-segment-gap:only-child) + .mytb-coll-video-block {
  margin-top: 0;
}

/*
 * 【H1 要比正文靠左】合集前台 .mytb-coll-body 里 entry-content / 条目卡 / 视频块
 * 还套着 max-width:48rem + 左右 auto 居中（合集整页本来就宽）。书架阅读页外层已经用
 * --kb-read-max 收过行宽，再居中一截就会让 100% 视频/小节标题缩进，章节一级标题却在
 * .mytb-coll-body 外面铺满——肉眼就是「标题没对齐」。这里取消内层 max-width。
 * 正文栏仍贴左；视频块左右 auto：100% 铺满无空隙，25/50/75% 在栏里居中。
 */
.mytheme-kb-content .mytb-coll-body .entry-content,
.mytheme-kb-content .mytb-coll-body .mytb-coll-items,
.mytheme-kb-content .mytb-coll-body .mytb-coll-video-block {
  max-width: none;
}

.mytheme-kb-content .mytb-coll-body .entry-content,
.mytheme-kb-content .mytb-coll-body .mytb-coll-items {
  margin-left: 0;
  margin-right: 0;
}

.mytheme-kb-content .mytb-coll-body .mytb-coll-video-block {
  margin-left: auto;
  margin-right: auto;
}

/* 视频块后面的 H2：分段器单独一块，用块自己的下边距，不再叠 36 */
.mytheme-kb-entry-content .mytb-coll-video-block + .entry-content > h2:first-child,
.mytheme-kb-entry-content .mytb-coll-video-block + .entry-content > h3:first-child {
  margin-top: 0;
}

/*
 * Markdown ``` / 从 Obsidian 粘过来的 <pre><code>：跟「插入代码块」同款浅底墨字。
 * WHY：主题 .entry-content pre 是深色底浅字，本文件又给 pre code 写了 #222，
 * 两套叠在一起就是黑底黑字。粘贴块没有 .mytb-code-block 壳，必须自己盖过主题。
 * 不用命中 .mytb-code-block 里的 pre（那层由 code-block.css 管）。
 */
.mytheme-kb-entry-content > pre,
.mytheme-kb-entry-content .entry-content > pre {
  margin: 1.5em 0;
  max-width: 100%;
  padding: 14px;
  overflow: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  background: #fcfcfc;
  color: #222222;
  font-size: 14px; /* text-caption · 等宽代码例外 */
  line-height: 1.6;
  font-family: Consolas, Monaco, "Courier New", monospace;
}

/*
 * 行内 code：跟后台 TinyMCE 同款灰底墨字。
 * 主题 .entry-content code 也会盖一层；这里再写一次，避免阅读页外层没有
 * entry-content（有工具卡/代码块时走 mytb-coll-body）时掉回浏览器默认。
 */
.mytheme-kb-entry-content code {
  background: #f3f4f6;
  color: #222222;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 14px; /* text-caption */
  font-family: Consolas, Monaco, "Courier New", monospace;
}

.mytheme-kb-entry-content pre code,
.mytheme-kb-entry-content pre code code,
.mytheme-kb-entry-content .mytb-code-block code {
  background: transparent;
  color: #222222;
  padding: 0;
  border-radius: 0;
}

/*
 * 高亮：红底必须配白字。章节里常见 TinyMCE/块编辑器留下的
 * has-inline-color has-vivid-red-color，全局样式带 color:!important，
 * 会盖过主题 .entry-content mark 的白字 → 红字压红底完全看不清。
 */
.mytheme-kb-entry-content mark {
  background-color: #cc1818;
  color: #ffffff !important;
  padding: 0.05em 0.25em;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* 工具条是 sticky 的：点目录跳转时留出它的高度，否则标题被压在工具条底下 */
.mytheme-kb-entry-content :is(h1, h2, h3) {
  scroll-margin-top: calc(var(--kb-toolbar-h) + 1.25rem);
}

.mytheme-kb-attachments {
  margin-top: 2.5rem;
}

.mytheme-kb-attachments h2 {
  font-size: 15px;
  font-weight: 600;
  color: #999;
  margin: 0 0 0.5rem;
}

.mytheme-kb-attachments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mytheme-kb-attachments-list .mytheme-kb-file-card {
  margin: 0;
}

/*
 * 正文文件卡：压缩包/文档不再只剩一条蓝链。
 * 字号跟设计系统：文件名 15/600/#222，大小 13/400/#999。
 * 整卡是 <a download>，右侧下载标只是视觉，不另套按钮。
 */
.mytheme-kb-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 20px auto;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  color: #222 !important;
  text-decoration: none !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mytheme-kb-file-card:hover,
.mytheme-kb-file-card:focus-visible {
  border-color: #d4d4d4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  color: #222 !important;
  text-decoration: none !important;
}

.mytheme-kb-file-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #111, 0 2px 8px rgba(0, 0, 0, 0.04);
}

.mytheme-kb-file-card__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mytheme-kb-file-card__icon svg {
  display: block;
  width: 40px;
  height: 40px;
}

.mytheme-kb-file-card__body {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mytheme-kb-file-card__name {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mytheme-kb-file-card__size {
  display: block;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: #999;
}

.mytheme-kb-file-card__download {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #999;
}

.mytheme-kb-file-card:hover .mytheme-kb-file-card__download,
.mytheme-kb-file-card:focus-visible .mytheme-kb-file-card__download {
  color: #222;
}

@media (prefers-reduced-motion: reduce) {
  .mytheme-kb-file-card {
    transition: none;
  }
}

/* 上一篇 / 下一篇：文档站那种左右灰箭头 + 标题，不要「上一篇」标签、不要卡片框 */
.mytheme-kb-adjacent {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #eee;
}

.mytheme-kb-adjacent-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  min-height: 24px;
  text-decoration: none;
  color: #666;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.mytheme-kb-adjacent-link:hover {
  color: #222;
}

.mytheme-kb-adjacent-link:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

/* 只有下一篇时别让它顶到左边，保持「上一篇在左、下一篇在右」的方位感 */
.mytheme-kb-adjacent-link.next {
  grid-column: 2;
  justify-self: end;
}

.mytheme-kb-adjacent-icon {
  flex-shrink: 0;
  display: block;
}

.mytheme-kb-adjacent-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .mytheme-kb-adjacent {
    grid-template-columns: minmax(0, 1fr);
  }
  .mytheme-kb-adjacent-link {
    min-height: 44px;
  }
  .mytheme-kb-adjacent-link.next {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mytheme-kb-adjacent-link,
  .mytheme-kb-edit-link {
    transition: none;
  }
}

.mytheme-kb-page-toc {
  /* 右内边距 = gutter：目录栏贴到壳的右缘。顶距跟左栏回书架圆钮一条线；
   * 「本页目录」标题仍靠下面的 edit-slot 垫到跟搜索框齐。 */
  padding: var(--kb-col-pad-top) var(--kb-gutter) 2.5rem 1.25rem;
  position: sticky;
  top: var(--kb-toolbar-h);
  max-height: calc(100vh - var(--kb-toolbar-h));
  overflow: auto;
}

/*
 * 这一格对齐左栏回书架圆钮那一行。管理员编辑键坐在这里；游客是空占位，
 * 好让「本页目录」继续跟搜索框顶齐。
 */
.mytheme-kb-page-toc-edit-slot {
  display: flex;
  align-items: center;
  min-height: var(--kb-back-size);
  margin-bottom: var(--kb-back-gap);
}

.mytheme-kb-edit-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 24px;
  padding: 0 0.625rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: #666;
  font-size: 13px; /* text-footnote */
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.mytheme-kb-edit-link:hover {
  background: #e5e7eb;
  color: #222;
}

.mytheme-kb-edit-link:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.mytheme-kb-edit-link-icon {
  flex-shrink: 0;
}

/* 窄屏本页目录整列会收掉，编辑键改挂章节标题上方 */
.mytheme-kb-edit-link--inline {
  display: none;
  margin: 0 0 0.75rem;
}

.mytheme-kb-page-toc-title {
  /* caption 14 / 20：跟左栏搜索框同一条顶线 */
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: #999;
  margin: 0 0 0.75rem;
}

/*
 * 【这条竖导轨是要的】2026-08-06 确认：正文四周和栏间都不要线，但本页目录这一列
 * 要保留左侧导轨——浅灰细线贯穿整个列表，当前小节那一段换成主色压在导轨上。
 * 标题「本页目录」跟左栏搜索框顶齐，字号仍是 caption 14。
 */
.mytheme-kb-page-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid #ebebeb;
}

.mytheme-kb-page-toc-list a,
.mytheme-kb-page-toc-list .mytheme-kb-page-toc-item {
  display: block;
  /* caption 14 / 400 / 20：与左栏章节树同一档，不要用 subhead 15 */
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: #666;
  text-decoration: none;
  padding: 0.3rem 0 0.3rem 0.75rem;
  /* 负 margin 让 2px 的激活线正好盖住 1px 导轨，而不是并排显示成两条 */
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mytheme-kb-page-toc-list a:hover {
  color: #222;
}

.mytheme-kb-page-toc-list a.is-active {
  color: var(--kb-primary, #e03030);
  border-left-color: var(--kb-primary, #e03030);
  font-weight: 500;
}

/* 试读壳：大纲可见但正文锚点不在，条目不可点 */
.mytheme-kb-page-toc.is-toc-locked .mytheme-kb-page-toc-item {
  color: #999;
  cursor: default;
}

.mytheme-kb-page-toc.is-toc-locked .mytheme-kb-page-toc-rail-bar {
  cursor: default;
  pointer-events: none;
}

/* h3 再缩进一档，跟 h2 拉开层级 */
.mytheme-kb-page-toc-list .level-3 a,
.mytheme-kb-page-toc-list .level-3 .mytheme-kb-page-toc-item {
  padding-left: 1.75rem;
}

/*
 * 概括页 /docs/{book}/
 *
 * 封面入口：不占章节栏。中列一块在整页里水平+垂直居中；简介仍用书 excerpt。
 * 左上角回书架圆钮是绝对定位，不进这列文档流，避免把封面顶下去。
 *
 * 【缓存里的旧 HTML】概括页曾输出章节栏。新 CSS 仍把 .is-intro 里的栏藏掉，
 * 避免整页缓存未清时左边还露着目录。
 */
.mytheme-kb-reader.is-intro {
  position: relative;
}

.mytheme-kb-intro-back {
  position: absolute;
  top: var(--kb-col-pad-top);
  left: var(--kb-gutter);
  z-index: 2;
}

.mytheme-kb-reader-grid.is-intro {
  grid-template-columns: minmax(0, 1fr);
}

.mytheme-kb-reader-grid.is-intro .mytheme-kb-chapter-nav {
  display: none;
}

.mytheme-kb-reader-grid.is-intro .mytheme-kb-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 4rem);
  margin-block: 0;
  padding-top: 4.5rem;
  padding-bottom: 4rem;
}

.mytheme-kb-intro {
  width: 100%;
}

.mytheme-kb-intro-head {
  --kb-intro-cover-w: 240px;
  display: flex;
  align-items: start;
  gap: 2rem;
}

.mytheme-kb-intro-cover {
  position: relative;
  flex: 0 0 var(--kb-intro-cover-w);
  width: var(--kb-intro-cover-w);
  /* 书封永远 3:4，只等比例放大，绝不跟着简介拉高或压扁 */
  aspect-ratio: 3 / 4;
  align-self: start;
  border-radius: 14px;
  overflow: hidden;
  background: #f5f5f5;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.mytheme-kb-intro-cover img,
.mytheme-kb-intro-cover video {
  /* 绝对铺满，避免原图像素把封面盒子撑破、按钮再掉下去 */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mytheme-kb-intro-cover img.is-poster {
  z-index: 0;
}

.mytheme-kb-intro-cover video {
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .mytheme-kb-intro-cover video {
    display: none;
  }
}

.mytheme-kb-intro-badge {
  position: absolute;
  z-index: 2;
  left: 0.75rem;
  bottom: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.5;
  color: #fff;
  background: var(--kb-primary, #e03030);
}

.mytheme-kb-intro-badge.is-completed {
  background: rgba(0, 0, 0, 0.55);
}

.mytheme-kb-intro-badge.is-preview {
  top: 12px;
  right: -40px;
  bottom: auto;
  left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0.32rem 2rem 0.24rem;
  border-radius: 0;
  font-size: 13px; /* text-footnote */
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
  color: #fff;
  background: var(--kb-primary, #e03030);
  transform: rotate(45deg);
}

.mytheme-kb-intro-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  /* 右栏跟封面一样高：顶书名、底基础信息，中间简介占多少是多少 */
  min-height: calc(var(--kb-intro-cover-w) * 4 / 3);
}

.mytheme-kb-intro-copy {
  min-width: 0;
}

.mytheme-kb-intro-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
}

.mytheme-kb-intro-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 0;
}

.mytheme-kb-intro-title-row:has(+ .mytheme-kb-intro-body) {
  margin-bottom: 1rem;
}

.mytheme-kb-intro-title {
  font-size: 28px;
  font-weight: 600;
  line-height: 36px;
  letter-spacing: -0.02em;
  color: #222;
  margin: 0;
}

.mytheme-kb-edit-link--title {
  display: inline-flex;
  flex-shrink: 0;
  align-self: center;
}

.mytheme-kb-intro-stats {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
}

.mytheme-kb-intro-stats > div {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
  font-size: 14px; /* text-caption */
  line-height: 20px;
  color: #666; /* ink-secondary */
}

.mytheme-kb-intro-stats dt,
.mytheme-kb-intro-stats dd {
  display: inline;
  margin: 0;
  font-size: inherit;
  font-weight: 400;
  line-height: inherit;
  color: inherit;
}

.mytheme-kb-intro-stats dt::after {
  content: "：";
}

.mytheme-kb-intro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.mytheme-kb-intro-actions .myquiz-intro-btn {
  margin-left: 0;
}

.mytheme-kb-intro-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: #1a1a1a;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.mytheme-kb-intro-start:hover {
  background: #000;
  color: #fff;
}

.mytheme-kb-intro-start:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.mytheme-kb-intro-start__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* 空书：按钮位置留着但明确不可点，免得看起来像加载失败 */
.mytheme-kb-intro-start.is-disabled,
.mytheme-kb-intro-start.is-disabled:hover {
  background: #f0f0f0;
  color: #999;
  cursor: default;
}

.mytheme-kb-intro-body {
  margin: 0;
  cursor: default;
}

.mytheme-kb-intro-body p {
  font-size: 16px; /* text-body */
  font-weight: 330;
  line-height: 28px;
  color: #666; /* ink-secondary */
  margin: 0;
  overflow-wrap: anywhere;
}

.mytheme-kb-intro-body p + p {
  margin-top: 12px;
}

/*
 * 断点定在 1100：两栏取 clamp 下限（230 + 190 = 420）后，正文还能剩 400 上下，
 * 三栏是撑得住的，所以别急着丢目录——用户要的就是「目录贴右边」。
 * 真到 1100 以下才撤目录，把宽度全给正文。
 */
@media (max-width: 1099px) {
  .mytheme-kb-reader-grid {
    grid-template-columns: var(--kb-nav-w) minmax(0, 1fr);
  }
  .mytheme-kb-page-toc {
    display: none;
  }
  .mytheme-kb-edit-link--inline {
    display: inline-flex;
  }
}

/* 宽屏：顶栏收掉，返回和搜索只出现在左栏「介绍」上面 */
@media (min-width: 1000px) {
  .mytheme-kb-reader-toolbar {
    display: none;
  }
  .mytheme-kb-nav-search-input {
    font-size: 14px;
  }
  /*
   * 旧缓存概括页没有 .mytheme-kb-intro-back，章节栏又被上面藏掉了，
   * 把顶栏露出来只留「← 书架」，免得回书架入口一起消失。
   */
  .mytheme-kb-reader:has(.mytheme-kb-reader-grid.is-intro):not(:has(.mytheme-kb-intro-back)) .mytheme-kb-reader-toolbar {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-bottom: 0;
    background: transparent;
    backdrop-filter: none;
  }
  .mytheme-kb-reader:has(.mytheme-kb-reader-grid.is-intro):not(:has(.mytheme-kb-intro-back)) .mytheme-kb-reader-title {
    visibility: hidden;
  }
}

/*
 * 1000 以下章节栏收成抽屉（☰ 打开）。
 *
 * 【为什么不是 767】站点自己左边还有一条 240px 的全站侧栏，它在 768 就出现了。
 * 768~1000 这一档若章节栏还占着 200px，正文只剩三百来像素，比手机还窄。
 */
@media (max-width: 999px) {
  /*
   * .is-intro 必须一起点名：它是 0-2-0，比裸的 .mytheme-kb-reader-grid 更具体，
   * 媒体查询里的后写规则压不过它，漏掉的话概括页在手机上还留着 200px 的空侧栏。
   */
  .mytheme-kb-reader-grid,
  .mytheme-kb-reader-grid.is-intro {
    grid-template-columns: minmax(0, 1fr);
  }
  .mytheme-kb-reader {
    --kb-toolbar-h: 59px;
    --kb-back-size: 44px;
  }
  .mytheme-kb-nav-tools .mytheme-kb-back {
    display: none;
  }
  .mytheme-kb-chapter-nav {
    position: fixed;
    inset: var(--kb-toolbar-h) auto 0 0;
    width: min(82vw, 330px);
    height: auto;
    max-height: none;
    background: #fff;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.08);
  }
  .mytheme-kb-reader.is-nav-open .mytheme-kb-chapter-nav {
    transform: translateX(0);
  }
  /* 章节栏收起来了，才需要这个开关。概括页没有目录抽屉，不要 ☰ */
  .mytheme-kb-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mytheme-kb-reader.is-intro .mytheme-kb-nav-toggle,
  .mytheme-kb-reader:has(.mytheme-kb-reader-grid.is-intro) .mytheme-kb-nav-toggle {
    display: none;
  }
  /* 窄屏有顶栏，中列用 margin 跟工具条拉开，不再跟侧栏抢同一条顶线 */
  .mytheme-kb-content {
    margin-block: 1.5rem 4rem;
    padding-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mytheme-kb-chapter-nav {
    transition: none;
  }
}

@media (max-width: 767px) {
  .mytheme-kb-content {
    margin-block: 1.5rem 3rem;
  }
  .mytheme-kb-content-title {
    margin-bottom: 16px;
  }
  .mytheme-kb-chapter-cover {
    margin-bottom: 16px;
    border-radius: 8px;
  }
  /* 概括页在窄屏改成上下排：封面留一半宽，再窄书名就没地方站了 */
  .mytheme-kb-intro-head {
    --kb-intro-cover-w: min(52%, 200px);
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
  }
  .mytheme-kb-intro-cover {
    flex-basis: auto;
    width: var(--kb-intro-cover-w);
    aspect-ratio: 3 / 4;
    align-self: start;
  }
  .mytheme-kb-intro-main {
    min-height: 0;
  }
  .mytheme-kb-intro-foot {
    margin-top: 1rem;
    padding-top: 0;
  }
  .mytheme-kb-intro-title-row {
    margin-bottom: 0;
  }
  .mytheme-kb-intro-title-row:has(+ .mytheme-kb-intro-body) {
    margin-bottom: 1rem;
  }
  .mytheme-kb-intro-title {
    font-size: 28px;
  }
  .mytheme-kb-edit-link--title {
    min-height: 44px;
    height: 44px;
    padding: 0 0.85rem;
  }
  .mytheme-kb-intro-stats {
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
  }
}

.kb-mermaid {
  background: #fafafa;
  border-radius: 12px;
  padding: 1rem;
  overflow: auto;
}

/* 旧「幻灯片」已删。沉浸阅读在 reader-immersive.css，不要把旧样式加回本文件。 */

/* ---- 文档机器人 FAB：对齐日报资讯机器人（primary-500 #e03030 / 36px） ---- */
.mytheme-kb-reader-bot {
	position: fixed;
	/*
	 * JS 会按阅读壳右缘再钉一次；这里是 JS 没跑起来时的兜底。
	 * 贴窗右边，不要再按「本页目录」文字左缘往里收。
	 */
	right: max(0.75rem, calc(env(safe-area-inset-right) + 0.5rem));
	bottom: max(3.5rem, calc(env(safe-area-inset-bottom) + 2.25rem));
	z-index: 45;
	pointer-events: none;
}

.mytheme-kb-reader-bot.is-chat-open {
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
}

.mytheme-kb-reader-bot-fab {
	position: relative;
	pointer-events: auto;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 999px;
	background: #e03030;
	box-shadow: 0 1px 2px rgba(17, 17, 17, 0.08);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	user-select: none;
	-webkit-appearance: none;
	appearance: none;
	transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease, opacity 0.15s ease;
}

.mytheme-kb-reader-bot-fab:hover {
	background: #c52a2a;
	box-shadow: 0 4px 6px rgba(17, 17, 17, 0.1);
}

.mytheme-kb-reader-bot-fab:active {
	transform: scale(0.98);
}

.mytheme-kb-reader-bot-fab:focus-visible {
	outline: none;
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(224, 48, 48, 0.4);
}

.mytheme-kb-reader-bot-fab-eye {
	position: absolute;
	top: 12px;
	width: 5px;
	height: 12px;
	border-radius: 999px;
	background: #fff;
	transition: height 0.1s ease-out;
	will-change: transform;
}

.mytheme-kb-reader-bot-fab-eye--left {
	left: 10px;
}

.mytheme-kb-reader-bot-fab-eye--right {
	right: 10px;
}

.mytheme-kb-reader-bot-fab-eye.is-blink {
	height: 2px;
}

@media (max-width: 767px) {
	.mytheme-kb-reader-bot {
		right: max(1.75rem, calc(env(safe-area-inset-right) + 1rem));
		bottom: max(5.75rem, calc(env(safe-area-inset-bottom) + 4.75rem));
	}
}

@media (prefers-reduced-motion: reduce) {
	.mytheme-kb-reader-bot-fab,
	.mytheme-kb-reader-bot-fab-eye {
		transition: none !important;
	}
}

/* 章节评论：上下篇下面；输入条共用主题 myt-reply-composer */
.mytheme-kb-comments {
	margin-top: 2rem;
	padding-top: 1.5rem;
}

.mytheme-kb-comments .myt-reply-composer {
	margin-top: 0;
}

.mytheme-kb-comment-list + .myt-reply-composer,
.mytheme-kb-comment-list + .mytheme-kb-comments-note {
	margin-top: 16px;
}

.mytheme-kb-comment-list,
.mytheme-kb-comment-list .children {
	margin: 0;
	padding: 0;
	list-style: none;
}

.mytheme-kb-comment-list .children {
	padding-left: 3.25rem;
}

.mytheme-kb-comment {
	margin: 0;
	padding: 1.25rem 0;
	border-top: 1px solid #f3f3f3;
}

.mytheme-kb-comment-list > .mytheme-kb-comment:first-child {
	border-top: 0;
	padding-top: 0;
}

.mytheme-kb-comment-body {
	display: flex;
	gap: 0.75rem;
	align-items: flex-start;
}

.mytheme-kb-comment-avatar {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
}

.mytheme-kb-comment-avatar img,
.mytheme-kb-comment-avatar .avatar,
.mytheme-kb-comment-avatar-img {
	display: block;
	width: 40px;
	height: 40px;
	border-radius: 999px;
	object-fit: cover;
}

.mytheme-kb-comment-main {
	flex: 1;
	min-width: 0;
}

.mytheme-kb-comment-head {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	margin-bottom: 0.35rem;
}

.mytheme-kb-comment-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	flex: 1;
	min-width: 0;
}

.mytheme-kb-comment-more {
	position: relative;
	flex: none;
	margin-left: auto;
}

.mytheme-kb-comment-more__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: #999;
	cursor: pointer;
}

.mytheme-kb-comment-more__btn:hover,
.mytheme-kb-comment-more__btn:focus-visible,
.mytheme-kb-comment-more.is-open .mytheme-kb-comment-more__btn {
	color: #222;
	background: #f7f7f7;
	outline: none;
}

.mytheme-kb-comment-more__btn svg {
	display: block;
	width: 16px;
	height: 16px;
}

.mytheme-kb-comment-more__menu[hidden] {
	display: none;
}

.mytheme-kb-comment-more__menu {
	position: absolute;
	top: calc(100% + 4px);
	right: 0;
	z-index: 8;
	display: flex;
	flex-direction: column;
	min-width: 148px;
	margin: 0;
	padding: 8px;
	border: 1px solid #eee;
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.96);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

.mytheme-kb-comment-more__item {
	display: block;
	width: 100%;
	margin: 0;
	padding: 10px 12px;
	border: 0;
	border-radius: 12px;
	background: transparent;
	color: #222;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.4;
	text-align: left;
	cursor: pointer;
}

.mytheme-kb-comment-more__item:hover,
.mytheme-kb-comment-more__item:focus-visible {
	background: #f9fafb;
	outline: none;
}

.mytheme-kb-comment-more__item--danger,
.mytheme-kb-comment-more__item--danger:hover {
	color: #e03030;
}

.mytheme-kb-comment-author {
	font-size: 15px;
	font-weight: 500;
	color: #222;
}

.mytheme-kb-comment-badge {
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	color: var(--kb-primary, #e03030);
	background: #fdecec;
	padding: 0.15rem 0.4rem;
	border-radius: 4px;
}

.mytheme-kb-comment-time {
	font-size: 13px;
	color: #999;
}

.mytheme-kb-comment-pending {
	margin: 0 0 0.35rem;
	font-size: 13px;
	color: #b45309;
}

.mytheme-kb-comment-text {
	font-size: 16px;
	font-weight: 330;
	line-height: 1.75;
	color: #666;
}

.mytheme-kb-comment-text p {
	margin: 0 0 0.35rem;
}

.mytheme-kb-comment-text p:last-child {
	margin-bottom: 0;
}

.mytheme-kb-comment-text img,
.mytheme-kb-comment-img img {
	display: block;
	max-width: min(100%, 420px);
	height: auto;
	margin-top: 0.5rem;
	border-radius: 12px;
}

.mytheme-kb-comment-reply {
	margin-top: 0.35rem;
}

.mytheme-kb-comment-reply a {
	font-size: 13px;
	color: #999;
	text-decoration: none;
}

.mytheme-kb-comment-reply a:hover,
.mytheme-kb-comment-reply a:focus-visible {
	color: #222;
}

.mytheme-kb-comments-note {
	margin: 1.25rem 0 0;
	font-size: 14px;
	color: #999;
}

@media (max-width: 767px) {
	.mytheme-kb-comment-list .children {
		padding-left: 1.25rem;
	}

	.mytheme-kb-comment-more__btn {
		width: 44px;
		height: 44px;
	}
}
