:root {
  --color-dark: #19102D;
  --color-paper: #FCFCFD;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #D66EED;
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1280px;
  --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);
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout Grid */
.layout-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .layout-grid { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 100; background: var(--color-paper); border-bottom: 1px solid rgba(0,0,0,0.08); padding: 1rem 1.5rem; }
  .main-content { max-width: var(--content-max); margin: 0 auto; padding: var(--section-y) 1.5rem; }
}
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--color-dark); color: var(--color-paper);
  padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--color-accent); display: flex; align-items: center; gap: 0.75rem; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.nav-list a {
  color: rgba(255,255,255,0.7); text-decoration: none; padding: 0.5rem 0.75rem;
  border-radius: var(--radius-btn); transition: color 0.2s, background 0.2s;
}
.nav-list a:hover, .nav-list a[aria-current="page"] { color: #fff; background: rgba(255,255,255,0.08); }
.nav-list a[aria-current="page"] { font-weight: 700; color: var(--color-accent); }

.main-content { padding: var(--section-y) clamp(1.5rem, 4vw, 4rem); }
.container { max-width: var(--content-max); margin: 0 auto; }

/* Typography */
h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: inherit; }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-top: 2rem; margin-bottom: 1.25rem; }
h3 { font-size: 1.25rem; margin-top: 1.5rem; margin-bottom: 0.75rem; }
p { margin-bottom: 1rem; max-width: 38em; }
code { background: rgba(0,0,0,0.06); padding: 0.15em 0.4em; border-radius: 2px; font-family: monospace; font-size: 0.9em; }
.surface-dark code { background: rgba(255,255,255,0.1); }

.badge {
  display: inline-block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; margin-bottom: 0.75rem; color: var(--color-brand);
}
.surface-dark .badge { color: var(--color-accent); }
.hl { color: var(--color-brand); }
.surface-dark .hl { color: var(--color-accent); }
.surface-dark h1, .surface-dark h2, .surface-dark h3, .surface-dark p, .surface-dark li { color: var(--color-paper); }
.surface-dark .hl { color: var(--color-accent); }

/* Components */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 600; text-decoration: none;
  border-radius: var(--radius-btn); cursor: pointer; transition: transform 0.2s, opacity 0.2s;
  height: 48px; min-width: 120px; white-space: nowrap;
}
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-secondary { background: transparent; border: 1px solid var(--color-text); color: var(--color-text); }
.surface-dark .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.btn:hover { transform: translateY(-1px); opacity: 0.95; }
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.card {
  background: var(--color-paper); border: var(--card-border); box-shadow: var(--card-shadow);
  padding: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem;
  border-radius: var(--radius-card);
}
.surface-dark .card { background: rgba(255,255,255,0.05); }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.1); }
th { font-weight: 700; }
td a { color: var(--color-brand); text-decoration: underline; text-underline-offset: 2px; }
.surface-dark th, .surface-dark td { border-color: rgba(255,255,255,0.1); color: var(--color-paper); }
.surface-dark td a { color: var(--color-accent); }

details { margin-bottom: 1rem; border-bottom: 1px solid rgba(0,0,0,0.08); padding-bottom: 0.5rem; }
summary { cursor: pointer; font-weight: 700; 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: "-"; }
.surface-dark details { border-color: rgba(255,255,255,0.15); }

/* SVG Utilities */
.svg-responsive { width: 100%; height: auto; display: block; }
svg [class*="anim-"] { transform-box: fill-box; transform-origin: center; }

/* SVG Animations */
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes drawStroke { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes pulseOpacity { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes slideInX { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.anim-float { animation: floatY 4s ease-in-out infinite; }
.anim-draw { stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawStroke 3s ease forwards; }
.anim-pulse { animation: pulseOpacity 2s ease-in-out infinite; }
.anim-slide { animation: slideInX 0.8s ease-out forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* 兜底：裁掉横向溢出 */
div.layout-grid {
  overflow-x: clip;
}
