/* ============================================================== */
/*  Shader Library — design system                                  */
/*  Dark only. Near-black canvas; the colour comes from the live    */
/*  shaders themselves. Chrome stays near-monochrome. One display   */
/*  face (Space Grotesk) + one mono (Space Mono), both self-hosted. */
/* ============================================================== */

/* ---------- 0. Self-hosted fonts (no CDN) --------------------- */
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/static/fonts/space-grotesk-400.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/static/fonts/space-grotesk-500.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 700;
  font-display: swap; src: url("/static/fonts/space-grotesk-700.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/static/fonts/space-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 700;
  font-display: swap; src: url("/static/fonts/space-mono-700.woff2") format("woff2");
}

/* ---------- 1. Tokens ----------------------------------------- */
:root {
  /* surface — near-black, faintly cool */
  --bg-0: #05070b;
  --bg-1: #0a0d14;
  --bg-2: #0f131c;
  --bg-3: #161b27;
  --bg-4: #1e2534;
  --line-1: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.10);
  --line-3: rgba(255, 255, 255, 0.18);

  /* ink */
  --ink-1: #f4f6fb;
  --ink-2: #c3cad9;
  --ink-3: #8b93a7;
  --ink-4: #586074;
  --ink-5: #383f4f;

  /* accent — a single restrained cyan for focus/links */
  --acc:        #22d3ee;
  --acc-soft:   rgba(34, 211, 238, 0.12);
  --acc-glow:   rgba(34, 211, 238, 0.42);
  --acc-edge:   rgba(34, 211, 238, 0.50);

  /* RGB — honest signal, not decoration */
  --r: #ff3a55;
  --g: #33e860;
  --b: #3380ff;

  /* status */
  --warn: #ffb547;
  --bad:  #ff4d6d;
  --ok:   #34e88a;

  /* type */
  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* 8-pt spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;

  /* radius */
  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-4: 20px; --r-pill: 999px;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -16px rgba(0,0,0,0.7);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.05) inset, 0 24px 70px -30px rgba(0,0,0,0.8);
  --shadow-glow: 0 0 0 1px var(--acc-edge), 0 0 26px -4px var(--acc-glow);

  --maxw: 1280px;
  --topbar-h: 60px;
}


/* ---------- 2. Reset ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100%;
  overflow-x: hidden;   /* belt-and-braces: nothing may scroll the page sideways */
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--acc); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--acc-soft); color: var(--ink-1); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }


/* ---------- 3. Top bar ---------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-5);
  padding: 0 var(--s-5);
  background: rgba(5, 7, 11, 0.72);
  border-bottom: 1px solid var(--line-1);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
}
.brand { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-1); }
.brand:hover { color: var(--ink-1); }
.brand-mark { display: inline-flex; gap: 3px; align-items: center; }
.brand-mark .dot {
  width: 6px; height: 17px; border-radius: 2px;
  box-shadow: 0 0 12px currentColor;
  transition: transform .25s cubic-bezier(.16,1,.3,1);
}
.brand-mark .dot-r { background: var(--r); color: rgba(255, 58, 85, 0.5); }
.brand-mark .dot-g { background: var(--g); color: rgba(51, 232, 96, 0.5); }
.brand-mark .dot-b { background: var(--b); color: rgba(51, 128, 255, 0.5); }
.brand:hover .dot-r { transform: translateY(-2px); }
.brand:hover .dot-b { transform: translateY(2px); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 500; letter-spacing: -0.01em; }
.brand-sub  { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); margin-top: 2px; letter-spacing: 0.02em; }

.topbar-nav { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }
.nav-link {
  font-family: var(--font-mono);
  font-size: 12.5px; color: var(--ink-3);
  padding: 6px 12px; border-radius: var(--r-1);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--ink-1); background: var(--bg-2); }
.nav-link.is-active { color: var(--ink-1); background: var(--bg-2); }


/* ---------- 4. Views ------------------------------------------ */
.view { display: none; }
.view.is-active { display: block; }


/* ---------- 5. Hero — live shader full-bleed ------------------ */
.hero {
  position: relative;
  min-height: min(88vh, 760px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s-9) var(--s-5) var(--s-8);
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--line-1);
}
.hero-stage { position: absolute; inset: 0; z-index: -1; }
.hero-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  min-width: 0;
  /* the shader is the wallpaper — let it bleed and bloom */
  filter: saturate(128%) brightness(1.03) contrast(1.04);
}
/* Legibility scrim: darkest at the centre where the type sits, so the
   shader still reads as light at the edges. */
