/* AI 人格成长 OS · 方案解剖 — 中文长文阅读样式 */

:root {
  color-scheme: light dark;

  --bg: #faf9f6;
  --bg-soft: #f2efe9;
  --surface: #ffffff;
  --fg: #23211e;
  --fg-soft: #4a4640;
  --muted: #7a736a;
  --rule: #e4ded3;
  --rule-strong: #d3cabb;
  --accent: #9c4a25;
  --accent-soft: #f6e9e0;
  --code-bg: #1c1f24;
  --code-fg: #dfe3e8;
  --code-rule: #2c313a;
  --shadow: 0 1px 2px rgba(35, 33, 30, .05), 0 8px 24px -16px rgba(35, 33, 30, .28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --bg-soft: #1b1e22;
    --surface: #1b1e22;
    --fg: #dcdee1;
    --fg-soft: #c2c5ca;
    --muted: #8d949c;
    --rule: #2a2e34;
    --rule-strong: #3a4048;
    --accent: #e2915f;
    --accent-soft: #2a2119;
    --code-bg: #101215;
    --code-fg: #d7dbe0;
    --code-rule: #23262b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 26px -18px rgba(0, 0, 0, .8);
  }
}

/* 让等宽块里的中文与 ASCII 保持 2:1 宽度关系，避免结构图错位。
   SF Mono / JetBrains Mono / Menlo 的 ASCII 步进为 0.6em，
   CJK 字形放大到 1.2em 恰好等于两格。浏览器不支持 size-adjust 时自动退回原样。 */
@font-face {
  font-family: "CJK Mono Fit";
  src: local("PingFang SC"), local("Noto Sans CJK SC"), local("Hiragino Sans GB"), local("Microsoft YaHei");
  size-adjust: 120%;
  unicode-range: U+2E80-303F, U+3040-30FF, U+3100-312F, U+31A0-31BF, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF, U+2010-201F, U+2026, U+00B7;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16.5px;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

/* ---------- 顶栏 ---------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
}

.head-inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: .6rem 1.25rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--fg);
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .01em;
  text-decoration: none;
  width: fit-content;
}
.brand-mark { width: 1.15rem; height: 1.15rem; color: var(--accent); flex: none; }

.topnav {
  display: flex;
  gap: .3rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: .15rem;
}
.topnav::-webkit-scrollbar { display: none; }

.topnav a, .topnav span {
  flex: none;
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  padding: .22rem .6rem;
  border-radius: 999px;
  font-size: .82rem;
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
}
.topnav a:hover { color: var(--fg); background: var(--bg-soft); }
.topnav .num { font-size: .72rem; font-variant-numeric: tabular-nums; opacity: .75; }
.topnav .is-current {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  font-weight: 600;
}

/* ---------- 布局 ---------- */

.layout {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2.4rem 1.25rem 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}

.prose { min-width: 0; max-width: 72ch; width: 100%; justify-self: center; }

@media (min-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 15.5rem; gap: 3rem; }
  .prose { grid-column: 1; grid-row: 1; }
  .toc { grid-column: 2; grid-row: 1; position: sticky; top: 5.4rem; align-self: start; max-height: calc(100vh - 7rem); overflow-y: auto; }
  .toc > details > summary {
    list-style: none;
    pointer-events: none;
    cursor: default;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-size: .7rem;
    margin-bottom: .4rem;
  }
  .toc > details > summary::-webkit-details-marker { display: none; }
}

/* ---------- 正文排版 ---------- */

.kicker {
  margin: 0 0 .5rem;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.page-title {
  margin: 0 0 .6rem;
  font-size: 1.85rem;
  line-height: 1.35;
  letter-spacing: -.01em;
  font-weight: 700;
}

.page-summary {
  margin: 0 0 2rem;
  padding: .7rem .95rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  color: var(--fg-soft);
  font-size: .94rem;
  line-height: 1.75;
}

.prose h2 {
  margin: 2.8rem 0 1rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1.3rem;
  line-height: 1.5;
  font-weight: 700;
  letter-spacing: -.005em;
}

.prose h3 { margin: 2rem 0 .7rem; font-size: 1.08rem; font-weight: 700; line-height: 1.6; }
.prose h4 { margin: 1.6rem 0 .5rem; font-size: .98rem; font-weight: 700; color: var(--fg-soft); }

.prose p { margin: 0 0 1.15rem; }
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.4rem; }
.prose li { margin: .3rem 0; }
.prose li > ul, .prose li > ol { margin: .3rem 0; }

.prose strong { font-weight: 700; color: var(--fg); }
.prose em { font-style: normal; border-bottom: 1px dashed var(--rule-strong); }

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4rem 0;
}

