/* ============================================================================
   余白 / Yubai — 文档页样式（隐私政策 · 用户协议 · 帮助）
   设计令牌严格取自 DesignSystem/Theme.swift（暖白纸面 · 黛绿主色 · 陶土点睛）。
   单一字族策略：展示字 = Serif（宋体 / New York），正文 = SF Pro。
   支持浅 / 深色（prefers-color-scheme），离线自包含，无任何外部请求。
   ============================================================================ */

:root {
  /* —— 暖白纸面 / 表面 —— */
  --bg:            #F6F3EC;
  --bg-grad-top:   #F8F5EE;
  --bg-grad-bot:   #EFEAE0;
  --surface:       #FFFFFF;
  --surface-sunk:  #EFEAE0;

  /* —— 墨色文字（暖炭黑，非纯黑） —— */
  --ink:           #26241F;
  --ink-2:         #6F695F;
  --ink-3:         #A39C8F;

  /* —— 黛绿主色 / 陶土点睛 —— */
  --brand:         #2E6F5E;
  --brand-soft:    #DCEAE3;
  --accent:        #E0915C;   /* 陶土橙：成就 / 温度 */
  --calm:          #4FA383;   /* 松绿：达标 / 放行 */
  --stop:          #C2685A;   /* 暗陶红：收起 / 警示 */
  --divider:       #E7E1D6;

  /* —— 罐子五档色 —— */
  --jar-sage:      #3F8E78;
  --jar-terra:     #D99A63;
  --jar-mist:      #6E94A6;
  --jar-plum:      #9A7FA6;
  --jar-celadon:   #4DA39A;

  /* —— 几何 —— */
  --r-chip: 8px;
  --r-control: 14px;
  --r-card: 16px;
  --r-panel: 24px;

  --shadow-card: 0 4px 18px rgba(38, 36, 31, 0.06);
  --shadow-soft: 0 1px 3px rgba(38, 36, 31, 0.05);
  --shadow-pop:  0 10px 34px rgba(38, 36, 31, 0.10);

  /* —— 字族 —— */
  --font-serif: "New York", "Songti SC", "Noto Serif CJK SC", "Noto Serif JP",
                "Hiragino Mincho ProN", "Yu Mincho", Georgia, "Times New Roman", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
                "Hiragino Sans", "Noto Sans CJK SC", "Segoe UI", system-ui, sans-serif;

  --measure: 42rem;     /* 阅读列宽 */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #15140F;
    --bg-grad-top:   #17160F;
    --bg-grad-bot:   #100F0B;
    --surface:       #201E18;
    --surface-sunk:  #2A271F;

    --ink:           #F2EFE7;
    --ink-2:         #B7B0A2;
    --ink-3:         #8B8473;

    --brand:         #5FB89A;
    --brand-soft:    #233A33;
    --accent:        #E8A877;
    --calm:          #74C7A8;
    --stop:          #D98A7E;
    --divider:       #38342B;

    --jar-sage:      #6BC0A6;
    --jar-terra:     #E6B07F;
    --jar-mist:      #8FB2C2;
    --jar-plum:      #B89CC2;
    --jar-celadon:   #79C4BB;

    --shadow-card: 0 1px 0 rgba(255,255,255,0.04), 0 8px 26px rgba(0,0,0,0.34);
    --shadow-soft: 0 1px 0 rgba(255,255,255,0.04);
    --shadow-pop:  0 1px 0 rgba(255,255,255,0.05), 0 16px 40px rgba(0,0,0,0.45);
  }
}

/* ----------------------------------------------------------------- 基础 */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-grad-top) 0%, var(--bg-grad-bot) 70%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.62;
  font-size: 17px;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection { background: var(--brand-soft); color: var(--ink); }

/* ----------------------------------------------------------- 顶部栏 */
.doc-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--divider) 70%, transparent);
}

.brandmark {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brandmark .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  align-self: center;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* —— 语言分段切换器 —— */
.lang-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-sunk);
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--divider) 60%, transparent);
}
.lang-switch button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
  white-space: nowrap;
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] {
  color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

/* --------------------------------------------------------------- 布局 */
.doc-wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 20px 96px;
}

/* —— 封面 —— */
.doc-hero {
  padding: 56px 0 28px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 8px;
}
.doc-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 14px;
}
.doc-hero h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.16;
  letter-spacing: 0.005em;
  margin: 0 0 14px;
  color: var(--ink);
}
.doc-lede {
  font-size: 17px;
  color: var(--ink-2);
  margin: 0;
  max-width: 34rem;
}
.doc-meta {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  font-size: 13px;
  color: var(--ink-3);
}
.doc-meta .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-soft);
  color: var(--ink-2);
}

