/* ==========================================================================
   新辅助化疗与围术期心脏事件 — 文献综述
   设计系统：配色取自已校验的数据可视化调色板（明/暗双模各自选步）
   字体：全系统字体栈，零外部请求
   ========================================================================== */

/* ---------- 1. 令牌 ---------- */
:root {
  color-scheme: light;

  /* 页面与纸面 */
  --plane:            #f9f9f7;
  --surface-1:        #fcfcfb;
  --surface-2:        #f3f2ee;

  /* 墨色 */
  --ink:              #0b0b0b;
  --ink-2:            #52514e;
  --ink-muted:        #898781;

  /* 线 */
  --hairline:         #e1e0d9;
  --baseline:         #c3c2b7;
  --border:           rgba(11, 11, 11, 0.10);

  /* 分类色槽（固定顺序，不循环） */
  --series-1:         #2a78d6;  /* 蓝 */
  --series-2:         #eb6834;  /* 橙 */
  --series-3:         #1baf7a;  /* 青 */
  --series-4:         #eda100;  /* 黄 */
  --series-5:         #e87ba4;  /* 品红 */
  --series-6:         #008300;  /* 绿 */
  --series-7:         #4a3aa7;  /* 紫 */
  --series-8:         #e34948;  /* 红 */

  /* 顺序色（单色相，浅→深） */
  --seq-100:          #cde2fb;
  --seq-250:          #86b6ef;
  --seq-400:          #3987e5;
  --seq-550:          #1c5cab;
  --seq-700:          #0d366b;

  /* 状态色（保留语义，不作系列色） */
  --good:             #0ca30c;
  --warning:          #fab219;
  --serious:          #ec835a;
  --critical:         #d03b3b;

  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
               "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 43rem;          /* 正文行宽 */
  --shell: 78rem;            /* 外壳最大宽 */

  --radius: 10px;
  --radius-sm: 6px;

  --shadow-1: 0 1px 2px rgba(11, 11, 11, .05), 0 4px 16px rgba(11, 11, 11, .04);
}

/* 暗色：操作系统设置 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:       #0d0d0d;
    --surface-1:   #1a1a19;
    --surface-2:   #232322;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-muted:   #898781;
    --hairline:    #2c2c2a;
    --baseline:    #383835;
    --border:      rgba(255, 255, 255, 0.10);

    --series-1:    #3987e5;
    --series-2:    #d95926;
    --series-3:    #199e70;
    --series-4:    #c98500;
    --series-5:    #d55181;
    --series-6:    #008300;
    --series-7:    #9085e9;
    --series-8:    #e66767;

    --seq-100:     #0d366b;
    --seq-250:     #184f95;
    --seq-400:     #2a78d6;
    --seq-550:     #6da7ec;
    --seq-700:     #cde2fb;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

/* 暗色：用户手动切换（两个方向都要能覆盖） */
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:       #0d0d0d;
  --surface-1:   #1a1a19;
  --surface-2:   #232322;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --ink-muted:   #898781;
  --hairline:    #2c2c2a;
  --baseline:    #383835;
  --border:      rgba(255, 255, 255, 0.10);

  --series-1:    #3987e5;
  --series-2:    #d95926;
  --series-3:    #199e70;
  --series-4:    #c98500;
  --series-5:    #d55181;
  --series-6:    #008300;
  --series-7:    #9085e9;
  --series-8:    #e66767;

  --seq-100:     #0d366b;
  --seq-250:     #184f95;
  --seq-400:     #2a78d6;
  --seq-550:     #6da7ec;
  --seq-700:     #cde2fb;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
}

