:root {
  --c-dark: #140E25;
  --c-paper: #FCFCFD;
  --c-text: #191523;
  --c-brand: #5214EB;
  --c-accent: #6EEDD2;
  --r-card: 8px;
  --r-btn: 6px;
  --sec-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --max-w: 1120px;
  --lh-body: 1.65;
  --lh-head: 1.15;
  --fw-head: 500;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.theme-light {
  --bg: var(--c-paper);
  --text: var(--c-text);
  --hl: var(--c-brand);
  --link: var(--c-brand);
  --btn-bg: var(--c-brand);
  --btn-text: var(--c-paper);
  --icon: var(--c-brand);
  --line: rgba(25, 21, 35, 0.12);
}
.theme-dark {
  --bg: var(--c-dark);
  --text: var(--c-paper);
  --hl: var(--c-accent);
  --link: var(--c-accent);
  --btn-bg: var(--c-accent);
  --btn-text: var(--c-dark);
  --icon: var(--c-accent);
  --line: rgba(255, 255, 255, 0.15);
}
.theme-dark .card-in {
  --bg: var(--c-paper);
  --text: var(--c-text);
  --hl: var(--c-brand);
  --link: var(--c-brand);
  --btn-bg: var(--c-brand);
  --btn-text: var(--c-paper);
  --icon: var(--c-brand);
  --line: rgba(25, 21, 35, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  line-height: var(--lh-body);
  color: var(--c-text);
  background: var(--c-paper);
  -webkit-font-smoothing: antialiased;
}

[data-theme="light"] { background: var(--bg); color: var(--text); }
[data-theme="dark"] { background: var(--bg); color: var(--text); }

h1, h2, h3, h4 { font-weight: var(--fw-head); line-height: var(--lh-head); color: var(--text); margin: 0 0 0.6em; }
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
p { margin: 0 0 1em; max-width: 38em; }
.hl { color: var(--hl); }
.eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; color: var(--hl); margin-bottom: 0.5em; display: inline-block; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 0.2em; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gap); }
section { padding-top: var(--sec-y); padding-bottom: var(--sec-y); border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0.8em 1.6em; border-radius: var(--r-btn); font-weight: 600;
  text-decoration: none; transition: transform 0.2s ease, filter 0.2s ease;
  cursor: pointer; border: none; font-size: 1rem;
}
.btn:focus-visible { outline: 2px solid var(--hl); outline-offset: 2px; }
.btn-primary { background: var(--btn-bg); color: var(--btn-text); }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(0.95); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--text); }
.btn-secondary:hover { transform: translateY(-1px); }

.card { background: var(--bg); border-radius: var(--r-card); padding: var(--gap); position: relative; overflow: hidden; }
.badge { display: inline-flex; align-items: center; justify-content: center; width: 2em; height: 2em; background: var(--hl); color: var(--btn-text); font-weight: 700; border-radius: 4px; margin-right: 0.5em; flex-shrink: 0; }

table { width: 100%; border-collapse: collapse; margin: 1em 0; min-width: 0; }
th, td { padding: 0.8em 1em; text-align: left; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: break-word; word-break: break-word; }
th { font-weight: 600; }

details { margin-bottom: 1em; border-bottom: 1px solid var(--line); padding-bottom: 1em; }
summary { cursor: pointer; font-weight: 600; list-style: none; }
summary::-webkit-details-marker { display: none; }

header { position: sticky; top: 0; z-index: 100; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color 0.2s, background 0.2s; padding: 1em 0; }
header.scrolled { border-bottom-color: var(--line); background: color-mix(in srgb, var(--bg) 95%, transparent); backdrop-filter: blur(8px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.nav { display: flex; gap: 1.5em; align-items: center; }
.nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.nav a[aria-current="page"] { color: var(--hl); }
.nav .btn { padding: 0.5em 1.2em; font-size: 0.9rem; }

footer { border-top: 1px solid var(--line); padding: 2em 0; margin-top: 2em; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1em; }
.footer-links { display: flex; gap: 1.5em; }
.footer-links a { color: var(--text); text-decoration: none; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.sidebar-toc { position: sticky; top: calc(var(--sec-y) + 2em); }
.toc-list { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.toc-list li { margin: 0.8em 0; padding-left: 1em; }
.toc-list a { color: var(--text); text-decoration: none; font-size: 0.95rem; }
.toc-list a:hover { color: var(--hl); }

.news-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--gap); }
.news-card { display: flex; flex-direction: column; }
.news-meta { font-size: 0.85rem; color: var(--text); opacity: 0.8; margin-bottom: 0.5em; }

.svg-grid-node {
  stroke: var(--hl); stroke-width: 1.5; fill: none;
  stroke-dasharray: 1; stroke-dashoffset: 0;
  opacity: 0.3;
  transform-box: fill-box; transform-origin: center;
  animation: nodeLightUp 8s ease-in-out infinite;
}
@keyframes nodeLightUp {
  0% { stroke-dashoffset: 1; opacity: 0.3; }
  50% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 1; opacity: 0.3; }
}
.delay-1 { animation-delay: 0s; }
.delay-2 { animation-delay: 1.5s; }
.delay-3 { animation-delay: 3s; }
.delay-4 { animation-delay: 4.5s; }

@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; }
}
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr !important; }
  .sidebar-toc { display: none; }
  .nav .hide-mobile { display: none; }
}