/* —— 目录 —— */
.doc-toc {
  margin: 26px 0 8px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-card);
}
.doc-toc h2 {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 12px;
}
.doc-toc ol {
  margin: 0; padding: 0;
  list-style: none;
  counter-reset: toc;
  columns: 2;
  column-gap: 28px;
}
@media (max-width: 540px) { .doc-toc ol { columns: 1; } }
.doc-toc li { counter-increment: toc; margin: 0 0 2px; break-inside: avoid; }
.doc-toc a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 14.5px;
  padding: 7px 8px;
  border-radius: var(--r-chip);
  transition: background .15s ease, color .15s ease;
}
.doc-toc a:hover { background: var(--surface-sunk); color: var(--ink); }
.doc-toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand);
  flex: none;
  padding-top: 2px;
}
.doc-toc a.active { color: var(--brand); background: var(--brand-soft); }

/* ----------------------------------------------------------- 章节排版 */
section.block { padding-top: 30px; scroll-margin-top: 84px; }

h2.sec {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(21px, 3.8vw, 26px);
  line-height: 1.28;
  margin: 8px 0 14px;
  color: var(--ink);
  display: flex;
  gap: 12px;
  align-items: baseline;
}
h2.sec .n {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--r-chip);
  padding: 3px 9px;
  letter-spacing: 0.02em;
  transform: translateY(-2px);
  flex: none;
}
h3.sub {
  font-size: 17.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 26px 0 8px;
  letter-spacing: 0.01em;
}
h4.subsub {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 18px 0 4px;
}

p { margin: 0 0 14px; color: var(--ink); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.tiny  { font-size: 12.5px; color: var(--ink-3); }

a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

strong, b { font-weight: 700; color: var(--ink); }
em { font-style: normal; color: var(--brand); font-weight: 600; }

ul, ol { margin: 0 0 16px; padding-left: 1.25em; color: var(--ink); }
li { margin: 0 0 8px; padding-left: 4px; }
li::marker { color: var(--ink-3); }
ul.clean { list-style: none; padding-left: 0; }
ul.clean > li {
  position: relative;
  padding-left: 24px;
}
ul.clean > li::before {
  content: "";
  position: absolute;
  left: 4px; top: 0.66em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

hr {
  border: 0;
  height: 1px;
  background: var(--divider);
  margin: 30px 0;
}

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  margin: 0 0 18px;
}
.card > :last-child { margin-bottom: 0; }

/* 提示框 / 注意 / 隐私承诺 */
.note {
  position: relative;
  border-radius: var(--r-card);
  padding: 16px 18px 16px 18px;
  margin: 0 0 18px;
  font-size: 15.5px;
  border: 1px solid transparent;
}
.note > :last-child { margin-bottom: 0; }
.note .note-h {
  display: block;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.note.brand { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 26%, transparent); }
.note.brand .note-h { color: var(--brand); }
.note.warn  { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 36%, transparent); }
.note.warn .note-h  { color: var(--accent); }
.note.stop  { background: color-mix(in srgb, var(--stop) 10%, var(--surface)); border-color: color-mix(in srgb, var(--stop) 34%, transparent); }
.note.stop .note-h  { color: var(--stop); }

