*, *::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, "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-text);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
}

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: 0 auto;
  padding: 0 var(--gap);
}

/* 表面层取色变量覆盖 */
.surface-dark {
  background: var(--color-dark);
  color: var(--color-paper);
}
.surface-dark .hl {
  color: var(--color-accent);
}
.surface-dark .badge,
.surface-dark .icon-link {
  color: var(--color-accent);
}
.surface-dark .btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}
.surface-dark .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}
.surface-dark .card {
  background: var(--color-paper);
  color: var(--color-text);
  border-color: var(--color-text);
}
.surface-dark table th,
.surface-dark table td {
  border-color: rgba(25, 21, 35, 0.15);
}

.surface-paper {
  background: var(--color-paper);
  color: var(--color-text);
}
.surface-paper .hl {
  color: var(--color-brand);
}
.surface-paper .badge,
.surface-paper .icon-link {
  color: var(--color-brand);
}
.surface-paper .btn-primary {
  background: var(--color-brand);
  color: var(--color-paper);
}
.surface-paper .btn-secondary {
  color: var(--color-text);
  border-color: var(--color-text);
}

/* 排版基础 */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-card);
  margin-bottom: 1rem;
  background: rgba(82, 20, 235, 0.08);
}
.surface-dark .badge {
  background: rgba(110, 237, 210, 0.15);
}

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: calc(var(--gap) * 0.8);
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.8rem;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

.text-muted {
  opacity: 0.8;
  font-size: 0.95rem;
}

/* 按钮系统 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  border: 2px solid transparent;
  min-height: 48px;
}
.btn:hover {
  transform: translateY(-2px);
}
.btn:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--color-brand);
  color: var(--color-paper);
}
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-text);
}

/* 卡片与网格 */
.card {
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  background: var(--color-paper);
  color: var(--color-text);
}

.grid-2 {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}
.grid-3 {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}

/* 表格 */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}
th, td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
  text-align: left;
}
th {
  font-weight: 700;
  white-space: nowrap;
}
td {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* 时间线 */
.timeline {
  position: relative;
  padding-left: 2.5rem;
}
.timeline-item {
  position: relative;
  margin-bottom: 2.5rem;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -2.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-brand);
}
.timeline-badge {
  position: absolute;
  left: -3.2rem;
  top: 0;
  width: 2rem;
  height: 2rem;
  background: var(--color-brand);
  color: var(--color-paper);
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.surface-dark .timeline-badge {
  background: var(--color-accent);
  color: var(--color-dark);
}

/* FAQ */
details {
  border: var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: 0.8rem;
  background: var(--color-paper);
}
summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
summary::-webkit-details-marker {
  display: none;
}
details[open] summary {
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}
.details-content {
  padding: 1rem 1.25rem;
}

/* 页头页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-paper);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
  backdrop-filter: blur(8px);
}
.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;
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  border-bottom-color: var(--color-brand);
}
.surface-dark .nav-links a[aria-current="page"] {
  border-bottom-color: var(--color-accent);
}

.site-footer {
  padding: 3rem 0;
  border-top: 1px solid rgba(25, 21, 35, 0.1);
  margin-top: 2rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}
.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  opacity: 0.7;
}
.footer-col a {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.8;
}
.footer-col a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* 响应式适配 */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .mobile-toggle { display: flex; }
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  h2 { font-size: clamp(1.4rem, 5vw, 2rem); }
}
@media (min-width: 769px) {
  .mobile-toggle { display: none; }
}

/* SVG 动效关键帧 */
.svg-node {
  animation: grid-light 6s infinite ease-in-out;
}
@keyframes grid-light {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1); }
}

.svg-bubble {
  animation: float-up 5s infinite ease-in-out;
}
@keyframes float-up {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(-10px); opacity: 1; }
}

.svg-input-dot {
  animation: breath 2s infinite ease-in-out;
}
@keyframes breath {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.svg-path-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-flow 8s infinite ease-in-out;
}
@keyframes draw-flow {
  0%, 100% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .svg-node, .svg-bubble, .svg-input-dot, .svg-path-draw {
    opacity: 1 !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
  }
}
