/* ==================== 设计变量与基础重置 ==================== */
:root {
  /* 色板 */
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;
  --color-border-subtle: rgba(25, 21, 35, 0.12);

  /* 结构 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 960px;

  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--color-paper);
  color: var(--color-text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ==================== 布局容器 ==================== */
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
section {
  padding-block: var(--section-y);
}

/* ==================== 排版 ==================== */
h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; letter-spacing: 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); text-wrap: balance; margin-bottom: 0.6em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 0.8em; position: relative; padding-top: 0.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5em; }
p { margin-bottom: 1em; max-width: 38em; }
small { font-size: 0.875rem; color: var(--color-text); opacity: 0.85; }

.label {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  margin-bottom: 0.8em;
}
.label span { color: var(--color-brand); }
.dark-theme .label span { color: var(--color-accent); }

.hl { color: var(--color-brand); }
.dark-theme .hl { color: var(--color-accent); }

/* ==================== 组件：按钮 ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  height: 52px; padding-inline: 1.5rem; border-radius: var(--radius-btn);
  font-weight: 600; font-size: 1rem; cursor: pointer; border: none; transition: transform 0.2s ease, filter 0.2s ease;
}
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn-primary {
  background: var(--color-accent); color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(0.95); }
.btn-secondary {
  background: transparent; border: 2px solid var(--color-text); color: var(--color-text);
}
.dark-theme .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.btn-secondary:hover { transform: translateY(-2px); filter: brightness(0.9); }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ==================== 组件：卡片 ==================== */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  transition: transform 0.2s ease;
}
.card:hover { transform: translate(-2px, -2px); }
.dark-theme .card { background: var(--color-paper); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }

/* ==================== 组件：表格 ==================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 320px; table-layout: fixed; }
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border-subtle); word-break: break-word; }
th { font-weight: 600; }
td:first-child { font-weight: 600; width: 40%; }

/* ==================== 组件：FAQ ==================== */
details {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  margin-bottom: 0.75rem;
  transition: background 0.2s;
}
details[open] { background: rgba(82, 20, 235, 0.03); }
summary {
  padding: 1rem 1.25rem; 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-weight: 400; font-size: 1.2rem; }
details[open] summary::after { content: "−"; }
details > div { padding: 0 1.25rem 1rem 1.25rem; }

/* ==================== 页头与页脚 ==================== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(252, 252, 253, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border-subtle);
}
.dark-theme .site-header { background: rgba(20, 14, 37, 0.95); border-bottom-color: rgba(110, 237, 210, 0.15); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--color-brand); }
.dark-theme .nav-links a:hover, .dark-theme .nav-links a[aria-current="page"] { color: var(--color-accent); }
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 28px; height: 28px; object-fit: contain; }

.site-footer {
  background: var(--color-dark); color: var(--color-paper);
  padding: 3rem 0; margin-top: auto;
}
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2rem;
}
.footer-col h4 { color: var(--color-accent); margin-bottom: 0.8rem; font-size: 1rem; }
.footer-col a { display: block; color: rgba(252, 252, 253, 0.8); margin-bottom: 0.5rem; font-size: 0.9rem; }
.footer-col a:hover { color: var(--color-accent); }
.copyright { text-align: center; margin-top: 2rem; font-size: 0.85rem; opacity: 0.7; }

/* ==================== 专题长文排版（杂志式） ==================== */
.magazine-layout {
  display: grid; grid-template-columns: 1fr 240px; gap: 2.5rem; align-items: start;
}
.toc {
  position: sticky; top: 80px; background: var(--color-paper);
  border: var(--card-border); box-shadow: var(--card-shadow);
  padding: 1rem; border-radius: var(--radius-card); font-size: 0.9rem;
}
.toc h4 { margin-bottom: 0.6rem; font-size: 0.95rem; }
.toc ul { border-left: 2px solid var(--color-brand); padding-left: 0.75rem; }
.toc li { margin-bottom: 0.6rem; }
.toc a { color: var(--color-text); font-weight: 500; }
.toc a:hover { color: var(--color-brand); }

/* ==================== 功能面板（分段导航） ==================== */
.feature-panel {
  background: var(--color-dark); color: var(--color-paper);
  border-radius: var(--radius-card); padding: 2rem; margin-top: 1rem;
}
.feature-panel h3 { color: var(--color-accent); margin-bottom: 0.5rem; }
.feature-panel p { color: rgba(252, 252, 253, 0.9); }

/* ==================== 时间线 ==================== */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: ""; position: absolute; left: 0.6rem; top: 0; bottom: 0;
  width: 2px; background: var(--color-border-subtle);
}
.timeline-item { position: relative; margin-bottom: 2rem; padding-left: 1.5rem; }
.timeline-item::before {
  content: attr(data-step); position: absolute; left: -2.15rem; top: 0;
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--color-brand); color: var(--color-paper);
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
}
.dark-theme .timeline-item::before { background: var(--color-accent); color: var(--color-dark); }

/* ==================== 新闻卡片 ==================== */
.news-card { display: flex; flex-direction: column; height: 100%; }
.news-card time { font-size: 0.8rem; color: var(--color-brand); margin-bottom: 0.5rem; font-weight: 600; }
.dark-theme .news-card time { color: var(--color-accent); }
.news-card p { flex-grow: 1; font-size: 0.95rem; }

/* ==================== SVG 动效关键帧 ==================== */
@keyframes flowLine {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.anim-flow {
  pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0;
  animation: flowLine 4s linear infinite;
}
.anim-breathe {
  animation: breathe 3s ease-in-out infinite;
  transform-box: fill-box; transform-origin: center;
}
.anim-slide-in {
  animation: slideInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.anim-float {
  animation: floatY 5s ease-in-out infinite;
  transform-box: fill-box; transform-origin: center;
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 768px) {
  .magazine-layout { grid-template-columns: 1fr; }
  .toc { position: static; margin-bottom: 1.5rem; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 1rem 0; }
  .nav-links { flex-wrap: wrap; gap: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ==================== 减少动态效果 ==================== */
@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;
  }
  .anim-flow, .anim-breathe, .anim-slide-in, .anim-float {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
