/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg: #0b0f17;
  --bg-elevated: #101624;
  --surface: #151c2c;
  --surface-hover: #1a2338;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2f8;
  --text-muted: #9aa7bd;
  --text-faint: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --header-bg: rgba(11, 15, 23, 0.75);
  --hero-gradient: linear-gradient(135deg, #fff 20%, #c7d2fe 60%, #a5b4fc 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --font:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;
  --mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --maxw: 1040px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --header-bg: rgba(248, 250, 252, 0.75);
  --hero-gradient: linear-gradient(
    135deg,
    #0f172a 20%,
    #4f46e5 60%,
    #7c3aed 100%
  );
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

/* ── Reset / base ──────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a {
  color: var(--accent-hover);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 650;
}
code,
pre {
  font-family: var(--mono);
}
img {
  max-width: 100%;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}
.logo:hover {
  text-decoration: none;
}
.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.site-header nav a {
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition:
    color 0.15s,
    background 0.15s;
}
.site-header nav a:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

/* ── Theme toggle ──────────────────────────────────────────────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 0.5rem;
  transition:
    color 0.15s,
    background 0.15s;
}
.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
[data-theme="dark"] .icon-sun {
  display: block;
}
[data-theme="dark"] .icon-moon {
  display: none;
}
[data-theme="light"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-moon {
  display: block;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.site-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ── Hero (homepage) ───────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 1rem 3rem;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  margin: 0 0 1rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero .lead {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 42rem;
  margin: 0 auto 2rem;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s;
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Prose / content ───────────────────────────────────────────────────── */
.content {
  font-size: 1rem;
}
.content h2 {
  margin-top: 3rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.5rem;
}
.content h3 {
  margin-top: 2rem;
  font-size: 1.15rem;
}
.content p {
  color: var(--text);
}
.content li {
  margin: 0.35rem 0;
}
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.content th,
.content td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.content th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.content tr:hover td {
  background: var(--surface);
}
.content code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
}
.content pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.content pre code {
  background: transparent;
  border: none;
  padding: 0;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Playground ────────────────────────────────────────────────────────── */
.playground {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
#preview {
  display: block;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  image-rendering: pixelated;
  background: repeating-conic-gradient(
      var(--surface) 0% 25%,
      var(--bg-elevated) 0% 50%
    )
    0 0 / 16px 16px;
}
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type="text"],
input[type="password"],
input[type="number"],
select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.result-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-height: 3rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.result-panel.ok {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.3);
}
.result-panel.err {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}

/* ── Docs layout ───────────────────────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}
.doc-nav {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.doc-nav a {
  color: var(--text-muted);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.doc-nav a:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.doc-nav a.active {
  color: var(--accent-hover);
  background: var(--accent-soft);
}

@media (max-width: 720px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .doc-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .site-header {
    padding: 0.6rem 1rem;
  }
}