.hero-scrim {
  position: absolute; inset: 0;
  background:
    radial-gradient(100% 80% at 50% 45%, rgba(5,7,11,0.7) 0%, rgba(5,7,11,0.34) 42%, rgba(5,7,11,0.06) 74%, transparent 100%),
    linear-gradient(180deg, rgba(5,7,11,0.5) 0%, transparent 20%, transparent 56%, var(--bg-0) 100%);
}
.hero-grain {
  position: absolute; inset: 0; opacity: 0.5; mix-blend-mode: overlay;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px);
}
/* Cursor-reactive glow — a soft light that trails the pointer. */
.hero-cursor {
  position: absolute; width: 460px; height: 460px;
  left: 0; top: 0; margin: -230px 0 0 -230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120,220,255,0.10), transparent 62%);
  transform: translate(-9999px, -9999px);
  pointer-events: none;
  transition: opacity .3s;
  opacity: 0;
}
.hero.is-pointer .hero-cursor { opacity: 1; }

.hero-inner { position: relative; max-width: 760px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-2);
  margin-bottom: var(--s-5);
}
.eyebrow-bar {
  display: inline-block; width: 26px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc));
}
.hero .eyebrow { justify-content: center; }

.hero-title {
  font-size: clamp(38px, 6.4vw, 78px);
  line-height: 1.0;
  letter-spacing: -0.035em;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 2px 40px rgba(0,0,0,0.5);
  margin-bottom: var(--s-5);
}
.hero-sub {
  color: var(--ink-2);
  max-width: 46ch;
  margin: 0 auto var(--s-6);
  font-size: clamp(15px, 1.6vw, 19px);
  line-height: 1.55;
}
.hero-actions {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-4);
}

/* Scroll-down affordance */
.hero-jump {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  padding: 6px 4px;
}
.hero-jump:hover { color: var(--ink-1); }


/* ---------- 5b. Sound control --------------------------------- */
.sound { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sound-btn {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-mono);
  font-size: 13px; letter-spacing: 0.02em;
  color: var(--ink-1);
  padding: 11px 20px 11px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-3);
  background: rgba(10, 13, 20, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: border-color .2s, background .2s, box-shadow .25s, color .2s;
}
.sound-btn:hover { border-color: var(--acc-edge); color: #fff; box-shadow: 0 0 26px -6px var(--acc-glow); }
.sound-btn[aria-pressed="true"] {
  border-color: var(--acc-edge);
  background: rgba(34, 211, 238, 0.14);
  color: #fff;
  box-shadow: 0 0 30px -8px var(--acc-glow);
}
/* Equaliser glyph — four bars. Flat when off, dancing when on. */
.sound-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 15px; }
.sound-eq i {
  width: 3px; height: 4px; border-radius: 2px;
  background: var(--ink-3);
  transition: background .2s;
}
.sound-btn[aria-pressed="true"] .sound-eq i { background: var(--acc); }
.sound-btn[aria-pressed="true"] .sound-eq i { animation: eq 0.9s ease-in-out infinite; }
.sound-btn[aria-pressed="true"] .sound-eq i:nth-child(1) { animation-delay: -0.2s; }
.sound-btn[aria-pressed="true"] .sound-eq i:nth-child(2) { animation-delay: -0.5s; }
.sound-btn[aria-pressed="true"] .sound-eq i:nth-child(3) { animation-delay: -0.1s; }
.sound-btn[aria-pressed="true"] .sound-eq i:nth-child(4) { animation-delay: -0.7s; }
@keyframes eq { 0%,100% { height: 4px; } 50% { height: 15px; } }
@media (prefers-reduced-motion: reduce) {
  .sound-btn[aria-pressed="true"] .sound-eq i { animation: none; height: 10px; }
}
.sound-credit {
  font-family: var(--font-mono);
  font-size: 10.5px; line-height: 1.5;
  color: var(--ink-4);
  max-width: 52ch;
}
.sound-credit a { color: var(--ink-3); text-decoration: underline; text-underline-offset: 2px; }
.sound-credit a:hover { color: var(--acc); }