/* ----------------------------------------------------- 规则类型胶囊 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 18px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 999px;
  padding: 6px 13px 6px 11px;
  box-shadow: var(--shadow-soft);
}
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.s-sage { background: var(--jar-sage); }
.s-terra { background: var(--jar-terra); }
.s-mist { background: var(--jar-mist); }
.s-plum { background: var(--jar-plum); }
.s-celadon { background: var(--jar-celadon); }

/* 规则卡（帮助页） */
.rule {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  margin: 0 0 14px;
}
.rule .glyph {
  width: 44px; height: 44px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 19px;
  color: #fff;
}
.rule .glyph.g-sage { background: linear-gradient(150deg, var(--jar-sage), color-mix(in srgb, var(--jar-sage) 70%, #000 8%)); }
.rule .glyph.g-terra { background: linear-gradient(150deg, var(--jar-terra), color-mix(in srgb, var(--jar-terra) 70%, #000 8%)); }
.rule .glyph.g-mist { background: linear-gradient(150deg, var(--jar-mist), color-mix(in srgb, var(--jar-mist) 70%, #000 8%)); }
.rule .glyph.g-plum { background: linear-gradient(150deg, var(--jar-plum), color-mix(in srgb, var(--jar-plum) 70%, #000 8%)); }
.rule .glyph.g-celadon { background: linear-gradient(150deg, var(--jar-celadon), color-mix(in srgb, var(--jar-celadon) 70%, #000 8%)); }
.rule h3 { margin: 2px 0 4px; font-size: 16.5px; }
.rule p { margin: 0 0 6px; font-size: 14.5px; color: var(--ink-2); }
.rule .tag {
  display: inline-block;
  font-size: 11.5px; font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 8px; border-radius: 999px;
  margin-top: 2px;
}

/* ------------------------------------------------ 冲突优先级阶梯 */
.ladder { margin: 6px 0 20px; padding: 0; list-style: none; counter-reset: prio; }
.ladder > li {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  padding: 0 0 18px 0;
  margin: 0;
}
.ladder > li::before {
  counter-increment: prio;
  content: "P" counter(prio);
  grid-column: 1;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  color: #fff;
  background: var(--brand);
  z-index: 1;
}
.ladder > li:nth-child(1)::before { background: var(--calm); }
.ladder > li:nth-child(2)::before { background: var(--jar-mist); }
.ladder > li:nth-child(3)::before { background: var(--stop); }
.ladder > li:nth-child(4)::before { background: var(--ink-3); }
.ladder > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 19px; top: 40px; bottom: 0;
  width: 2px;
  background: var(--divider);
}
.ladder .body { grid-column: 2; }
.ladder .body h4 { margin: 8px 0 4px; font-size: 15.5px; font-weight: 700; }
.ladder .body p { margin: 0; font-size: 14.5px; color: var(--ink-2); }

/* --------------------------------------------------------- 对比表 */
.table-wrap { overflow-x: auto; border-radius: var(--r-card); border: 1px solid var(--divider); box-shadow: var(--shadow-card); margin: 0 0 18px; }
table.cmp {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  background: var(--surface);
  min-width: 360px;
}
table.cmp th, table.cmp td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}
table.cmp thead th {
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--ink-2);
  background: var(--surface-sunk);
  position: sticky; top: 0;
}
table.cmp thead th.pro { color: var(--brand); }
table.cmp tbody tr:last-child td { border-bottom: 0; }
table.cmp td.feat { font-weight: 600; color: var(--ink); width: 46%; }
table.cmp td.free { color: var(--ink-2); }
table.cmp td.pro  { color: var(--ink); font-weight: 600; }
.yes { color: var(--calm); font-weight: 700; }
.no  { color: var(--ink-3); }

/* 定义型问答（FAQ） */
.faq { margin: 0 0 10px; }
.faq details {
  border: 1px solid var(--divider);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  margin: 0 0 10px;
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 15px 18px;
  font-weight: 600;
  font-size: 15.5px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-size: 20px;
  color: var(--brand);
  font-weight: 400;
  transition: transform .2s ease;
  flex: none;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq .ans { padding: 0 18px 16px; color: var(--ink-2); font-size: 14.5px; }
.faq .ans > :last-child { margin-bottom: 0; }

/* 步骤 */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li {
  position: relative;
  padding: 0 0 16px 46px;
  min-height: 30px;
}
ol.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800; font-size: 14px;
  display: grid; place-items: center;
}
ol.steps > li:not(:last-child)::after {
  content: "";
  position: absolute; left: 14px; top: 30px; bottom: 4px;
  width: 2px; background: var(--divider);
}
ol.steps b { display: block; margin-bottom: 2px; }

/* 脚注 / 页脚 */
.doc-foot {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
  color: var(--ink-3);
  font-size: 13px;
}
.doc-foot .brandmark { font-size: 16px; opacity: 0.9; margin-bottom: 8px; }
.doc-foot p { color: var(--ink-3); margin-bottom: 6px; }

.backtop {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}

/* 语言显隐：默认隐藏，由 JS 在 <html data-lang> 命中时显示 */
[data-i18n] { display: none; }
html[data-lang="zh-Hans"] [data-i18n~="zh-Hans"],
html[data-lang="en"]      [data-i18n~="en"],
html[data-lang="ja"]      [data-i18n~="ja"] { display: revert; }

/* 行内语言片段（用于切换器标签等） */
.i { display: none; }
html[data-lang="zh-Hans"] .i.zh,
html[data-lang="en"]      .i.en,
html[data-lang="ja"]      .i.ja { display: inline; }

/* 日文行距略宽 */
html[data-lang="ja"] body { line-height: 1.78; }
html[data-lang="ja"] .doc-hero h1 { letter-spacing: 0.02em; }

/* 打印 */
@media print {
  .doc-topbar, .lang-switch, .backtop { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .card, .note, .rule, .table-wrap, .faq details { box-shadow: none; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
