/* ==========================================================================
   Hekouwang — Typora theme (V2 编辑 · 素白/墨绿（免费默认） · free · skill V2)
   默认：中文长文阅读档（work）· 素白纸面 + 墨绿强调 + Anthropic Sans/Inter 西文与系统中文混排。
   浅色 / 深色各一份：hekouwang.css · hekouwang-dark.css。

   本文件由 scripts/build.py 从 scripts/tokens.json 生成，请勿手改。
   改视觉 → 改 tokens.json → 重跑 build.py。
   ========================================================================== */

/* --------------------------------------------------------------------------
   字体
   实测：Anthropic Sans 共 581 字符、CJK 汉字 0 个，连「，」「。」都没有。
   所以中文必然 fallback 到系统字体 —— 桌面端本身就是这个机制，不是妥协。
   栈序铁律：西文族必须排在中文族之前，否则中文字体会把西文一起吃掉。

   local() 优先命中系统已装字体；未装则读主题目录内的文件；
   两者都没有时，优雅降级到 -apple-system。
   -------------------------------------------------------------------------- */
/* ⚠️ 别用 format("truetype-variations")：那是早期实验语法，
   Typora 内嵌的 Chromium 不认识它，整条 src 会被丢弃 → 悄悄 fallback 到 SF Pro。
   在新版 Chrome 里测是通过的，所以这个坑只有在 Typora 里才暴露。
   正解：woff2 优先（体积小、可变字体支持面最广），ttf 作兜底，
   format 一律用标准值，让不认识的浏览器跳到下一个 src 而不是整条作废。 */
@font-face {
  font-family: "Hekouwang Sans";
  src: local("Anthropic Sans"),
       local("Anthropic Sans Text"),
       url("./hekouwang/fonts-local/AnthropicSans-Romans-Variable-25x258.woff2") format("woff2"),
       url("./hekouwang/fonts-local/AnthropicSans-Romans-Variable-25x258.ttf") format("truetype");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  font-feature-settings: "dlig" 0;
}
@font-face {
  font-family: "Hekouwang Sans";
  src: local("Anthropic Sans"),
       local("Anthropic Sans Text Italic"),
       url("./hekouwang/fonts-local/AnthropicSans-Italics-Variable-25x258.woff2") format("woff2"),
       url("./hekouwang/fonts-local/AnthropicSans-Italics-Variable-25x258.ttf") format("truetype");
  font-weight: 300 800;
  font-style: italic;
  font-display: swap;
  font-feature-settings: "dlig" 0;
}
@font-face {
  font-family: "Hekouwang Serif";
  src: local("Anthropic Serif"),
       local("Anthropic Serif Text"),
       url("./hekouwang/fonts-local/AnthropicSerif-Romans-Variable-25x258.woff2") format("woff2"),
       url("./hekouwang/fonts-local/AnthropicSerif-Romans-Variable-25x258.ttf") format("truetype");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Hekouwang Mono";
  src: local("Anthropic Mono"),
       local("Anthropic Mono Variable"),
       url("./hekouwang/fonts-local/AnthropicMonoVariable.woff2") format("woff2"),
       url("./hekouwang/fonts-local/AnthropicMonoVariable.ttf") format("truetype");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

/* —— 兜底字体：Inter（SIL OFL，随包分发）——
   没有 Anthropic 字体的人（也就是绝大多数下载者）会落到这一层。
   Inter 与 Anthropic Sans 同属几何人文 sans，x-height 接近，
   与苹方混排的基线关系也接近，是最省事的替身。
   只打包 latin 子集：中文由系统字体承担，不需要 CJK。 */
@font-face {
  font-family: "Hekouwang Sans Fb";
  src: url("./hekouwang/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Hekouwang Sans Fb";
  src: url("./hekouwang/fonts/inter-latin-wght-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* 字体诊断条：主题装好后，在 Typora 里新建一篇 md 粘贴
   <p class="bone-probe">Handgloves Fupanwang 2026</p>
   若它与正文西文长得一样 → 字体已生效；若明显不同 → 没加载上。 */
.hk-probe { font-family: "Hekouwang Sans", sans-serif; }
.hk-probe-fallback { font-family: -apple-system, sans-serif; }

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;   /* 原生控件/滚动条跟浅色或深色变体一致 */
  /* —— Typora 官方变量（优先覆盖这些，而不是硬写规则）—— */
  --bg-color:                 #ffffff;
  --text-color:               #37413c;
  --side-bar-bg-color:        #fafaf7;
  --item-hover-bg-color:      #f2f3ef;
  --item-hover-text-color:    #37413c;
  --active-file-bg-color:     #f2f3ef;
  --active-file-text-color:   #141a17;
  --active-file-border-color: #2e6f5e;
  --primary-color:            #2e6f5e;
  --primary-btn-border-color: #2e6f5e;
  --primary-btn-text-color:   #ffffff;
  --window-border:            rgba(20,26,23,0.14);
  --md-char-color:            #636e68;
  --meta-content-color:       #59635d;
  --control-text-color:       #4c554f;
  --control-text-hover-color: #37413c;
  --select-text-bg-color:     rgba(46,111,94,0.16);
  --search-select-bg-color:   rgba(46,111,94,0.26);
  --blur-text-color:          #59635d;
  --monospace:                "Hekouwang Mono", "Anthropic Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --rawblock-edit-panel-bd:   rgba(20,26,23,0.14);
  --mermaid-theme:            neutral;

  /* —— Bone 私有 —— */
  --hk-raised:    #ffffff;
  --hk-sunken:    #f7f8f3;
  --hk-ink:       #141a17;
  --hk-soft:      #4c554f;
  --hk-muted:     #59635d;
  --hk-faint:     #636e68;
  --hk-accent:    #2e6f5e;
  --hk-accent-decor: #2e6f5e;
  --hk-accent-text: #2e6f5e;
  --hk-on-accent: #ffffff;
  --hk-control-border: #848c86;
  --hk-accent2:   #2e6f5e;
  --hk-accent3:   #2e6f5e;
  --hk-link:      #2e6f5e;
  --hk-link-hover: #235647;
  --hk-code:      #37413c;
  --hk-hairline:  rgba(20,26,23,0.10);
  --hk-line:      rgba(20,26,23,0.14);
  --hk-divider:   rgba(20,26,23,0.20);
  --hk-r-sm:      0;
  --hk-r:         0;
  --hk-r-lg:      0;
  --hk-pill:      999px;
  --hk-sans:      "Hekouwang Sans", "Anthropic Sans", "Hekouwang Sans Fb", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --hk-serif:     "Hekouwang Serif", "Anthropic Serif", Georgia, "Times New Roman", "Songti SC", serif;
  /* 用户可在 hekouwang.user.css 中覆盖，不必重建整套配色。 */
  --hk-reading-measure: clamp(48rem, calc(100vw - 16rem), 96rem);
}

/* --------------------------------------------------------------------------
   骨架
   -------------------------------------------------------------------------- */
html {
  font-size: 16px;          /* 规范：唯一允许用 px 的地方 */
  /* 画布 = 纸面色。导出无 <content>，html 即整页底；
     若 html 与 #write 一深一浅，就会「外面有底色、中间白柱」。 */
  background-color: #ffffff;
}

html, body {
  font-family: var(--hk-sans);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  font-feature-settings: "dlig" 0;
}

body {
  font-variant-numeric: proportional-nums;
  font-kerning: normal;
}

/* Windows：Typora 会在 body 挂 .os-windows。不能只把「微软雅黑」塞进通用
   fallback：system-ui 在 Windows 版本间的 CJK 回退并不稳定，且 macOS 的
   antialiased 会绕开 ClearType，长文会发灰。这里让阅读面、代码和 UI 控件
   共享可预期的栈；不打包 CJK 字体，保留系统更新与许可边界。 */
body.os-windows {
  --hk-sans: "Hekouwang Sans", "Anthropic Sans", "Hekouwang Sans Fb", "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  --hk-serif: "Hekouwang Serif", "Anthropic Serif", Georgia, "Times New Roman", "SimSun", serif;
  --monospace: "Hekouwang Mono", "Anthropic Mono", "Cascadia Mono", "Cascadia Code", Consolas, "Lucida Console", monospace;
  -webkit-font-smoothing: auto;
  font-smoothing: auto;
  text-rendering: auto;
  font-synthesis: none;
  letter-spacing: 0.005em;
}
body.os-windows #write {
  -webkit-font-smoothing: auto;
  text-rendering: auto;
  letter-spacing: 0;
}
body.os-windows input,
body.os-windows textarea,
body.os-windows select,
body.os-windows button { font: inherit; }

/* 编辑区：两侧 gutter 铺浅底；纸感跟 #write 走，宽度随窗口伸缩 */
content {
  background: #f8f8f5;
}

#write {
  width: 100%;
  max-width: min(120em, calc(var(--hk-reading-measure) + 2 * 2rem + 6rem), calc(100% - 4rem));
  box-sizing: border-box;
  margin: 0 auto;
  margin-top: 1rem;
  padding: 2.25rem 2rem 5rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-color);
  caret-color: var(--hk-accent);
  overflow-wrap: break-word;
  text-autospace: normal;
  text-spacing-trim: space-first;
  hanging-punctuation: first last allow-end;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  font-feature-settings: "dlig" 0;
  /* Anthropic Sans opsz：正文用 Text 光学尺寸（轴默认 16） */
  font-variation-settings: "opsz" 16;
  background: radial-gradient(140% 95% at 50% -8%, #ffffff 0%, #ffffff 48%, #fbfbf8 100%); border-radius: var(--hk-r-lg); box-shadow: 0 1px 2px rgba(20,26,23,0.04);
}

/* 宽窗口保留技术画布；正文阅读列在下方单独限宽。
   纸面只比阅读列多出 wide_canvas_extra，避免正文两侧留出大片空纸。 */
@media (min-width: 1440px) {
  #write {
    max-width: min(120em, calc(var(--hk-reading-measure) + 2 * 2rem + 6rem), calc(100% - 4rem));
  }
}