/* ---------- 6. Library: designed search + grid ---------------- */
.library {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--s-8) var(--s-5) var(--s-9);
}
.library-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-4) var(--s-5);
  margin-bottom: var(--s-6);
}
.section-title {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink-1);
  white-space: nowrap;
}
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 16px;
  width: 17px; height: 17px; color: var(--ink-3);
  pointer-events: none;
}
.search {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  padding: 13px 56px 13px 46px;
  color: var(--ink-1);
  font-size: 15px;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.search::placeholder { color: var(--ink-4); }
.search::-webkit-search-cancel-button { -webkit-appearance: none; }
.search:hover { border-color: var(--line-3); }
.search:focus {
  outline: none; border-color: var(--acc-edge);
  background: var(--bg-2);
  box-shadow: 0 0 0 4px var(--acc-soft), 0 0 30px -10px var(--acc-glow);
}
.search-kbd {
  position: absolute; right: 14px;
  font-family: var(--font-mono);
  font-size: 11px; color: var(--ink-3);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 4px; padding: 2px 7px;
  pointer-events: none;
}
.result-summary {
  grid-column: 1 / -1;
  min-height: 16px;
  font-family: var(--font-mono);
  font-size: 11.5px; color: var(--ink-4);
}
.result-summary b { color: var(--ink-2); font-weight: 400; }

@media (max-width: 700px) {
  .library-head { grid-template-columns: 1fr; }
}


/* ---------- 7. Card grid -------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
}
@media (max-width: 1180px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px)  { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px)  { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.16,1,.3,1), border-color .2s, box-shadow .25s;
  outline: none;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--acc-edge);
  box-shadow: var(--shadow-glow);
}
.card:hover .card-glow, .card:focus-visible .card-glow { opacity: 1; }
.card:hover .card-preview { transform: scale(1.04); }
.card-glow {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(420px 200px at 50% 0%, var(--acc-soft), transparent 60%);
  opacity: 0;
  transition: opacity .35s;
}
.card-frame {
  position: relative;
  background:
    linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.4) 100%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.012) 0 12px, transparent 12px 24px),
    #04060a;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card-preview {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 8px;
  filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.16));
  transition: transform .35s cubic-bezier(.16,1,.3,1), opacity .12s linear;
  position: absolute; inset: 0;
  z-index: 1;
}
.card-preview--live {
  position: absolute; inset: 0;
  width: calc(100% - 16px); height: calc(100% - 16px);
  margin: 8px;
  padding: 0;
  border-radius: 4px;
  opacity: 0;
  z-index: 1;
  transition: opacity .12s linear;
  pointer-events: none;
  filter: drop-shadow(0 0 18px rgba(34, 211, 238, 0.28));
  display: block;
}
.card.is-hover .card-preview--live { opacity: 1; }
.card.is-hover .card-preview--static { opacity: 0; }
.card.is-hover .card-glow { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .card-preview--live { display: none !important; }
  .card { transition: none; }
  .card:hover, .card:focus-visible { transform: none; }
}
.card-preview-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  z-index: 0;
}
.card-preview.is-loaded + .card-preview-skeleton { display: none; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .card-preview-skeleton { animation: none; } }

.card-badges {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; gap: 6px; z-index: 2;
}
.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: rgba(5, 7, 11, 0.72);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.badge-cat { color: var(--acc); border-color: var(--acc-edge); background: rgba(34, 211, 238, 0.12); }
.badge-render { color: var(--warn); border-color: rgba(255, 181, 71, 0.4); background: rgba(255, 181, 71, 0.1); margin-left: auto; }
.badge-render.is-error { color: var(--bad); border-color: rgba(255, 77, 109, 0.4); background: rgba(255, 77, 109, 0.1); }
.badge-compile { color: var(--bad); border-color: rgba(255, 77, 109, 0.4); background: rgba(255, 77, 109, 0.12); margin-left: auto; }

.card-body { padding: var(--s-4); }
.card-name {
  font-family: var(--font-mono);
  font-size: 13.5px; font-weight: 400;
  color: var(--ink-1);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-desc {
  font-size: 13px; color: var(--ink-3); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.grid-empty { text-align: center; padding: var(--s-9) var(--s-4); color: var(--ink-3); }
.grid-empty-title { font-size: 18px; color: var(--ink-1); margin-bottom: 6px; }
.grid-empty-sub { font-size: 14px; }


/* ---------- 7b. Library empty state (zero shaders) ------------- */
.library-empty {
  position: relative; max-width: 640px;
  margin: var(--s-7) auto var(--s-9);
  padding: var(--s-7) var(--s-6);
  text-align: center;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.04) 0%, transparent 60%), var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.library-empty-orb { position: relative; width: 140px; height: 140px; margin: 0 auto var(--s-5); }
