:root {
  --bg: #0c0d10;
  --surface: #13151b;
  --surface-2: #171a21;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --tick: rgba(255, 255, 255, 0.55);
  --text: #f2f3f5;
  --muted: #a7abb4;
  --dim: #6b7079;
  --crimson: #be1e3c;
  --crimson-hover: #d22548;
  --radius: 4px;
  --max: 1200px;
  --gutter: 48px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 1.5px solid var(--text); outline-offset: 3px; }

.wrap {
  width: 100%;
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(12, 13, 16, 0.86);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 72px;
}
.wordmark {
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.03em;
  justify-self: start;
}
.nav { display: flex; gap: 48px; }
.nav a, .footer-nav a {
  font-size: 15px;
  color: var(--muted);
  transition: color 160ms var(--ease);
}
.nav a:hover, .footer-nav a:hover, .nav a[aria-current="page"] { color: var(--text); }
.site-header .btn { justify-self: end; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 22px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.btn-primary { background: var(--crimson); color: #fff; }
.btn-primary:hover { background: var(--crimson-hover); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.03); }
.btn-lg { height: 56px; padding: 0 38px; font-size: 17px; }

/* ---------- Sections ---------- */
.section { border-bottom: 1px solid var(--line); }
.section-pad { padding: 40px 0 36px; }
.section h2 {
  margin: 0 0 20px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

/* ---------- Hero ---------- */
.hero .wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  padding-top: 24px;
  padding-bottom: 28px;
}
.hero h1 {
  margin: 0 0 28px;
  font-size: clamp(40px, 5.2vw, 68px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.04em;
}
.hero p {
  margin: 0 0 36px;
  max-width: 30ch;
  font-size: 21px;
  line-height: 1.4;
  color: var(--muted);
}
.actions { display: flex; flex-wrap: wrap; gap: 16px; }

/* Stage frame */
.stage {
  position: relative;
  aspect-ratio: 454 / 448;
  width: 100%;
  max-width: 580px;
  justify-self: end;
  background:
    radial-gradient(ellipse 70% 60% at 50% 38%, rgba(255, 255, 255, 0.07), transparent 70%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  overflow: hidden;
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  background: var(--line);
  pointer-events: none;
}
.stage::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.stage::after { top: 48%; left: 0; right: 0; height: 1px; }
.tick {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 0 solid var(--tick);
  z-index: 3;
  pointer-events: none;
}
.tick.tl { top: 12px; left: 12px; border-top-width: 1.5px; border-left-width: 1.5px; }
.tick.tr { top: 12px; right: 12px; border-top-width: 1.5px; border-right-width: 1.5px; }
.tick.bl { bottom: 12px; left: 12px; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.tick.br { bottom: 12px; right: 12px; border-bottom-width: 1.5px; border-right-width: 1.5px; }

#runtime-mount {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#runtime-mount .poster {
  height: 104%;
  width: auto;
  max-width: none;
  margin-bottom: -4%;
  object-fit: contain;
  user-select: none;
}
#runtime-mount canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#runtime-mount.is-live .poster { display: none; }

/* ---------- Avatars ---------- */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.avatar-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 200ms var(--ease);
}
.avatar-card:hover { border-color: var(--line-strong); }
.avatar-card .portrait {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background:
    radial-gradient(ellipse 65% 55% at 50% 40%, #2a2d35 0%, #1a1c22 55%, #121318 100%);
}
.avatar-card .portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
  transition: transform 500ms var(--ease);
}
.avatar-card:hover .portrait img { transform: scale(1.025); }
.avatar-card .name {
  display: block;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

/* ---------- Spec ---------- */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.9fr;
  gap: 16px;
  align-items: stretch;
}
.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 36px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color 200ms var(--ease);
}
.feature:hover { border-color: var(--line-strong); }
.feature svg {
  width: 68px;
  height: 68px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.feature h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.code {
  margin: 0;
  padding: 18px 0;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  overflow-x: auto;
  counter-reset: ln;
}
.code code { display: block; min-width: max-content; }
.code .ln { display: block; padding-right: 20px; }
.code .ln::before {
  counter-increment: ln;
  content: counter(ln);
  display: inline-block;
  width: 3.2em;
  padding-right: 1.2em;
  text-align: right;
  color: var(--dim);
  user-select: none;
}
.tok-k { color: #f07a8e; }
.tok-s { color: #e6e7ea; }
.tok-n { color: #9cc4ff; }
.tok-p { color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.site-footer .wordmark { font-size: 24px; }
.footer-nav { display: flex; gap: 44px; }

/* ---------- Lightbox ---------- */
.lightbox {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(6, 7, 9, 0.82); backdrop-filter: blur(4px); }
.lightbox[open] { animation: lb-in 220ms var(--ease); }
@keyframes lb-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.lightbox .lb-stage {
  position: relative;
  height: min(70vh, 720px);
  background: radial-gradient(ellipse 65% 55% at 50% 40%, #2a2d35 0%, #1a1c22 55%, #121318 100%);
  border-bottom: 1px solid var(--line);
}
.lightbox .lb-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
}
.lightbox .lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}
.lightbox .lb-name { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.lightbox .lb-actions { display: flex; gap: 12px; }
.lightbox .lb-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: rgba(12, 13, 16, 0.7);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 160ms var(--ease);
}
.lightbox .lb-close:hover { border-color: rgba(255, 255, 255, 0.4); }
.lightbox .lb-close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.5; fill: none; }

/* ---------- Doc pages (format / docs) ---------- */
.doc .site-footer { border-top: 1px solid var(--line); }
.doc main .wrap { max-width: calc(980px + var(--gutter) * 2); }
.doc-head { padding: 56px 0 40px; border-bottom: 1px solid var(--line); }
.doc-head h1 {
  margin: 0;
  font-size: clamp(36px, 4.4vw, 56px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.doc-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 56px;
  padding: 40px 0 72px;
}
.toc { position: sticky; top: 104px; align-self: start; display: flex; flex-direction: column; gap: 10px; }
.toc a { font-size: 14px; color: var(--muted); transition: color 160ms var(--ease); }
.toc a:hover { color: var(--text); }
.doc-body section { padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--line); scroll-margin-top: 96px; }
.doc-body section:last-child { border-bottom: 0; margin-bottom: 0; }
.doc-body h2 { margin: 0 0 16px; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; }
.doc-body h3 { margin: 28px 0 10px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.doc-body p, .doc-body li { color: var(--muted); font-size: 16px; }
.doc-body p { margin: 0 0 14px; }
.doc-body ul { margin: 0 0 14px; padding-left: 20px; }
.doc-body strong { color: var(--text); font-weight: 600; }
.doc-body a { color: var(--text); border-bottom: 1px solid var(--line-strong); transition: border-color 160ms var(--ease); }
.doc-body a:hover { border-color: var(--text); }
.doc-body :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.doc-body .code { margin: 0 0 16px; }
.table-scroll { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.doc-body table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.doc-body th, .doc-body td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-body tr:last-child td { border-bottom: 0; }
.doc-body th { color: var(--text); font-weight: 600; background: var(--surface); }
.doc-body td { color: var(--muted); }
.doc-body td:first-child { white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .spec-grid { grid-template-columns: repeat(3, 1fr); }
  .spec-grid .code { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  :root { --gutter: 24px; }
  .nav { gap: 28px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 32px; padding-top: 40px; }
  .stage { justify-self: stretch; max-width: none; }
  .doc-layout { grid-template-columns: 1fr; gap: 24px; }
  .toc { position: static; flex-direction: row; flex-wrap: wrap; gap: 8px 20px; }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; }
  .site-header .wrap { grid-template-columns: 1fr auto; height: 60px; }
  .site-header .nav { display: none; }
  .wordmark { font-size: 22px; }
  .site-header .btn { height: 38px; padding: 0 16px; font-size: 14px; }
  .hero .wrap { padding-top: 32px; }
  .hero h1 { margin-bottom: 20px; }
  .hero p { font-size: 18px; margin-bottom: 28px; }
  .btn-lg { height: 50px; padding: 0 24px; font-size: 16px; flex: 1 1 0; }
  .section h2 { font-size: 32px; }
  .avatar-grid { grid-template-columns: 1fr; gap: 12px; }
  .avatar-card .portrait { aspect-ratio: 4 / 4.4; }
  .avatar-card .name { font-size: 22px; padding: 12px 16px 14px; }
  .spec-grid { grid-template-columns: 1fr; gap: 12px; }
  .feature { flex-direction: row; justify-content: flex-start; gap: 20px; padding: 20px; text-align: left; }
  .feature svg { width: 44px; height: 44px; flex: none; }
  .feature h3 br { display: none; }
  .code { font-size: 12.5px; }
  .site-footer .wrap { flex-direction: column; justify-content: center; gap: 14px; height: auto; padding-top: 28px; padding-bottom: 28px; }
  .footer-nav { gap: 28px; }
  .lightbox .lb-bar { flex-direction: column; align-items: stretch; }
  .lightbox .lb-actions .btn { flex: 1 1 0; }
  .doc-head { padding: 36px 0 28px; }
}
