:root {
  color-scheme: light dark;
  --canvas: light-dark(oklch(97.8% 0.004 255), oklch(14.5% 0.012 258));
  --surface: light-dark(oklch(100% 0 0), oklch(18.5% 0.014 258));
  --surface-muted: light-dark(oklch(94.6% 0.007 255), oklch(22.5% 0.016 258));
  --surface-stage: light-dark(oklch(20% 0.018 255), oklch(11.5% 0.014 258));
  --ink: light-dark(oklch(19% 0.016 258), oklch(95% 0.006 255));
  --muted: light-dark(oklch(47% 0.015 258), oklch(71% 0.012 255));
  --border: light-dark(oklch(88% 0.008 255), oklch(28% 0.016 258));
  --accent: light-dark(oklch(52% 0.17 255), oklch(68% 0.16 255));
  --accent-soft: light-dark(oklch(93% 0.04 255), oklch(28% 0.06 255));
  --accent-ink: oklch(98.5% 0.004 255);
  --shadow-card: 0 1px 2px oklch(15% 0.02 258 / 0.06), 0 8px 24px -12px oklch(15% 0.02 258 / 0.12);
  --shadow-modal: 0 24px 64px -16px oklch(8% 0.02 258 / 0.42);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Default live SVG theme tokens */
  --sf-primary: #062c1e;
  --sf-surface: #123b2c;
  --sf-accent: #fbbf24;
  --sf-accent2: #34d399;
  --sf-ink: #f8fafc;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code,
pre {
  font-family: var(--font-mono);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.container {
  width: min(1240px, calc(100% - 32px));
  margin-inline: auto;
}

/* Full-width sticky header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--canvas) 84%, transparent);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.brand-icon {
  display: block;
  border-radius: 6px;
  padding: 3px;
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme toggle label visibility */
.theme-label-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-label-light {
    display: none;
  }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-label-dark {
    display: inline;
  }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-label-light {
  display: none;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-label-dark {
  display: inline;
}

/* Buttons & badges */
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: color-mix(in oklch, var(--accent) 88%, var(--ink));
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.btn-icon {
  width: 36px;
  padding: 0;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
}
.btn-icon:hover {
  background: var(--border);
}

.mono-btn {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 550;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hero */
.hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: 32px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.hero h1 {
  margin: 12px 0 12px;
  font-size: clamp(1.85rem, 3.6vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.hero-lead {
  margin: 0 0 24px;
  max-width: 56ch;
  color: var(--muted);
  font-size: 1rem;
}

.hero-lead code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.875em;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-code-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.code-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.code-card-tag {
  font-family: var(--font-mono);
  color: var(--muted);
}

.hero-code-card pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--ink);
}

/* Catalog toolbar */
.catalog-section {
  padding: 32px 0 64px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.search-field {
  flex: 1 1 260px;
}

.search-field input {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
}

.search-field input::placeholder {
  color: var(--muted);
}

/* Filled rounded segmented tabs */
.segmented-track,
.palette-track {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.tab-pill {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  text-transform: capitalize;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}

.tab-pill:hover {
  color: var(--ink);
}

.tab-pill[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.palette-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.palette-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.palette-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 550;
  cursor: pointer;
}

.palette-chip[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px oklch(15% 0.02 258 / 0.12);
}

.swatch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid oklch(100% 0 0 / 0.35);
}

.catalog-meta {
  margin-bottom: 16px;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* Vector grid */
.vector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.vector-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: transform 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.vector-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklch, var(--accent) 45%, var(--border));
}

.vector-preview-btn {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-stage);
  cursor: pointer;
  overflow: hidden;
}

.vector-preview-btn svg {
  width: 100%;
  height: 100%;
  max-height: 170px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
}

.card-desc {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-tag {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-actions button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

/* Native Modal Dialog */
dialog:modal {
  overscroll-behavior: contain;
  width: min(920px, calc(100vw - 24px));
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.97) translateY(6px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), overlay 180ms allow-discrete, display 180ms allow-discrete;
}

dialog[open]:modal {
  opacity: 1;
  transform: scale(1) translateY(0);
}

@starting-style {
  dialog[open]:modal {
    opacity: 0;
    transform: scale(0.97) translateY(6px);
  }
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: oklch(10% 0.015 258 / 0.56);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.dialog-title-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.dialog-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 650;
}

.dialog-body {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 24px;
  padding: 24px;
  overflow-y: auto;
}

.inspector-stage-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspector-stage {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-stage);
}

.inspector-stage svg {
  width: 100%;
  height: 100%;
}

.inspector-stage svg g {
  transition: opacity 160ms var(--ease-out), filter 160ms var(--ease-out);
}

.inspector-stage.is-isolating svg g[id] {
  opacity: 0.2;
}

.inspector-stage.is-isolating svg g[data-highlighted="true"] {
  opacity: 1;
  filter: drop-shadow(0 0 10px var(--sf-accent));
}

.inspector-stage.is-animating svg g[id]:nth-child(odd) {
  animation: sf-demo-pulse 1.8s var(--ease-out) infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}

.inspector-stage.is-animating svg g[id]:nth-child(even) {
  animation: sf-demo-float 2.2s var(--ease-out) infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes sf-demo-pulse {
  from {
    opacity: 0.78;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1.02);
  }
}

@keyframes sf-demo-float {
  from {
    transform: translateY(-2px);
  }
  to {
    transform: translateY(3px);
  }
}

.inspector-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inspector-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.inspector-info-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.inspector-desc {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.inspector-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.link-btn {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.parts-list,
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.part-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.part-btn:hover,
.part-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

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

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}
.footer-links a:hover {
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--ink);
  color: var(--canvas);
  font-size: 0.8125rem;
  font-weight: 550;
  box-shadow: var(--shadow-modal);
}

@media (max-width: 820px) {
  .hero-inner,
  .dialog-body {
    grid-template-columns: 1fr;
  }
  .hero {
    padding: 32px 0 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