.library-empty-orb .orb {
  position: absolute; width: 90px; height: 90px; border-radius: 50%;
  filter: blur(18px); mix-blend-mode: screen; opacity: 0.45;
  animation: orbDrift 12s ease-in-out infinite alternate;
}
.library-empty-orb .orb-r { left: 10%; top: 25%;  background: var(--r); }
.library-empty-orb .orb-g { right: 8%; bottom: 22%; background: var(--g); animation-delay: -4s; }
.library-empty-orb .orb-b { width: 100px; height: 100px; left: 30%; bottom: 0%; background: var(--b); animation-delay: -8s; }
.library-empty-orb .orb-ring {
  position: absolute; inset: 28px; border-radius: 50%;
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03), 0 0 40px rgba(34, 211, 238, 0.10);
  animation: orbSpin 18s linear infinite;
}
@keyframes orbDrift {
  0% { transform: translate(0,0) scale(1); }
  50% { transform: translate(20px,-12px) scale(1.06); }
  100% { transform: translate(-10px,8px) scale(0.97); }
}
@keyframes orbSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .library-empty-orb .orb, .library-empty-orb .orb-ring { animation: none; }
}
.library-empty-eyebrow {
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.22em;
  color: var(--ink-3); margin-bottom: var(--s-3);
}
.library-empty-title { font-size: clamp(28px, 3.4vw, 36px); font-weight: 500; letter-spacing: -0.02em; margin-bottom: var(--s-3); }
.library-empty-sub { color: var(--ink-2); max-width: 50ch; margin: 0 auto var(--s-5); font-size: 15px; line-height: 1.6; }
.library-empty-sub code, .library-empty-pattern code {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--bg-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-1);
}
.library-empty-sub code { color: var(--ink-1); }
.library-empty-pattern {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-3);
  background: var(--bg-2); border: 1px solid var(--line-1); border-radius: var(--r-1); padding: 8px 14px;
}
.library-empty-pattern code { color: var(--acc); background: none; border: 0; padding: 0; }
.library-empty-pattern-k { text-transform: uppercase; letter-spacing: 0.16em; font-size: 10.5px; color: var(--ink-4); }
.library-empty-pattern-hint code { color: var(--ink-2); }


/* ---------- 8. Footnote --------------------------------------- */
.footnote {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-9);
  font-size: 13px; color: var(--ink-3);
  border-top: 1px solid var(--line-1);
}
.footnote p { max-width: 78ch; line-height: 1.7; }
.footnote code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }
.footnote a { color: var(--acc); }


/* ---------- 9. Footer ----------------------------------------- */
.footer {
  border-top: 1px solid var(--line-1);
  padding: var(--s-5);
  background: rgba(5, 7, 11, 0.6);
  font-family: var(--font-mono);
  font-size: 11px; color: var(--ink-4);
}
.footer-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-4);
  flex-wrap: wrap;
}
.footer-credit { color: var(--ink-5); max-width: 60ch; line-height: 1.5; }
.footer-credit a { color: var(--ink-4); text-decoration: underline; text-underline-offset: 2px; }
.footer-credit a:hover { color: var(--acc); }
.footer-link { color: var(--ink-3); }
.footer-link:hover { color: var(--acc); }


/* ============================================================ */
/*  DETAIL VIEW                                                   */
/* ============================================================ */
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px; color: var(--ink-3);
  padding: 8px 12px; border-radius: var(--r-1);
  margin: var(--s-5) 0 0 var(--s-5);
  transition: color .15s, background .15s;
}
.back-link svg { width: 16px; height: 16px; }
.back-link:hover { color: var(--ink-1); background: var(--bg-2); }

