:root {
  --color-dark: #140E25;
  --color-paper: #F5F0E5;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  
  --bg-base: var(--color-paper);
  --fg-base: var(--color-text);
  --link-base: var(--color-brand);
  --highlight-base: var(--color-brand);
  --card-stroke: rgba(25, 21, 35, 0.16);
  
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;
  
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --fs-h1: clamp(2.2rem, 5vw, 3.8rem);
  --fs-h2: clamp(1.6rem, 3vw, 2.4rem);
  --fs-body: clamp(1rem, 1.2vw, 1.125rem);
  --lh-body: 1.75;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--fg-base);
  line-height: var(--lh-body);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

section { padding: var(--section-y) 0; }

/* Typography */
h1, h2, h3 {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: 0.6em;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
p { max-width: 38em; margin-bottom: 1.5em; }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--link-base);
  margin-bottom: 0.5em;
}
.hl { color: var(--highlight-base); }

/* Dark Section Override */
.section-dark {
  background: var(--color-dark);
  color: var(--color-paper);
  --bg-base: var(--color-dark);
  --fg-base: var(--color-paper);
  --link-base: var(--color-accent);
  --highlight-base: var(--color-accent);
  --card-stroke: rgba(245, 240, 229, 0.16);
}
.section-dark .badge { color: var(--color-accent); }
.section-dark p { color: var(--color-paper); }

/* Layout */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
.flex-center { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; justify-content: center; }
.text-right { text-align: right; }

/* Components: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.8em 1.6em;
  border-radius: var(--radius-btn);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-secondary { background: transparent; border: 1px solid var(--fg-base); color: var(--fg-base); }
.btn:hover { transform: translateY(-1px); opacity: 0.9; }
.btn:focus-visible { outline: 2px solid var(--highlight-base); outline-offset: 2px; }

/* Components: Cards */
.card {
  border: 1px solid var(--card-stroke);
  border-radius: var(--radius-card);
  padding: 1.5em;
  background: transparent;
  box-shadow: var(--card-shadow);
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }

/* Components: Table */
table { width: 100%; border-collapse: collapse; margin: 1em 0; }
th, td { padding: 0.8em 1em; text-align: left; border-bottom: 1px solid var(--card-stroke); }
th { font-weight: 600; }

/* Components: FAQ / Details */
details { margin-bottom: 1em; border: 1px solid var(--card-stroke); border-radius: var(--radius-card); padding: 1em; }
summary { cursor: pointer; font-weight: 600; list-style: none; position: relative; padding-left: 1.2em; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: '';
  position: absolute; left: 0; top: 0.4em;
  width: 0.5em; height: 0.5em;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  transform: rotate(45deg);
}

/* SVG Base & Animations */
svg { width: 100%; height: auto; display: block; }
svg path, svg line, svg circle, svg rect { transition: opacity 0.3s ease; }
svg [class*="anim-"] { transform-box: fill-box; transform-origin: center; }

@keyframes drawLine {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.anim-draw { stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawLine 4s ease forwards; }
.anim-float { animation: float 6s ease-in-out infinite; }
.anim-twinkle { animation: twinkle 5s ease-in-out infinite; }
.anim-slide { animation: slideIn 0.8s ease both; }
.anim-delay-1 { animation-delay: 0.2s; }
.anim-delay-2 { animation-delay: 0.4s; }
.anim-delay-3 { animation-delay: 0.6s; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Header / Footer */
.header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-base);
  border-bottom: 1px solid var(--card-stroke);
  padding: 1em 0;
}
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 0.6em; text-decoration: none; color: inherit; font-weight: 700; font-size: 1.2rem; }
.logo img { height: 32px; width: auto; }
.nav { display: flex; gap: 1.5em; align-items: center; }
.nav a { text-decoration: none; color: var(--fg-base); font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--link-base); }
.footer { background: var(--color-dark); color: var(--color-paper); padding: 3em 0; margin-top: 0; }
.footer-inner { display: flex; flex-direction: column; gap: 1.5em; align-items: center; text-align: center; }
.footer a { color: var(--color-accent); text-decoration: none; }
.footer small { opacity: 0.7; }

/* Feature Tabs Navigation */
.feat-nav { display: flex; gap: 0.5em; margin-bottom: 1.5em; flex-wrap: wrap; }
.feat-nav a {
  padding: 0.5em 1em; border-radius: var(--radius-btn);
  background: transparent; border: 1px solid var(--card-stroke);
  color: var(--fg-base); text-decoration: none; font-weight: 500;
}
.feat-nav a:hover, .feat-nav a:focus { background: var(--card-stroke); }

/* Flow Diagram */
.flow { display: flex; align-items: center; gap: 1em; flex-wrap: wrap; justify-content: center; }
.flow-step { padding: 1em; border: 1px solid var(--card-stroke); border-radius: var(--radius-card); min-width: 140px; text-align: center; }
.flow-arrow { color: var(--link-base); font-size: 1.5em; }

/* Utility */
.mt-1 { margin-top: 1em; }
.mb-1 { margin-bottom: 1em; }
.max-w-38 { max-width: 38em; }
.grid-alt-row:nth-child(even) .grid-2 { direction: rtl; }
.grid-alt-row:nth-child(even) .grid-2 > * { direction: ltr; }
.grid-alt-row:nth-child(even) .text-right { text-align: left; }
