/* ===== Design tokens ===== */
:root {
  --bg: #060a14;
  --bg-soft: #0c1120;
  --surface: rgba(10, 16, 30, 0.92);
  --surface-2: rgba(13, 20, 38, 0.96);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --brand: #818cf8;
  --brand-dim: rgba(129, 140, 248, 0.15);
  --brand-2: #34d399;
  --border: rgba(148, 163, 184, 0.11);
  --border-bright: rgba(148, 163, 184, 0.24);
  --radius: 16px;
  --radius-sm: 10px;
  --topbar-h: 60px;
  --transition: 0.18s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 10% -10%, rgba(52, 211, 153, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(129, 140, 248, 0.15), transparent),
    radial-gradient(ellipse 100% 70% at 50% 110%, rgba(6, 182, 212, 0.07), transparent);
  -webkit-font-smoothing: antialiased;
}

/* ===== Sticky topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 1.75rem;
  background: rgba(6, 10, 20, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
  letter-spacing: -.01em;
}
.brand img { width: 28px; height: 28px; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1.8rem;
  flex: 1;
  justify-content: center;
}
.topbar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: color var(--transition);
  white-space: nowrap;
}
.topbar-nav a:hover { color: var(--text); }

/* ===== Buttons ===== */
.button {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  color: #fff;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  border: 0;
  padding: .52rem 1.1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}
.button:hover { opacity: .92; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45); }
.button.ghost {
  background: var(--brand-dim);
  color: #c7d2fe;
  border: 1px solid rgba(129, 140, 248, 0.28);
  box-shadow: none;
}
.button.ghost:hover { background: rgba(129, 140, 248, 0.24); box-shadow: none; transform: none; }
.button.small { padding: .35rem .75rem; font-size: .8rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-dim);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.22);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(129, 140, 248, 0.28); color: #e0e7ff; }

/* ===== Main layout ===== */
main { max-width: 1160px; margin: 0 auto; padding: 0 1.5rem 6rem; }

/* ===== Section base ===== */
.section-header { margin-bottom: 1.5rem; }
.section-header h2 { margin: 0 0 .35rem; }
.section-lead { margin: 0; color: var(--muted); font-size: 1rem; }

/* ===== Hero ===== */
.hero {
  padding: 6rem 0 3rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.2rem;
  align-items: center;
  min-height: 340px;
}
.hero-content {
  min-width: 0;
  text-align: left;
  max-width: 760px;
}
.hero-accent { color: var(--brand); }
.hero-period { color: #f1f5f9; }

h1 {
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.07;
  letter-spacing: -.035em;
  margin: 0 0 1rem;
  color: #f1f5f9;
}
h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -.022em;
  color: #f1f5f9;
  margin: 0 0 .5rem;
}
h3 { font-size: 1rem; font-weight: 600; color: #cbd5e1; margin: 0 0 .5rem; }

.subhead {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 46ch;
  margin: 0 0 1.8rem;
  margin-inline: 0;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 0;
}
.hero-preview { min-width: 0; }
.hero-chart-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #050911;
  overflow: hidden;
}
.hero-chart-img { display: block; width: 100%; aspect-ratio: 24 / 13; object-fit: contain; }

/* ===== Code ===== */
code, pre {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Monaco, Consolas, monospace;
}
code {
  font-size: .84em;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-bright);
  color: #bfdbfe;
  padding: .22rem .5rem;
  border-radius: 6px;
}
pre {
  margin: 0;
  background: #020617;
  color: #dbeafe;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.12);
  font-size: .875rem;
  line-height: 1.7;
  white-space: pre;
}

/* ===== Example cards ===== */
.examples {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2.5rem 0;
}
.example-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.example-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.example-img-wrap {
  position: relative;
  aspect-ratio: 2 / 1;
  background: #050911;
  overflow: hidden;
}
.example-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s;
}
.example-footer {
  padding: .6rem .85rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.example-footer code {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted-2);
  font-size: .74rem;
  margin-left: auto;
}
.ex-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .18rem .5rem;
  border-radius: 99px;
  background: rgba(129, 140, 248, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.2);
  white-space: nowrap;
}
.ex-badge--style {
  background: rgba(52, 211, 153, 0.1);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.2);
}

/* ===== How it works ===== */
.how {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.25rem;
}
.how-steps {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.how-steps li {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid rgba(129, 140, 248, 0.13);
  border-radius: var(--radius-sm);
  padding: 1.15rem;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}
.how-steps strong { display: block; margin-bottom: .2rem; font-size: .95rem; }
.how-steps li > div > span { display: block; color: var(--muted); font-size: .875rem; }
.how-steps code { font-size: .82em; }

/* ===== Playground ===== */
.playground {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.25rem;
}

.pg-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Controls */
.pg-controls { display: flex; flex-direction: column; gap: .85rem; }

fieldset.control-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem 1rem;
  margin: 0;
}
.control-group-label {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 .3rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin-top: .7rem;
}
label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .81rem;
  font-weight: 500;
  color: #94a3b8;
}
label.full { grid-column: 1 / -1; }
.label-optional {
  font-size: .72rem;
  font-weight: 400;
  color: var(--muted-2);
}