.detail { max-width: var(--maxw); margin: 0 auto; padding: var(--s-4) var(--s-5) var(--s-9); }
.detail-header { margin-bottom: var(--s-5); }
.detail-title {
  font-size: clamp(30px, 3.8vw, 46px);
  font-weight: 500; letter-spacing: -0.03em;
  margin-bottom: var(--s-2);
  line-height: 1.02;
}
.detail-desc { color: var(--ink-2); max-width: 65ch; font-size: 16px; line-height: 1.6; }
.detail-meta { margin-top: var(--s-3); display: flex; flex-wrap: wrap; gap: var(--s-2); }
.meta-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-1); border: 1px solid var(--line-1);
  border-radius: var(--r-pill); padding: 5px 11px; color: var(--ink-2);
}
.meta-pill-k { color: var(--ink-4); }
.meta-pill-v { color: var(--ink-1); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s-4); }
@media (max-width: 1080px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  margin-bottom: var(--s-4);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.panel-head {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-2);
}
.panel-title { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-1); }
.panel-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-2);
  padding: 6px 12px; border-radius: var(--r-1); cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn:hover { color: var(--ink-1); border-color: var(--line-3); background: var(--bg-3); }
.btn[aria-pressed="true"] { color: var(--ok); border-color: rgba(52, 232, 138, 0.45); }
.btn-primary { color: var(--acc); border-color: var(--acc-edge); background: var(--acc-soft); }
.btn-primary:hover { color: #04121a; background: var(--acc); border-color: var(--acc); box-shadow: 0 0 16px -4px var(--acc-glow); }
.btn-ghost { background: transparent; }

.inline { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.inline input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 4px; background: var(--bg-3);
  border-radius: 99px; outline: none; cursor: pointer;
}
.inline input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; background: var(--acc); border-radius: 50%;
  box-shadow: 0 0 8px var(--acc-glow);
}
.inline input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; background: var(--acc); border-radius: 50%; }
.inline-val { color: var(--ink-1); min-width: 38px; text-align: right; }

.select, .num {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--ink-1);
  border-radius: var(--r-1); padding: 5px 8px; outline: none;
}
.select:hover, .num:hover { border-color: var(--line-3); }
.select:focus, .num:focus { border-color: var(--acc); }
.num { width: 56px; text-align: right; }


/* ----- canvas stack ----- */
.detail-canvas-stack { display: flex; flex-direction: column; }
.detail-canvas-stack, .detail-side { min-width: 0; }
.canvas-host {
  position: relative; background: #000;
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; overflow: hidden;
}
.canvas-gl { width: 100%; height: 100%; display: block; min-width: 0; max-width: 100%; }
.canvas-error {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--s-5); background: var(--bg-1);
}
.canvas-error-title { font-family: var(--font-mono); color: var(--bad); font-size: 14px; margin-bottom: 8px; }
.canvas-error-sub { color: var(--ink-3); max-width: 50ch; font-size: 13px; }

.led-host { display: flex; align-items: center; justify-content: center; padding: var(--s-3) 0; background: var(--bg-0); }
.canvas-led { display: block; background: #05060a; border-radius: var(--r-2); }
.canvas-spec { width: 100%; height: 64px; display: block; background: var(--bg-0); }


/* ----- source panel ----- */
.panel-source .panel-head { gap: var(--s-2); }
.source-pre {
  margin: 0; max-height: 720px; overflow: auto;
  padding: 16px 18px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: var(--ink-1); background: var(--bg-0);
}
.source-pre code { font-family: inherit; }
.source-pre::-webkit-scrollbar { width: 10px; height: 10px; }
.source-pre::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 99px; }
.source-pre::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

