:root {
  --color-dark: #13102D;
  --color-paper: #F7F5F3;
  --color-text: #171523;
  --color-brand: #2714EB;
  --color-emphasis: #89ED6E;
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(23, 21, 35, 0.3);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;
  --font-heading-weight: 600;
  --line-height-body: 1.65;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--color-text);
  background: var(--color-paper);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }

.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }

/* Layout: Left Nav Desktop / Top Nav Mobile */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  padding: 2rem 1.5rem;
  background: var(--color-paper);
  border-right: 1px solid rgba(23, 21, 35, 0.08);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  flex-shrink: 0;
}
.top-nav { display: none; }
.main-content { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .top-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem var(--gap); background: var(--color-paper);
    border-bottom: 1px solid rgba(23, 21, 35, 0.08); position: sticky; top: 0; z-index: 10;
  }
  .nav-links { display: flex; gap: 1rem; }
  .nav-links a { font-size: 0.9rem; font-weight: 600; }
}

/* Typography */
h1, h2, h3 { font-weight: var(--font-heading-weight); line-height: 1.25; letter-spacing: 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: 1.5rem; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-top: 2rem; margin-bottom: 1.2rem; }
h3 { font-size: 1.25rem; margin-top: 1.5rem; margin-bottom: 0.75rem; }
p { margin-bottom: 1rem; max-width: 38em; }
.marker {
  display: inline-block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em;
  margin-bottom: 0.5rem; text-transform: uppercase;
}
.paper-theme .marker { color: var(--color-brand); }
.dark-theme .marker { color: var(--color-emphasis); }
.hl { font-weight: 700; }
.paper-theme .hl { color: var(--color-brand); }
.dark-theme .hl { color: var(--color-emphasis); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.8em 1.6em; border-radius: var(--radius-btn);
  font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border: none; text-align: center;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--color-brand); outline-offset: 2px; }
.btn-primary { background: var(--color-emphasis); color: var(--color-dark); }
.btn-secondary { background: transparent; border: 1.5px solid var(--color-text); color: var(--color-text); }
.dark-theme .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.dark-theme .btn:focus-visible { outline-color: var(--color-emphasis); }

/* Cards & Panels */
.card {
  background: var(--color-paper); border-radius: var(--radius-card);
  box-shadow: var(--card-shadow); padding: var(--gap);
  border: var(--card-border); transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 12px 32px -12px rgba(23, 21, 35, 0.4); }
.panel {
  background: var(--color-dark); border-radius: var(--radius-card);
  padding: var(--gap); position: relative; overflow: hidden;
}
.panel .paper-card {
  background: var(--color-paper); color: var(--color-text);
  border-radius: calc(var(--radius-card) - 4px); padding: 1.25rem;
}

/* Grid & Split */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: center; }
@media (max-width: 768px) { .split-row { grid-template-columns: 1fr; } }

/* Table */
.data-table { width: 100%; border-collapse: collapse; margin: 1rem 0; display: block; overflow-x: auto; }
.data-table thead, .data-table tbody { display: table; width: 100%; table-layout: fixed; }
.data-table th, .data-table td { padding: 0.8rem; text-align: left; border-bottom: 1px solid rgba(23, 21, 35, 0.1); }
.data-table td a { word-break: break-all; overflow-wrap: anywhere; }
.data-table th { font-weight: 600; color: var(--color-text); }
.dark-theme .data-table th, .dark-theme .data-table td { border-color: rgba(247, 245, 243, 0.15); color: var(--color-paper); }

/* FAQ */
details { margin-bottom: 1rem; border-bottom: 1px solid rgba(23, 21, 35, 0.1); padding-bottom: 1rem; }
.summary { cursor: pointer; font-weight: 600; padding: 0.5rem 0; 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 { margin-top: 0.5rem; font-size: 0.95rem; }

/* SVG Base */
.svg-wrap { width: 100%; height: auto; max-width: 100%; }
svg { width: 24; height: 24; display: block; }
svg.flow-svg { width: 100%; height: auto; }

/* Animations */
@keyframes drawPath {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes flowDot {
  0% { offset-distance: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}
@keyframes floatGentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.draw-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawPath 4s ease-in-out infinite alternate;
}
.move-dot {
  offset-path: path("M10,20 Q30,10 50,20 T90,20");
  animation: flowDot 5s linear infinite;
}
.float-layer { animation: floatGentle 6s ease-in-out infinite; }

/* Dark Theme Overrides */
.dark-theme { background: var(--color-dark); color: var(--color-paper); }
.dark-theme h2, .dark-theme h3, .dark-theme p, .dark-theme li { color: var(--color-paper); }
.dark-theme .marker { color: var(--color-emphasis); }
.dark-theme .hl { color: var(--color-emphasis); }
.dark-theme .card { background: rgba(247, 245, 243, 0.08); color: var(--color-paper); }
.dark-theme .data-table th, .dark-theme .data-table td { border-color: rgba(247, 245, 243, 0.15); color: var(--color-paper); }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
