:root {
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;
  --color-line: rgba(25, 21, 35, 0.12);
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--color-body);
  --card-shadow: 4px 4px 0 var(--color-body);
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-body);
  background-color: var(--color-paper);
}
img, svg { display: block; max-width: 100%; }
a { color: var(--color-brand); text-decoration: underline; text-underline-offset: 2px; }
.dark-face a { color: var(--color-accent); }
p { margin: 0 0 1.2em; max-width: 38em; }
ul, ol { padding-left: 1.5em; margin: 0 0 1.2em; }
li { margin-bottom: 0.5em; }

.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }
section { padding: var(--section-y) 0; border-top: 1px solid var(--color-line); }
section:first-of-type { border-top: none; }

/* Typography */
h1, h2, h3 { font-weight: 500; line-height: 1.15; letter-spacing: -0.02em; margin-top: 0; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); margin-bottom: var(--gap); }
h3 { font-size: clamp(1.3rem, 2vw, 1.6rem); margin-bottom: calc(var(--gap) / 2); }
.subtitle { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.8em; display: inline-block; }
.paper-section .subtitle { color: var(--color-brand); }
.dark-section .subtitle { color: var(--color-accent); }
.hl { font-weight: 600; }
.paper-section .hl { color: var(--color-brand); }
.dark-section .hl { color: var(--color-accent); }

/* Theme Overrides */
.dark-face { background-color: var(--color-dark); color: var(--color-paper); }
.dark-face h1, .dark-face h2, .dark-face h3, .dark-face p, .dark-face li, .dark-face strong { color: var(--color-paper); }
.dark-face .subtitle { color: var(--color-accent); }
.dark-face .hl { color: var(--color-accent); }
.dark-face a { color: var(--color-accent); }
.paper-card {
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  color: var(--color-body);
}
.paper-card h1, .paper-card h2, .paper-card h3, .paper-card p, .paper-card li, .paper-card strong { color: var(--color-body); }
.paper-card .subtitle { color: var(--color-brand); }
.paper-card .hl { color: var(--color-brand); }
.paper-card a { color: var(--color-brand); }

/* Layout Utilities */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.flex-row { display: flex; flex-direction: column; gap: var(--gap); width: 100%; }
@media (min-width: 768px) { .flex-row { flex-direction: row; align-items: center; } }
.text-right { text-align: right; }

/* Components: Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6em;
  padding: 0 1.4em; height: 52px; font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-btn); text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
  cursor: pointer; border: none; white-space: nowrap;
}
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-primary:hover { transform: translateY(-2px); opacity: 0.95; }
.btn-secondary { background: transparent; color: var(--color-body); border: 2px solid var(--color-body); }
.btn-secondary:hover { background: rgba(25,21,35,0.05); transform: translateY(-2px); }
.dark-face .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
.dark-face .btn-secondary:hover { background: rgba(252,252,253,0.08); }
.btn:focus-visible { outline: 3px solid var(--color-brand); outline-offset: 2px; }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Components: Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th, td { text-align: left; padding: 0.9em 1em; border-bottom: 1px solid var(--color-line); vertical-align: top; }
th { font-weight: 600; width: 40%; }
tr:last-child td { border-bottom: none; }

/* Components: FAQ */
details { margin-bottom: 1em; border: var(--card-border); border-radius: var(--radius-card); background: var(--color-paper); }
summary { cursor: pointer; font-weight: 600; list-style: none; position: relative; padding: 1em 1em 1em 2em; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; position: absolute; left: 0.8em; font-weight: 700; }
details[open] summary::before { content: "-"; }
details > div { padding: 0 1em 1em; line-height: 1.7; }

/* SVG Animation System */
.svg-panel { width: 100%; height: auto; max-width: 100%; }
.anim-float { animation: safeFloat 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-breathe { animation: safeBreathe 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-slide-in { animation: safeSlideIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.anim-draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }
.anim-draw-active { animation: safeDraw 3s ease forwards; }
.anim-pulse-dot { animation: safePulse 2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

@keyframes safeFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes safeBreathe { 0%, 100% { opacity: 0.5; transform: scale(0.98); } 50% { opacity: 0.9; transform: scale(1.02); } }
@keyframes safeSlideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes safeDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes safePulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .anim-float, .anim-breathe, .anim-slide-in, .anim-draw-active, .anim-pulse-dot { animation: none !important; transform: none !important; opacity: 1 !important; }
}

/* Header & Footer */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--color-paper); border-bottom: 1px solid var(--color-line); backdrop-filter: blur(8px); }
.dark-face .site-header { background: var(--color-dark); border-color: rgba(252,252,253,0.1); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.8em; text-decoration: none; color: inherit; font-weight: 700; font-size: 1.1rem; }
.brand img { height: 32px; width: auto; }
nav ul { display: flex; gap: 1.5em; list-style: none; margin: 0; padding: 0; }
nav a { text-decoration: none; font-weight: 500; font-size: 0.95rem; padding: 0.4em 0; position: relative; }
nav a:hover, nav a[aria-current="page"] { color: var(--color-brand); }
.dark-face nav a:hover, .dark-face nav a[aria-current="page"] { color: var(--color-accent); }
footer { padding: 3rem 0; border-top: 1px solid var(--color-line); font-size: 0.9rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.footer-col h4 { margin: 0 0 1em; font-weight: 600; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col a { text-decoration: none; color: inherit; opacity: 0.8; }
.footer-col a:hover { opacity: 1; }
.copyright { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--color-line); text-align: center; opacity: 0.7; }

/* Mobile Nav Toggle (Simple) */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5em; }
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  nav ul { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--color-paper); flex-direction: column; padding: 1em; border-bottom: 1px solid var(--color-line); }
  .dark-face nav ul { background: var(--color-dark); }
  nav.open ul { display: flex; }
}