/* 含 Windows 分屏在内的窄窗口：避免双重 padding 把正文挤成竖条。 */
@media (max-width: 760px) {
  #write {
    max-width: calc(100% - 1.5rem);
    margin-top: 0.75rem;
    padding: 1.5rem 1.25rem 3.5rem;
    border-radius: var(--hk-r);
  }
}
/* 侧栏收起时：纸面直接铺满内容区，不再出现纸边 / gutter / 投影；
   正文仍由 --hk-reading-measure 限宽居中。检测 Typora 的 body.pin-outline：
   侧栏打开时 Typora 会加这个类，收起时移除。

   ⚠️ 这里必须写实色，不能用 var(--bg-color)。
   Typora 启动时会把上一个主题的窗口底色缓存进偏好 backgroundColor，
   再写进 body 的 --bg-color（body 上的是 inline style，压过主题 :root）。
   于是深色主题 + 侧栏收起 = 浅色纸面 + 浅色正文 = 整页几乎看不见。
   这条规则只在侧栏收起时生效，所以症状只在折叠后出现。
   参见 references/typora-spec.md 第 6 个静默坑：纸面一律写实色。 */
body:not(.pin-outline) content {
  background: #f8f8f5;
}
body:not(.pin-outline) #write {
  max-width: none;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  background: #ffffff;
  box-shadow: none;
}

/* 裸 pre > code 用于预览/HTML 片段；Typora 编辑器的 CodeMirror 仍自行滚动。
   pre 保留 overflow:visible 以让语言工具浮层可见，因此在 code 子节点折行。 */
@media screen {
  body:not(.typora-export) #write pre.md-fences > code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
}

/* C：首行缩进只打在段落上，绝不能写在 #write 上 —— 否则会继承到
   列表 / 标题 / 图片，序号会顶到最左、图片左侧空出一截灰底。
   对齐 Typora base 的 #write.first-line-indent p 机制。
   默认 tech 为 "0"；散文可读改为 "2em"。 */
#write p {
  text-indent: 0;
}
#write li,
#write li p,
#write blockquote p,
#write table p,
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6,
#write .md-alert,
#write .md-toc,
#write pre,
#write p * {
  text-indent: 0;
}
/* 有首行缩进时，顶层列表整体右移，与正文首行对齐；
   嵌套序号就会落在「核心配置要素」这一级后面，而不是文档最左 */
#write > ul,
#write > ol {
  margin-left: 0;
}

#write > p {
  margin-top: 0;
  margin-bottom: 0.85rem;
}

#write > p:last-child { margin-bottom: 0; }

/* 宽屏补偿：1792px 起阅读列触顶 96rem（约 96 字/行）。
   1.65 的行距撑不住这个行宽，正文与引用放宽到 1.78、段距到 1rem；
   表格与代码保持原密度，避免整页被拉松。 */
@media screen and (min-width: 1800px) {
  #write { line-height: 1.78; }
  #write > p { margin-bottom: 1rem; }
  #write table { line-height: 1.6; }
}

/* --------------------------------------------------------------------------
   标题
   字距克制：满幅汉字标题不宜强负 tracking（会挤）；西文标题仍略收一点。
   层级主要靠字号、字重、上下距，不靠装饰色块。
   -------------------------------------------------------------------------- */
