:root {
  --color-dark: #140E25;
  --color-paper: #F7F5F3;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(25, 21, 35, 0.3);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;
  --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;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 243, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-header.scrolled { border-bottom-color: rgba(25, 21, 35, 0.1); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.brand img { height: 28px; width: auto; }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { font-size: 0.95rem; font-weight: 500; opacity: 0.85; transition: opacity 0.2s; }
.nav-links a:hover, .nav-links a[aria-current="page"] { opacity: 1; color: var(--color-brand); }
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}
.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(200, 237, 110, 0.4); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-text);
  color: var(--color-text);
}
.btn-secondary:hover { background: rgba(25, 21, 35, 0.05); }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* Layout */
.page-layout {
  display: flex;
  gap: 32px;
  padding-top: var(--gap);
}
.index-nav {
  flex: 0 0 220px;
  position: sticky;
  top: 80px;
  padding-right: 16px;
  border-right: 1px solid rgba(25, 21, 35, 0.08);
}
.index-nav ul { list-style: none; }
.index-nav li { margin-bottom: 12px; }
.index-nav a {
  display: block;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: rgba(25, 21, 35, 0.7);
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.index-nav a:hover, .index-nav a.active { background: rgba(82, 20, 235, 0.06); color: var(--color-brand); }
.main-content { flex: 1; min-width: 0; }

/* Typography */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-brand);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.dark-section .section-label { color: var(--color-accent); }
h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 24px;
  text-wrap: balance;
}
.dark-section h1 { color: var(--color-paper); }
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  color: var(--color-text);
}
.dark-section h2 { color: var(--color-paper); }
h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--color-text);
}
.dark-section h3 { color: var(--color-paper); }
.hl { color: var(--color-brand); }
.dark-section .hl { color: var(--color-accent); }
p { margin-bottom: 16px; max-width: 38em; }
.lead { font-size: 1.1rem; line-height: 1.7; margin-bottom: 24px; }

/* Sections */
section { margin-bottom: var(--section-y); }
.dark-section { background: var(--color-dark); padding: var(--section-y) 0; }
.paper-section { padding: var(--section-y) 0; }

/* Cards & Grids */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}
.card {
  background: var(--color-paper);
  border: var(--card-border) solid var(--color-text);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -12px rgba(25, 21, 35, 0.35); }
.card-title { font-weight: 700; margin-bottom: 8px; }
.card-meta { font-size: 0.85rem; opacity: 0.7; margin-bottom: 12px; }
.card p { font-size: 0.95rem; line-height: 1.6; }

/* Definition List */
.def-list dt { font-weight: 700; margin: 24px 0 8px; display: flex; align-items: center; gap: 8px; }
.def-list dd { margin-left: 28px; margin-bottom: 16px; color: rgba(25, 21, 35, 0.85); }
.def-list dl { margin-bottom: 32px; }

/* Flow Diagram */
.flow-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0;
}
.flow-node {
  background: rgba(82, 20, 235, 0.08);
  padding: 12px 16px;
  border-radius: var(--radius-card);
  font-weight: 600;
  font-size: 0.95rem;
}
.flow-arrow { width: 40px; height: 24px; }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
  text-align: left;
}
.data-table th { font-weight: 700; width: 40%; }
.data-table tr:last-child td { border-bottom: none; }

/* Details / FAQ */
details {
  border: 1px solid rgba(25, 21, 35, 0.1);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  overflow: hidden;
}
summary {
  padding: 16px;
  font-weight: 600;
  cursor: pointer;
  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; font-weight: 400; }
details[open] summary::after { content: "−"; }
details p { padding: 0 16px 16px; line-height: 1.7; color: rgba(25, 21, 35, 0.85); }

/* SVG Utilities */
.svg-responsive { width: 100%; height: auto; display: block; }
.svg-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.anim-draw { animation: drawPath 5s ease-in-out infinite; }
.anim-breathe { animation: breathe 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-slide { animation: slideIn 6s ease-in-out infinite; }
@keyframes drawPath {
  0% { stroke-dashoffset: 1; opacity: 0; }
  10% { opacity: 1; }
  90% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 1; opacity: 0; }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.03); opacity: 1; }
}
@keyframes slideIn {
  0%, 10% { transform: translateX(100%); opacity: 0; }
  15%, 85% { transform: translateX(0); opacity: 1; }
  90%, 100% { transform: translateX(100%); opacity: 0; }
}

/* Focus & Accessibility */
:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
  html { scroll-behavior: auto; }
}

/* Responsive */
@media (max-width: 900px) {
  .page-layout { flex-direction: column; }
  .index-nav {
    position: relative;
    top: auto;
    border-right: none;
    border-bottom: 1px solid rgba(25, 21, 35, 0.1);
    padding: 0 0 16px;
    margin-bottom: 24px;
  }
  .index-nav ul { display: flex; flex-wrap: wrap; gap: 8px; }
  .index-nav a { padding: 6px 10px; font-size: 0.85rem; }
  .flow-row { flex-direction: column; align-items: flex-start; }
  .flow-arrow { transform: rotate(90deg); margin: 8px 0; }
}
@media (max-width: 600px) {
  .nav-links { gap: 16px; }
  .btn-primary, .btn-secondary { height: 44px; font-size: 0.9rem; }
}
