:root {
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-text: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1280px;
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  background: var(--color-paper);
  color: var(--color-text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* 主题切换变量覆盖 */
.theme-dark {
  background: var(--color-dark);
  color: var(--color-paper);
}
.theme-dark .hl { color: var(--color-accent); }
.theme-dark .eyebrow { color: var(--color-accent); }
.theme-dark .link { color: var(--color-accent); }
.theme-dark .icon { color: var(--color-accent); }
.theme-dark .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
.theme-dark .toc a { color: var(--color-paper); }
.theme-dark .toc a:hover { color: var(--color-accent); }
.theme-dark details { background: var(--color-dark); border-color: var(--color-paper); }
.theme-dark details > p { color: var(--color-paper); }

/* 排版 */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: 0; line-height: 1.25; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: var(--gap); }
h3 { font-size: 1.25rem; margin-bottom: 0.75rem; }
p { max-width: 38em; margin-bottom: 1rem; }
.hl { color: var(--color-brand); }
.eyebrow { display: inline-block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 0.5rem; color: var(--color-brand); }
.link { color: var(--color-brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.icon { width: 20px; height: 20px; stroke-width: 1.8; vertical-align: middle; }

/* 区块 */
section { padding: var(--section-y) 0; position: relative; }
section + section { border-top: 1px solid var(--color-text); }

/* 网格与布局 */
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: center; }
.magazine { display: grid; grid-template-columns: 2fr 1fr; gap: var(--gap); align-items: start; }
.toc { min-width: 0; width: 100%; overflow: hidden; position: sticky; top: 2rem; }
.toc ul { list-style: none; padding-left: 1rem; border-left: 2px solid var(--color-brand); }
.toc li { margin-bottom: 0.75rem; }
.toc a { text-decoration: none; color: var(--color-text); font-size: 0.9rem; }
.toc a:hover { color: var(--color-brand); }

@media (max-width: 768px) {
  .split, .magazine { grid-template-columns: 1fr; }
  .toc { position: static; margin-top: 1rem; }
}

/* 组件：按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0 1.25rem; height: 52px;
  border-radius: var(--radius-btn); font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-secondary { background: transparent; border: 2px solid var(--color-text); color: var(--color-text); }
.btn svg { width: 20px; height: 20px; stroke-width: 2; }

/* 组件：卡片 */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

/* 组件：表格 */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--color-text); }
th { font-weight: 600; }

/* 组件：FAQ */
details { border: 1px solid var(--color-text); border-radius: var(--radius-card); margin-bottom: 0.75rem; background: var(--color-paper); }
summary { padding: 1rem; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; font-size: 1.2rem; }
details[open] summary::after { content: '−'; }
details > p { padding: 0 1rem 1rem; margin: 0; }

/* 组件：页头/页脚 */
header, footer { padding: 1.5rem 0; border-bottom: 1px solid var(--color-text); }
.nav { display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: inherit; font-weight: 700; font-size: 1.25rem; }
.logo img { width: 32px; height: 32px; object-fit: contain; }
nav ul { display: flex; gap: 1.5rem; list-style: none; }
nav a { text-decoration: none; color: inherit; font-weight: 500; }
nav a[aria-current="page"] { color: var(--color-brand); font-weight: 700; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); margin-top: 2rem; }
.footer-grid a { text-decoration: none; color: inherit; }

/* SVG 动效基础 */
.svg-container { width: 100%; height: auto; max-width: 100%; display: block; }
.flow-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }
.bubble-group, .notif-group, .dot-group { transform-box: fill-box; transform-origin: center; }

/* 动效关键帧 */
@keyframes dashFlow {
  0% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1; }
}
@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes slideNotif {
  0%, 100% { transform: translateX(0); opacity: 1; }
  50% { transform: translateX(-4px); opacity: 0.85; }
}

.flow-line { animation: dashFlow 6s linear infinite; }
.bubble-group { animation: floatBubble 5s ease-in-out infinite; }
.dot-group { animation: breathe 3s ease-in-out infinite; }
.notif-group { animation: slideNotif 7s ease-in-out infinite; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
    animation: none !important;
  }
}

/* 全局防溢出：box-sizing border-box + 限制最大宽度 */
*, *::before, *::after { box-sizing: border-box; }
html {
  max-width: 100vw;
  overflow-x: hidden;
}
body {
  max-width: 100%;
  overflow-x: hidden;
}
/* 防止固定宽度的 SVG 或表格撑开容器 */
svg, table {
  max-width: 100%;
  height: auto;
}