#write h1, #write h2, #write h3,
#write h4, #write h5, #write h6 {
  font-family: var(--hk-sans);
  color: var(--hk-ink);
  break-after: avoid;
  text-wrap: balance;
  overflow-wrap: break-word;
  /* 大纲 / 目录跳转后给标题留出顶部呼吸，避免贴住工具栏 */
  scroll-margin-top: 3rem;
}
#write p, #write li { text-wrap: pretty; }

#write h1 { font-size: 2.125rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; margin: 2rem 0 1rem; font-variation-settings: "opsz" 32; }
#write h2 { font-size: 1.5rem; line-height: 1.3; font-weight: 700; letter-spacing: -0.02em; margin: 2.15rem 0 0.85rem; font-variation-settings: "opsz" 24; }
#write h3 { font-size: 1.25rem; line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; margin: 1.4rem 0 0.5rem; font-variation-settings: "opsz" 20; }
#write h4 { font-size: 1.0625rem; line-height: 1.4; font-weight: 700; letter-spacing: 0; margin: 1.15rem 0 0.35rem; }
#write h5 { font-size: 0.9375rem; line-height: 1.45; font-weight: 650; margin: 0.95rem 0 0.28rem; }
#write h6 { font-size: 0.875rem; line-height: 1.45; font-weight: 650; margin: 0.9rem 0 0.28rem; color: var(--hk-muted); }

#write h1:first-child, #write h2:first-child,
#write h3:first-child, #write h4:first-child { margin-top: 0; }

/* 开篇第一枚 H2：题头区之后多一口气，后文章节仍用常规 h2.mt */
#write h1 ~ h2:first-of-type {
  margin-top: calc(2.15rem + 0.55rem);
}

/* 标题不加装饰线 —— Claude 桌面端靠字号/字重分层，没有签名下划线 */

/* --------------------------------------------------------------------------
   行内
   -------------------------------------------------------------------------- */
/* 强调保持正文墨色，靠字重建立层级；不把语义强调降成灰字。 */
#write strong { font-weight: 650; color: inherit; }
#write h1 strong, #write h2 strong, #write h3 strong,
#write h4 strong, #write h5 strong, #write h6 strong {
  color: inherit;
}
/* 强调：不用着重号。长句（尤其是「*(图：…)＊」图注）整段打点会像疹子；
   斜体对拉丁有效，CJK 无真斜体时保持正常字形、略用字色区分即可。 */
#write em {
  font-style: italic;
  color: var(--hk-soft);
}
#write figcaption em,
#write p > em:only-child {
  /* 图注 / 独占一段的说明：不斜、不抢，只做小字灰提示 */
  font-style: normal;
  color: var(--hk-muted);
  font-size: 0.875rem;
}
#write del    { color: var(--hk-muted); }

#write a {
  color: var(--hk-link);
  text-decoration: underline;
  text-decoration-color: rgba(46,111,94,0.50);
  text-underline-offset: 0.22em;
  text-decoration-thickness: from-font;
  transition: text-decoration-color .15s ease, color .15s ease;
}
#write a:hover {
  color: var(--hk-link-hover);
  text-decoration-color: var(--hk-accent);
}

#write mark {
  background: rgba(46,111,94,0.16);
  color: inherit;
  border-radius: var(--hk-r-sm);
  padding: 0.05em 0.2em;
}

/* 行内代码：极轻的中性浅底 + 深灰字，不抢正文 */
#write code,
#write tt {
  font-family: var(--monospace);
  font-size: 0.9em;
  color: var(--hk-code);
  background: rgba(20,26,23,0.04);
  border: none;
  border-radius: var(--hk-r-sm);
  padding: 0.12em 0.34em;
  word-break: break-word;
}

#write h1 code, #write h2 code, #write h3 code,
#write h4 code, #write h5 code, #write h6 code {
  font-size: 0.88em;
}

/* --------------------------------------------------------------------------
   引用
   V2 的粗浅灰竖线 + 弱化字色，不加沉底——沉底会让 `> ![](...)` 截图变成灰画框，
   也会让长文引用变成色块墙。
   -------------------------------------------------------------------------- */
#write blockquote {
  margin: 1.1rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 0.5rem solid var(--hk-line);
  background: transparent;
  color: var(--hk-muted);
}
#write blockquote blockquote {
  margin: 0.5rem 0;
  border-left-color: var(--hk-line);
}
/* 题头署名 / byline：紧跟 H1 的第一条引用（如「——来自…」），去左边线、缩小灰阶；正文里的 > 仍保留竖线 */
#write h1 + blockquote {
  border-left: none;
  padding: 0;
  margin: 1.35rem 0 1.2rem;
  color: var(--hk-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}
#write h1 + blockquote > p {
  margin: 0;
  color: inherit;
}
/* 题头元数据里的 code 不再铺灰底：一行八个小按钮会把 H1 压下去 */
#write h1 + blockquote code {
  background: transparent;
  padding: 0;
  color: var(--hk-soft);
}
/* 纯图片引用：去掉左边线与内边距，截图贴正文栏宽。
   ⛔ :has() 不能嵌套在另一个 :has() 里；旧写法会让整条规则被浏览器丢弃。 */
#write blockquote:has(> p:only-child > .md-image:only-child),
#write blockquote:has(> p:only-child > img:only-child),
#write blockquote:has(> figure) {
  border-left: none;
  padding: 0;
  color: inherit;
}
#write blockquote:has(> p:only-child > .md-image:only-child) > p,
#write blockquote:has(> p:only-child > img:only-child) > p,
#write blockquote:has(> figure) > p {
  margin: 0;
  text-indent: 0;
}

/* --------------------------------------------------------------------------
   列表 —— disc/decimal + outside + padding-left≈18px，
   项间距由 type.list_gap 控制。圆点用正文软色，不抢 【标签】/加粗。
   -------------------------------------------------------------------------- */
#write ul, #write ol {
  margin: 0 0 0.85rem;
  padding-left: 1.1rem;
}
#write li { margin: 0.26rem 0; }
#write li > p { margin: 0.26rem 0; }

#write ul:not(.task-list) {
  list-style-type: disc;
  list-style-position: outside;
}
#write ul:not(.task-list) > li::marker {
  color: var(--hk-soft);
}
#write ol {
  list-style-type: decimal;
  list-style-position: outside;
}
#write ol li::marker {
  color: var(--hk-muted);
  font-variant-numeric: tabular-nums;
}
#write li > ul,
#write li > ol {
  margin-top: 0.15rem;
  margin-bottom: 0.15rem;
  padding-left: 1.1rem;
}

