:root {
  --color-dark: #1B1231;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #9977EE;
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;
  --line-height-base: 1.55;
  --font-main: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--color-paper);
  color: var(--color-text);
  line-height: var(--line-height-base);
  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; }
p { margin-bottom: 1rem; max-width: 38em; }
strong { font-weight: 700; }

/* Layout Containers */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }
section { padding: var(--section-y) 0; }

/* Section Themes */
.section-dark { background-color: var(--color-dark); color: var(--color-paper); }
.section-dark .hl { color: var(--color-accent); }
.section-dark .eyebrow { color: var(--color-accent); }
.card-light-on-dark { background-color: var(--color-paper); color: var(--color-text); border-color: var(--color-text); }
.card-light-on-dark .hl { color: var(--color-brand); }
.card-light-on-dark .eyebrow { color: var(--color-brand); }

/* Typography */
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; margin-bottom: 1.25rem; text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 800; line-height: 1.25; margin-bottom: 0.5rem; margin-top: 0; }
h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.75rem; }
.eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 0.6rem; display: block; text-transform: uppercase; }
.hl { color: var(--color-brand); }
.text-muted { opacity: 0.85; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.9rem 1.6rem; font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-btn); cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.btn-primary { background-color: var(--color-accent); color: var(--color-dark); }
.btn-primary:hover { background-color: #8A68E6; }
.btn-secondary { border: 2px solid var(--color-text); background: transparent; color: var(--color-text); }
.btn-secondary:hover { background: rgba(0,0,0,0.05); }
.section-dark .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.section-dark .btn-secondary:hover { background: rgba(255,255,255,0.08); }

/* Cards & Panels */
.panel {
  background: var(--color-dark); border-radius: var(--radius-card);
  padding: 2rem; border: var(--card-border); box-shadow: var(--card-shadow);
  position: relative; overflow: hidden;
}
.card {
  background: var(--color-paper); border-radius: var(--radius-card);
  padding: 1.5rem; border: var(--card-border); box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 0.75rem;
}
.article-card { background: var(--color-paper); border: var(--card-border); border-radius: 16px; padding: 1.25rem; box-shadow: 3px 3px 0 var(--color-text); }

/* Grid & Flex */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.flex-row { display: flex; gap: var(--gap); align-items: center; }
.flex-col { display: flex; flex-direction: column; gap: var(--gap); }
.alt-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: center; }
@media (max-width: 768px) {
  .alt-layout, .grid-3, .hero-split { grid-template-columns: 1fr !important; }
  .hero-split > div:first-child { order: 1; }
  .hero-split > div:last-child { order: 2; margin-top: var(--gap); }
}

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 0.85rem 1rem; border-bottom: 1px solid currentColor; text-align: left; vertical-align: top; }
th { font-weight: 700; width: 40%; }
tr:last-child th, tr:last-child td { border-bottom: none; }

/* FAQ */
details { margin-bottom: 1rem; border: var(--card-border); border-radius: 16px; overflow: hidden; }
summary { padding: 1rem 1.25rem; background: var(--color-paper); cursor: pointer; font-weight: 600; list-style: none; position: relative; padding-left: 2rem; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; position: absolute; left: 1rem; font-weight: 700; }
details[open] summary { background: var(--color-dark); color: var(--color-paper); }
details[open] summary::before { content: "-"; }
.faq-body { padding: 1rem 1.25rem 1.25rem; background: var(--color-paper); line-height: 1.65; }
.section-dark .faq-body { background: var(--color-paper); color: var(--color-text); }

/* Header & Footer */
header { position: sticky; top: 0; z-index: 100; background: var(--color-paper); border-bottom: 1px solid rgba(0,0,0,0.08); padding: 0.75rem 0; backdrop-filter: blur(8px); }
.section-dark header { background: var(--color-dark); border-bottom: 1px solid rgba(255,255,255,0.08); }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.nav-links { display: flex; gap: 1.25rem; align-items: center; }
.nav-link { font-weight: 500; font-size: 0.95rem; padding: 0.4rem 0; transition: color 0.2s; }
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--color-brand); }
.section-dark .nav-link:hover, .section-dark .nav-link[aria-current="page"] { color: var(--color-accent); }
.footer { padding: 2rem 0; border-top: 1px solid currentColor; margin-top: 2rem; text-align: center; opacity: 0.85; font-size: 0.9rem; }
.footer a { text-decoration: underline; text-underline-offset: 3px; }

/* Sidebar TOC */
.toc-sidebar { position: sticky; top: 5rem; height: fit-content; padding-right: 1rem; }
.toc-list li { margin-bottom: 0.5rem; }
.toc-link { font-size: 0.9rem; color: var(--color-text); opacity: 0.7; transition: opacity 0.2s, color 0.2s; display: block; padding: 0.25rem 0; }
.toc-link:hover, .toc-link.active { opacity: 1; color: var(--color-brand); font-weight: 600; }
.section-dark .toc-link { color: var(--color-paper); }
.section-dark .toc-link:hover, .section-dark .toc-link.active { color: var(--color-accent); }
@media (max-width: 900px) { .toc-sidebar { display: none; } .alt-layout { grid-template-columns: 1fr; } }

/* SVG Animation Utilities */
@keyframes twinkle { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes draw-loop { 0% { stroke-dashoffset: 1; } 25% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }
.star { animation: twinkle 4.5s ease-in-out infinite alternate; }
.float-el { animation: float 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.draw-path { stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw-loop 6s ease infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