.tok-kw  { color: #c084fc; }
.tok-ty  { color: #38bdf8; }
.tok-bi  { color: #fbbf24; }
.tok-num { color: #f0abfc; }
.tok-co  { color: #6b7280; font-style: italic; }
.tok-st  { color: #a3e635; }
.tok-mac { color: #fb923c; }
.tok-pn  { color: #94a3b8; }


/* ----- install panel (detail) + generic accordions ----- */
.panel-install details > summary {
  list-style: none; cursor: pointer;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-1);
  transition: background .15s;
}
.panel-install details > summary::-webkit-details-marker { display: none; }
.panel-install details > summary::after { content: "+"; margin-left: auto; color: var(--ink-4); font-size: 18px; line-height: 1; transition: transform .2s; }
.panel-install details[open] > summary::after { transform: rotate(45deg); }
.panel-install details > summary:hover { background: var(--bg-2); }
.install-title { text-transform: uppercase; letter-spacing: 0.14em; }
.install-meta  { color: var(--ink-4); font-size: 11px; }
.install-steps { margin: 0; padding: 0 16px 16px 36px; color: var(--ink-2); font-size: 14px; line-height: 1.65; display: flex; flex-direction: column; gap: 10px; }
.install-steps b { color: var(--ink-1); font-weight: 500; }
.install-steps code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-1); color: var(--ink-1); }
.install-steps a { color: var(--acc); }
.install-foot { padding: 0 16px 16px; color: var(--ink-4); font-size: 12.5px; line-height: 1.55; }


/* ----- 404 ----- */
.detail-notfound { max-width: 640px; margin: var(--s-9) auto; padding: var(--s-7) var(--s-5); text-align: center; }
.detail-notfound-eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.3em; color: var(--bad); margin-bottom: var(--s-3); }
.detail-notfound-title { font-size: 28px; font-weight: 500; letter-spacing: -0.02em; margin-bottom: var(--s-3); }
.detail-notfound-title code { font-family: var(--font-mono); background: var(--bg-2); padding: 2px 10px; border-radius: 6px; color: var(--acc); font-size: 22px; }
.detail-notfound-sub { color: var(--ink-3); margin-bottom: var(--s-5); }


/* ============================================================ */
/*  Prompt block (detail view)                                    */
/* ============================================================ */
.prompt-block { max-width: var(--maxw); margin: 0 auto var(--s-4); padding: 0 var(--s-5); }
.prompt-block-k { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 8px; }
.prompt-block-q {
  position: relative; background: var(--bg-1);
  border: 1px solid var(--line-2); border-left: 2px solid var(--acc-edge);
  border-radius: var(--r-2); padding: var(--s-4) var(--s-5);
}
.prompt-block-q p { color: var(--ink-2); font-size: 15px; line-height: 1.65; max-width: 90ch; overflow-wrap: anywhere; white-space: pre-wrap; }
.prompt-block-q p::before { content: '\201C'; }
.prompt-block-q p::after  { content: '\201D'; }


/* ============================================================ */
/*  Live controls — iParam0..7 (detail view)                      */
/* ============================================================ */
.params-list { display: flex; flex-direction: column; }
.param-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(120px, 1.4fr) 48px;
  align-items: center; gap: var(--s-3);
  padding: 9px var(--s-4);
  border-bottom: 1px solid var(--line-1);
}
.param-row:last-child { border-bottom: 0; }
.param-row:hover { background: rgba(255, 255, 255, 0.015); }
.param-name { font-size: 13px; color: var(--ink-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.param-slot { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); background: rgba(255, 255, 255, 0.04); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.param-range { width: 100%; }
.param-val { font-family: var(--font-mono); font-size: 11.5px; color: var(--acc); text-align: right; }
.param-row input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--bg-3); border-radius: 99px; outline: none; cursor: pointer;
}
.param-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 13px; height: 13px; background: var(--acc); border-radius: 50%; box-shadow: 0 0 8px var(--acc-glow); }
.param-row input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border: 0; background: var(--acc); border-radius: 50%; }
@media (max-width: 620px) {
  .param-row { grid-template-columns: minmax(0, 1fr) 48px; row-gap: 6px; }
  .param-slot { display: none; }
  .param-range { grid-column: 1 / -1; }
}


/* ============================================================ */
/*  Scrollbar                                                     */
/* ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 99px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }


/* ============================================================ */
/*  Engine / plugin compatibility (detail only)                   */
/* ============================================================ */
.badge-engine.is-effects { color: var(--ok); border-color: rgba(52, 232, 138, 0.35); background: rgba(52, 232, 138, 0.10); }
.badge-engine.is-ai { color: var(--warn); border-color: rgba(255, 181, 71, 0.35); background: rgba(255, 181, 71, 0.10); }

.engine-note {
  max-width: var(--maxw); margin: 0 auto var(--s-5); padding: var(--s-4);
  display: flex; gap: var(--s-3); align-items: flex-start;
  border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--bg-1);
}
.engine-note-icon { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 6px; border-radius: 50%; background: var(--ink-4); }
.engine-note.is-effects { border-color: rgba(52, 232, 138, 0.30); }
.engine-note.is-effects .engine-note-icon { background: var(--ok); box-shadow: 0 0 10px rgba(52, 232, 138, 0.6); }
.engine-note.is-ai { border-color: rgba(255, 181, 71, 0.30); }
.engine-note.is-ai .engine-note-icon { background: var(--warn); box-shadow: 0 0 10px rgba(255, 181, 71, 0.6); }
.engine-note-body { min-width: 0; }
.engine-note-head { font-size: 14.5px; color: var(--ink-1); font-weight: 500; line-height: 1.45; }
.engine-note-why { margin-top: 4px; font-size: 13.5px; color: var(--ink-3); line-height: 1.6; max-width: 78ch; }