#write ul.task-list { padding-left: 1.25rem; }
#write ul.task-list li.task-list-item { list-style: none; }
#write .md-task-list-item > input {
  -webkit-appearance: none;
  appearance: none;
  width: 1.05em;
  height: 1.05em;
  margin-left: -1.45em;
  margin-top: 0.28em;
  border: 1.5px solid var(--hk-control-border);
  border-radius: var(--hk-r-sm);
  background: var(--hk-raised);
  transition: background .15s ease, border-color .15s ease;
}
#write .md-task-list-item > input:hover { border-color: var(--hk-accent-text); }
#write .md-task-list-item > input:checked {
  background: var(--hk-ink);
  border-color: var(--hk-ink);
}
#write .md-task-list-item > input:checked::after {
  content: "";
  display: block;
  width: 0.28em;
  height: 0.55em;
  margin: 0.08em 0 0 0.32em;
  border: solid var(--hk-on-accent);
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}
/* 任务列表：不加卡片底——清单文档一屏十几条灰块会毁阅读流。
   完成态只淡字色，不删线（删线在密集 checklist 里噪声太大）。 */
#write li.md-task-list-item > p { margin: 0.26rem 0; }
#write li.md-task-list-item > input:checked ~ p,
#write li.md-task-list-item > input:checked ~ span {
  color: var(--hk-muted);
}

/* --------------------------------------------------------------------------
   代码块
   -------------------------------------------------------------------------- */
#write pre.md-fences {
  font-family: var(--monospace);
  font-size: 0.9375rem;
  line-height: 1.55;
  background: var(--hk-sunken);
  border: 1px solid var(--hk-hairline);
  border-radius: var(--hk-r);
  padding: 0.88rem 1.05rem;
  margin: 1.25rem 0;
  color: var(--text-color);
  box-shadow: none;
  /* 继承自 #write 的 hanging-punctuation 会把行首 [ 挂到盒外再被裁 */
  hanging-punctuation: none;
  text-spacing-trim: space-all;
  /* ⛔ 勿设 overflow-x:auto —— 规范会把 overflow-y 也变成 auto，
     裁掉 Typora 语言输入框（.code-tooltip 在 bottom:-2.5em） */
  overflow: visible;
}
/* 连续短 fence：多留一点，避免实操贴连成灰条墙 */
#write pre.md-fences + pre.md-fences {
  margin-top: 1.55rem;
}
#write pre.md-fences,
#write pre.md-fences .CodeMirror,
#write pre.md-fences .CodeMirror-code,
#write pre.md-fences .CodeMirror-line {
  hanging-punctuation: none;
  /* 默认 8 列会让 YAML / Makefile 的缩进宽一倍 */
  tab-size: 4;
  -moz-tab-size: 4;
}
#write pre.md-fences .CodeMirror-lines {
  padding: 0.15rem 0;
}
#write pre.md-fences .CodeMirror pre {
  padding: 0 0.5rem; /* 左右留空，避免 [ ] 贴边被裁 */
}
#write pre.md-fences.md-focus { border-color: var(--hk-accent-text); }

/* 语言选择器：必须露在代码块下方，可点可输入 */
.md-fences .code-tooltip {
  background: var(--hk-raised);
  border: 1px solid var(--hk-line);
  border-radius: var(--hk-r-sm);
  box-shadow: 0 6px 18px rgba(20,26,23,0.05);
  color: var(--text-color);
  z-index: 30;
  pointer-events: auto;
}
.md-fences .code-tooltip .ty-input,
.md-fences .code-tooltip .ty-cm-lang-input,
.md-fences .code-tooltip input {
  color: var(--text-color);
  caret-color: var(--hk-accent);
  min-width: 8em;
}

/* 语法高亮：低饱和语义色，跟白纸同一个色温 */
.cm-s-inner .CodeMirror-gutters   { background: transparent; border: none; }
.cm-s-inner .CodeMirror-linenumber{ color: var(--hk-faint); }
.cm-s-inner .CodeMirror-cursor    { border-left: 1.5px solid var(--hk-accent); }
.cm-s-inner div.CodeMirror-selected,
.cm-s-inner .CodeMirror-selectedtext { background: rgba(46,111,94,0.16); }
.cm-s-inner .CodeMirror-activeline-background { background: transparent; }

