/* =========================================================
   Code lab — standalone craft demos
   ========================================================= */
:root {
  --void: #03050c;
  --ink: #070b16;
  --panel: #0c1224;
  --line: rgba(148, 163, 184, 0.14);
  --text: #f4f7ff;
  --muted: #9aa8c7;
  --cyan: #4da3ff;
  --blue: #2563ff;
  --violet: #818cf8;
  --gold: #f5d76e;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mood: #2563ff;
  --mood-2: #4da3ff;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  /* Stop sideways page scroll on mobile (canvas/pre/logo were expanding the document) */
  overflow-x: hidden;
  max-width: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--void);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden;
  /* Prefer clip when supported so sticky pin stages still work */
  overflow-x: clip;
}
img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}
/* Intrinsic canvas width attrs (640/1200) must never force document wider than the viewport */
canvas {
  max-width: 100% !important;
  box-sizing: border-box;
}
.bg-particles {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}
main,
.lab-section,
.lab-hero,
.demo-card,
.lab-cta,
.type-board,
.motion-grid,
.ui-row,
.canvas-grid,
.widget-grid,
.three-row,
.python-grid,
.python-live,
.code-grid,
.sticky-stack,
.bento-lab {
  max-width: 100%;
  min-width: 0;
}
.demo-card,
.canvas-card,
.glass-card,
.scene,
.stack,
.orbit,
.h-scroll,
.code-panel,
.python-pre,
.mono-card {
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}
.scene,
.stack,
.orbit {
  overflow: hidden;
}
a { color: var(--cyan); text-decoration: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.skip {
  position: absolute; left: 1rem; top: -100px; z-index: 99;
  background: var(--blue); color: #fff; padding: .6rem 1rem; border-radius: 999px;
}
.skip:focus { top: 1rem; }

.lab-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35;
  transition: background .6s var(--ease);
}
.orb-a {
  width: 42vw; height: 42vw; top: -10%; left: -8%;
  background: color-mix(in srgb, var(--mood) 70%, transparent);
}
.orb-b {
  width: 36vw; height: 36vw; bottom: 5%; right: -10%;
  background: color-mix(in srgb, var(--mood-2) 55%, transparent);
}
.grid-fade {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(148,163,184,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 70%);
}