/* ---------- 2. 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  padding-block: 0;
  padding-inline: 20px;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 40rem) {
  body { padding-inline: 16px; font-size: 16px; }
}

a { color: var(--series-1); text-decoration: none; text-underline-offset: .18em; }
a:hover { text-decoration: underline; }
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 { line-height: 1.35; text-wrap: balance; }

p { margin: 0 0 1.05em; }
ul, ol { margin: 0 0 1.05em; padding-left: 1.5em; }
li { margin-bottom: .4em; }
li > ul, li > ol { margin-top: .4em; }
strong { font-weight: 650; }
code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--surface-2);
  padding: .1em .35em;
  border-radius: 4px;
}

/* ---------- 3. 版面外壳 ---------- */
.shell {
  max-width: var(--shell);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 15.5rem minmax(0, var(--measure));
  gap: 3.5rem;
  justify-content: center;
  align-items: start;
}
@media (max-width: 68rem) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .shell > .toc-col { display: none; }
}

/* ---------- 4. 页头 ---------- */
.masthead {
  grid-column: 1 / -1;
  padding-block: 3.5rem 2.25rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 3rem;
}
.masthead .eyebrow {
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 .9rem;
  font-weight: 600;
}
.masthead h1 {
  font-size: clamp(1.6rem, 1.1rem + 2.1vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.012em;
  margin: 0 0 .7rem;
  max-width: 30ch;
}
.masthead .standfirst {
  font-size: 1.06rem;
  color: var(--ink-2);
  max-width: 52ch;
  margin: 0 0 1.6rem;
}
.byline {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  font-size: .84rem;
  color: var(--ink-muted);
}
.byline span { display: inline-flex; align-items: center; gap: .4rem; }

/* ---------- 5. 目录 ---------- */
.toc-col { position: sticky; top: 1.75rem; padding-bottom: 4rem; }
.toc {
  font-size: .86rem;
  line-height: 1.5;
}
.toc-title {
  font-size: .72rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 650;
  margin: 0 0 .85rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: tocitem; }
.toc li { margin: 0 0 .12rem; }
.toc a {
  display: block;
  padding: .34rem .6rem .34rem .1rem;
  color: var(--ink-2);
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: color .12s, border-color .12s;
}
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.is-active {
  color: var(--series-1);
  border-left-color: var(--series-1);
  font-weight: 600;
}
.toc .toc-sub { padding-left: .85rem; font-size: .96em; }
.toc .toc-sub a { color: var(--ink-muted); }

/* ---------- 6. 正文区 ---------- */
.content { padding-bottom: 5rem; min-width: 0; }

section { scroll-margin-top: 1.5rem; margin-bottom: 3.25rem; }

h2 {
  font-size: 1.42rem;
  font-weight: 680;
  letter-spacing: -0.008em;
  margin: 0 0 1.15rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: baseline;
  gap: .7rem;
}
h2 .num {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--series-1);
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: .1em .45em;
  flex: none;
  transform: translateY(-.14em);
}
h3 {
  font-size: 1.1rem;
  font-weight: 650;
  margin: 2rem 0 .7rem;
  scroll-margin-top: 1.5rem;
}
h4 {
  font-size: .97rem;
  font-weight: 650;
  margin: 1.4rem 0 .5rem;
  color: var(--ink-2);
}

.lede { font-size: 1.04rem; color: var(--ink-2); }

/* ---------- 7. 组件 ---------- */
/* 核心要点 */
.keypoints {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--series-1);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem 1.15rem;
  margin: 0 0 2.5rem;
  box-shadow: var(--shadow-1);
}
.keypoints h2 {
  border: 0; padding: 0; margin: 0 0 .9rem;
  font-size: .74rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-muted); font-weight: 700; display: block;
}
.keypoints ol { margin: 0; padding-left: 1.35em; }
.keypoints li { margin-bottom: .55rem; }
.keypoints li::marker { color: var(--series-1); font-weight: 700; }

/* 提示框 */
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink-muted);
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem .85rem;
  margin: 1.5rem 0;
  font-size: .95rem;
}
.callout > :last-child { margin-bottom: 0; }
.callout .callout-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: .4rem;
}
.callout.is-warn { border-left-color: var(--warning); }
.callout.is-warn .callout-label { color: var(--serious); }
.callout.is-alert { border-left-color: var(--critical); }
.callout.is-alert .callout-label { color: var(--critical); }
.callout.is-key { border-left-color: var(--series-1); }
.callout.is-key .callout-label { color: var(--series-1); }