.cm-s-inner .cm-comment  { color: #5f6a64; font-style: italic; }
.cm-s-inner .cm-keyword  { color: #7c3aed; }
.cm-s-inner .cm-atom     { color: #7c3aed; }
.cm-s-inner .cm-def      { color: #0b5f92; }
.cm-s-inner .cm-variable { color: var(--text-color); }
.cm-s-inner .cm-variable-2,
.cm-s-inner .cm-variable-3 { color: #0b5f92; }
.cm-s-inner .cm-property { color: #0b5f92; }
.cm-s-inner .cm-operator { color: var(--hk-soft); }
.cm-s-inner .cm-string,
.cm-s-inner .cm-string-2 { color: #147239; }
.cm-s-inner .cm-number   { color: #9c5405; }
.cm-s-inner .cm-tag      { color: #7c3aed; }
.cm-s-inner .cm-attribute{ color: #9c5405; }
.cm-s-inner .cm-builtin  { color: #0b5f92; }
.cm-s-inner .cm-meta     { color: var(--hk-muted); }
.cm-s-inner .cm-link     { color: var(--hk-link); }
.cm-s-inner .cm-error    { color: #c81d25; }

/* 源码模式保持与正文接近的阅读宽度，并保留 Typora 的行号内边距。 */
#typora-source .CodeMirror-lines {
  box-sizing: border-box;
  max-width: min(calc(var(--hk-reading-measure) + 4rem), calc(100% - 4rem));
  margin: 0 auto;
}
@media (max-width: 760px) {
  #typora-source .CodeMirror-lines { max-width: calc(100% - 1.5rem); }
}
/* 源码模式（另一套 CodeMirror 主题类，cm-s-inner 管不到） */
.cm-s-typora-default .cm-header      { color: var(--hk-ink); font-weight: 650; }
.cm-s-typora-default .cm-comment     { color: #5f6a64; }
.cm-s-typora-default .cm-string      { color: #147239; }
.cm-s-typora-default .cm-link        { color: var(--hk-link); }
.cm-s-typora-default .cm-variable-2  { color: var(--hk-soft); }
#typora-source .CodeMirror-cursor    { border-left: 1.5px solid var(--hk-accent); }

/* --------------------------------------------------------------------------
   表格
   表头：极淡沉底 + ink 字色（认出行，不成灰条带）。
   常规表填满阅读列，宽数据表使用技术画布和局部滚动。
   -------------------------------------------------------------------------- */
#write table {
  margin: 1.1rem 0;
  width: 100%;
  min-width: min(100%, 32rem);
  max-width: 100%;
  font-size: 0.875rem;
  border-collapse: collapse;
  border: 1px solid var(--hk-hairline);
}
/* ≥ table_wide_min_cols 列的宽数据表：内容放得下时与阅读列对齐，
   放不下才向技术画布展开，再宽则在自身滚动容器中滚动。
   nth 由 tokens layout.table_* 注入（默认 compact≤3 → nth 4；wide≥10 → nth 10）。 */
@media screen {
  #write figure > table:has(tr > :nth-child(10)) {
    min-width: max-content;
    max-width: none;
  }
  #write > figure:has(> table tr > :nth-child(10)) {
    box-sizing: border-box;
    width: fit-content;
    min-width: min(100%, var(--hk-reading-measure));
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  /* 多列表多为短数值，收窄单元格左右留白，免得只因留白就横向滚动。 */
  #write table:has(tr > :nth-child(10)) :is(th, td) {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
}
/* compact+1 .. wide-1 列：填满响应式阅读列。 */
#write > figure:has(> table):not(:has(> table tr > :nth-child(10))) {
  box-sizing: border-box;
  max-width: min(100%, var(--hk-reading-measure));
  margin-left: auto;
  margin-right: auto;
}
/* 1..compact 列：按内容变宽；触顶阅读列后 figure 横向滚动，避免挤成一字一行。
   紧凑表开 overflow 会挡列拖拽把手——此类表很少拖列，可读性优先。 */
#write > figure:has(> table):not(:has(> table tr > :nth-child(4))) {
  width: fit-content;
  max-width: min(100%, var(--hk-reading-measure));
  margin-left: max(0px, calc((100% - var(--hk-reading-measure)) / 2));
  margin-right: auto;
  overflow-x: auto;
}
#write > figure:has(> table):not(:has(> table tr > :nth-child(4))) > table {
  width: max-content;
  max-width: none;
}
/* 窄窗：中列表也给单元格下限 + 局部滚动（桌面中列表仍靠折行，保留列拖拽）。 */
@media screen and (max-width: 1100px) {
  body:not(.typora-export) #write > figure:has(> table):not(:has(> table tr > :nth-child(10))) {
    overflow-x: auto;
  }
  body:not(.typora-export) #write > figure:has(> table):not(:has(> table tr > :nth-child(10))) > table {
    max-width: none;
  }
  body:not(.typora-export) #write > figure:has(> table):not(:has(> table tr > :nth-child(10))) > table th,
  body:not(.typora-export) #write > figure:has(> table):not(:has(> table tr > :nth-child(10))) > table td {
    min-width: 7rem;
  }
  body:not(.typora-export) #write > figure:has(> table):not(:has(> table tr > :nth-child(10))) > table td:has(code) {
    min-width: 12rem;
  }
}
#write > table:not(:has(tr > :nth-child(10))) {
  width: min(100%, var(--hk-reading-measure));
  max-width: min(100%, var(--hk-reading-measure));
  margin-left: auto;
  margin-right: auto;
}
#write > table:not(:has(tr > :nth-child(4))) {
  width: max-content;
  max-width: min(100%, var(--hk-reading-measure));
  margin-left: max(0px, calc((100% - var(--hk-reading-measure)) / 2));
  margin-right: auto;
}
#write table th,
#write table td {
  overflow-wrap: break-word;
}
/* 首列多是编号 / 字段名：允许折行，但别把 P01 拆成 P0 / 1 */
#write table th:first-child,
#write table td:first-child {
  overflow-wrap: break-word;
}
/* 首列下限：避免「问题」「编号」被挤成竖排一字；多列表同样生效。 */
#write table :is(th, td):first-child {
  min-width: 4.5rem;
}
/* 紧凑表（标签/结论）首列尽量不拆字；过长时由 figure 横向滚动承接。 */
#write table:not(:has(tr > :nth-child(4))) :is(th, td):first-child {
  white-space: nowrap;
  overflow-wrap: normal;
}
#write table th {
  font-weight: 700;
  text-align: left;
  color: var(--hk-ink);
  background: rgba(20,26,23,0.03);
  border: 1px solid var(--hk-hairline);
  padding: 0.68rem 0.85rem;
  font-variant-numeric: tabular-nums;
}
#write table td {
  border: 1px solid var(--hk-hairline);
  padding: 0.68rem 0.85rem;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
/* 宽表只留横向分隔，避免变成 Excel 网格。 */
#write figure:has(> table tr > :nth-child(10)) th,
#write figure:has(> table tr > :nth-child(10)) td,
#write > table:has(tr > :nth-child(10)) th,
#write > table:has(tr > :nth-child(10)) td {
  border-left: 0;
  border-right: 0;
}
#write table tbody tr:hover { background: rgba(20,26,23,0.045); }
#write table code { font-size: 1em; }

/* --------------------------------------------------------------------------
   其他块
   -------------------------------------------------------------------------- */
#write hr {
  width: 100%;
  height: 1px;
  border: none;
  margin: 2.4rem auto;
  background: var(--hk-line);
}
/* Typora 给可聚焦的 .md-hr 加 5px 自动外框；点中 HR 时会像多出一条线 */
#write .md-hr:focus {
  outline: none;
}
#write .md-hr {
  padding: 0;
  border: 0;
}

/* 图片：只圆角，绝对不加任何背景/边框/阴影
   Typora 结构：<p><span class="md-image"><img></span></p> 或 <figure>
   每一层都必须显式透明；并补偿段落首行缩进（否则左侧空出一截，像灰底）。 */
#write img,
#write .md-image img,
#write a img {
  border-radius: var(--hk-r);
  max-width: 100%;
  height: auto;
  background: transparent;
  background-color: transparent;
  box-shadow: none;
}
/* :only-child 不计文本节点，句内图片也可能被 Typora 误排成整行。 */
#write p > .md-image,
#write p > .md-image:only-child {
  display: inline;
  width: auto;
}
#write p > .md-image img,
#write p > .md-image:only-child img,
#write p > img:only-child {
  display: inline-block;
  vertical-align: middle;
}
#write figure img { display: block; }
#write figure,
#write .md-image,
#write p > .md-image,
#write li .md-image,
#write p:has(> .md-image),
#write p:has(> img) {
  background: transparent;
  background-color: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
/* 对齐 Typora base：#write.first-line-indent p>.md-image… img { left:-2em }
   para_indent 为 "0" 时 calc 仍为 0，无副作用 */
#write p > .md-image:only-child:not(.md-img-error) img,
#write p > img:only-child {
  position: relative;
  left: calc(0px - 0);
}