input[type="text"], input[type="number"], input[type="url"], select {
  background: rgba(6, 10, 20, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  color: #f1f5f9;
  font-family: inherit;
  font-size: .875rem;
  padding: .48rem .65rem;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.5);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding-right: 2rem;
  cursor: pointer;
}
.seed-row {
  display: flex;
  gap: .45rem;
  align-items: center;
}
.seed-row input { flex: 1; min-width: 0; }

/* Toggles */
.toggle-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  font-size: .82rem;
  font-weight: 500;
  color: #94a3b8;
  cursor: pointer;
  grid-column: span 1;
  background: rgba(6, 10, 20, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  padding: .48rem .7rem;
}
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  background: rgba(148,163,184,0.2);
  border-radius: 99px;
  flex-shrink: 0;
  transition: background var(--transition);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-input:checked + .toggle { background: #6366f1; }
.toggle-input:checked + .toggle::after { transform: translateX(14px); }

/* Preview + output */
.pg-output { display: flex; flex-direction: column; gap: 1rem; }
.preview-wrap {
  position: relative;
  background: #040810;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 2 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
#playgroundPreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: rgba(4, 8, 16, 0.5);
}
.preview-loading[hidden] { display: none; }
.loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: .2s; }
.loading-dot:nth-child(3) { animation-delay: .4s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Output tabs */
.output-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.output-tabs, .snippet-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 10, 20, 0.6);
  padding: .2rem .2rem 0;
  gap: .1rem;
}
.tab-btn {
  background: none;
  border: none;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  padding: .45rem .9rem;
  transition: color var(--transition), background var(--transition);
}
.tab-btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.07); }
.tab-btn.active {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-color: var(--surface-2);
  margin-bottom: -1px;
}
.tab-pane { padding: .85rem 1rem .65rem; }
.tab-pane pre {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: .6rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.copy-btn {
  background: var(--brand-dim);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.22);
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  padding: .3rem .7rem;
  transition: background var(--transition), color var(--transition);
}
.copy-btn:hover { background: rgba(129, 140, 248, 0.28); color: #e0e7ff; }
.output-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ===== Snippets ===== */
.snippets {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.25rem;
}
.snippet-tabs {
  margin-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}
.snippet-pane {
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 1.1rem 1.1rem .8rem;
}
.snippet-pane pre {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: .75rem;
}
.snippet-pane pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}
.snippet-base { color: #6ee7b7; }

/* Syntax highlighting in snippets */
.syn-comment { color: #64748b; font-style: italic; }
.syn-tag { color: #93c5fd; }
.syn-attr { color: #a5b4fc; }
.syn-str { color: #86efac; }
.syn-kw { color: #c084fc; }
.syn-fn { color: #67e8f9; }
.syn-num { color: #fbbf24; }
.syn-prop { color: #a5b4fc; }
.syn-selector { color: #fb7185; }
.syn-tmpl { color: #fbbf24; }

/* ===== API Reference ===== */
.api-ref {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.25rem;
}
.url-anatomy {
  background: #020617;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.anatomy-code { font-size: .88rem; background: none; border: none; padding: 0; color: var(--text); }
.a-base { color: #6ee7b7; }
.a-path { color: #93c5fd; }
.a-q { color: #c4b5fd; }

.param-group-label {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 1.5rem 0 .6rem;
}
.param-group-label:first-of-type { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
th {
  color: #94a3b8;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: rgba(6,10,20,0.4);
}
td:first-child code { color: #93c5fd; }
td { color: #cbd5e1; }
td code { font-size: .82em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(148,163,184,0.03); }

/* ===== Footer ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  max-width: 1160px;
  margin: 0 auto;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
}
footer p { margin: 0; color: var(--muted); font-size: .875rem; }
.footer-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  transition: color var(--transition);
}
.footer-link:hover { color: var(--text); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .hero { padding-top: 4.5rem; }
}
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 3rem 0 2rem;
    min-height: unset;
  }
  .hero-content { text-align: center; }
  .subhead { margin-inline: auto; }
  .hero-actions { justify-content: center; }
  .examples { grid-template-columns: 1fr 1fr; }
  .pg-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-nav { display: none; }
  .hero { padding-top: 2.2rem; }
  h1 { font-size: 2.1rem; }
  .examples { grid-template-columns: 1fr; }
  .how, .playground, .snippets, .api-ref { padding: 1.25rem; }
  .controls-grid { grid-template-columns: 1fr; }
  main { padding: 0 1rem 3rem; }
  .topbar { padding: 0 1rem; }
}