/* 数字卡 */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: .75rem;
  margin: 1.6rem 0;
}
.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .95rem 1rem .85rem;
}
.stat .label {
  font-size: .76rem;
  color: var(--ink-muted);
  line-height: 1.4;
  margin-bottom: .3rem;
  display: block;
}
.stat .value {
  font-size: 1.7rem;
  font-weight: 680;
  letter-spacing: -0.015em;
  line-height: 1.1;
  display: block;
}
.stat .value .unit { font-size: .58em; font-weight: 600; color: var(--ink-2); margin-left: .12em; }
.stat .note { font-size: .76rem; color: var(--ink-2); display: block; margin-top: .25rem; line-height: 1.45; }

/* 表格 */
.table-wrap {
  overflow-x: auto;
  margin: 1.6rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}
table { border-collapse: collapse; width: 100%; font-size: .88rem; line-height: 1.6; }
caption {
  caption-side: top;
  text-align: left;
  font-size: .8rem;
  color: var(--ink-muted);
  padding: .8rem 1rem .55rem;
  border-bottom: 1px solid var(--hairline);
}
caption strong { color: var(--ink); font-weight: 650; }
th, td { padding: .6rem .85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--hairline); }
thead th {
  font-weight: 650;
  font-size: .8rem;
  color: var(--ink-2);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }

/* 引文角标 */
.cite {
  font-size: .72em;
  font-weight: 650;
  vertical-align: super;
  line-height: 0;
  margin-left: .1em;
  color: var(--series-1);
  text-decoration: none;
  white-space: nowrap;
}
.cite:hover { text-decoration: underline; }

/* ---------- 8. 图 ---------- */
figure {
  margin: 2rem 0;
  padding: 1.25rem 1.25rem .95rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
figure svg { display: block; width: 100%; height: auto; max-width: 100%; }

/* 窄屏时图内文字若跟着缩放会小到读不清：让图保持可读的最小宽度，
   只在 .fig-scroll 内横向滚动（页面本身不横向滚动，图注仍正常换行）。 */
.fig-scroll { overflow-x: auto; overflow-y: hidden; }

@media (max-width: 46rem) {
  .fig-scroll { padding-bottom: .2rem; }
  .fig-scroll > svg { min-width: 34rem; }
  .fig-scroll::after {
    content: "← 左右滑动查看完整图示 →";
    display: block;
    font-size: .72rem;
    color: var(--ink-muted);
    padding-top: .55rem;
    letter-spacing: .02em;
  }
}
@media print {
  .fig-scroll { overflow-x: visible; }
  .fig-scroll > svg { min-width: 0; }
  .fig-scroll::after { display: none; }
}
figcaption {
  font-size: .82rem;
  color: var(--ink-2);
  line-height: 1.6;
  margin-top: .95rem;
  padding-top: .8rem;
  border-top: 1px solid var(--hairline);
}
figcaption .fig-label { font-weight: 680; color: var(--ink); }
figcaption .fig-src { color: var(--ink-muted); }

/* 图表交互层 */
.viz-tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--surface-1);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  padding: .55rem .7rem;
  font-size: .8rem;
  line-height: 1.5;
  max-width: 17rem;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .1s, transform .1s;
}
.viz-tip.is-on { opacity: 1; transform: translateY(0); }
.viz-tip .tip-title { font-weight: 650; display: block; margin-bottom: .18rem; }
.viz-tip .tip-row { display: flex; justify-content: space-between; gap: 1rem; }
.viz-tip .tip-row .k { color: var(--ink-2); }
.viz-tip .tip-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }

[data-tip] { cursor: default; }
[data-tip]:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* 图内文字 —— 一律走墨色令牌，不着系列色 */
.viz-axis-text { fill: var(--ink-muted); font-size: 11px; }
.viz-label      { fill: var(--ink); font-size: 12px; font-weight: 600; }
.viz-sub        { fill: var(--ink-2); font-size: 11px; }
.viz-grid       { stroke: var(--hairline); stroke-width: 1; }
.viz-baseline   { stroke: var(--baseline); stroke-width: 1; }
.viz-legend-text { fill: var(--ink-2); font-size: 11.5px; }

