:root {
  --bg: #0b1020;
  --bg-soft: #111733;
  --panel: #151c3a;
  --panel-2: #1b2347;
  --border: #283163;
  --text: #e7ecff;
  --muted: #9aa6d4;
  --brand: #6366f1;
  --brand-2: #06b6d4;
  --accent: #22d3ee;
  --code-bg: #0d1430;
  --radius: 16px;
  --maxw: 1080px;
  --shadow: 0 20px 60px rgba(2, 6, 23, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 80% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
              radial-gradient(1000px 600px at -10% 10%, rgba(6, 182, 212, 0.12), transparent 55%),
              var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Nav ---------- */
header.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(140%) blur(10px);
  background: rgba(11, 16, 32, 0.72);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: -0.01em; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand span b { color: #fff; }
.brand span small { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { color: var(--muted); font-size: 0.95rem; font-weight: 500; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-links .gh {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff; border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 10px; background: var(--panel);
}
.nav-links .gh:hover { border-color: var(--brand); }
.menu-toggle { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 90px 0 70px; text-align: center; }
.eyebrow {
  display: inline-block;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 6px 14px; border-radius: 999px;
  margin-bottom: 26px;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffffff, #b9c2f0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead {
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  color: var(--muted);
  max-width: 720px; margin: 0 auto 34px;
}
.hero .lead b { color: var(--text); }
.cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 600; font-size: 1rem;
  padding: 13px 24px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  color: #0a0f22;
  background: linear-gradient(135deg, var(--brand-2), var(--accent));
  box-shadow: 0 10px 30px rgba(6, 182, 212, 0.35);
}
.btn-ghost { color: #fff; background: var(--panel); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--brand); }

.badges { margin-top: 30px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.badges img { height: 22px; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
  margin: 20px 0 10px;
}
.stat {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 20px; text-align: center;
}
.stat .num {
  font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--brand));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .label { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

/* ---------- Sections ---------- */
section { padding: 64px 0; }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 44px; }
.section-head h2 {
  font-size: clamp(1.8rem, 3.6vw, 2.5rem); letter-spacing: -0.02em; margin: 0 0 12px; font-weight: 800;
}
.section-head p { color: var(--muted); font-size: 1.08rem; margin: 0; }

/* ---------- Feature grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: transform .15s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-4px); border-color: var(--brand); }
.card .ico {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 16px;
  background: rgba(99, 102, 241, 0.15); border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 1.4rem;
}
.card h3 { margin: 0 0 8px; font-size: 1.18rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.98rem; }

/* ---------- Code ---------- */
.code-wrap {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.code-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.code-bar .fname { margin-left: 10px; color: var(--muted); font-size: 0.85rem; font-family: ui-monospace, monospace; }
pre {
  margin: 0; padding: 22px 24px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem; line-height: 1.7;
}
code { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
:not(pre) > code {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 6px; font-size: 0.88em; color: var(--accent);
}
/* token colors */
.tok-c { color: #6b7aa8; font-style: italic; }   /* comment */
.tok-k { color: #c792ea; }                        /* keyword */
.tok-t { color: #82aaff; }                        /* type */
.tok-f { color: #ffcb6b; }                        /* function */
.tok-s { color: #c3e88d; }                        /* string */
.tok-n { color: #f78c6c; }                        /* number */
.tok-p { color: #89ddff; }                        /* preproc */

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.two-col .prose h3 { font-size: 1.3rem; margin: 0 0 12px; }
.two-col .prose p { color: var(--muted); }
.two-col .prose ul { color: var(--muted); padding-left: 20px; }
.two-col .prose li { margin: 8px 0; }
.two-col .prose b { color: var(--text); }

/* ---------- API table ---------- */
.api-table {
  width: 100%; border-collapse: collapse;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.api-table th, .api-table td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.api-table th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.api-table tr:last-child td { border-bottom: none; }
.api-table code { color: var(--accent); font-size: 0.86rem; }
.api-table td.desc { color: var(--muted); font-size: 0.94rem; }
.api-cat { color: var(--brand-2); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Bench note ---------- */
.note {
  margin-top: 18px; color: var(--muted); font-size: 0.88rem; text-align: center;
}

/* ---------- Citation ---------- */
.cite {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; color: var(--muted);
  font-size: 0.95rem;
}
.cite + .cite { margin-top: 16px; }
.cite a { font-weight: 600; }

/* ---------- Related ---------- */
.related { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.related a {
  display: block; padding: 16px 18px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  transition: border-color .2s ease, transform .12s ease;
}
.related a:hover { border-color: var(--brand); transform: translateY(-2px); text-decoration: none; }
.related a b { display: block; color: #fff; margin-bottom: 3px; }
.related a span { color: var(--muted); font-size: 0.85rem; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 40px 0; margin-top: 30px; color: var(--muted); font-size: 0.92rem;
}
.foot-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.foot-inner a { color: var(--muted); }
.foot-inner a:hover { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .related { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
    position: absolute; top: 64px; left: 0; right: 0;
    background: var(--bg-soft); border-bottom: 1px solid var(--border); padding: 20px 24px;
  }
  .menu-toggle {
    display: inline-flex; background: var(--panel); border: 1px solid var(--border);
    color: #fff; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 1.1rem;
  }
}