/* ============================================================ */
/*  Downloads view                                                */
/* ============================================================ */
.dl-head { max-width: var(--maxw); margin: 0 auto; padding: var(--s-8) var(--s-5) var(--s-5); }
.dl-title { font-size: clamp(30px, 4.6vw, 48px); line-height: 1.04; letter-spacing: -0.03em; color: var(--ink-1); margin: var(--s-3) 0 var(--s-4); font-weight: 500; }
.dl-sub { max-width: 70ch; font-size: 16px; line-height: 1.65; color: var(--ink-2); }
.dl-sub code { font-family: var(--font-mono); font-size: 13px; color: var(--ink-1); background: var(--bg-2); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.dl-sub a { color: var(--acc); }
.dl-sub b { color: var(--ink-1); font-weight: 500; }
.dl-meta { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-5); }

/* The host requirement — loud, above the buttons, but calm by default:
   one clear sentence, with the deep detail folded into an accordion. */
.dl-warn {
  max-width: var(--maxw); margin: 0 auto var(--s-6); padding: var(--s-5);
  border: 1px solid rgba(255, 181, 71, 0.42); border-left: 3px solid var(--warn);
  border-radius: var(--r-2); background: rgba(255, 181, 71, 0.06);
}
.dl-warn-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.dl-warn-icon {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--warn); color: #1a1204;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
}
.dl-warn-title { font-size: 18px; line-height: 1.3; color: var(--ink-1); font-weight: 500; letter-spacing: -0.01em; min-width: 0; }
.dl-warn-lead { max-width: 80ch; font-size: 14.5px; line-height: 1.7; color: var(--ink-2); margin-bottom: var(--s-4); }
.dl-warn-lead b { color: var(--ink-1); font-weight: 500; }
.dl-warn-lead em { color: var(--ink-1); font-style: normal; text-decoration: underline; text-underline-offset: 3px; }

