:root {
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-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;
  --line-height: 1.65;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  line-height: var(--line-height);
  color: var(--color-body);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Surface Themes */
.surface-dark {
  background: var(--color-dark);
  color: var(--color-paper);
  --text-main: var(--color-paper);
  --text-muted: rgba(252, 252, 253, 0.75);
  --brand-highlight: var(--color-accent);
  --link-color: var(--color-accent);
  --border-color: rgba(255, 255, 255, 0.08);
}

.surface-paper {
  background: var(--color-paper);
  color: var(--color-body);
  --text-main: var(--color-body);
  --text-muted: rgba(25, 21, 35, 0.65);
  --brand-highlight: var(--color-brand);
  --link-color: var(--color-brand);
  --border-color: rgba(0, 0, 0, 0.08);
}

/* Card inside dark surface reverts to paper palette */
.dark-surface .paper-card {
  background: var(--color-paper);
  color: var(--color-body);
  --text-main: var(--color-body);
  --text-muted: rgba(25, 21, 35, 0.65);
  --brand-highlight: var(--color-brand);
  --link-color: var(--color-brand);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  margin-bottom: 1.5rem;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 1.25rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

.hl {
  color: var(--brand-highlight);
  font-weight: 700;
}

.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  color: var(--brand-highlight);
}

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:not(.btn):hover {
  text-decoration-thickness: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-btn);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s ease, filter 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(0.95);
}

.btn-secondary {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
}

.surface-paper .btn-secondary {
  border-color: var(--color-body);
  color: var(--color-body);
}

.surface-dark .btn-secondary {
  border-color: var(--color-paper);
  color: var(--color-paper);
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Layout Utilities */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
}

/* Cards */
.card {
  border-radius: var(--radius-card);
  padding: 1.5rem;
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}

/* Table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--text-main);
}

td {
  color: var(--text-main);
}

/* FAQ */
details {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  font-size: 1.2rem;
  transition: transform 0.2s;
}

details[open] summary::after {
  content: "−";
  transform: rotate(180deg);
}

details p {
  margin-top: 0.75rem;
  color: var(--text-muted);
}

/* Header / Footer */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: var(--color-paper);
  border-bottom: 1px solid var(--border-color);
}

.surface-dark header {
  background: var(--color-dark);
}

.nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a {
  text-decoration: none;
  font-weight: 500;
  color: var(--text-main);
}

nav a[aria-current="page"] {
  color: var(--brand-highlight);
  font-weight: 700;
}

footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

/* Magazine Layout */
.magazine-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 3rem;
}

.magazine-sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
}

@media (max-width: 768px) {
  .magazine-layout {
    grid-template-columns: 1fr;
  }
  .magazine-sidebar {
    display: none;
  }
}

/* SVG Animation Keyframes */
@keyframes grid-pulse {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes flow-line {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

@keyframes float-bubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes type-dot {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

@keyframes slide-in {
  0% { transform: translateX(20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* Animation Classes */
.anim-node {
  animation: grid-pulse 4s infinite ease-in-out;
  transform-box: fill-box;
  transform-origin: center;
}

.anim-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: flow-line 3s infinite linear;
}

.anim-bubble {
  animation: float-bubble 5s infinite ease-in-out;
  transform-box: fill-box;
  transform-origin: center;
}

.anim-dot {
  animation: type-dot 1.5s infinite ease-in-out;
  transform-box: fill-box;
  transform-origin: center;
}

.anim-slide {
  animation: slide-in 0.8s ease-out forwards;
}

.n1 { animation-delay: 0s; }
.n2 { animation-delay: 0.2s; }
.n3 { animation-delay: 0.4s; }
.n4 { animation-delay: 0.6s; }
.n5 { animation-delay: 0.8s; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Responsive Tweaks */
@media (max-width: 640px) {
  .flex-row { flex-direction: column; align-items: flex-start; }
  .btn { width: 100%; justify-content: center; }
  h1 { font-size: 2rem; }
}