/* 图注：居中 + 灰字 + 小字号，跟正文拉开层级 */
#write figcaption {
  text-align: center;
  color: var(--hk-muted);
  font-size: 0.875rem;
  margin-top: 0.4rem;
}

/* Typora 1.14 的可见块级公式使用 .md-math-block；.md-mathblock-panel 是编辑控件。 */
#write .md-math-block, #write .md-inline-math,
#write mjx-container, #write .katex { color: var(--text-color); }
#write .md-math-block {
  background: transparent;
  border: 1px solid var(--hk-hairline);
  border-radius: var(--hk-r);
  padding: 0.6rem 0.9rem;
  margin: 1.1rem 0;
  overflow-x: auto;
}
/* Typora 编辑时会加 .md-rawblock-on-edit，让内部公式工具条完整露出。 */
#write .md-math-block.md-rawblock-on-edit {
  overflow: visible;
  border-color: var(--hk-control-border);
}

/* Mermaid：浅色用 neutral 灰阶，避免默认主题的淡紫节点；
   图表块不铺代码块灰底，让图直接落在纸面上。 */
.md-diagram-panel { padding: 0.3rem 0; background: transparent; }
.md-diagram-panel-preview { background: transparent; }
#write pre.md-fences[lang="mermaid"],
#write pre.md-fences[lang="sequence"] {
  background: transparent;
  border-color: transparent;
}
#write .md-diagram-panel svg { background: transparent; }

/* YAML front matter */
#write pre.md-meta-block {
  background: var(--hk-sunken);
  border: 1px solid var(--hk-hairline);
  border-radius: var(--hk-r);
  padding: 0.7rem 0.95rem;
  color: var(--hk-muted);
  font-family: var(--monospace);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* 脚注 */
#write .md-def-footnote { color: var(--hk-muted); font-size: 0.875rem; }
#write sup.md-footnote {
  background: rgba(20,26,23,0.045);
  color: var(--hk-accent-text);
  border-radius: var(--hk-pill);
  padding: 1px 5px;
  font-size: 0.72em;
  /* 行内上标会把行盒撑高 1.3px，长文里出现忽松忽紧的行 */
  line-height: 0;
}
#write .footnotes {
  color: var(--hk-muted);
  font-size: 0.875rem;
  /* Typora base 默认 .footnotes{opacity:.8}，叠加后掉到 AA 以下 */
  opacity: 1;
}
#write .footnote-line { font-size: 0.875rem; }

/* 目录 */
#write .md-toc { font-size: 0.875rem; }
/* 目录是导航不是正文链接：默认用弱化墨色，悬停 / 焦点才点亮 */
#write .md-toc-item,
#write .md-toc-item a { color: var(--hk-soft); }
#write .md-toc-item:hover,
#write .md-toc-item:hover a,
#write .md-toc-item:focus-within,
#write .md-toc-item:focus-within a { color: var(--hk-link); }

/* GitHub 风格 callout：左边线定语义，底色压到几乎看不见 */
#write .md-alert {
  margin: 1.1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--hk-divider);
  border-radius: 0;
  background: rgba(9,105,218,0.04);
}
#write .md-alert-note      { border-left-color: #0969da;     background: rgba(9,105,218,0.04); }
#write .md-alert-important { border-left-color: #8250df; background: rgba(130,80,223,0.04); }
#write .md-alert-warning   { border-left-color: #976500;   background: rgba(154,103,0,0.05); }
#write .md-alert-tip       { border-left-color: #1d803a;       background: rgba(31,136,61,0.04); }
#write .md-alert-caution   { border-left-color: #cf222e;   background: rgba(207,34,46,0.04); }
#write .md-alert-text      { font-weight: 650; font-size: 0.9rem; }
#write .md-alert-text-note      { color: #0969da; }
#write .md-alert-text-important { color: #8250df; }
#write .md-alert-text-warning   { color: #976500; }
#write .md-alert-text-tip       { color: #1d803a; }
#write .md-alert-text-caution   { color: #cf222e; }

/* 宽纸面中的阅读列：连续文字和代码块居中对齐；宽表格、图表保留整幅空间。
   代码块不跟纸面同宽：收起侧边栏后会比正文两侧各宽出一截。 */
#write > :is(p, h1, h2, h3, h4, h5, h6, pre.md-fences,
             ul, ol, blockquote, hr, .md-hr, .md-alert, .md-toc,
             .md-htmlblock, .md-def-footnote, .footnotes) {
  box-sizing: border-box;
  max-width: min(100%, var(--hk-reading-measure));
  margin-left: auto;
  margin-right: auto;
}

/* Markdown 语法符号（未展开时的灰度） */
#write .md-meta { color: var(--md-char-color); font-family: var(--monospace); font-size: 0.9em; }

/* --------------------------------------------------------------------------
   Focus mode
   -------------------------------------------------------------------------- */
.on-focus-mode .md-end-block:not(.md-focus):not(.md-focus-container) *,
.on-focus-mode .md-end-block:not(.md-focus):not(.md-focus-container) {
  color: var(--blur-text-color);
  transition: color .2s ease;
}
.on-focus-mode .md-end-block:not(.md-focus):not(.md-focus-container) :is(img, input[type="checkbox"], .md-diagram-panel),
.on-focus-mode .md-math-block:not(.md-focus):not(.md-focus-container):not(.md-rawblock-on-edit) {
  opacity: 0.42;
  transition: opacity .2s ease;
}
.on-focus-mode pre.md-fences:not(.md-focus):not(.md-focus-container) .cm-s-inner span {
  color: var(--blur-text-color);
}

