/* === 设计变量 === */
:root {
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-text: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  --color-dark-surface-bg: #141838;
  --color-dark-surface-text: #F7F5F3;
  --color-dark-surface-link: #6EAFED;
  --color-paper-surface-bg: #F7F5F3;
  --color-paper-surface-text: #151723;
  --color-paper-surface-link: #142CEB;
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}

/* === 表面层变量覆盖 === */
.surface-dark {
  background-color: var(--color-dark-surface-bg);
  color: var(--color-dark-surface-text);
}
.surface-dark a, .surface-dark .hl, .surface-dark .badge { color: var(--color-dark-surface-link); }
.surface-dark input, .surface-dark textarea { background: #1e224a; color: #F7F5F3; border: 1px solid #2a2f5c; }
.surface-dark .card { background: #1e224a; }

.surface-paper {
  background-color: var(--color-paper-surface-bg);
  color: var(--color-paper-surface-text);
}
.surface-paper a, .surface-paper .hl, .surface-paper .badge { color: var(--color-paper-surface-link); }
.surface-paper input, .surface-paper textarea { background: #fff; color: #151723; border: 1px solid #d0d0d0; }
.surface-paper .card { background: #ffffff; }

/* === 基础重置 === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

/* === 布局容器 === */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}
.section { padding-block: var(--section-y); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }

/* === 排版 === */
h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: inherit; }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); margin-bottom: 0.8em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 0.6em; }
h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5em; }
p { margin-bottom: 1em; max-width: 38em; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; margin-bottom: 0.8em;
}
.badge::before { content: ""; width: 16px; height: 2px; background: currentColor; }
.hl { font-weight: 800; }

/* === 组件：按钮 === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 24px; border-radius: var(--radius-btn);
  font-size: 1rem; font-weight: 600; cursor: pointer; border: none; transition: transform 0.2s, background 0.2s;
}
.btn-primary { background: var(--color-accent); color: #141838; }
.btn-primary:hover { transform: translateY(-2px); background: #5da0e0; }
.btn-secondary { background: transparent; border: 1px solid currentColor; color: inherit; }
.btn-secondary:hover { background: rgba(0,0,0,0.05); }
.surface-dark .btn-secondary { border-color: var(--color-paper); }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* === 组件：卡片与面板 === */
.card {
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }
.panel {
  background: var(--color-dark-surface-bg);
  border-radius: 16px;
  padding: 32px;
  position: relative;
  overflow: hidden;
}

/* === 组件：表格 === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 400px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid rgba(128,128,128,0.2); }
th { font-weight: 700; }
td:first-child { font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* === 组件：FAQ === */
details {
  border: 1px solid rgba(128,128,128,0.2);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  overflow: hidden;
}
summary {
  padding: 16px 20px;
  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.2em; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(45deg); }
.details-content { padding: 0 20px 16px; line-height: 1.6; }

/* === 组件：时间线 === */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px;
  background: linear-gradient(to bottom, var(--color-brand), var(--color-accent));
  opacity: 0.3;
}
.timeline-item { position: relative; margin-bottom: 32px; }
.timeline-item::before {
  content: attr(data-step);
  position: absolute; left: -32px; top: 0; width: 24px; height: 24px;
  background: var(--color-accent); color: var(--color-dark);
  border-radius: 6px; display: grid; place-items: center;
  font-weight: 800; font-size: 0.85rem;
}

/* === 组件：杂志侧栏 === */
.magazine-layout { display: grid; grid-template-columns: 1fr 240px; gap: 48px; }
.toc { position: sticky; top: 100px; font-size: 0.9rem; }
.toc li { margin-bottom: 12px; }
.toc a { opacity: 0.7; transition: opacity 0.2s; }
.toc a:hover { opacity: 1; }
.toc a.active { opacity: 1; font-weight: 700; }

/* === 响应式调整 === */
@media (max-width: 768px) {
  .magazine-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  h1 br { display: none; }
}

/* === SVG 响应式 === */
.svg-responsive { width: 100%; height: auto; display: block; }
.svg-panel { width: 100%; max-width: 600px; margin: 0 auto; aspect-ratio: 4/3; }

/* === SVG 动效关键帧 === */
@keyframes drawPath {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.02); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes flowDot {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, -30px); }
}

.anim-draw {
  stroke-dasharray: 1; stroke-dashoffset: 0;
  animation: drawPath 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.anim-float { animation: floatBubble 4s ease-in-out infinite; }
.anim-breathe { animation: breathe 3.5s ease-in-out infinite; }
.anim-slide-in { animation: slideInRight 2.5s ease-out forwards; }
.anim-flow { animation: flowDot 5s ease-in-out infinite alternate; }

/* 旋转/缩放中心修正 */
.anim-float, .anim-breathe, .anim-flow {
  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;
  }
}
