/* === 设计变量与基础重置 === */
:root {
  --bg-dark: #141838;
  --bg-paper: #FCFCFD;
  --text-primary: #151723;
  --brand: #142CEB;
  --accent: #6EAFED;
  --border-light: rgba(21, 23, 35, 0.12);
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--text-primary);
  --card-shadow: 4px 4px 0 var(--text-primary);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;
  --body-lh: 1.55;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: var(--body-lh);
  color: var(--text-primary);
  background: var(--bg-paper);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* === 布局容器 === */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }
.section-divider { height: 4px; background: var(--text-primary); margin: 0; border: none; }

/* === 页面背景上下文 === */
.dark-surface { background: var(--bg-dark); color: var(--bg-paper); }
.dark-surface a { color: var(--accent); }
.dark-surface h1, .dark-surface h2, .dark-surface h3, .dark-surface p, .dark-surface span { color: var(--bg-paper); }
.dark-surface .hl { color: var(--accent); }
.dark-surface .label-tag { background: rgba(110, 175, 237, 0.15); color: var(--accent); }
.paper-surface { background: var(--bg-paper); color: var(--text-primary); }
.paper-surface a { color: var(--brand); }
.paper-surface h1, .paper-surface h2, .paper-surface h3, .paper-surface p, .paper-surface span { color: var(--text-primary); }
.paper-surface .hl { color: var(--brand); }
.paper-surface .label-tag { background: rgba(20, 44, 235, 0.08); color: var(--brand); }

/* 深色面内的浅色卡片恢复纸面取色 */
.dark-surface .paper-card {
  background: var(--bg-paper);
  color: var(--text-primary);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
}
.dark-surface .paper-card a { color: var(--brand); }
.dark-surface .paper-card h1, .dark-surface .paper-card h2, .dark-surface .paper-card h3, .dark-surface .paper-card p, .dark-surface .paper-card span { color: var(--text-primary); }
.dark-surface .paper-card .hl { color: var(--brand); }
.dark-surface .paper-card .label-tag { background: rgba(20, 44, 235, 0.08); color: var(--brand); }

/* === 排版 === */
.micro-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: inline-block;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}
h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}
p { margin-bottom: 1rem; max-width: 38em; }
.highlight-text { font-weight: 700; }

/* === 按钮 === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  border: none;
}
.btn:hover { transform: translateY(-2px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--bg-dark); }
.btn-primary:hover { background: #5a9bd6; }

/* 对比度修复：深色 SVG 面板内的说明文字 */
.paper-surface .container .magazine-layout div.svg-panel p {
  color: #ffffff !important;
}
.btn-secondary { background: transparent; border: 2px solid var(--text-primary); color: var(--text-primary); }
.dark-surface .btn-secondary { border-color: var(--bg-paper); color: var(--bg-paper); }
.dark-surface .btn-secondary:hover { background: rgba(255,255,255,0.08); }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* === 卡片与面板 === */
.card-grid { display: grid; gap: var(--gap); }
@media (min-width: 768px) { .card-grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .card-grid-3 { grid-template-columns: repeat(3, 1fr); } }
.card-panel {
  background: var(--bg-paper);
  color: var(--text-primary);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  position: relative;
}
.dark-surface .card-panel { background: var(--bg-dark); color: var(--bg-paper); border-color: rgba(255,255,255,0.2); box-shadow: 4px 4px 0 rgba(255,255,255,0.1); }
.dark-surface .card-panel a { color: var(--accent); }
.panel-title { font-weight: 700; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }

/* === 表格 === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: normal;
  word-break: break-word;
}
.data-table th { font-weight: 700; width: 40%; }
.dark-surface .data-table th, .dark-surface .data-table td { border-bottom-color: rgba(255,255,255,0.15); }

/* === FAQ === */
.faq-item { border: 1px solid var(--border-light); border-radius: var(--radius-card); margin-bottom: 0.75rem; overflow: hidden; }
.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-weight: 400; font-size: 1.2rem; transition: transform 0.2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-content { padding: 0 1.25rem 1rem; font-size: 0.95rem; line-height: 1.6; }

/* === 步骤条 === */
.steps-row { display: flex; flex-wrap: wrap; gap: var(--gap); counter-reset: step-counter; }
.step-item { flex: 1 1 200px; position: relative; padding-left: 2.5rem; }
.step-num {
  position: absolute; left: 0; top: 0;
  width: 2rem; height: 2rem;
  background: var(--accent); color: var(--bg-dark);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem;
}
.dark-surface .step-num { background: var(--accent); color: var(--bg-dark); }

/* === 新闻卡片 === */
.news-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  background: var(--bg-paper);
}
.dark-surface .news-card { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.15); }
.news-meta { font-size: 0.8rem; opacity: 0.8; margin-bottom: 0.5rem; }

/* === 页头页脚 === */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
}
.dark-surface .site-header { background: var(--bg-dark); border-bottom-color: rgba(255,255,255,0.1); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.nav-list { display: flex; gap: 1.5rem; }
.nav-link { font-weight: 500; padding: 0.5rem 0; position: relative; }
.nav-link[aria-current="page"] { color: var(--brand); font-weight: 700; }
.dark-surface .nav-link[aria-current="page"] { color: var(--accent); }
.site-footer {
  background: var(--bg-dark);
  color: rgba(255,255,255,0.7);
  padding: 2rem 0;
  font-size: 0.9rem;
}
.footer-inner { display: flex; flex-direction: column; gap: 1.5rem; }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a:hover { color: var(--bg-paper); }

/* === 杂志排版侧栏 === */
.magazine-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 1024px) { .magazine-layout { grid-template-columns: minmax(0, 1fr) 240px; } }
.toc-sidebar { position: sticky; top: 80px; align-self: start; }
.toc-list { border-left: 2px solid var(--border-light); padding-left: 1rem; }
.toc-link { display: block; padding: 0.5rem 0; font-size: 0.9rem; color: var(--text-primary); opacity: 0.7; transition: opacity 0.2s; }
.toc-link:hover, .toc-link.active { opacity: 1; color: var(--brand); }
.dark-surface .toc-link { color: var(--bg-paper); }
.dark-surface .toc-link:hover, .dark-surface .toc-link.active { color: var(--accent); }

/* === SVG 动效系统 === */
.svg-anim { width: 100%; height: auto; }
.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s ease;
}
.bubble-group { animation: floatBubble 4s ease-in-out infinite; }
.input-dot { animation: breatheDot 2.5s ease-in-out infinite; }
.conn-line { animation: drawConn 3s ease forwards; }
.slide-card { animation: slideInCard 1.8s ease forwards; }

@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes breatheDot {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes drawConn {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes slideInCard {
  0% { transform: translateX(-15px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* 旋转/缩放子元素中心修正 */
.rot-center, .scale-center { transform-box: fill-box; transform-origin: center; }

/* 减少动态效果 */
@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;
  }
  .draw-path { stroke-dashoffset: 0; }
  .bubble-group, .input-dot, .conn-line, .slide-card { animation: none; transform: none; opacity: 1; }
}