/* Generic accordion (native details/summary) */
.dl-acc { border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--bg-1); overflow: hidden; }
.dl-acc + .dl-acc { margin-top: var(--s-3); }
.dl-acc > summary {
  list-style: none; cursor: pointer;
  padding: 13px 16px;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-1);
  transition: background .15s;
}
.dl-acc > summary::-webkit-details-marker { display: none; }
.dl-acc > summary span { flex: 1; min-width: 0; }
.dl-acc > summary::after { content: "+"; color: var(--ink-4); font-size: 18px; line-height: 1; transition: transform .2s; }
.dl-acc[open] > summary::after { transform: rotate(45deg); }
.dl-acc > summary:hover { background: var(--bg-2); }
.dl-acc-body { padding: var(--s-4) var(--s-5) var(--s-5); border-top: 1px solid var(--line-1); }
.dl-acc-body p { max-width: 80ch; font-size: 14px; line-height: 1.7; color: var(--ink-2); margin-bottom: var(--s-3); }
.dl-acc-body p:last-child { margin-bottom: 0; }
.dl-acc-body b { color: var(--ink-1); font-weight: 500; }
.dl-acc-body em { color: var(--ink-1); font-style: normal; text-decoration: underline; text-underline-offset: 3px; }
.dl-acc-body code { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-1); background: var(--bg-2); padding: 1px 6px; border-radius: 4px; overflow-wrap: anywhere; word-break: break-all; }
.dl-acc-body a { color: var(--acc); overflow-wrap: anywhere; }
.dl-acc-body ul { list-style: none; padding: 0; margin: 0 0 var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.dl-acc-body li { position: relative; padding-left: var(--s-4); font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.dl-acc-body li::before { content: '›'; position: absolute; left: 2px; color: var(--acc); }

/* structured key/value list inside accordions */
.dl-fieldlist { display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); gap: 8px var(--s-4); margin-bottom: var(--s-3); font-size: 13.5px; min-width: 0; }
.dl-fieldkey { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-4); padding-top: 2px; overflow-wrap: anywhere; }
.dl-fieldval { min-width: 0; color: var(--ink-2); line-height: 1.6; overflow-wrap: anywhere; }
.dl-fieldval code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-1); background: var(--bg-2); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
@media (max-width: 620px) {
  .dl-fieldlist { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl-fieldval { margin-bottom: var(--s-2); }
}

/* Asset rows. */
.dl-assets-section { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s-5) var(--s-6); }
.dl-section-title { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-4); margin-bottom: var(--s-4); }
.dl-assets { display: flex; flex-direction: column; gap: var(--s-3); }
.dl-asset {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: var(--s-3) var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--line-2); border-radius: var(--r-2);
  background: var(--bg-1); box-shadow: var(--shadow-1); min-width: 0;
}
.dl-asset-main { min-width: 0; }
.dl-asset-label { font-size: 15px; color: var(--ink-1); font-weight: 500; overflow-wrap: anywhere; }
.dl-asset-sub { margin-top: 3px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-4); overflow-wrap: anywhere; }
.dl-asset-btn { white-space: nowrap; }
.dl-asset-verify { grid-column: 1 / -1; margin-top: 2px; }
.dl-asset-verify > summary {
  list-style: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-4);
  padding: 6px 0; display: inline-flex; align-items: center; gap: 6px;
}
.dl-asset-verify > summary::-webkit-details-marker { display: none; }
.dl-asset-verify > summary:hover { color: var(--ink-2); }
.dl-asset-verify > summary::before { content: '+'; color: var(--ink-4); }
.dl-asset-verify[open] > summary::before { content: '–'; }
.dl-hash {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding-top: var(--s-3); border-top: 1px solid var(--line-1); min-width: 0;
}
.dl-hash-k { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-4); flex: 0 0 auto; }
.dl-hash-v {
  flex: 1 1 200px; min-width: 0;
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5;
  color: var(--ink-2); background: var(--bg-0);
  border: 1px solid var(--line-1); border-radius: var(--r-1); padding: 6px 8px;
  word-break: break-all; overflow-wrap: anywhere; user-select: all;
}
.dl-copy { flex: 0 0 auto; }
@media (max-width: 560px) {
  .dl-asset { grid-template-columns: minmax(0, 1fr); }
  .dl-asset-btn { justify-self: stretch; text-align: center; }
}

.dl-empty, .dl-error { font-size: 14px; color: var(--ink-3); line-height: 1.7; padding: var(--s-4); border: 1px dashed var(--line-2); border-radius: var(--r-2); }
.dl-error { color: var(--bad); border-color: rgba(255, 77, 109, 0.35); }

.dl-windows { margin-top: var(--s-4); padding: var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--bg-1); }
.dl-windows-title { font-size: 15px; color: var(--ink-1); font-weight: 500; }
.dl-windows-sub { margin-top: 4px; max-width: 74ch; font-size: 13.5px; color: var(--ink-3); line-height: 1.65; }

.dl-extras { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s-5) var(--s-9); }
.dl-extras .dl-acc + .dl-acc { margin-top: var(--s-3); }

@media (max-width: 700px) {
  .dl-head { padding: var(--s-6) var(--s-4) var(--s-4); }
  .dl-warn { padding: var(--s-4); }
  .dl-assets-section, .dl-extras { padding-left: var(--s-4); padding-right: var(--s-4); }
}


/* ============================================================ */
/*  Small-screen polish                                           */
/* ============================================================ */
@media (max-width: 700px) {
  .topbar { gap: var(--s-3); padding: 0 var(--s-4); }
  .nav-link--ext { display: none; }
  .nav-link { padding: 6px 10px; }
  .brand-sub { display: none; }
  .hero { min-height: 78vh; padding: var(--s-8) var(--s-4) var(--s-7); }
  .library { padding: var(--s-6) var(--s-4) var(--s-8); }
  .panel-head { padding: 10px 12px; gap: 8px; }
  .inline input[type="range"] { width: 70px; }
  .source-pre { font-size: 11.5px; }
  .prompt-block { padding: 0 var(--s-4); }
  .prompt-block-q { padding: var(--s-3) var(--s-4); }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
}