blockquote {
  margin: 0 0 1.25rem;
  padding: .15rem 0 .15rem 1rem;
  border-left: 3px solid var(--rule-strong);
  color: var(--fg-soft);
}
blockquote p:last-child { margin-bottom: 0; }

/* 行内代码 */
code {
  font-family: "SF Mono", "JetBrains Mono", Menlo, "CJK Mono Fit", ui-monospace, monospace;
  font-size: .86em;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .06em .32em;
  word-break: break-word;
}

/* 代码 / ASCII 结构图：深色底、不换行、可横滑 */
pre {
  margin: 1.4rem 0 1.6rem;
  padding: 1rem 1.15rem;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--code-rule);
  border-radius: 8px;
  font-family: "SF Mono", "JetBrains Mono", Menlo, "CJK Mono Fit", ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  tab-size: 4;
  -webkit-text-size-adjust: none;
}
pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
  white-space: inherit;
  word-break: normal;
}
pre.mermaid {
  font-family: inherit;   /* 图表标签走正文中文字体，不用等宽 */
  background: var(--surface);
  color: var(--fg);
  border-color: var(--rule);
  text-align: center;
  line-height: 1.5;
}

/* 表格：斑马纹 + 横向滚动容器 */
.table-wrap {
  margin: 1.4rem 0 1.6rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 34rem; font-size: .9rem; line-height: 1.7; }
.table-wrap th, .table-wrap td { padding: .55rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.table-wrap thead th { background: var(--bg-soft); font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.table-wrap tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap td code { font-size: .8em; }
.table-wrap a { word-break: break-all; }

/* ---------- 报告导航卡片 ---------- */

.cards { margin: 0 0 2.6rem; }
.cards-title {
  margin: 0 0 .9rem;
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  border: 0;
  padding: 0;
}
.card-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }

.card {
  display: block;
  padding: .85rem .95rem .95rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease;
}
a.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); transform: translateY(-1px); }
.card-head { display: flex; align-items: baseline; gap: .45rem; margin-bottom: .3rem; }
.card-num { font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; letter-spacing: .04em; }
.card-name { font-size: .98rem; font-weight: 700; letter-spacing: -.005em; }
.card-lens { font-size: .72rem; color: var(--muted); }
.card-sum { margin: 0; font-size: .84rem; line-height: 1.7; color: var(--fg-soft); }
.card.is-current { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.card.is-current .card-name::after { content: "（当前页）"; font-size: .72rem; font-weight: 400; color: var(--muted); }

/* ---------- 目录 ---------- */

.toc { min-width: 0; font-size: .84rem; line-height: 1.65; }
.toc > details {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: .35rem .75rem .6rem;
}
.toc > details > summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: .8rem; padding: .3rem 0; }
.toc-inner { max-height: 45vh; overflow-y: auto; }
@media (min-width: 1180px) {
  .toc > details { background: none; border: 0; border-left: 1px solid var(--rule); border-radius: 0; padding: 0 0 0 1rem; }
  .toc-inner { max-height: none; overflow: visible; }
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: .8rem; }
.toc li { margin: .28rem 0; }
.toc a { color: var(--muted); text-decoration: none; display: block; }
.toc a:hover { color: var(--accent); }
.toc > details > .toc-inner > ul > li > a { color: var(--fg-soft); }

/* ---------- 上一篇 / 下一篇 ---------- */

.pager {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 3.2rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}
.pager a {
  flex: 1 1 13rem;
  min-width: 0;
  padding: .6rem .85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.pager a:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); }
.pager .dir { display: block; font-size: .72rem; color: var(--muted); letter-spacing: .06em; }
.pager .label { display: block; font-size: .92rem; font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.pager .next { text-align: right; }

/* ---------- 页脚 ---------- */

.site-foot {
  max-width: 78rem;
  margin: 2rem auto 0;
  padding: 1.2rem 1.25rem 2.4rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .78rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.site-foot .warn { color: var(--accent); }
.site-foot .dot { opacity: .5; }

/* ---------- 移动端 ---------- */

@media (max-width: 600px) {
  body { font-size: 16px; }
  .layout { padding: 1.6rem 1rem .5rem; }
  .page-title { font-size: 1.45rem; }
  .prose h2 { font-size: 1.16rem; margin-top: 2.2rem; }
  pre { font-size: 12px; padding: .8rem .9rem; border-radius: 6px; }
  .table-wrap table { font-size: .85rem; }
}

@media print {
  .site-head, .toc, .pager { display: none; }
  pre { background: none; color: #000; border: 1px solid #999; }
}