.lab-nav {
  position: sticky; top: 0; z-index: 100; /* above snippet drawer so menu stays visible */
  display: flex; flex-wrap: wrap; gap: .55rem 1rem; align-items: center;
  padding: 0.55rem 1.15rem 0.55rem 1rem;
  min-height: 6.25rem;
  background: rgba(3, 5, 12, 0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.lab-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  line-height: 0;
  margin-right: 0.35rem;
}
.lab-brand img {
  height: clamp(88px, 10.5vw, 120px);
  width: auto;
  max-width: min(480px, 52vw);
  object-fit: contain;
  object-position: left center;
  display: block;
}

/* Primary section links — clear white type, simple hover */
.lab-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.15rem;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}
.lab-links a {
  color: #e8eefc;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}
.lab-links a:hover,
.lab-links a:focus-visible {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
.lab-links a:active {
  background: rgba(77, 163, 255, 0.18);
  color: #dbeafe;
}

/* Actions — quieter secondary chips */
.lab-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5ff;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover,
.chip:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.chip-ghost {
  color: #c5d0e8;
  border-color: rgba(255, 255, 255, 0.1);
  background: transparent;
  font-weight: 600;
}
.chip-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.chip-hot {
  background: linear-gradient(135deg, #2563ff, #4da3ff);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 20px rgba(37, 99, 255, 0.28);
}
.chip-hot:hover {
  filter: brightness(1.06);
  color: #fff;
  background: linear-gradient(135deg, #2563ff, #4da3ff);
}

main { position: relative; z-index: 1; }

.lab-hero {
  max-width: 920px; margin: 0 auto; padding: 4.5rem 1.25rem 3rem;
}
.eyebrow {
  margin: 0 0 .75rem; font-size: .72rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase; color: var(--mood-2);
}
.hero-kicker {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.08;
}
.hero-kicker .line { display: block; }
.hero-kicker .accent {
  background: linear-gradient(90deg, #fff, var(--mood-2), var(--mood));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { margin: 1.25rem 0 0; max-width: 36rem; color: var(--muted); font-size: 1.1rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.5rem; }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; margin-top: 1.75rem;
  font-size: .8rem; color: var(--muted); font-weight: 600;
}
.hero-meta span::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--mood-2); margin-right: .45rem; vertical-align: middle;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .75rem 1.2rem; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 800; font-size: .92rem; cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--mood-2));
  color: #fff; box-shadow: 0 12px 40px color-mix(in srgb, var(--mood) 35%, transparent);
}
.btn-ghost {
  background: transparent; color: var(--text); border-color: var(--line);
}
.btn-soft {
  background: rgba(37,99,255,.12); color: #bfdbfe; border-color: rgba(96,165,250,.3);
}
.btn-sm { padding: .45rem .9rem; font-size: .8rem; }
.btn:hover { transform: translateY(-1px); }
.btn.magnetic span { display: inline-block; transition: transform .15s var(--ease); }

.lab-section {
  max-width: 1100px; margin: 0 auto; padding: 3.5rem 1.25rem 2rem;
  border-top: 1px solid var(--line);
}
.sec-head { max-width: 40rem; margin-bottom: 1.75rem; }
.sec-head h2 {
  margin: .35rem 0; font-size: clamp(1.75rem, 3.5vw, 2.4rem); letter-spacing: -.02em;
}
.sec-lead { margin: .5rem 0 0; color: var(--muted); }

/* Type */
.type-board {
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  background: rgba(12,18,36,.7);
}
.type-row {
  display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; align-items: center;
  padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.type-label {
  font-size: .72rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.type-display {
  margin: 0; font-family: var(--serif); font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.15;
}
.type-gradient {
  margin: 0; font-size: clamp(1.4rem, 3vw, 2.2rem); font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--mood-2) 40%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.type-fluid {
  margin: 0; font-size: clamp(1rem, 2.5vw + .5rem, 2rem); font-weight: 700;
}
.type-scale {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
}
.type-scale div {
  padding: 1rem; text-align: center; border-right: 1px solid var(--line);
}
.type-scale div:last-child { border-right: 0; }
.type-scale span {
  display: block; font-size: .68rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .35rem;
}
.mono { font-family: var(--mono); }
.split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem;
}
.split-card {
  padding: 1.25rem; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(12,18,36,.65);
}
.split-card h3 { margin: 0 0 .75rem; }
.tight { letter-spacing: -.03em; line-height: 1.25; font-weight: 700; color: #fff; }
.loose { color: var(--muted); line-height: 1.75; }
.mono-card { background: #050810; }
.typewriter {
  min-height: 3.5rem; color: #86efac; font-size: .92rem; line-height: 1.55;
}
.typewriter::after {
  content: "▍"; animation: blink 1s step-end infinite; color: var(--mood-2);
}
@keyframes blink { 50% { opacity: 0; } }

/* Motion */
.motion-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
}
.demo-card {
  padding: 1.25rem; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(12,18,36,.7);
}
.demo-card h3 { margin: 0 0 .85rem; font-size: 1.05rem; }
.demo-card p { margin: .75rem 0 0; color: var(--muted); font-size: .92rem; }

.pulse-stage {
  position: relative; height: 88px; display: grid; place-items: center;
}
.pulse-core {
  position: relative; z-index: 1; padding: .45rem 1rem; border-radius: 999px;
  background: rgba(52,211,153,.15); color: #6ee7b7; font-weight: 800; font-size: .85rem;
  border: 1px solid rgba(52,211,153,.4);
}
.pulse-ring {
  position: absolute; width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid rgba(52,211,153,.55);
  animation: pulseRing 1.8s var(--ease) infinite;
}
@keyframes pulseRing {
  0% { transform: scale(.7); opacity: .9; }
  100% { transform: scale(2.1); opacity: 0; }
}

.stagger {
  display: flex; gap: .45rem; height: 64px; align-items: flex-end;
}
.stagger i {
  flex: 1; height: 20%; border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--mood-2), var(--mood));
  transform-origin: bottom;
  animation: barUp .7s var(--ease) both;
}
.stagger i:nth-child(1) { animation-delay: 0s; height: 35%; }
.stagger i:nth-child(2) { animation-delay: .06s; height: 55%; }
.stagger i:nth-child(3) { animation-delay: .12s; height: 80%; }
.stagger i:nth-child(4) { animation-delay: .18s; height: 45%; }
.stagger i:nth-child(5) { animation-delay: .24s; height: 95%; }
.stagger i:nth-child(6) { animation-delay: .3s; height: 60%; }
@keyframes barUp {
  from { transform: scaleY(0); opacity: .3; }
  to { transform: scaleY(1); opacity: 1; }
}
.stagger.replay i { animation: none; }
.stagger.replay.run i { animation: barUp .7s var(--ease) both; }

.blob {
  width: 110px; height: 110px; margin: .5rem auto;
  background: linear-gradient(135deg, var(--mood), var(--gold));
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  animation: morph 8s ease-in-out infinite;
  filter: drop-shadow(0 12px 30px color-mix(in srgb, var(--mood) 40%, transparent));
}
@keyframes morph {
  0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
  33% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
  66% { border-radius: 50% 50% 40% 60% / 40% 70% 30% 60%; }
}

.counters {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center;
}
.counters strong {
  display: block; font-size: 1.75rem; font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--mood-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.counters span { font-size: .72rem; color: var(--muted); font-weight: 600; }

.marquee-lab {
  margin-top: 1.5rem; overflow: hidden; border: 1px solid var(--line);
  border-radius: 999px; background: rgba(0,0,0,.25);
}
.marquee-track {
  display: flex; gap: 2.5rem; width: max-content; padding: .85rem 0;
  animation: marquee 18s linear infinite; font-weight: 800;
  text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; color: var(--muted);
}
.marquee-track span { white-space: nowrap; }
@keyframes marquee {
  to { transform: translateX(-50%); }
}

/* UI */
.ui-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}
.glass-card {
  padding: 1.35rem; border-radius: 20px;
  background: rgba(17,26,48,.55); border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  transform-style: preserve-3d;
  transition: transform .15s ease, border-color .2s;
}
.glass-card h3 { margin: .25rem 0 .5rem; }
.glass-card p { color: var(--muted); font-size: .92rem; }
.tiny { font-size: .78rem !important; margin-top: .75rem !important; }
.btn-stack { display: flex; flex-direction: column; gap: .55rem; align-items: flex-start; }
.swatch-row { display: flex; gap: .45rem; margin-top: 1rem; }
.swatch-row i {
  width: 28px; height: 28px; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c) 45%, transparent);
}

.bento-lab {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-top: 1.25rem;
}
.bento-cell {
  position: relative; overflow: hidden;
  padding: 1.1rem; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(12,18,36,.75); min-height: 96px;
  transition: border-color .2s, transform .2s var(--ease);
}
.bento-cell.wide { grid-column: span 2; }
.bento-cell strong {
  display: block; font-size: 1.4rem;
  background: linear-gradient(90deg, var(--mood-2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.bento-cell span { color: var(--muted); font-weight: 600; font-size: .9rem; }
.bento-cell:hover {
  border-color: color-mix(in srgb, var(--mood-2) 55%, transparent);
  transform: translateY(-2px);
}
.bento-cell::after {
  content: ""; position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--mood-2) 18%, transparent), transparent 45%);
  transition: opacity .2s;
}
.bento-cell:hover::after { opacity: 1; }

/* Scroll */
.scroll-progress-demo { margin-bottom: 1.5rem; }
.scroll-bar {
  height: 6px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden;
}
.scroll-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--mood), var(--mood-2), var(--gold));
  transition: width .05s linear;
}
.scroll-progress-demo p { margin: .5rem 0 0; font-size: .85rem; color: var(--muted); }

