:root {
  --c-dark: #271334;
  --c-paper: #E9E8EA;
  --c-text: #1D1523;
  --c-brand: #8A13DD;
  --c-accent: #9EED6E;
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.55; font-size: 16px; color: var(--c-text); }
img, svg { display: block; max-width: 100%; height: auto; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }

/* Surface Contexts */
.ctx-light { background: var(--c-paper); color: var(--c-text); }
.ctx-light h1, .ctx-light h2, .ctx-light h3, .ctx-light p, .ctx-light li, .ctx-light td, .ctx-light th { color: var(--c-text); }
.ctx-light a:not(.btn-primary):not(.btn-secondary) { color: var(--c-brand); }
.ctx-light .card { background: #DAD8DA; }
.ctx-light .tag { color: var(--c-brand); }
.ctx-light .btn-secondary { border-color: var(--c-text); color: var(--c-text); }

.ctx-dark { background: var(--c-dark); color: var(--c-paper); }
.ctx-dark h1, .ctx-dark h2, .ctx-dark h3, .ctx-dark p, .ctx-dark li, .ctx-dark td, .ctx-dark th { color: var(--c-paper); }
.ctx-dark a:not(.btn-primary):not(.btn-secondary) { color: var(--c-accent); }
.ctx-dark .card { background: #3B224F; }
.ctx-dark .tag { color: var(--c-accent); }
.ctx-dark .btn-secondary { border-color: var(--c-paper); color: var(--c-paper); }

/* Layout */
.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); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }

/* Typography */
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: var(--gap); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: var(--gap); }
h3 { font-size: 1.25rem; font-weight: 700; line-height: 1.2; margin-bottom: calc(var(--gap) / 2); }
.lead { font-size: 1.1rem; line-height: 1.6; margin-bottom: var(--gap); max-width: 38em; }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: calc(var(--gap) / 2); }
.hl { font-weight: 800; }
.ctx-light .hl { color: var(--c-brand); }
.ctx-dark .hl { color: var(--c-accent); }

/* Components */
.btn-primary { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0 1.5rem; height: 52px; border-radius: var(--radius-btn); background: var(--c-accent); color: var(--c-dark); font-weight: 700; border: none; cursor: pointer; transition: transform 0.2s ease, filter 0.2s ease; }
.btn-primary:hover { transform: translateY(-2px); filter: brightness(0.95); }
.btn-secondary { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0 1.5rem; height: 52px; border-radius: var(--radius-btn); background: transparent; border: 1.5px solid var(--c-text); color: var(--c-text); font-weight: 600; cursor: pointer; transition: transform 0.2s ease, background 0.2s ease; }
.btn-secondary:hover { transform: translateY(-2px); background: rgba(128,128,128,0.1); }
.card { border-radius: var(--radius-card); border: var(--card-border); box-shadow: var(--card-shadow); padding: var(--gap); }
table { width: 100%; border-collapse: collapse; margin-top: var(--gap); }
th, td { padding: calc(var(--gap) * 0.8); text-align: left; border-bottom: 1px solid rgba(128,128,128,0.2); }
th { font-weight: 700; }
details { margin-bottom: var(--gap); border-radius: var(--radius-card); background: var(--bg-card, inherit); padding: var(--gap); }
summary { 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; }
details[open] summary::after { content: "-"; }

/* SVG Animations */
@keyframes nodePulse { 0%, 100% { opacity: 0.25; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes dashDraw { to { stroke-dashoffset: 0; } }
.svg-node { animation: nodePulse 4s ease-in-out infinite; }
.svg-node:nth-child(1) { animation-delay: 0s; }
.svg-node:nth-child(2) { animation-delay: 0.6s; }
.svg-node:nth-child(3) { animation-delay: 1.2s; }
.svg-node:nth-child(4) { animation-delay: 1.8s; }
.svg-node:nth-child(5) { animation-delay: 2.4s; }
.svg-node:nth-child(6) { animation-delay: 3.0s; }
.svg-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: dashDraw 3s ease-out forwards; }
.visual-svg { width: 100%; height: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .svg-line { stroke-dashoffset: 0 !important; }
}

/* Focus & Accessibility */
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--c-accent); color: var(--c-dark); padding: 0.5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }

/* Header/Footer */
header { position: sticky; top: 0; z-index: 10; background: var(--c-paper); border-bottom: 1px solid rgba(0,0,0,0.05); padding: 0.75rem 0; }
.ctx-dark header { background: var(--c-dark); border-bottom: 1px solid rgba(255,255,255,0.1); }
.nav-row { display: flex; justify-content: space-between; align-items: center; }
.nav-links { display: flex; gap: var(--gap); }
.nav-links a { font-weight: 600; font-size: 0.95rem; }
.nav-links a[aria-current="page"] { font-weight: 800; border-bottom: 2px solid currentColor; }
footer { padding: var(--gap) 0; border-top: 1px solid rgba(128,128,128,0.2); margin-top: var(--section-y); }
.footer-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--gap); }
.footer-links { display: flex; gap: var(--gap); }