/* 键盘焦点要与装饰强调色分开：焦点环至少有 3:1 的边界对比。 */
#write a:focus-visible,
#write .md-task-list-item > input:focus-visible,
.btn:focus-visible,
.file-node-content:focus-visible,
.file-list-item:focus-visible,
#outline-content .outline-item:focus-visible,
#file-library-search-input:focus-visible,
#md-searchpanel input:focus-visible,
.ty-editor-toolbar-btn:focus-visible,
.ty-editor-toolbar-hint-close:focus-visible,
.ty-editor-toolbar-menu-item:focus-visible {
  outline: 2px solid var(--hk-accent-text);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   无障碍：尊重系统"减少动效"偏好
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  #write a, #write .md-task-list-item > input,
  .btn, .file-node-content:hover,
  .file-list-item:hover,
  .on-focus-mode .md-end-block:not(.md-focus):not(.md-focus-container),
  .on-focus-mode .md-end-block:not(.md-focus):not(.md-focus-container) *,
  .on-focus-mode .md-end-block:not(.md-focus):not(.md-focus-container) :is(img, input[type="checkbox"], .md-diagram-panel),
  .on-focus-mode .md-math-block:not(.md-focus):not(.md-focus-container):not(.md-rawblock-on-edit) {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   界面：侧边栏 / 文件树 / 大纲 / 搜索
   现成主题基本没管这块，这里逐项对齐桌面端。
   -------------------------------------------------------------------------- */
#typora-sidebar {
  background: var(--side-bar-bg-color);
  border-right: 1px solid var(--hk-hairline);
  font-family: var(--hk-sans);
}
/* 树：加大左边距 + 每层缩进，深层级不再贴纸边；给 4px 强调色条留空 */
#file-library-tree {
  padding-left: 14px;
  padding-right: 8px;
}
.file-tree-node {
  padding-left: 12px;
}
.file-node-content {
  padding-left: 2px;
}
.file-tree-node.active > .file-node-background {
  background: var(--active-file-bg-color);
  border-left-width: 3px;
  border-left-style: solid;
  border-left-color: var(--active-file-border-color);
}
#file-library-list {
  padding-left: 10px;
  padding-right: 8px;
}
.file-list-item {
  padding-left: 12px;
  padding-right: 10px;
}
#outline-content {
  padding-left: 12px;
  padding-right: 8px;
}
#typora-sidebar .file-list-item,
#typora-sidebar .file-node-content {
  color: var(--hk-soft);
  font-size: 0.875rem;
  border-radius: var(--hk-r-sm);
}
.file-node-content:hover,
.file-list-item:hover { background: var(--item-hover-bg-color); }
.file-list-item.active,
.file-node-content.active { background: var(--active-file-bg-color); color: var(--active-file-text-color); }
.file-list-item-summary,
.file-list-item-time { color: var(--hk-faint); }

#file-library-search-input,
#md-searchpanel input {
  background: var(--hk-raised);
  border: 1px solid var(--hk-line);
  border-radius: var(--hk-r-sm);
  color: var(--text-color);
}

#md-searchpanel {
  background: var(--hk-raised);
  border: 1px solid var(--hk-line);
  border-radius: var(--hk-r);
  box-shadow: 0 12px 32px rgba(20,26,23,0.14);
}
.md-search-hit    { background: rgba(46,111,94,0.16); border-radius: var(--hk-r-sm); }
.md-search-select { background: rgba(46,111,94,0.26); }

#outline-content .outline-item { color: var(--hk-soft); font-size: 0.875rem; border-radius: var(--hk-r-sm); }
#outline-content .outline-item:hover { background: var(--item-hover-bg-color); }
#outline-content .outline-active > .outline-item { color: var(--hk-accent-text); font-weight: 650; }

.sidebar-tabs, .sidebar-footer, #ty-sidebar-footer {
  border-color: var(--hk-hairline);
  color: var(--hk-muted);
}

/* 弹层 / 菜单 / 按钮 */
.modal-content, .popover .popover-content, .context-menu, .dropdown-menu {
  background: var(--hk-raised);
  border: 1px solid var(--hk-line);
  border-radius: var(--hk-r);
  box-shadow: 0 16px 44px rgba(20,26,23,0.14);
  font-family: var(--hk-sans);
}
.btn {
  border-radius: var(--hk-r-sm);
  border: 1px solid var(--hk-line);
  background: var(--hk-raised);
  color: var(--hk-soft);
}
.btn-primary {
  background: var(--hk-accent);
  border-color: var(--hk-accent);
  color: var(--hk-on-accent);
}

/* Typora 1.14 的浮动工具栏：保留原生位置和收起逻辑，只修正灰化文字与焦点。 */
.ty-editor-toolbar,
.ty-editor-toolbar-menu {
  background-color: var(--hk-raised);
  color: var(--text-color);
  border-color: var(--hk-control-border);
  font-family: var(--hk-sans);
}
.ty-editor-toolbar-btn,
.ty-editor-toolbar-hint-close,
.ty-editor-toolbar-hint-text,
.ty-editor-toolbar-menu-item .tmi-extra,
.ty-editor-toolbar-menu-item .tmi-icon,
.ty-editor-toolbar-select .fa {
  color: var(--hk-muted);
  opacity: 1;
}
.ty-editor-toolbar-btn,
.ty-editor-toolbar-hint-close { background-color: transparent; }
.ty-editor-toolbar-btn:is(:hover, .hover, .active, :focus-visible),
.ty-editor-toolbar-hint-close:is(:hover, :focus-visible),
.ty-editor-toolbar-menu-item:is(:hover, .active, :focus-visible) {
  color: var(--text-color);
}
.ty-editor-toolbar-btn:is(:hover, .hover, .active),
.ty-editor-toolbar-menu-item:is(:hover, .active) {
  background-color: var(--item-hover-bg-color);
}
.ty-editor-toolbar-divider,
.ty-editor-toolbar-menu-divider { background-color: var(--hk-control-border); }

/* 滚动条 */
.typora-node ::-webkit-scrollbar,
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(20,26,23,0.22);
  border-radius: var(--hk-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(20,26,23,0.36); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   顶栏 / 标题栏 / 菜单（整窗一致性最后一块）
   壳层 = 侧栏 / content gutter；顶栏显式铺 gutter（html 已改为画布色）。
   -------------------------------------------------------------------------- */
#top-titlebar,
titlebar {
  background-color: #f8f8f5;
  border-bottom: 1px solid var(--hk-hairline);
}
#top-titlebar .title-text {
  color: var(--hk-muted);
  font-size: 0.875rem;
}
#top-titlebar .title-text:hover { color: var(--text-color); }
#top-titlebar header:hover .title-text { color: var(--text-color); }
/* 窗口控制按钮区域：hover 不用系统默认的刺眼红/黄/绿 */
#top-titlebar #w-close:hover { background-color: #e81123; }
#top-titlebar #w-minimize:hover,
#top-titlebar #w-maximize:hover { background-color: rgba(0,0,0,.12); }
/* 大菜单面板 */
.megamenu-content {
  background: var(--hk-raised);
  color: var(--text-color);
  box-shadow: 0 16px 44px rgba(20,26,23,0.14);
}
.megamenu-menu-section { background: transparent; }
.megamenu-menu-list li a.active,
.megamenu-menu-list:not(.saved) li a:hover {
  background: var(--item-hover-bg-color);
  color: var(--item-hover-text-color);
}
/* 大菜单内的搜索框：默认白底输入框在深色大菜单里会露馅 */
.megamenu-content input {
  background: var(--hk-sunken);
  border: 1px solid var(--hk-line);
  border-radius: var(--hk-r-sm);
  color: var(--text-color);
}

