:root {
  --bg: #090d16;
  --bg-elevated: #0f1624;
  --bg-code: #0b101b;
  --border: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-bright: #38bdf8;
  --accent-glow: rgba(37, 99, 235, 0.22);
  --brand-loom: #f8fafc;
  --brand-cfg: #38bdf8;
  --radius: 12px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-code: #0f172a;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0057d9;
  --accent-bright: #0284c7;
  --accent-glow: rgba(0, 87, 217, 0.12);
  --brand-loom: #0b172a;
  --brand-cfg: #0057d9;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(148, 163, 184, 0.14);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none !important;
}

.brand-icon { display: block; border-radius: 6px; }

.brand-wordmark {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-loom { color: var(--brand-loom); }
.brand-cfg { color: var(--brand-cfg); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.15s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
  text-decoration: none;
}

.nav-github {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-toggle, .mobile-menu-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 0.95rem;
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
.mobile-menu-btn { display: none; }

.hero {
  padding: 5rem 0 4rem;
  background: radial-gradient(circle at 75% 20%, var(--accent-glow), transparent 55%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 3rem;
  align-items: center;
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-bright);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.25rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.035em;
  margin: 0 0 1.25rem;
}

.text-accent {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin: 0 0 1.75rem;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.35rem;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
  text-decoration: none !important;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-secondary { background: var(--bg-elevated); border-color: var(--border); color: var(--text); }

.cli-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.45rem 0.65rem 0.45rem 0.9rem;
}

.cli-pill code { background: none; padding: 0; color: var(--text-muted); }

.copy-btn {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent-bright);
  border: none;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.code-window {
  background: var(--bg-code);
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

.window-dots { display: flex; gap: 6px; }
.window-dots span { width: 10px; height: 10px; border-radius: 50%; background: #334155; }
.window-tabs { display: flex; gap: 0.4rem; }

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
}

.tab-btn.active { background: #1e293b; color: #f8fafc; }

.code-pane {
  display: none;
  margin: 0;
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: #e2e8f0;
  overflow-x: auto;
}

.code-pane.active { display: block; }
.code-pane code { background: none; padding: 0; }

.tok-com { color: #64748b; font-style: italic; }
.tok-dir { color: #c084fc; }
.tok-kw { color: #f472b6; }
.tok-key { color: #7dd3fc; }
.tok-str { color: #86efac; }
.tok-num { color: #fbbf24; }
.tok-bool { color: #f87171; }
.tok-tag { color: #38bdf8; font-weight: 600; }
.tok-spread { color: #c084fc; }

.features, .comparison-section {
  padding: 4.5rem 0;
  border-top: 1px solid var(--border);
}

.section-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 3rem;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 0.6rem;
}

.section-header p { color: var(--text-muted); margin: 0; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.feature-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--accent-bright);
  font-family: var(--font-mono);
  font-weight: 700;
  margin-bottom: 1rem;
}

.feature-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.comp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.94rem;
}

.comp-table th, .comp-table td {
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.comp-table tr:last-child td { border-bottom: none; }
.col-highlight { background: rgba(37, 99, 235, 0.08); font-weight: 600; }

.doc-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 3rem;
  padding: 3rem 1.5rem 5rem;
}

.doc-sidebar { position: sticky; top: 92px; align-self: start; }
.sidebar-group { margin-bottom: 1.75rem; }

.sidebar-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.sidebar-link {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.93rem;
  margin-bottom: 0.2rem;
}

.sidebar-link:hover, .sidebar-link.active {
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
}

.doc-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-bright);
  margin-bottom: 0.4rem;
}

.doc-content h1 {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}

.doc-lead { font-size: 1.12rem; color: var(--text-muted); margin: 0 0 2rem; }

.prose pre {
  background: var(--bg-code);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 1.1rem;
  overflow-x: auto;
  color: #e2e8f0;
}

.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; }
.prose th, .prose td { padding: 0.75rem 1rem; border: 1px solid var(--border); text-align: left; }

.playground-section { padding: 3rem 0 5rem; }

.playground-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.playground-header h1 { margin: 0 0 0.35rem; font-size: 2.1rem; }
.playground-header p { margin: 0; color: var(--text-muted); }

.playground-controls { display: flex; gap: 0.65rem; align-items: center; }

.select-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.playground-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.editor-card {
  background: var(--bg-code);
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.editor-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #94a3b8;
}

.status-badge {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
}

.status-badge.error { background: rgba(239, 68, 68, 0.18); color: #f87171; }

#loomInput {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  color: #f1f5f9;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  padding: 1.15rem;
  resize: vertical;
  outline: none;
}

.json-output {
  flex: 1;
  margin: 0;
  padding: 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  color: #86efac;
  overflow: auto;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.footer-brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { color: var(--text-muted); }

@media (max-width: 900px) {
  .hero-grid, .feature-grid, .doc-shell, .playground-grid { grid-template-columns: 1fr; }
  .doc-sidebar { position: static; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
  }
  .mobile-menu-btn { display: inline-flex; }
}
