:root {
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;
  --color-dark-text: #FCFCFD;
  --color-dark-accent: #6EEDD2;
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 960px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--color-paper);
  color: var(--color-text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
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-inline: auto; padding-inline: var(--gap); }
section { padding-block: var(--section-y); }
.dark-bg { background: var(--color-dark); color: var(--color-dark-text); }
.light-bg { background: var(--color-paper); color: var(--color-text); }
.dark-bg .hl { color: var(--color-dark-accent); }
.light-bg .hl { color: var(--color-brand); }

h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: var(--gap); text-wrap: balance; }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-bottom: calc(var(--gap) * 0.5); }
p { margin-bottom: var(--gap); max-width: 38em; }

.eyebrow { display: block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; margin-bottom: calc(var(--gap) * 0.25); }
.light-bg .eyebrow { color: var(--color-brand); }
.dark-bg .eyebrow { color: var(--color-dark-accent); }

/* Header & Footer */
header { position: sticky; top: 0; z-index: 100; background: rgba(252, 252, 253, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(25, 21, 35, 0.08); }
.dark-bg header { background: rgba(20, 14, 37, 0.92); border-color: rgba(252, 252, 255, 0.08); }
.nav-wrapper { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; }
.logo img { width: 32px; height: 32px; object-fit: contain; }
nav ul { display: flex; gap: var(--gap); }
nav a { font-size: 0.9rem; font-weight: 500; padding: 4px 0; position: relative; }
nav a:hover, nav a[aria-current="page"] { color: var(--color-brand); }
.dark-bg nav a:hover, .dark-bg nav a[aria-current="page"] { color: var(--color-dark-accent); }
footer { border-top: 1px solid rgba(25, 21, 35, 0.08); padding-block: var(--gap); font-size: 0.85rem; color: rgba(25, 21, 35, 0.6); }
.dark-bg footer { border-color: rgba(252, 252, 255, 0.08); color: rgba(252, 252, 255, 0.6); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--gap); }
.footer-grid h4 { font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.footer-grid a { display: block; margin-bottom: 6px; transition: color 0.2s; }
.dark-bg .footer-grid a { color: rgba(252, 252, 255, 0.7); }
.dark-bg .footer-grid a:hover { color: var(--color-dark-accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding-inline: 24px; border-radius: var(--radius-btn); font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease; }
.btn-primary { background: var(--color-accent); color: var(--color-dark); border: none; }
.btn-primary:hover { transform: translateY(-1px); background: #5ddcc1; }
.btn-secondary { background: transparent; border: 1px solid var(--color-text); color: var(--color-text); }
.dark-bg .btn-secondary { border-color: var(--color-dark-text); color: var(--color-dark-text); }
.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.dark-bg .btn:focus-visible { outline-color: var(--color-dark-accent); }

/* Cards & Surfaces */
.card { background: rgba(25, 21, 35, 0.03); border-radius: var(--radius-card); padding: var(--gap); transition: background 0.2s ease; }
.dark-bg .card { background: rgba(252, 252, 255, 0.05); }
.card:hover { background: rgba(25, 21, 35, 0.06); }
.dark-bg .card:hover { background: rgba(252, 252, 255, 0.08); }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-block: var(--gap); font-size: 0.95rem; }
th, td { text-align: left; padding: 12px var(--gap); border-bottom: 1px solid rgba(25, 21, 35, 0.1); vertical-align: top; }
.dark-bg th, .dark-bg td { border-color: rgba(252, 252, 255, 0.1); }
th { font-weight: 700; }

/* FAQ */
details { margin-bottom: var(--gap); border-bottom: 1px solid rgba(25, 21, 35, 0.1); padding-bottom: var(--gap); }
.dark-bg details { border-color: rgba(252, 252, 255, 0.1); }
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-size: 1.2rem; }
details[open] summary::after { content: "-"; }
details p { margin-top: var(--gap); font-size: 0.95rem; }

/* Layout Helpers */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.magazine-layout { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 768px) {
  .magazine-layout { grid-template-columns: 2fr 1fr; }
  .toc-sticky { position: sticky; top: 80px; align-self: start; }
}

/* Badges & Lists */
.badge { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--color-accent); color: var(--color-dark); font-weight: 700; border-radius: 6px; font-size: 0.85rem; flex-shrink: 0; }
.step-item { display: flex; gap: 12px; align-items: flex-start; }
.check-list li { position: relative; padding-left: 24px; margin-bottom: 8px; }
.check-list li::before { content: ""; position: absolute; left: 0; top: 6px; width: 14px; height: 14px; border: 2px solid var(--color-brand); border-radius: 4px; }
.dark-bg .check-list li::before { border-color: var(--color-dark-accent); }

/* SVG Panels */
.svg-panel { width: 100%; height: auto; max-width: 100%; display: block; }
.svg-panel circle, .svg-panel rect, .svg-path { fill: none; stroke-width: 1.5; }
.transform-box { transform-box: fill-box; transform-origin: center; }

/* Animations */
@keyframes drawLine { 0% { stroke-dashoffset: 1; } 100% { stroke-dashoffset: 0; } }
@keyframes floatBubble { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breatheDots { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes slideIn { 0% { transform: translateX(20px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes nodeGlow { 0%, 100% { opacity: 0.2; r: 3; } 50% { opacity: 1; fill: var(--color-accent); r: 5; } }
@keyframes flowDash { 0% { stroke-dashoffset: 24; } 100% { stroke-dashoffset: 0; } }

.anim-draw { stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawLine 4s ease forwards; }
.anim-float { animation: floatBubble 4s ease-in-out infinite; }
.anim-breathe { animation: breatheDots 2s ease-in-out infinite; }
.anim-slide { animation: slideIn 1.5s ease forwards; }
.anim-node { animation: nodeGlow 5s ease-in-out infinite; }
.anim-flow { stroke-dasharray: 8 16; animation: flowDash 2s linear infinite; }

.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }
.delay-4 { animation-delay: 0.8s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .anim-draw, .anim-float, .anim-breathe, .anim-slide, .anim-node, .anim-flow { animation: none !important; }
}

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  nav ul { flex-wrap: wrap; gap: 8px; }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