/* --------------------------------------------------------------------------
   导出 / 打印
   1) 整页画布同色（纸面），拆掉 #write 浮卡片 —— 不许画布与纸面一深一浅
   2) 精装层：呼吸边距、H2 签名线、抬升 fence、表格圆角、渐变 HR
   导出 DOM：body.typora-export > .typora-export-content > #write
   !important 仅本段；check() 豁免。⛔ 不用左边彩色竖条。
   -------------------------------------------------------------------------- */

html {
  background: #ffffff !important;
  background-color: #ffffff !important;
}

body.typora-export,
body.typora-export .typora-export-content,
body.typora-export #write {
  background: #ffffff !important;
  background-color: #ffffff !important;
  background-image: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}
body.typora-export #write {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  /* 页内呼吸：保留 Typora 导出设置的左右留白，这里只补内边距。 */
  padding: 2rem 0.15rem 2.4rem !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* —— 标题：字距 + H2 底部签名线（非左边竖条）—— */
body.typora-export #write h1 {
  letter-spacing: -0.02em;
  margin-top: 0 !important;
  margin-bottom: 0.85rem !important;
}
body.typora-export #write h2 {
  width: fit-content;
  max-width: min(100%, var(--hk-reading-measure));
  margin-left: max(0px, calc((100% - var(--hk-reading-measure)) / 2));
  margin-right: auto;
  letter-spacing: -0.014em;
  padding-bottom: 0.55rem;
  margin-top: 2rem !important;
  background-image: linear-gradient(90deg, #2e6f5e 0%, transparent 100%);
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 2px;
}
body.typora-export #write h3 {
  letter-spacing: -0.006em;
  margin-top: 1.35rem !important;
}

/* 开篇元信息引用：h1 后连续引用更轻，不抢标题 */
body.typora-export #write h1 + blockquote,
body.typora-export #write h1 + blockquote + blockquote,
body.typora-export #write h1 + blockquote + blockquote + blockquote,
body.typora-export #write h1 + blockquote + blockquote + blockquote + blockquote {
  background: transparent !important;
  border-left: none !important;
  padding-left: 0 !important;
  color: var(--hk-muted);
  font-size: 0.92em;
  line-height: 1.55;
  margin: 0.2rem 0 !important;
}
body.typora-export #write h1 + blockquote {
  margin-top: 0.35rem !important;
}
body.typora-export #write h1 + blockquote + blockquote + blockquote + blockquote {
  margin-bottom: 1.25rem !important;
}

/* 普通引用：V2 的粗浅灰竖线 + 弱化字色，不加底 */
body.typora-export #write blockquote {
  background: transparent !important;
  border-left: 0.5rem solid rgba(20,26,23,0.14) !important;
  border-radius: 0 !important;
  padding: 0.1rem 0 0.1rem 1.1rem !important;
}

/* 标题 fence（发布文案灰盒）→ 纸面抬升，略亮于画布、绝不用纯白 */
body.typora-export #write pre.md-fences {
  background: #f7f8f3 !important;
  border: 1px solid rgba(20,26,23,0.10) !important;
  border-radius: var(--hk-r-lg) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55),
    0 8px 22px rgba(20,26,23,0.05) !important;
  padding: 1rem 1.2rem !important;
  margin: 0.85rem auto 1.15rem !important;
  /* 编辑区仍保留语言选择器；导出的静态代码允许长行在页内折行。 */
  white-space: pre-wrap !important;
  overflow-wrap: break-word !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  overflow: visible !important;
}
body.typora-export #write pre.md-fences code,
body.typora-export #write pre.md-fences .CodeMirror-line {
  white-space: pre-wrap !important;
  overflow-wrap: break-word !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
body.typora-export #write pre.md-fences + pre.md-fences {
  margin-top: 1.35rem !important;
}

/* 表格：圆角容器 + 表头轻强调 + 斑马纹 */
body.typora-export #write table {
  border-collapse: separate !important;
  border-spacing: 0;
  width: 100%;
  border: 1px solid rgba(20,26,23,0.10) !important;
  border-radius: var(--hk-r-lg);
  overflow: hidden;
  margin: 1rem 0 1.35rem !important;
  background: #f7f8f3 !important;
}
body.typora-export #write table th {
  background: rgba(20,26,23,0.03) !important;
  border-bottom: 1px solid rgba(20,26,23,0.10) !important;
  padding: 0.72rem 0.9rem !important;
  font-weight: 700;
}
body.typora-export #write table td {
  padding: 0.62rem 0.9rem !important;
  border-bottom: 1px solid rgba(20,26,23,0.10) !important;
  background: transparent !important;
}
body.typora-export #write table tbody tr:nth-child(even) td {
  background: rgba(20,26,23,0.045) !important;
}
body.typora-export #write table tbody tr:last-child td {
  border-bottom: none !important;
}
body.typora-export #write table tbody tr:hover {
  background: transparent !important;
}

/* 分隔线：中间淡入的品牌色 */
body.typora-export #write hr {
  width: 100% !important;
  max-width: var(--hk-reading-measure);
  height: 1px !important;
  border: 0 !important;
  margin: 1.85rem auto !important;
  background: rgba(20,26,23,0.14) !important;
}

/* 行内代码：在白纸上更清晰一点 */
body.typora-export #write code,
body.typora-export #write tt {
  background: rgba(20,26,23,0.04) !important;
  border-radius: var(--hk-r-sm);
  padding: 0.12em 0.38em;
}

@media print {
  .typora-export * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page {
    /* 纸张尺寸、页边距和页眉页脚交给 Typora 的导出设置。 */
    background: #ffffff;
  }
  html, body, #write {
    background: #ffffff !important;
    background-color: #ffffff !important;
    background-image: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  #write {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 0.15rem !important;
  }
  #typora-sidebar { display: none; }
  #write pre.md-fences, #write blockquote,
  #write figure:not(:has(> table)), #write img, #write .md-alert,
  #write .md-math-block { break-inside: avoid; }
  /* Typora base.css 在 macOS 对整表设 page-break-inside:avoid。
     表格 figure 和 table 都要恢复按行分页，否则长表会留下大块空白。 */
  #write figure.table-figure, #write figure.md-table-fig,
  #write table {
    break-inside: auto !important;
    page-break-inside: auto !important;
  }
  #write figure.table-figure, #write figure.md-table-fig,
  #write table { overflow: visible !important; }
  #write table tr { break-inside: avoid; page-break-inside: avoid; }
  #write p, #write li { orphans: 3; widows: 3; }
}

/* 付费工艺必须压在共享编辑区与导出规则之后，避免同权重规则被覆盖。 */
/* free tier: no paid craft overlay */