.sticky-stack {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.5rem; align-items: start;
}
.sticky-rail { display: grid; gap: 1rem; }
.sticky-panel {
  position: sticky; top: 5.5rem;
  padding: 1.35rem; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(12,18,36,.85); backdrop-filter: blur(10px);
  min-height: 28vh;
}
.sticky-panel .step {
  font-family: var(--mono); color: var(--mood-2); font-weight: 700; font-size: .85rem;
}
.sticky-panel h3 { margin: .35rem 0; }
.sticky-panel p { margin: 0; color: var(--muted); }
.parallax-stack {
  position: relative; height: 120vh; border-radius: 20px; overflow: hidden;
  border: 1px solid var(--line); background: #050810;
}
.plx {
  position: absolute; border-radius: 20px; opacity: .7;
  will-change: transform;
}
.plx-a {
  inset: 12% 18% 40% 12%;
  background: linear-gradient(135deg, color-mix(in srgb, var(--mood) 50%, #000), transparent);
}
.plx-b {
  inset: 35% 10% 20% 30%;
  background: linear-gradient(160deg, color-mix(in srgb, var(--mood-2) 40%, #000), transparent);
  border: 1px solid rgba(255,255,255,.06);
}
.plx-c {
  inset: 55% 25% 12% 15%;
  background: radial-gradient(circle at 30% 30%, var(--gold), transparent 60%);
  opacity: .45;
}

/* FX */
.spotlight {
  position: relative; min-height: 240px; border-radius: 22px; overflow: hidden;
  border: 1px solid var(--line); padding: 2rem 1.5rem;
  background:
    radial-gradient(500px circle at var(--sx, 50%) var(--sy, 40%),
      color-mix(in srgb, var(--mood-2) 22%, transparent), transparent 40%),
    linear-gradient(180deg, #0a1020, #050810);
  background-image:
    radial-gradient(500px circle at var(--sx, 50%) var(--sy, 40%),
      color-mix(in srgb, var(--mood-2) 25%, transparent), transparent 42%),
    linear-gradient(rgba(148,163,184,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.07) 1px, transparent 1px),
    linear-gradient(180deg, #0a1020, #050810);
  background-size: auto, 36px 36px, 36px 36px, auto;
}
.spot-title {
  margin: 0; font-family: var(--serif); font-size: clamp(1.8rem, 4vw, 2.6rem);
}
.spot-sub { margin: .5rem 0 0; max-width: 28rem; color: var(--muted); }

.fx-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem;
}
.noise-card, .lines-card {
  position: relative; overflow: hidden;
  padding: 1.25rem; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(12,18,36,.75);
}
.noise-layer {
  position: absolute; inset: 0; opacity: .12; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.noise-card h3, .lines-card h3 { position: relative; margin: 0 0 .4rem; }
.noise-card p, .lines-card p { position: relative; margin: 0; color: var(--muted); font-size: .92rem; }
.wave-svg { width: 100%; height: 80px; margin-bottom: .5rem; }
.wave-path {
  stroke-dasharray: 480; stroke-dashoffset: 480;
}
.wave-path.is-on { animation: draw 1.6s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Code */
.code-grid {
  display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem;
}
.code-panel {
  margin: 0; padding: 1.25rem 1.35rem; border-radius: 16px;
  background: #050810; border: 1px solid var(--line);
  overflow: auto; font-family: var(--mono); font-size: .82rem; line-height: 1.55;
  color: #cbd5e1;
}
.c-k { color: #c084fc; }
.c-s { color: #67e8f9; }
.c-n { color: #fcd34d; }
.a11y-card {
  padding: 1.35rem; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(12,18,36,.75);
}
.a11y-card h3 { margin: 0 0 .75rem; }
.a11y-card ul { margin: 0 0 1.25rem; padding-left: 1.1rem; color: var(--muted); }
.a11y-card li { margin: .35rem 0; }
.a11y-card code {
  font-family: var(--mono); font-size: .85em; color: var(--mood-2);
}

.lab-end {
  max-width: 720px; margin: 0 auto; padding: 3rem 1.25rem 4rem; text-align: center;
}
.lab-end h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; }
.lab-end p { color: var(--muted); margin: .75rem 0 0; }
.lab-end .hero-cta { justify-content: center; }

.lab-foot {
  border-top: 1px solid var(--line); padding: 1.25rem; text-align: center;
  color: var(--muted); font-size: .85rem; position: relative; z-index: 1;
}

/* Reveal */
.reveal {
  opacity: 0; transform: translateY(18px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; }

@media (max-width: 900px) {
  .lab-nav {
    min-height: 0;
    padding: 0.55rem 0.75rem 0.65rem;
    gap: 0.5rem 0.5rem;
    /* Full-width stack so logo + chips never force page sideways scroll */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .lab-brand {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    margin-right: 0;
  }
  /* Readable wordmark without exceeding the viewport */
  .lab-brand img {
    height: 72px !important;
    max-width: min(280px, 72vw) !important;
    width: auto !important;
    object-fit: contain !important;
    object-position: left center !important;
  }
  .lab-actions {
    order: 2;
    flex: 1 1 100%;
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    gap: 0.3rem;
  }
  .lab-links {
    order: 3;
    width: 100%;
    max-width: 100%;
    gap: 0.1rem;
    padding-top: 0.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .lab-links a {
    font-size: 0.82rem;
    padding: 0.35rem 0.55rem;
    flex: 0 0 auto;
  }
  .chip { font-size: 0.75rem; padding: 0.36rem 0.65rem; }
  .type-row { grid-template-columns: 1fr; gap: .25rem; }
  .type-scale { grid-template-columns: repeat(3, 1fr); }
  .split, .motion-grid, .ui-row, .fx-row, .code-grid, .sticky-stack {
    grid-template-columns: 1fr;
  }
  .bento-lab { grid-template-columns: 1fr 1fr; }
  .bento-cell.wide { grid-column: span 2; }
  .parallax-stack { height: 50vh; }
  .sticky-panel { position: relative; top: 0; min-height: 0; }
  /* Room for bottom section rail without horizontal drag of the page */
  body {
    padding-bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px));
  }
  .lab-section,
  .lab-hero,
  .lab-cta {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
  }
  .lab-hero {
    padding-top: 2.5rem;
  }
  .hero-kicker {
    font-size: clamp(1.85rem, 8.5vw, 2.6rem);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .tech-pills {
    max-width: 100%;
  }
  .code-panel,
  .python-pre,
  pre,
  code {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
  }
  #webgl-canvas {
    height: min(52vh, 320px) !important;
    min-height: 220px;
  }
  #canvas-audio {
    height: min(40vh, 220px) !important;
  }
}

/* ========== MAX EDITION additions ========== */
body.light-stage {
  --void: #eef2ff; --ink: #e0e7ff; --panel: #fff; --text: #0f172a; --muted: #475569;
  --line: rgba(15, 23, 42, 0.12);
}
body.light-stage .code-panel, body.light-stage .mono-card { background: #0f172a; color: #e2e8f0; }
body.light-stage .lab-bg .orb { opacity: .2; }

/* —— Light theme: full menu / chrome (after mobile rules so it always wins) —— */
body.light-stage .lab-nav {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}
/* Logo is drawn for dark backgrounds (white type) — flip for light bar */
body.light-stage .lab-brand img {
  filter: invert(1) hue-rotate(180deg);
}
body.light-stage .lab-links {
  border-top-color: rgba(15, 23, 42, 0.1);
}
body.light-stage .lab-links a,
body.light-stage .lab-links a:visited {
  color: #0f172a !important;
}
body.light-stage .lab-links a:hover,
body.light-stage .lab-links a:focus-visible {
  color: #020617 !important;
  background: rgba(37, 99, 255, 0.1) !important;
}
body.light-stage .lab-links a:active {
  color: #1e3a8a !important;
  background: rgba(37, 99, 255, 0.16) !important;
}
body.light-stage .chip {
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.16) !important;
  background: rgba(15, 23, 42, 0.04) !important;
}
body.light-stage .chip:hover,
body.light-stage .chip:focus-visible {
  color: #020617 !important;
  background: rgba(15, 23, 42, 0.08) !important;
  border-color: rgba(15, 23, 42, 0.24) !important;
}
body.light-stage .chip-ghost {
  color: #334155 !important;
  background: transparent !important;
}
body.light-stage .chip-ghost:hover {
  color: #0f172a !important;
  background: rgba(15, 23, 42, 0.06) !important;
}
body.light-stage .chip-hot {
  color: #fff !important;
  background: linear-gradient(135deg, #2563ff, #4da3ff) !important;
  border-color: transparent !important;
}
body.light-stage .chip-hot:hover {
  color: #fff !important;
  filter: brightness(1.05);
}
/* Side rail readable on light page */
body.light-stage .lab-rail a { color: #64748b; }
body.light-stage .lab-rail a.is-active { color: #0f172a; }
body.light-stage .lab-rail a span {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.1);
}
body.light-stage .lab-rail a i {
  border-color: rgba(15, 23, 42, 0.28);
}
body.light-stage .present-hud {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border-top-color: rgba(15, 23, 42, 0.12);
}
body.light-stage .present-keys { color: #64748b; }
body.light-stage .share-toast {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.4);
}

@media (max-width: 900px) {
  body.light-stage .lab-links {
    border-top: 1px solid rgba(15, 23, 42, 0.1);
  }
  body.light-stage .lab-rail {
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(15, 23, 42, 0.12);
  }
  body.light-stage .lab-rail a i {
    border-color: rgba(15, 23, 42, 0.3);
  }
}

.bg-particles {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55;
}
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0; pointer-events: none; z-index: 100;
  border-radius: 50%; mix-blend-mode: difference; opacity: 0;
  transition: opacity .2s;
}
.cursor-dot { width: 8px; height: 8px; background: #fff; margin: -4px 0 0 -4px; }
.cursor-ring {
  width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.7);
  margin: -18px 0 0 -18px; transition: transform .12s var(--ease), opacity .2s;
}
body.has-cursor .cursor-dot, body.has-cursor .cursor-ring { opacity: 1; }

.tech-pills {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1.5rem;
}
.tech-pills span {
  font-family: var(--mono); font-size: .7rem; padding: .3rem .55rem;
  border-radius: 8px; border: 1px solid var(--line); color: var(--muted); background: rgba(0,0,0,.2);
}

/* Glitch */
.type-glitch {
  margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; position: relative; color: #fff;
}
.type-glitch::before, .type-glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%; overflow: hidden;
}
.type-glitch::before {
  color: #67e8f9; animation: glitch1 2.5s infinite linear alternate-reverse; clip-path: inset(0 0 55% 0);
}
.type-glitch::after {
  color: #f472b6; animation: glitch2 3s infinite linear alternate-reverse; clip-path: inset(45% 0 0 0);
}
@keyframes glitch1 {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  100% { transform: translate(0); }
}
@keyframes glitch2 {
  0% { transform: translate(0); }
  25% { transform: translate(2px, 0); }
  50% { transform: translate(-2px, 1px); }
  100% { transform: translate(0); }
}

.scramble-live {
  font-family: var(--mono); font-size: 1.15rem; font-weight: 700; color: #86efac; min-height: 2rem;
}
.mask-card { overflow: hidden; }
.mask-text {
  font-size: 1.35rem; font-weight: 800; line-height: 1.35;
  background: linear-gradient(90deg, transparent 0%, #fff 40%, #fff 60%, transparent 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: maskSlide 3.5s linear infinite;
}
@keyframes maskSlide {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Loaders */
.loaders { display: flex; align-items: center; gap: 1.25rem; height: 64px; }
.spin {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12); border-top-color: var(--mood-2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dots { display: flex; gap: .35rem; }
.dots i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--mood-2);
  animation: bounce 1s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50% { transform: translateY(-8px); opacity: 1; }
}
.bar-load {
  flex: 1; height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden;
}
.bar-load i {
  display: block; height: 100%; width: 40%; border-radius: inherit;
  background: linear-gradient(90deg, var(--mood), var(--mood-2));
  animation: barSlide 1.2s ease-in-out infinite;
}
@keyframes barSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}

/* Ring */
.ring { width: 120px; height: 120px; display: block; margin: 0 auto .5rem; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 8; }
.ring-fg {
  fill: none; stroke: url(#none); stroke: var(--mood-2); stroke-width: 8;
  stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset 1s var(--ease);
}
.ring-label {
  fill: #fff; font-size: 18px; font-weight: 800; font-family: var(--font);
  transform: rotate(90deg); transform-origin: 60px 60px;
}

/* Flip */
.flip { perspective: 800px; height: 100px; }
.flip-inner {
  position: relative; width: 100%; height: 100%; transition: transform .6s var(--ease);
  transform-style: preserve-3d;
}
.flip:hover .flip-inner, .flip:focus .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 14px;
  backface-visibility: hidden; font-weight: 800;
}
.flip-front { background: rgba(37,99,255,.2); border: 1px solid rgba(96,165,250,.35); }
.flip-back {
  background: rgba(245,215,110,.15); border: 1px solid rgba(245,215,110,.4); color: #fde68a;
  transform: rotateY(180deg);
}

/* Skeleton */
.skel { display: grid; gap: .55rem; }
.skel i {
  display: block; height: 14px; border-radius: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.14), rgba(255,255,255,.06));
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skel i.w2 { width: 80%; }
.skel i.w3 { width: 55%; }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Compare */
.compare {
  position: relative; margin-top: 1.5rem; border-radius: 20px; overflow: hidden;
  border: 1px solid var(--line); height: min(42vw, 320px); min-height: 200px;
  user-select: none;
}
.compare-after, .compare-before { position: absolute; inset: 0; }
.compare-after img, .compare-before img { width: 100%; height: 100%; object-fit: cover; }
.compare-before { clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); z-index: 1; }
.compare-tag {
  position: absolute; top: .75rem; padding: .25rem .6rem; border-radius: 999px;
  font-size: .7rem; font-weight: 800; background: rgba(0,0,0,.55); color: #fff;
}
.compare-before .compare-tag { left: .75rem; }
.compare-after .compare-tag { right: .75rem; }
.compare-range {
  position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: ew-resize;
}

/* 3D */
.three-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.scene {
  height: 180px; perspective: 600px; display: grid; place-items: center;
}
.cube {
  width: 90px; height: 90px; position: relative; transform-style: preserve-3d;
  animation: cubespin 12s linear infinite;
}
.cube.paused { animation-play-state: paused; }
@keyframes cubespin {
  from { transform: rotateX(-20deg) rotateY(0); }
  to { transform: rotateX(-20deg) rotateY(360deg); }
}
.face {
  position: absolute; inset: 0; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.2); background: rgba(37,99,255,.35);
  font-weight: 800; font-size: .75rem; backface-visibility: visible;
}
.f1 { transform: translateZ(45px); }
.f2 { transform: rotateY(90deg) translateZ(45px); background: rgba(77,163,255,.35); }
.f3 { transform: rotateY(180deg) translateZ(45px); background: rgba(129,140,248,.35); }
.f4 { transform: rotateY(-90deg) translateZ(45px); background: rgba(245,215,110,.3); }
.f5 { transform: rotateX(90deg) translateZ(45px); background: rgba(52,211,153,.3); }
.f6 { transform: rotateX(-90deg) translateZ(45px); background: rgba(244,114,182,.3); }

.stack { position: relative; height: 160px; margin: .5rem 0 1rem; }
.stack-card {
  position: absolute; left: 50%; top: 20%; width: 80%; padding: 1rem;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(17,26,48,.9);
  font-weight: 700; transform: translateX(-50%); transition: transform .45s var(--ease), opacity .45s;
}
.stack-card:nth-child(1) { transform: translateX(-50%) translateY(0) scale(1); z-index: 4; }
.stack-card:nth-child(2) { transform: translateX(-50%) translateY(12px) scale(.96); z-index: 3; opacity: .85; }
.stack-card:nth-child(3) { transform: translateX(-50%) translateY(24px) scale(.92); z-index: 2; opacity: .7; }
.stack-card:nth-child(4) { transform: translateX(-50%) translateY(36px) scale(.88); z-index: 1; opacity: .55; }

.orbit {
  position: relative; width: 180px; height: 180px; margin: .5rem auto 0;
}
.orbit-core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; background: linear-gradient(135deg, var(--mood), var(--mood-2));
  z-index: 2;
}
/* Reliable transform orbit (works everywhere) */
.orbit i {
  --ang: calc(var(--i) * 60deg);
  position: absolute; left: 50%; top: 50%;
  width: 36px; height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%; display: grid; place-items: center; font-style: normal;
  font-size: .65rem; font-weight: 800; background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  /* rotate around orbit centre without nested counter-rotate (more reliable) */
  transform: rotate(var(--ang)) translateX(70px);
  animation: orbitSpin 14s linear infinite;
  animation-delay: calc(var(--i) * -2.33s);
}
.orbit i::after {
  /* keep labels upright */
  content: none;
}
@keyframes orbitSpin {
  from { transform: rotate(var(--ang)) translateX(70px); }
  to { transform: rotate(calc(var(--ang) + 360deg)) translateX(70px); }
}

/* Canvas */
.canvas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.canvas-card canvas {
  width: 100%;
  max-width: 100% !important;
  height: 220px;
  display: block;
  border-radius: 12px;
  background: #050810;
  border: 1px solid var(--line);
  margin: .5rem 0;
  touch-action: none;
  box-sizing: border-box;
}
#canvas-constellation { height: 260px; max-width: 100% !important; }
#webgl-canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: 420px !important;
  min-height: 320px;
  max-height: 480px;
  display: block;
  background: #050810;
  box-sizing: border-box;
}
#canvas-audio {
  width: 100% !important;
  max-width: 100% !important;
  height: 280px !important;
  display: block;
  background: #050810;
  box-sizing: border-box;
}

/* Horizontal scroll */
.h-scroll {
  overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  border-radius: 16px; border: 1px solid var(--line); background: rgba(0,0,0,.25);
  padding: 1rem;
}
.h-track { display: flex; gap: .85rem; width: max-content; }
.h-card {
  scroll-snap-align: start; width: min(70vw, 220px); min-height: 120px;
  padding: 1rem; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(12,18,36,.9); color: var(--muted); font-size: .85rem;
}
.h-card strong { display: block; margin-top: .35rem; color: #fff; font-size: 1.1rem; }

/* Filter / clip */
.filter-img {
  width: 100%; height: 140px; object-fit: cover; border-radius: 12px; margin-bottom: .65rem;
}
.demo-card label.tiny {
  display: flex; justify-content: space-between; gap: .75rem; align-items: center;
  margin: .35rem 0; color: var(--muted);
}
.demo-card label.tiny input[type="range"] { flex: 1; accent-color: var(--mood-2); }
.clip-morph {
  width: 140px; height: 140px; margin: .5rem auto 1rem;
  background: linear-gradient(135deg, var(--mood), var(--gold));
  transition: clip-path .6s var(--ease);
  clip-path: circle(48% at 50% 50%);
}

/* Widgets */
.widget-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.terminal { padding: 0 !important; overflow: hidden; }
.term-bar {
  display: flex; align-items: center; gap: .35rem; padding: .55rem .75rem;
  background: #111a30; border-bottom: 1px solid var(--line); font-size: .72rem; color: var(--muted);
}
.term-bar span { width: 10px; height: 10px; border-radius: 50%; background: #334155; }
.term-bar span:nth-child(1) { background: #f87171; }
.term-bar span:nth-child(2) { background: #fbbf24; }
.term-bar span:nth-child(3) { background: #4ade80; }
.term-bar em { margin-left: .5rem; font-style: normal; }
.term-body {
  height: 160px; overflow: auto; padding: .75rem; font-family: var(--mono);
  font-size: .8rem; line-height: 1.5; color: #86efac; background: #050810;
}
.term-body .out { color: #94a3b8; }
.term-form {
  display: flex; gap: .4rem; align-items: center; padding: .5rem .75rem;
  border-top: 1px solid var(--line); background: #0a1020;
}
.term-prompt { font-family: var(--mono); color: var(--mood-2); font-weight: 700; }
.term-form input {
  flex: 1; background: transparent; border: 0; color: #fff; font-family: var(--mono); font-size: .85rem;
  outline: none;
}

.tabs { display: flex; gap: .35rem; margin-bottom: .75rem; }
.tab {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: .4rem .75rem; border-radius: 999px; font-weight: 700; font-size: .8rem; cursor: pointer;
}
.tab.is-on { background: rgba(37,99,255,.2); color: #fff; border-color: rgba(96,165,250,.4); }
.tab-panel { color: var(--muted); font-size: .95rem; line-height: 1.55; min-height: 4rem; }

.acc {
  border: 1px solid var(--line); border-radius: 12px; padding: .65rem .85rem; margin-bottom: .45rem;
  background: rgba(0,0,0,.2);
}
.acc summary { cursor: pointer; font-weight: 700; }
.acc p { margin: .5rem 0 0; color: var(--muted); font-size: .92rem; }

.toast-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.toast-dock { display: grid; gap: .4rem; min-height: 3rem; }
.toast-item {
  padding: .65rem .85rem; border-radius: 12px; font-size: .85rem; font-weight: 700;
  animation: toastIn .35s var(--ease);
}
.toast-item.ok { background: rgba(16,185,129,.18); color: #6ee7b7; border: 1px solid rgba(52,211,153,.4); }
.toast-item.err { background: rgba(244,63,94,.16); color: #fda4af; border: 1px solid rgba(251,113,133,.4); }
.toast-item.info { background: rgba(37,99,255,.18); color: #93c5fd; border: 1px solid rgba(96,165,250,.4); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

kbd {
  font-family: var(--mono); font-size: .75em; padding: .1rem .35rem;
  border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.06);
}

/* Modal + command */
.modal-root, .cmd-root {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
}
.modal-root[hidden], .cmd-root[hidden] { display: none !important; }
.modal-backdrop, .cmd-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(6px);
}
.modal-panel {
  position: relative; z-index: 1; width: min(92vw, 420px); padding: 1.5rem;
  border-radius: 20px; border: 1px solid var(--line);
  background: rgba(12,18,36,.92); box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal-panel h2 { margin: 0 0 .5rem; }
.modal-panel p { color: var(--muted); margin: 0 0 1.25rem; }
.cmd-panel {
  position: relative; z-index: 1; width: min(92vw, 480px);
  border-radius: 16px; border: 1px solid var(--line); background: #0b1220;
  overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.cmd-panel input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: #fff; padding: 1rem 1.1rem; font: inherit; font-weight: 600;
  outline: none;
}
.cmd-list { list-style: none; margin: 0; padding: .4rem; max-height: 280px; overflow: auto; }
.cmd-list li button {
  width: 100%; text-align: left; border: 0; background: transparent; color: var(--text);
  padding: .65rem .75rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.cmd-list li button:hover, .cmd-list li button.is-active {
  background: rgba(37,99,255,.2);
}

/* Phase 3 */
.webgl-stage, .audio-stage {
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  background: #050810;
}
.webgl-ui, .audio-controls {
  padding: .85rem 1rem 1rem; border-top: 1px solid var(--line);
  background: rgba(12,18,36,.9);
}
.webgl-stats {
  display: flex; gap: 1rem; font-family: var(--mono); font-size: .78rem;
  color: var(--muted); margin-bottom: .65rem;
}
.webgl-controls, .audio-controls {
  display: flex; flex-wrap: wrap; gap: .55rem .75rem; align-items: center;
}
.webgl-controls label, .audio-controls label.tiny {
  display: inline-flex; align-items: center; gap: .45rem; color: var(--muted);
  font-size: .8rem; font-weight: 600;
}
.webgl-controls input[type="range"], .audio-controls input[type="range"] {
  accent-color: var(--mood-2); width: 100px;
}
@keyframes webglFallback {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.btn-snippet {
  margin-top: .45rem;
  border-color: rgba(96,165,250,.35) !important;
  color: #bfdbfe !important;
}

.snippet-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1rem;
}
.snippet-filter-chip {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(12, 18, 36, 0.75);
  color: #9aa8c7;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.snippet-filter-chip:hover,
.snippet-filter-chip:focus-visible {
  color: #e2e8f0;
  border-color: rgba(56, 189, 248, 0.45);
  outline: none;
}
.snippet-filter-chip.is-active {
  color: #03050c;
  background: linear-gradient(120deg, #7dd3fc, #60a5fa);
  border-color: transparent;
}
.snippet-library {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem;
}
.snippet-card {
  padding: 1rem; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(12,18,36,.75);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.snippet-card:hover {
  border-color: rgba(96,165,250,.35);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0,0,0,.28);
}
.snippet-card h3 { margin: 0 0 .25rem; font-size: .98rem; }
.snippet-card .tiny { margin: 0 0 .75rem; }

/* Snippet drawer — starts BELOW sticky lab-nav so the menu stays visible */
.snip-root {
  position: fixed;
  top: var(--lab-nav-offset, 5rem);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: 1fr min(520px, 100%);
  grid-template-rows: 1fr;
  padding: 0;
  pointer-events: none;
}
.snip-root[hidden] { display: none !important; }
.snip-root.is-open { pointer-events: auto; }
.snip-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}
.snip-panel {
  position: relative;
  z-index: 1;
  grid-column: 2;
  width: 100%;
  height: 100%;
  max-height: none;
  display: flex;
  flex-direction: column;
  border-radius: 16px 0 0 0;
  border: 1px solid var(--line);
  border-right: 0;
  border-bottom: 0;
  background: #0b1220;
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: snipIn .32s var(--ease);
  pointer-events: auto;
  margin: 0;
}
@keyframes snipIn {
  from { transform: translateX(18px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.snip-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: rgba(12, 18, 36, 0.95);
}
.snip-head h2 { margin: .15rem 0 0; font-size: 1.1rem; line-height: 1.25; }
.snip-code {
  margin: 0; padding: 1rem 1.15rem; overflow: auto; flex: 1;
  font-family: var(--mono); font-size: .8rem; line-height: 1.55; color: #cbd5e1;
  background: #050810; white-space: pre-wrap; word-break: break-word;
  min-height: 0;
}
.snip-actions {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
  padding: .85rem 1.1rem; border-top: 1px solid var(--line); background: #0c1224;
  flex-shrink: 0;
}
body.snip-open .lab-rail {
  opacity: 0.35;
  pointer-events: none;
}
@media (max-width: 760px) {
  .snip-root {
    grid-template-columns: 1fr;
    place-items: end stretch;
  }
  .snip-panel {
    grid-column: 1;
    width: 100%;
    height: min(78vh, 640px);
    max-height: 78vh;
    border-radius: 18px 18px 0 0;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    animation: snipUp .32s var(--ease);
  }
  @keyframes snipUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
}

/* Phase 4 — bollocks edition */
.lab-intro {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #111a30, #03050c 70%);
  transition: opacity .45s var(--ease), visibility .45s;
}
.lab-intro[hidden] { display: none !important; }
.lab-intro.is-out { opacity: 0; visibility: hidden; pointer-events: none; }
.lab-intro-inner { text-align: center; padding: 2rem 1.25rem; max-width: 28rem; }
.intro-line {
  font-family: var(--serif); font-size: clamp(2rem, 6vw, 3.2rem); margin: .5rem 0 0.75rem;
  line-height: 1.1;
}
.intro-sub { color: var(--muted); margin: 0 0 1.5rem; }
.lab-intro .btn { margin: 0 .25rem .5rem; }

.lab-rail {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
  z-index: 45; display: flex; flex-direction: column; gap: .35rem;
}
.lab-rail a {
  display: flex; align-items: center; gap: .4rem; color: var(--muted);
  font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  text-decoration: none;
}
.lab-rail a i {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid rgba(148,163,184,.45); background: transparent;
  transition: transform .2s, background .2s, border-color .2s;
}
.lab-rail a span {
  opacity: 0; transform: translateX(6px); max-width: 0; overflow: hidden;
  transition: opacity .2s, transform .2s, max-width .2s;
  white-space: nowrap; background: rgba(3,5,12,.85); padding: .2rem .4rem; border-radius: 6px;
}
.lab-rail a:hover span, .lab-rail a:focus-visible span {
  opacity: 1; transform: none; max-width: 5rem;
}
.lab-rail a.is-active i {
  background: var(--mood-2); border-color: var(--mood-2);
  transform: scale(1.35); box-shadow: 0 0 12px color-mix(in srgb, var(--mood-2) 60%, transparent);
}
.lab-rail a.is-active { color: #fff; }

body.is-present .lab-nav { opacity: 0; pointer-events: none; transform: translateY(-100%); }
body.is-present .lab-nav {
  transition: opacity .35s, transform .35s;
}
.lab-nav { transition: opacity .35s, transform .35s; }
body.is-present .lab-rail { right: 18px; }
body.is-present .lab-intro { display: none !important; }

.present-hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .65rem 1.25rem;
  background: rgba(3,5,12,.9); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px); font-weight: 800;
}
.present-hud[hidden] { display: none !important; }
.present-keys { font-size: .75rem; color: var(--muted); font-weight: 600; }
.present-keys kbd { margin: 0 .1rem; }

.help-root {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
}
.help-root[hidden] { display: none !important; }
.help-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
}
.help-panel {
  position: relative; z-index: 1; width: min(92vw, 400px); padding: 1.5rem;
  border-radius: 20px; border: 1px solid var(--line); background: #0c1224;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.help-panel h2 { margin: 0 0 1rem; }
.help-list {
  list-style: none; margin: 0 0 1.25rem; padding: 0; color: var(--muted); font-size: .92rem;
}
.help-list li {
  display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}

.share-toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(12px);
  z-index: 130; padding: .65rem 1.1rem; border-radius: 999px;
  background: rgba(16,185,129,.2); border: 1px solid rgba(52,211,153,.45);
  color: #6ee7b7; font-weight: 800; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s;
}
.share-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.share-toast[hidden] { display: none !important; }
.share-toast.is-on[hidden] { display: block !important; }

@media (max-width: 900px) {
  .three-row, .canvas-grid, .widget-grid { grid-template-columns: 1fr; }
  .cursor-dot, .cursor-ring { display: none !important; }
  .lab-rail {
    top: auto; bottom: 0; left: 0; right: 0; transform: none;
    flex-direction: row; justify-content: flex-start; flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: .55rem;
    padding: .55rem max(0.75rem, env(safe-area-inset-right, 0px)) calc(.55rem + env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
    background: rgba(3,5,12,.92);
    border-top: 1px solid var(--line);
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    /* Rail scrolls inside itself — never widens the page */
    touch-action: pan-x;
  }
  .lab-rail a {
    flex: 0 0 auto;
  }
  .lab-rail a span { display: none; }
  body.is-present .present-hud { bottom: 44px; }
  /* Contain intentional horizontal demos inside the card, not the page */
  .h-scroll,
  .marquee-lab {
    max-width: 100%;
    overscroll-behavior-x: contain;
  }
  .marquee-track {
    /* still animates inside overflow:hidden parent */
    max-width: none;
  }
}

/* Extra-small phones */
@media (max-width: 400px) {
  .lab-brand img {
    height: 60px !important;
    max-width: min(220px, 68vw) !important;
  }
  .chip {
    font-size: 0.7rem;
    padding: 0.32rem 0.55rem;
  }
}

/* Pin theatre */
.pin-section { border-top: 1px solid var(--line); }
.pin-stage {
  position: relative;
  height: 240vh;
  margin-top: 1rem;
}
.pin-sticky {
  position: sticky; top: 18vh;
  display: grid; place-items: center;
  text-align: center; padding: 2rem 1rem 3rem;
  min-height: 55vh;
}
.pin-kicker {
  margin: 0 0 1rem; font-size: .72rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase; color: var(--mood-2);
}
.pin-line {
  margin: 0; max-width: 16ch;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.4rem, 7vw, 4.2rem); line-height: 1.12;
  display: flex; flex-wrap: wrap; justify-content: center; gap: .2em .35em;
}
.pin-word {
  display: inline-block; opacity: 0.12;
  will-change: transform, opacity;
  transition: color .2s;
}
.pin-word.is-lit {
  background: linear-gradient(90deg, #fff, var(--mood-2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pin-bar {
  width: min(280px, 70vw); height: 4px; margin: 1.75rem auto 0;
  border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden;
}
.pin-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--mood), var(--mood-2), var(--gold));
}
.pin-caption {
  margin: .65rem 0 0; font-family: var(--mono); font-size: .75rem; color: var(--muted);
}

/* Mic drop */
.drop-section {
  border-top: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--mood) 22%, transparent), transparent 55%);
}
.drop-inner {
  max-width: 40rem; margin: 0 auto; text-align: center; padding: 2rem 0 1rem;
}
.drop-title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.12; margin: .35rem 0 1.25rem;
}
.drop-title .accent {
  background: linear-gradient(90deg, #fff, var(--mood-2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.drop-points {
  list-style: none; margin: 0 auto 1.5rem; padding: 0; text-align: left; max-width: 28rem;
  color: var(--muted);
}
.drop-points li {
  padding: .55rem 0 .55rem 1.4rem; position: relative; border-bottom: 1px solid var(--line);
}
.drop-points li::before {
  content: "▸"; position: absolute; left: 0; color: var(--mood-2); font-weight: 900;
}
.drop-actions {
  display: flex; flex-wrap: wrap; gap: .65rem; justify-content: center;
}
.drop-note { margin-top: 1.25rem !important; }

/* —— Python section —— */
.python-section { position: relative; }
.python-hero-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1rem;
  margin: 0 0 1.35rem; padding: .75rem 1rem;
  border-radius: 14px; border: 1px solid rgba(55, 180, 90, 0.28);
  background:
    linear-gradient(120deg, rgba(55, 180, 90, 0.12), rgba(12, 18, 36, 0.5)),
    rgba(8, 14, 28, 0.85);
  font-size: .88rem; color: var(--muted); font-weight: 600;
}
.py-badge {
  display: inline-flex; align-items: center;
  padding: .28rem .65rem; border-radius: 999px;
  font-size: .72rem; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(120deg, #4ade80, #22c55e 50%, #16a34a);
  color: #052e16;
}
.py-badge-soft {
  background: rgba(74, 222, 128, 0.12);
  color: #86efac;
  border: 1px solid rgba(74, 222, 128, 0.25);
}
.python-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.python-card {
  display: flex; flex-direction: column; gap: .55rem;
  border-color: rgba(74, 222, 128, 0.14) !important;
}
.python-card:hover {
  border-color: rgba(74, 222, 128, 0.4) !important;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28), 0 0 30px rgba(34, 197, 94, 0.08);
}
.python-card-top {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
}
.py-lang {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  color: #4ade80; letter-spacing: .04em;
}
.py-tag {
  font-size: .65rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 999px;
  background: rgba(74, 222, 128, 0.1); color: #86efac;
  border: 1px solid rgba(74, 222, 128, 0.2);
}
.python-card h3 { margin: 0; font-size: 1.08rem; }
.python-pre {
  margin: 0; padding: .9rem 1rem; border-radius: 12px;
  background: #050a10; border: 1px solid rgba(148, 163, 184, 0.12);
  overflow: auto; max-height: 220px;
  font-family: var(--mono); font-size: .78rem; line-height: 1.5;
  color: #c8e6c9;
}
.python-pre .c-k { color: #f472b6; }
.python-pre .c-s { color: #67e8f9; }
.python-pre .c-n { color: #fde68a; }
.python-pre .c-c { color: #64748b; font-style: italic; }
.python-live {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  margin-top: 1.15rem;
}
.python-repl .term-bar em { color: #86efac; }
.py-prompt { color: #4ade80 !important; font-weight: 800; }
.py-in { color: #e2e8f0; font-family: var(--mono); font-size: .88rem; }
.python-repl #py-term-body {
  min-height: 140px; max-height: 220px; overflow: auto;
  font-family: var(--mono); font-size: .88rem; line-height: 1.55;
}
.python-repl #py-term-body .out { color: #86efac; }
.py-repl-note { margin: .65rem 0 0; color: var(--muted); }
.python-why h3 { margin: 0 0 .75rem; }
.python-bullets {
  margin: 0 0 1rem; padding: 0 0 0 1.1rem; color: var(--muted);
  font-size: .95rem; line-height: 1.55;
}
.python-bullets li { margin: .4rem 0; }
.python-bullets strong { color: #e2e8f0; }

@media (max-width: 860px) {
  .python-grid,
  .python-live { grid-template-columns: 1fr; }
  .python-pre { max-height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .lab-intro { transition: none; }
  .pin-word { opacity: 1 !important; transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .pulse-ring, .blob, .marquee-track, .stagger i, .typewriter::after, .wave-path,
  .spin, .dots i, .bar-load i, .cube, .orbit i, .type-glitch::before, .type-glitch::after,
  .mask-text, .skel i {
    animation: none !important;
  }
  .wave-path { stroke-dashoffset: 0; }
  .btn.magnetic span { transition: none; }
  .bg-particles { display: none; }
}

