:root {
  --bg: #fbfaff;
  --bg-soft: #f2effc;
  --card: #ffffff;
  --text: #1f1b2e;
  --muted: #625d78;
  --faint: #8a86a0;
  --border: #e3def5;
  --accent: #6d4fd9;
  --accent-2: #17c3b2;
  --accent-soft: #ece7ff;
  --danger: #e5484d;
  --code-bg: #f4f1fd;
  --shadow: 0 1px 2px rgba(30, 20, 70, 0.06), 0 8px 24px rgba(30, 20, 70, 0.08);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f0d18;
    --bg-soft: #17142a;
    --card: #1a1730;
    --text: #e8e6f3;
    --muted: #aaa5c4;
    --faint: #8d88a8;
    --border: #2c2747;
    --accent: #9b82ff;
    --accent-2: #2ad3c1;
    --accent-soft: #241d45;
    --code-bg: #1c1833;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme='dark'] {
  --bg: #0f0d18;
  --bg-soft: #17142a;
  --card: #1a1730;
  --text: #e8e6f3;
  --muted: #aaa5c4;
  --faint: #8d88a8;
  --border: #2c2747;
  --accent: #9b82ff;
  --accent-2: #2ad3c1;
  --accent-soft: #241d45;
  --code-bg: #1c1833;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

code,
pre {
  font-family: var(--mono);
  font-size: 0.88em;
}
:not(pre) > code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(160%) blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand img {
  width: 34px;
  height: 34px;
}
.brand:hover {
  text-decoration: none;
}
.nav {
  display: flex;
  gap: 18px;
  margin-left: auto;
  align-items: center;
}
.nav a {
  color: var(--muted);
  font-weight: 500;
}
.nav a.active,
.nav a:hover {
  color: var(--text);
  text-decoration: none;
}
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

/* ---- hero ---- */
.hero {
  padding: 72px 0 40px;
  background: radial-gradient(1200px 400px at 70% -10%, var(--accent-soft), transparent 70%);
}
.hero .wrap {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 40px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.08;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p.lead {
  font-size: 19px;
  color: var(--muted);
  margin: 0 0 26px;
  max-width: 34em;
}
.hero-logo {
  width: 100%;
  max-width: 340px;
  justify-self: center;
  filter: drop-shadow(0 20px 40px rgba(109, 79, 217, 0.35));
}
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.btn:hover {
  text-decoration: none;
  border-color: var(--accent);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.08);
}

/* ---- sections ---- */
section {
  padding: 56px 0;
}
section.soft {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
h2 {
  font-size: 30px;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.section-lead {
  color: var(--muted);
  margin: 0 0 30px;
  max-width: 46em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 4px 0 6px;
  font-size: 17px;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}
.card .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}
.shot {
  margin: 0;
}
.shot img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: block;
  background: var(--card);
}
.shot figcaption {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 44px;
  margin-bottom: 18px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.arch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.arch .card h3 {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---- docs ---- */
.docs {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 40px;
  padding: 36px 0 70px;
}
.toc {
  position: sticky;
  top: 80px;
  align-self: start;
  font-size: 14px;
}
.toc a {
  display: block;
  color: var(--muted);
  padding: 4px 0;
}
.toc a:hover {
  color: var(--text);
}
.toc .group {
  font-weight: 700;
  color: var(--text);
  margin: 14px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.doc h2 {
  margin-top: 48px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.doc h2:first-child {
  margin-top: 0;
  border-top: none;
}
.doc h3 {
  margin-top: 28px;
}
.doc table,
.result-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.doc th,
.doc td,
.result-table th,
.result-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.doc th,
.result-table th {
  background: var(--bg-soft);
}
.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
}

/* ---- blog and long-form pages ---- */
.post {
  max-width: 792px;
  margin: 0 auto;
  padding-top: 44px;
  padding-bottom: 70px;
  font-size: 17px;
  line-height: 1.7;
}
.post h1 {
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 8px 0 12px;
}
.post .meta {
  color: var(--faint);
  font-size: 14px;
}
.post .standfirst {
  font-size: 20px;
  color: var(--muted);
  margin: 18px 0 28px;
}
.post h2 {
  margin-top: 46px;
}
.post h3 {
  margin-top: 30px;
}
.post figure {
  margin: 26px 0;
}
.post figure img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.post figcaption {
  color: var(--faint);
  font-size: 14px;
  margin-top: 8px;
}
.post table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}
.post th,
.post td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.post th {
  background: var(--bg-soft);
}
.post .next {
  margin-top: 50px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.post-list {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}
.post-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  color: var(--text);
}
.post-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.post-card h2 {
  margin: 6px 0 8px;
  font-size: 22px;
}
.post-card p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}
.post-card .meta {
  color: var(--faint);
  font-size: 13px;
}
.tree {
  font-family: var(--mono);
  font-size: 14px;
}

/* ---- demo ---- */
.demo {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  padding: 24px 0 50px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.panel header .grow {
  flex: 1;
}
.panel textarea {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  width: 100%;
}
#vault {
  min-height: 560px;
}
#query {
  min-height: 150px;
}
#result {
  height: 470px;
  overflow: auto;
}
#result table {
  margin: 12px;
  width: calc(100% - 24px);
}
select,
button.run {
  font: inherit;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 6px 10px;
}
button.run {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.message {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  padding: 0 14px;
  white-space: pre-wrap;
  min-height: 20px;
}
.message.error {
  color: var(--danger);
}
.stats {
  color: var(--faint);
  font-weight: 500;
  font-size: 13px;
}

footer {
  border-top: 1px solid var(--border);
  padding: 30px 0 40px;
  color: var(--faint);
  font-size: 14px;
}
footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
}

@media (max-width: 860px) {
  .hero .wrap,
  .two-col,
  .demo,
  .docs {
    grid-template-columns: minmax(0, 1fr);
  }
  .arch {
    grid-template-columns: minmax(0, 1fr);
  }
  .hero-logo {
    max-width: 200px;
    order: -1;
  }
  .toc {
    position: static;
  }
  .site-header .wrap {
    height: auto;
    flex-wrap: wrap;
    gap: 4px 18px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand {
    white-space: nowrap;
  }
  .nav {
    gap: 14px;
    font-size: 14px;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
  }
  .theme-toggle {
    flex-shrink: 0;
  }
  .doc table {
    display: block;
    overflow-x: auto;
  }
  .panel header {
    flex-wrap: wrap;
  }
  .post {
    font-size: 16px;
  }
  #vault {
    min-height: 320px;
  }
}
