/* ===== 金融营销与风控知识库 ===== */
:root {
  --bg: #fbfaf7;
  --bg-soft: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --border: #e6e2d8;
  --border-strong: #d6d1c4;
  --text: #1f2421;
  --text-soft: #5b615c;
  --text-faint: #8a8f88;
  --accent: #0f766e;
  --accent-soft: #e3f1ee;
  --accent-line: #0b5f59;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --info: #1d4ed8;
  --info-soft: #e8eefc;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --code-bg: #f2efe7;
  --shadow: 0 1px 2px rgba(31, 36, 33, .05), 0 8px 24px rgba(31, 36, 33, .05);
  --sidebar-w: 284px;
  --toc-w: 236px;
  --header-h: 60px;
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "New York", "Songti SC", "Songti TC", "SimSun", Georgia, serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0e1113;
  --bg-soft: #131719;
  --surface: #161b1e;
  --surface-2: #1a2023;
  --border: #272e31;
  --border-strong: #333c40;
  --text: #e6e9e6;
  --text-soft: #a2aaa4;
  --text-faint: #6f776f;
  --accent: #2dd4bf;
  --accent-soft: #10302d;
  --accent-line: #5eead4;
  --warn: #fbbf24;
  --warn-soft: #2b2312;
  --info: #93b4ff;
  --info-soft: #17203a;
  --danger: #f87171;
  --danger-soft: #2c1616;
  --code-bg: #1d2427;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 8px 14px; z-index: 200;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 15.5px; letter-spacing: .2px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-family: var(--font-serif); font-size: 13px; font-weight: 700; letter-spacing: .5px;
}
html[data-theme="dark"] .brand-mark { color: #06201d; }

.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search input {
  width: 100%; height: 38px;
  padding: 0 40px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2);
}
.search-results {
  position: absolute; top: 46px; left: 0; right: 0;
  max-height: 62vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px; z-index: 120;
}
.sr-item { display: block; padding: 9px 11px; border-radius: 7px; color: var(--text); cursor: pointer; }
.sr-item:hover, .sr-item.active { background: var(--accent-soft); text-decoration: none; }
.sr-item .sr-sec { font-size: 11.5px; color: var(--text-faint); letter-spacing: .3px; }
.sr-item .sr-title { font-weight: 600; font-size: 14.5px; }
.sr-item .sr-snip { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; margin-top: 2px; }
.sr-empty { padding: 14px 12px; color: var(--text-faint); font-size: 13.5px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text-soft);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
#menuBtn { display: none; }
html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 22px 14px 40px;
  border-right: 1px solid var(--border);
  overscroll-behavior: contain;
}
.sidebar::-webkit-scrollbar, .toc-rail::-webkit-scrollbar, .search-results::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .toc-rail::-webkit-scrollbar-thumb, .search-results::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.nav-section { margin-bottom: 6px; }
.nav-sec-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 7px 10px;
  background: transparent; border: 0; border-radius: 7px;
  color: var(--text-soft); cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: .9px; text-transform: uppercase;
  text-align: left;
}
.nav-sec-head:hover { background: var(--surface-2); color: var(--text); }
.nav-sec-head .chev { transition: transform .18s; opacity: .6; }
.nav-section.collapsed .chev { transform: rotate(-90deg); }
.nav-section.collapsed .nav-list { display: none; }
.nav-list { list-style: none; margin: 2px 0 8px; padding: 0 0 0 6px; }
.nav-link {
  display: block;
  padding: 6px 10px 6px 12px;
  margin: 1px 0;
  border-radius: 7px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.4;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active {
  color: var(--accent-line);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-footer { margin-top: 22px; padding: 14px 10px 0; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 12px; }
.sidebar-note { margin-top: 8px; line-height: 1.6; }

/* ---------- Main ---------- */
.main { min-width: 0; padding: 40px 56px 90px; }
.crumb { font-size: 13px; color: var(--text-faint); margin-bottom: 14px; }
.crumb a { color: var(--text-soft); }
.crumb .sep { margin: 0 7px; opacity: .5; }

.content { max-width: 780px; outline: none; }
.content h1 {
  font-family: var(--font-serif);
  font-size: 34px; line-height: 1.25; letter-spacing: -.3px;
  margin: 0 0 8px;
}
.content .lead { color: var(--text-soft); font-size: 16.5px; margin: 0 0 26px; }
.content h2 {
  font-family: var(--font-serif);
  font-size: 25px; line-height: 1.3;
  margin: 44px 0 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 80px;
}
.content h3 {
  font-size: 19px; font-weight: 700;
  margin: 30px 0 10px;
  scroll-margin-top: 80px;
}
.content h4 { font-size: 16px; font-weight: 700; margin: 22px 0 8px; color: var(--text-soft); }
.content p { margin: 12px 0; }
.content ul, .content ol { margin: 12px 0; padding-left: 24px; }
.content li { margin: 5px 0; }
.content li > ul, .content li > ol { margin: 4px 0; }
.content strong { color: var(--text); font-weight: 700; }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 30px 0; }
.content a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }

.content code {
  font-family: var(--font-mono); font-size: .875em;
  background: var(--code-bg); padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--border);
}
.content pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; overflow-x: auto;
  line-height: 1.6; margin: 16px 0;
}
.content pre code { background: none; border: 0; padding: 0; font-size: 13.5px; }

/* tables */
.content .table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.content table { border-collapse: collapse; width: 100%; font-size: 14px; }
.content th, .content td { padding: 9px 13px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.content th { background: var(--surface-2); font-weight: 700; color: var(--text); white-space: nowrap; font-size: 13px; letter-spacing: .2px; }
.content tr:last-child td { border-bottom: 0; }
.content tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.content td code { white-space: nowrap; }

/* callouts */
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 13px 16px;
  margin: 18px 0;
  font-size: 14.5px;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-label { display: block; font-weight: 700; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 4px; color: var(--accent-line); }
.callout.tip { border-left-color: var(--accent); }
.callout.note { border-left-color: var(--info); background: var(--info-soft); }
.callout.note .callout-label { color: var(--info); }
.callout.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.warning .callout-label { color: var(--warn); }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.danger .callout-label { color: var(--danger); }

/* ---------- TOC rail ---------- */
.toc-rail {
  position: sticky; top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 30px 22px 40px 8px;
  width: var(--toc-w);
  display: none;
}
.toc-title { font-size: 12px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.toc { border-left: 1px solid var(--border); }
.toc a {
  display: block; padding: 3px 0 3px 12px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-soft); font-size: 13px; line-height: 1.45;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.lvl-3 { padding-left: 24px; font-size: 12.5px; color: var(--text-faint); }
.toc a.active { color: var(--accent-line); border-left-color: var(--accent); font-weight: 600; }
.toc:empty::after { content: "本页无目录"; color: var(--text-faint); font-size: 12px; padding-left: 12px; }

/* ---------- Pager ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 780px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager a {
  display: block; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); background: var(--surface);
  transition: border-color .15s, transform .15s;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { font-size: 12px; color: var(--text-faint); }
.pager .ptitle { font-weight: 600; font-size: 15px; margin-top: 2px; }
.pager .next { text-align: right; }
.pager .placeholder { visibility: hidden; }

/* ---------- Footer ---------- */
.foot {
  max-width: 1600px; margin: 0 auto;
  padding: 22px 56px 40px;
  border-top: 1px solid var(--border);
  color: var(--text-faint); font-size: 12.5px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.dot { opacity: .5; }

.link-btn {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--accent); font: inherit; font-size: 13.5px;
  padding: 3px 10px; border-radius: 6px; cursor: pointer; margin-left: 8px;
}
.link-btn:hover { border-color: var(--accent); }
.content mark, .sr-snip mark { background: var(--warn-soft); color: var(--warn); border-radius: 3px; padding: 0 2px; }
.content blockquote {
  margin: 16px 0; padding: 6px 16px; border-left: 3px solid var(--border-strong);
  color: var(--text-soft); background: var(--surface-2); border-radius: 0 8px 8px 0;
}
.content blockquote p { margin: 8px 0; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }

/* ---------- Responsive ---------- */
@media (min-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0,1fr) var(--toc-w); }
  .toc-rail { display: block; }
  .main { padding: 44px 48px 90px; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 274px; }
  #menuBtn { display: inline-flex; }
  .brand-text { font-size: 14px; }
  .layout { grid-template-columns: minmax(0,1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 95;
    width: var(--sidebar-w); height: 100vh;
    background: var(--surface);
    transform: translateX(-102%);
    transition: transform .24s ease;
    padding-top: 70px;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 26px 22px 70px; }
  .foot { padding: 20px 22px 34px; }
  .content h1 { font-size: 27px; }
  .content h2 { font-size: 22px; margin-top: 36px; }
  .search { max-width: none; }
  .search-kbd { display: none; }
}
@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .brand-text { display: none; }
  .main { padding: 22px 16px 64px; }
  .content { font-size: 15.5px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}