/* 示意图连接线（2px 圆头；箭头单独画成折线，保证细而不糊） */
.viz-arrow-line { stroke: var(--baseline); stroke-width: 2; stroke-linecap: round; fill: none; }
.viz-arrow-head { stroke: var(--baseline); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }

.viz-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .76rem;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .2rem .6rem;
  cursor: pointer;
  font-family: inherit;
}
.viz-toggle:hover { background: var(--surface-2); color: var(--ink); }

/* 表格视图孪生 */
.viz-table[hidden] { display: none; }
.viz-table { margin-top: 1rem; }
.viz-table table { font-size: .82rem; }
.viz-table caption { padding-left: 0; }

/* ---------- 9. 参考文献 ---------- */
.refs { counter-reset: ref; list-style: none; padding: 0; margin: 1.5rem 0 0; }
.refs li {
  counter-increment: ref;
  position: relative;
  padding: .85rem 0 .85rem 2.6rem;
  border-bottom: 1px solid var(--hairline);
  font-size: .87rem;
  line-height: 1.68;
  margin: 0;
  scroll-margin-top: 1.5rem;
}
.refs li::before {
  content: counter(ref);
  position: absolute;
  left: 0;
  top: .95rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: .74rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.refs li:target { background: var(--surface-2); border-radius: var(--radius-sm); }
.refs li:target::before { background: var(--series-1); color: #fff; }
.refs .ref-authors { color: var(--ink); }
.refs .ref-title { color: var(--ink); }
.refs .ref-journal { font-style: italic; color: var(--ink-2); }
.refs .ref-meta { color: var(--ink-muted); }
.refs .ref-links { display: inline-flex; gap: .55rem; margin-left: .3rem; flex-wrap: wrap; }
.refs .ref-links a {
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .02rem .5rem;
  white-space: nowrap;
}
.refs .ref-links a:hover { background: var(--surface-2); text-decoration: none; }
.ref-tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 650;
  letter-spacing: .02em;
  padding: .06em .45em;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
  margin-right: .35em;
  white-space: nowrap;
  vertical-align: .05em;
}

/* 参考文献分组小标题 */
.ref-group {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 2rem 0 .5rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--hairline);
}

/* ---------- 10. 页脚 ---------- */
.site-footer {
  grid-column: 1 / -1;
  border-top: 1px solid var(--hairline);
  padding: 2rem 0 3.5rem;
  font-size: .82rem;
  color: var(--ink-muted);
  line-height: 1.7;
  margin-top: 2rem;
}
.site-footer .disclaimer {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
  color: var(--ink-2);
}
.site-footer .disclaimer strong { color: var(--ink); }
.site-footer p { margin-bottom: .6rem; }

/* ---------- 11. 工具栏（主题切换） ---------- */
.toolbar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  gap: .4rem;
}
.toolbar button {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: var(--shadow-1);
  transition: color .12s, background .12s;
}
.toolbar button:hover { color: var(--ink); background: var(--surface-2); }
.toolbar svg { width: 1.05rem; height: 1.05rem; display: block; }

/* ---------- 12. 打印 ---------- */
@media print {
  :root { --plane: #fff; --surface-1: #fff; --surface-2: #f5f5f5; --ink: #000; --ink-2: #333; }
  body { font-size: 10.5pt; padding: 0; }
  .toolbar, .toc-col, .viz-toggle { display: none !important; }
  .shell { grid-template-columns: 1fr; max-width: none; }
  .masthead { padding-block: 0 1rem; margin-bottom: 1.5rem; }
  section { break-inside: auto; margin-bottom: 1.5rem; }
  h2 { break-after: avoid; }
  figure, .table-wrap, .keypoints, .stat-row { break-inside: avoid; }
  a { color: inherit; }
  .refs li { break-inside: avoid; }
}
