/* ============================================================
   Gradient Studio: CSS Gradient Generator
   All colors/spacing/radii come from design-tokens.css so brand
   changes radiate here automatically.

   Hierarchy: one vivid full-bleed gradient stage, one slim glass
   dock, everything else quiet and generous with whitespace.
   ============================================================ */

/* One continuous night canvas. We pin dark-surface tokens to THIS page so every
   section below the hero reads on the same midnight floor (no boxed light cards,
   no hard cuts) regardless of the global light/dark theme. The hero's shader
   mesh sits on top of this same floor, so the whole page is one dark stage. */
/* On this page only: the global body reserves 5rem at the top for the fixed
   header — that reserved strip (body background behind the transparent header)
   was the "cut". Remove it so the stage starts at y=0 and the light flows up
   through the transparent header with no seam. */
body.gs-page .site-header:not(.header-scrolled) {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  border: 0 !important;
}

.gradient-studio {
  /* Cancel the global body top-padding (5rem reserved for the fixed header) so
     the stage starts at y=0 and the light flows up behind the transparent
     header — no reserved dark strip, no cut. The hero's own top padding keeps
     the headline clear of the nav. */
  margin-top: -5rem;
  --color-bg: #080b14;
  --color-bg-elevated: #11161f;
  --color-bg-muted: #161c27;
  --color-bg-hover: rgba(255, 255, 255, 0.06);
  --color-text-primary: #eef2f8;
  --color-text-secondary: rgba(226, 232, 240, 0.64);
  --color-border: rgba(255, 255, 255, 0.10);
  --color-shadow: rgba(0, 0, 0, 0.5);
  background: #080b14;
  color: var(--color-text-primary);
  font-family: var(--font-secondary);
}

.gs-container {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.gs-section-head { max-width: 38rem; margin-bottom: var(--space-lg); }

.gs-section-eyebrow {
  font-family: var(--font-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-color-extractly);
  margin: 0 0 var(--space-xs);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.gs-section-eyebrow::before {
  content: '';
  width: 1.6rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-color-extractly);
}

.gradient-studio h2 {
  font-family: var(--font-primary);
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 var(--space-xs);
  letter-spacing: 0.01em;
}

.gs-section-sub {
  color: var(--color-text-secondary);
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

/* ── Hero ─────────────────────────────────────────────────── */

.gs-hero {
  position: relative;
  /* Full-bleed stage: the whole viewport is the light. Copy + the glass control
     panel float over it as a centered column; the 2D nodes live on the light
     itself in the open areas around them. */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(var(--space-sm), 1.6vh, var(--space-md));
  padding: calc(var(--space-md) + 3.5rem) var(--space-md) 1.5rem;
  overflow: clip;
  isolation: isolate;
}

.gs-hero__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  /* Night-sky aurora fallback: instant paint, slow drift if the shader never
     mounts. JS rebuilds --gs-ambient from the user's stops on every edit. */
  background: var(--gs-ambient,
    radial-gradient(58% 55% at 18% 24%, rgba(54, 201, 240, 0.35), transparent 70%),
    radial-gradient(52% 60% at 80% 16%, rgba(187, 107, 217, 0.3), transparent 70%),
    radial-gradient(70% 58% at 52% 88%, rgba(78, 28, 255, 0.25), transparent 72%),
    linear-gradient(180deg, #070b14, #0c1424));
  background-size: 180% 180%;
  animation: gs-ambient-drift 26s ease-in-out infinite alternate;
  /* Cursor parallax: JS sets --gs-px/--gs-py (px). Slight overscale hides the
     edges as the stage drifts toward the pointer. */
  transform: translate3d(calc(var(--gs-px, 0) * 1px), calc(var(--gs-py, 0) * 1px), 0) scale(1.06);
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

@keyframes gs-ambient-drift {
  from { background-position: 0% 0%; }
  to   { background-position: 100% 100%; }
}


/* Fine film grain keeps the big gradient surface from looking flat-vector */
.gs-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.04;
  /* overlay blending textures the stage without lifting the blacks to haze */
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Legibility scrims. Smooth and monotonic — no banded stops — so the stage
   dissolves up through the (transparent) fixed header with no visible cut, and
   sinks back to the page floor at the bottom. A soft center vignette keeps the
   copy and dock legible over bright blooms. */
.gs-hero__scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    /* gentle hold-down behind the title/dock (kept light so the stage stays vivid) */
    radial-gradient(72% 66% at 50% 52%, rgba(7, 11, 20, 0.42), transparent 82%),
    /* bottom: dissolve into the page night floor with no edge */
    linear-gradient(to top,
      #080b14 0%,
      rgba(8, 11, 20, 0.7) 10%,
      transparent 34%);
  /* NO top band — the light flows straight up through the transparent header so
     there is no cut. The header keeps its own legibility treatment. */
}

.gs-hero__copy {
  text-align: center;
  text-wrap: balance;
  width: 100%;
  max-width: 46rem;
  overflow-wrap: break-word;
  position: relative;
  z-index: 5;
  /* Sit near the top; the auto bottom margin pushes the controls to the floor,
     leaving the whole middle of the stage for the light. */
  margin-top: clamp(1rem, 5vh, 4rem);
  margin-bottom: auto;
  /* Non-interactive text → clicks pass through to the color nodes on the light */
  pointer-events: none;
}

/* Bare letter-spaced label: the brand wink without chrome around it */
.gs-eyebrow {
  display: inline-block;
  font-family: var(--font-primary);
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.66);
  margin: 0 0 var(--space-xs);
}

/* Quiet, confident display type: the shader provides the spectacle, the
   headline stays neutral. Silkscreen lives only in the eyebrow (brand wink). */
.gs-title {
  font-family: var(--font-secondary);
  font-weight: 650;
  font-size: clamp(2.4rem, 1.4rem + 4.4vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-xs);
  color: #fff;
}

.gs-subtitle {
  font-size: clamp(1rem, 0.92rem + 0.5vw, 1.2rem);
  color: rgba(255, 255, 255, 0.92);
  max-width: min(32rem, 100%);
  margin: 0 auto;
}

/* ── Editor dock ──────────────────────────────────────────── */

.gs-editor {
  /* Hug the controls instead of a fixed 40rem slab — a wide bar with edge-pinned
     groups left a dead void in the middle. Content width + centered rows reads as
     one compact, intentional instrument. */
  width: fit-content;
  max-width: min(44rem, 94vw);
  position: relative;
  z-index: 6; /* floats above the light + nodes */
  /* Minimal floating instrument bar: a thin slab of frosted glass that sits
     low over the light. Slim padding + tight gaps keep it out of the way so the
     gradient owns the stage. */
  background: rgba(10, 14, 22, 0.55);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  backdrop-filter: blur(30px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.25rem;
  padding: 0.7rem 0.85rem;
  padding-top: 0rem;
  display: grid;
  gap: 0.55rem;
  color: var(--shade-000);
  overflow: clip;
  box-shadow:
    0 1.75rem 4rem -1.5rem rgba(0, 0, 0, 0.7),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
}

/* Faint glass sheen catching light from top-left */
.gs-editor::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  background: radial-gradient(120% 80% at 12% 0%, rgba(255, 255, 255, 0.08), transparent 55%);
}

/* ── Color stripe: thin live-gradient line that grows into a stop bar ─────────
   Collapsed it's a 4px gradient edge tying the panel to the work. On hover (for
   linear/radial/conic) it expands and reveals draggable swatches you slide along
   it. In mesh mode it stays a decorative line (nodes live on the stage). */
.gs-stripe {
  position: relative;
  z-index: 2;
  height: 0.3rem;
  border-radius: 999px;
  background: var(--gs-gradient-bar, linear-gradient(90deg in oklch, #36c9f0, #4e1cff));
  transition: height 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms ease;
  cursor: copy;
}

.gs-stripe .gs-stop-handle {
  top: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

/* Expand on hover/focus — only when the stripe is the active editor (not mesh) */
.gs-hero:not(.is-mesh) .gs-editor:hover .gs-stripe,
.gs-hero:not(.is-mesh) .gs-editor:focus-within .gs-stripe {
  height: 2.2rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.gs-hero:not(.is-mesh) .gs-editor:hover .gs-stripe .gs-stop-handle,
.gs-hero:not(.is-mesh) .gs-editor:focus-within .gs-stripe .gs-stop-handle {
  opacity: 1;
  pointer-events: auto;
}

/* Mesh: the stripe is purely decorative */
.gs-hero.is-mesh .gs-stripe { pointer-events: none; cursor: default; }

/* ── Layer stack UI (in the bottom toolbar) ─────────────────────────────────── */
.gs-layers {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.gs-layers:empty { display: none; }

.gradient-studio .gs-layers .gs-layer {
  min-width: 0;
  min-height: 0;
  width: 2.4rem;
  height: 1.5rem;
  padding: 0;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: box-shadow 140ms ease, border-color 140ms ease;
}
.gradient-studio .gs-layers .gs-layer:hover { border-color: rgba(255, 255, 255, 0.4); }
.gradient-studio .gs-layers .gs-layer.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.gradient-studio .gs-layers .gs-layer:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.gs-layer-blend {
  height: 1.7rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: var(--font-secondary);
  font-size: 0.68rem;
  padding: 0 0.35rem;
  cursor: pointer;
}
.gs-layer-blend option { color: #111; }

.gradient-studio .gs-layer-add,
.gradient-studio .gs-layer-del {
  min-height: 0;
  height: 1.7rem;
  padding: 0 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: var(--font-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.gradient-studio .gs-layer-add:hover,
.gradient-studio .gs-layer-del:hover { background: rgba(255, 255, 255, 0.12); }
.gradient-studio .gs-layer-del { color: rgba(255, 180, 180, 0.9); }

/* ── Editor foot: layer stack (left) ⇄ actions (right) as one balanced row ───── */
.gs-editor-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.gs-editor-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
/* CODE is the one emphasized action: a solid brand-accent pill (not the muddy
   live gradient), always legible and clearly primary. */
.gs-editor-actions .gs-code-open {
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1.15rem;
  background: var(--accent-color-extractly);
  box-shadow: 0 4px 14px var(--color-shadow);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.gs-editor-actions .gs-code-open:hover {
  background: color-mix(in oklab, var(--accent-color-extractly) 88%, #fff);
}

.gs-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 2.4rem;
  padding: 0 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  color: #fff;
  font-family: var(--font-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.gs-tool:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.3); }
.gs-tool:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.gs-tool--save { width: 2.4rem; padding: 0; color: rgba(255, 255, 255, 0.92); }
.gs-tool--save.is-saved { color: var(--accent-color-extractly); }
.gs-tool--save.is-saved svg { transform: scale(1.18); }
.gs-tool--save svg { transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1); }
.gs-tool--icon { width: 2.4rem; padding: 0; }

/* ── Focus mode: hide EVERYTHING but the gradient itself ─────────────────────── */
.gs-hero.gs-focus .gs-editor,
.gs-hero.gs-focus .gs-hero__copy,
.gs-hero.gs-focus .gs-starters,
.gs-hero.gs-focus .gs-trustline,
.gs-hero.gs-focus .gs-mesh-layer,
.gs-hero.gs-focus .gs-geo,
.gs-hero.gs-focus .gs-hero__scrim,
body.gs-focus .site-header {
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.gs-hero.gs-focus .gs-node-info { display: none; }
.gs-hero.gs-focus .gs-mesh-lines { opacity: 0; }

/* Exit-focus: a round ✕ pinned top-right, above everything. */
.gs-focus-exit {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 14, 22, 0.55);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 1rem 2.5rem -0.75rem rgba(0, 0, 0, 0.6);
}
.gs-focus-exit[hidden] { display: none; }
.gs-focus-exit:hover { background: rgba(255, 255, 255, 0.16); }
.gs-focus-exit .gs-icon, .gs-focus-exit > svg { font-size: 1.1rem; }

/* ── Color-order panel (Photoshop-style, right-docked, mesh only) ───────────── */
.gs-layer-panel {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 7;
  width: 12rem;
  max-height: 60svh;
  overflow-y: auto;
  padding: 0.6rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 22, 0.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 1.5rem 4rem -1rem rgba(0, 0, 0, 0.6);
}
.gs-layer-panel[hidden] { display: none; }
body.gs-focus .gs-layer-panel { opacity: 0; pointer-events: none; transition: opacity 320ms ease; }

.gs-layer-panel__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  padding: 0.1rem 0.3rem 0.5rem;
  cursor: move;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
/* Grip affordance (Fluent re-order-dots) so the header reads as draggable */
.gs-layer-panel__grip {
  flex-shrink: 0;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.32);
}
.gs-layer-panel.is-dragging { cursor: grabbing; }
.gs-layer-panel__head-text { flex: 1; min-width: 0; }
/* Collapse / expand toggle (overrides the global button chrome) */
.gs-layer-panel .gs-layer-panel__toggle {
  margin-left: auto;
  width: 1.3rem;
  height: 1.3rem;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}
.gs-layer-panel .gs-layer-panel__toggle:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* Inline Fluent icons (sized to the control's font-size, coloured via currentColor) */
.gs-icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.gs-icon > svg { width: 1em; height: 1em; display: block; }

/* The degree readout is redundant (rotation = the dial + the on-canvas arm) */
.gs-angle-label { display: none; }

/* Toolbar drag grip — floats top-left of the editor, doesn't disturb the grid */
.gs-editor__grip {
  position: absolute;
  top: 0.4rem;
  left: 0.55rem;
  z-index: 2;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.3);
  cursor: move;
  touch-action: none;
  margin-bottom: .25rem;
}
.gs-editor__grip:hover { color: rgba(255, 255, 255, 0.65); }
.gs-editor.is-dragging { cursor: grabbing; }

/* ── In-panel HSV colour picker ──────────────────────────────────────────── */
.gs-hsv {
  position: fixed;
  z-index: 9;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  width: 13rem;
  padding: 0.6rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 22, 0.85);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 1rem 3rem -0.5rem rgba(0, 0, 0, 0.6);
}
.gs-hsv[hidden] { display: none; }
.gs-hsv__sv {
  position: relative;
  height: 9rem;
  border-radius: 0.4rem;
  cursor: crosshair;
  touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.gs-hsv__sv-thumb {
  position: absolute;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.gs-hsv__hue {
  position: relative;
  width: 0.9rem;
  height: 9rem;
  border-radius: 0.4rem;
  cursor: ns-resize;
  touch-action: none;
  background: linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.gs-hsv__hue-thumb {
  position: absolute;
  left: -2px;
  right: -2px;
  height: 0.35rem;
  border: 2px solid #fff;
  border-radius: 0.25rem;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  transform: translateY(-50%);
  pointer-events: none;
}
.gs-hsv .gs-hsv__hex {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0.3rem 0.45rem;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.75rem;
  text-align: center;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.4rem;
}
.gs-hsv .gs-hsv__hex:focus { outline: none; border-color: rgba(255, 255, 255, 0.5); }

.gs-layer-panel__list { display: flex; flex-direction: column; gap: 0.25rem; }

/* ── Collapsed: a thin rail of just the colour swatches (still reorder/recolor) ── */
.gs-layer-panel.is-collapsed {
  width: auto;
  padding: 0.45rem;
}
.gs-layer-panel.is-collapsed .gs-layer-panel__head { padding: 0 0 0.4rem; }
.gs-layer-panel.is-collapsed .gs-layer-panel__head-text,
.gs-layer-panel.is-collapsed .gs-layer-row__hex,
.gs-layer-panel.is-collapsed .gs-layer-row__del,
.gs-layer-panel.is-collapsed .gs-layer-panel__add,
.gs-layer-panel.is-collapsed .gs-layer-panel__hint,
.gs-layer-panel.is-collapsed .gs-layer-panel__subhead { display: none; }
.gs-layer-panel.is-collapsed .gs-layer-row { padding: 0.25rem; justify-content: center; gap: 0; }
.gs-layer-panel.is-collapsed .gs-layer-row__swatch { width: 1.7rem; height: 1.7rem; }

.gs-layer-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.4rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: grab;
  touch-action: none;
  /* transform transitions drive the smooth reorder slide; the dragged row turns
     it off so it tracks the pointer 1:1 (see .is-dragging). */
  transition: transform 160ms ease, background 140ms ease, border-color 140ms ease;
}
.gs-layer-row:hover { background: rgba(255, 255, 255, 0.06); }
.gs-layer-row.is-active { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.28); }
.gs-layer-row.is-dragging {
  transition: none;
  position: relative;
  z-index: 3;
  opacity: 0.97;
  cursor: grabbing;
  box-shadow: 0 0.6rem 1.4rem -0.3rem rgba(0, 0, 0, 0.55);
}

/* Swatch = the colour-picker grip. A tap opens the (hidden) native picker; a drag
   reorders. The real <input type=color> is kept in the DOM for its value/events
   but visually hidden and opened programmatically. */
.gs-layer-row__swatch {
  position: relative;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  /* Eyedropper cursor (Fluent-style, filled for contrast on any colour) → reads
     as "click to pick a colour"; falls back to pointer. */
  cursor: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3E%3Cpath%20d='M17%203.4a2.3%202.3%200%200%201%203.3%203.3l-2.1%202.1.7.7-1.4%201.4-.7-.7-6.9%206.9-3.3.9.9-3.3%206.9-6.9-.7-.7%201.4-1.4.7.7%202.1-2.1z'%20fill='rgb(255,255,255)'%20stroke='rgb(0,0,0)'%20stroke-width='1'%20stroke-linejoin='round'%20stroke-opacity='0.55'/%3E%3C/svg%3E") 5 19, pointer;
  overflow: hidden;
}
/* While actually dragging a row, force the grabbing cursor everywhere */
body.gs-reordering, body.gs-reordering * { cursor: grabbing !important; }
.gs-layer-row__color {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
}

/* Inline-editable hex: clean text by default, input affordance on hover/focus.
   Scoped to .gs-layer-panel so it out-specifies the global input[type=text] chrome
   (dark fill, border, 44px min-height) — the panel lives on <body>, outside
   .gradient-studio, so it inherits the site-wide form styles otherwise. */
.gs-layer-panel .gs-layer-row__hex {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 0;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.72rem;
  color: rgba(232, 240, 255, 0.9);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  padding: 0.15rem 0.35rem;
  cursor: text;
  transition: background 140ms ease, border-color 140ms ease;
}
.gs-layer-panel .gs-layer-row__hex:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
}
.gs-layer-panel .gs-layer-row__hex:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.35);
}

.gs-layer-panel .gs-layer-panel__add {
  min-height: 0;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem;
  border-radius: 0.5rem;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--font-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.gs-layer-panel .gs-layer-panel__add:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); color: #fff; }
.gs-layer-panel .gs-layer-panel__add:disabled { opacity: 0.35; cursor: default; }
.gs-layer-panel .gs-layer-row__del {
  min-width: 0;
  min-height: 0;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}
.gs-layer-panel .gs-layer-row__del:hover:not(:disabled) { background: rgba(255, 120, 120, 0.2); color: #fff; }
.gs-layer-panel .gs-layer-row__del:disabled { opacity: 0.3; cursor: default; }

.gs-layer-panel__hint {
  margin: 0.5rem 0 0;
  padding: 0 0.3rem;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
}
.gs-layer-panel__subhead {
  margin: 0.7rem 0 0.35rem;
  padding: 0 0.3rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}
.gs-layer-row--edge { cursor: pointer; }
.gs-layer-row--edgebg { cursor: default; }
/* Unset background = transparent: show a checker so the swatch reads as "none". */
.gs-layer-row--edgebg.is-transparent .gs-layer-row__swatch {
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.28) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.28) 75%) 0 0 / 0.6rem 0.6rem,
    linear-gradient(45deg, rgba(255, 255, 255, 0.28) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.28) 75%) 0.3rem 0.3rem / 0.6rem 0.6rem,
    rgba(0, 0, 0, 0.25);
}
body.gs-reordering { cursor: grabbing; }

/* ── Code: a side panel on desktop, a bottom sheet on mobile ─────────────────
   Lifted to <body>, fixed, above the header — so it has room and never fights
   the stage for space. */
/* The code output reuses the shared ContextMenu behaviour (open/close, anchored
   positioning, outside-click + Escape) but keeps its own dark-card styling.
   `.context-menu` already supplies position:absolute + the fade/slide on `.active`. */
.gs-code-menu.context-menu {
  width: min(30rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - var(--header-height, 70px) - 1.5rem);
  padding: 1.1rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 22, 0.92);
  -webkit-backdrop-filter: blur(36px) saturate(1.5);
  backdrop-filter: blur(36px) saturate(1.5);
  box-shadow: 0 1.5rem 4rem -1rem rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 1100;
}
/* The module sets inline display:block on the root, so the flex column lives on an
   inner wrapper. */
.gs-code-menu__inner {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
/* Re-scope the panel's controls so the component's generic `.context-menu button`
   reset (width:100%, background:none, list padding, …) can't flatten them. These
   are more specific than that rule, so our styling wins. */
.gs-code-menu button { width: auto; }
.gs-code-menu .gs-btn {
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}
.gs-code-menu .gs-btn--gradient {
  border: none;
  color: #fff;
  background: var(--gs-gradient, var(--accent-color-extractly));
}
.gs-code-menu .gs-btn--ghost {
  background: none;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.gs-code-menu .gs-codetab {
  padding: 0.3rem 0.55rem;
  background: none;
  color: rgba(255, 255, 255, 0.55);
}
.gs-code-menu .gs-codetab.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.gs-code-menu .gs-code-window__close {
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.gs-code-window__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.gs-code-window__close {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.gs-code-window__close:hover { background: rgba(255, 255, 255, 0.16); }
.gs-code-window__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.gs-code-window__code {
  width: 100%;
  flex: 1;
  min-height: 8rem;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.7rem;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(232, 240, 255, 0.95);
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 0.7rem 0.85rem;
}
.gs-code-window__code:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 0; }

.gs-code-window__foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.gs-code-window__note {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.55);
}
.gs-code-window__note[hidden] { display: none; }

/* Mesh image-format view: the rendered gradient + a direct download. */
.gs-code-preview {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: stretch;
}
.gs-code-preview[hidden] { display: none; }
.gs-code-preview__img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
}
.gs-code-preview__download { align-self: flex-start; }

/* Grid items default to min-width:auto, so the nowrap code line would force
   the column track wider than the dock and clip every row at the right edge.
   z-index:1 keeps controls above the glass sheen (::after, z-index:0). */
.gs-editor > * { min-width: 0; position: relative; z-index: 1; }

/* ── Full-bleed light stage ──────────────────────────────────────────────
   The whole hero IS the light. Layers stack inside .gs-hero:
   backdrop (shader/ambient, z-1) ▸ stage-light (--gs-gradient, z0) ▸
   compare (sRGB wipe, z1) ▸ scrim (legibility, z2) ▸ nodes (z4) ▸
   copy (z5) ▸ dock (z6). */
.gs-stage-light {
  position: absolute;
  inset: 0;
  z-index: 0;
  /* The composited layer stack: image list + per-layer blend modes over the
     bottom layer's base colour. */
  background-color: var(--gs-base, #080b14);
  background-image: var(--gs-gradient, linear-gradient(135deg in oklch, #36c9f0, #4e1cff));
  background-blend-mode: var(--gs-blend, normal);
  /* Cursor parallax: JS sets --gs-px/--gs-py. Overscale hides the edges. */
  transform: translate3d(calc(var(--gs-px, 0) * 1px), calc(var(--gs-py, 0) * 1px), 0) scale(1.06);
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* Real WebGL gradient stage: covers the CSS layer when the engine is live. */
.gs-stage-gl {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 320ms ease, transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
  transform: translate3d(calc(var(--gs-px, 0) * 1px), calc(var(--gs-py, 0) * 1px), 0) scale(1.06);
  will-change: transform;
  pointer-events: none;
}
.gs-stage-gl.is-live { opacity: 1; }

.gs-stage-compare {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--gs-gradient-srgb, linear-gradient(135deg, #36c9f0, #4e1cff));
  /* Simple swap on toggle — the toggle is enough, no scrub. */
  opacity: 0;
  transition: opacity 260ms ease;
  pointer-events: none;
}

.gs-hero.is-comparing .gs-stage-compare { opacity: 1; }

.gs-stage-nodes {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none; /* the nodes themselves opt back in */
}

/* Compare toggle: an inline pill in the control rail (not floating on a box) */
.gs-compare-toggle {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: var(--font-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: background 140ms ease;
}

.gs-compare-toggle:hover { background: color-mix(in oklab, var(--shade-500) 50%, transparent); }
.gs-compare-toggle:active { transform: scale(0.96); }

/* ── Stop bar ─────────────────────────────────────────────── */

/* Linear/radial/conic slider: a minimal floating bar near the toolbar, not a
   full-width strip across the top of the stage. */
.gs-stopbar {
  position: absolute;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  width: min(30rem, 86vw);
  height: 2rem;
  border-radius: 999px;
  background: var(--gs-gradient-bar, linear-gradient(90deg in oklch, #36c9f0, #4e1cff));
  box-shadow: 0 1rem 2.5rem -0.75rem rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  cursor: copy; /* hints "double-click adds a stop" */
  touch-action: none;
  pointer-events: auto;
}

/* Big, grabbable pucks. Centered purely with negative margins — NO transform —
   so nothing can move on hover/drag (the old levitation/shift bug). The only
   feedback is light: the ring brightens and the shadow deepens in place. */
.gs-stop-handle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1.6rem;
  height: 1.6rem;
  margin-top: -0.8rem;   /* half of height → vertical centre, no transform */
  margin-left: -0.8rem;  /* half of width  → centre on its position */
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  cursor: grab;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  padding: 0;
  /* Transparent ring of extra hit area: easy to grab without growing the box */
  outline: 0.5rem solid transparent;
}

/* Premium hover/active: brighter ring + soft halo, zero movement */
.gs-stop-handle:hover {
  border-color: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(255, 255, 255, 0.16);
}
.gs-stop-handle.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 2px 14px rgba(0, 0, 0, 0.5);
}
.gs-stop-handle.is-dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 3px #fff, 0 6px 22px rgba(0, 0, 0, 0.6);
}

/* ── Mesh: 2D color nodes you sculpt directly on the light ──────────────────
   In mesh mode the preview becomes a real canvas: a taller stage with color
   nodes you drag anywhere. The node layer overlays the preview and is
   pointer-transparent except on the nodes themselves, so the compare toggle
   underneath stays clickable. */

.gs-mesh-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  /* Catches clicks on empty canvas to add a swatch; the dock/toolset (higher z)
     stay clickable, and the copy layer is pointer-events:none. */
  pointer-events: auto;
}

.gs-mesh-node {
  position: absolute;
  width: 1.7rem;
  height: 1.7rem;
  margin-top: -0.85rem;  /* centre on (mx,my) with margins — never a transform */
  margin-left: -0.85rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  padding: 0;
  cursor: grab;
  pointer-events: auto;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  outline: 0.55rem solid transparent; /* generous hit area, no size change */
}

.gs-mesh-node:hover {
  border-color: #fff;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.6), 0 0 0 5px rgba(255, 255, 255, 0.16);
}
.gs-mesh-node.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 3px 16px rgba(0, 0, 0, 0.55);
}
.gs-mesh-node.is-dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 3px #fff, 0 8px 26px rgba(0, 0, 0, 0.65);
}

/* Mesh edge points: the locked rectangular boundary ring (Illustrator-style).
   Smaller than the draggable colour dots and pinned to the rectangle. Auto edges
   read faint (they're just the base tone); an overridden edge shows its colour. */
.gs-mesh-edge {
  position: absolute;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: -0.575rem;
  margin-left: -0.575rem;
  border-radius: 0.3rem; /* rounded square — distinct from the round colour dots */
  border: 2px solid #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.6), inset 0 0 0 1.5px rgba(0, 0, 0, 0.45);
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 120ms ease, border-color 160ms ease, box-shadow 160ms ease;
  outline: 0.7rem solid transparent; /* generous hit area, no size change */
}
.gs-mesh-edge:hover {
  border-color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.65), 0 0 0 5px rgba(255, 255, 255, 0.22),
    inset 0 0 0 1.5px rgba(0, 0, 0, 0.45);
}
/* Auto edges (still on the base tone) read as a hollow chip so they're visibly
   "unset" yet easy to find; an overridden edge fills with its colour. */
.gs-mesh-edge:not(.is-set) {
  background: rgba(20, 16, 28, 0.55) !important;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.gs-mesh-edge.is-set {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: -0.675rem;
  margin-left: -0.675rem;
}
.gs-mesh-edge.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 2px 12px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1.5px rgba(0, 0, 0, 0.45);
}

/* Mesh topology lines linking neighbouring nodes (Delaunay edges, behind pucks).
   Subtle at rest; they brighten while a node is being dragged (`.is-meshing`). */
.gs-mesh-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.gs-mesh-edges line {
  stroke: rgba(255, 255, 255, 0.32);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-dasharray: 1 6;
  transition: stroke 180ms ease, stroke-width 180ms ease, stroke-dasharray 180ms ease;
}
.gs-mesh-layer.is-meshing .gs-mesh-edges line {
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.75;
  stroke-dasharray: none;
}
/* Gradient-mesh GRID lines (curved row/column patch boundaries). Kept faint so
   they hint at the lattice without competing with the colour; they brighten
   gently only while a control point is being dragged. */
.gs-mesh-edges path {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 180ms ease, stroke-width 180ms ease;
}
.gs-mesh-layer.is-meshing .gs-mesh-edges path {
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 1.2;
}

/* Color readout chip: OKLCH + ΔE-to-nearest, for color pros (hover/focus) */
.gs-node-info {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  white-space: nowrap;
  padding: 0.4rem 0.6rem;
  border-radius: 0.55rem;
  background: rgba(8, 11, 17, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.62rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 6;
}
.gs-node-info b { font-size: 0.72rem; letter-spacing: 0.02em; }
.gs-node-info span { color: rgba(232, 240, 255, 0.72); }
.gs-mesh-node:hover .gs-node-info,
.gs-mesh-node:focus-visible .gs-node-info { opacity: 1; }

/* Resize ring on the active node: a faint circle (radius = size) + a drag knob */
.gs-node-ring {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
}
.gs-node-ring::before {
  content: '';
  position: absolute;
  width: calc(var(--ring-r, 5rem) * 2);
  height: calc(var(--ring-r, 5rem) * 2);
  margin-left: calc(var(--ring-r, 5rem) * -1);
  margin-top: calc(var(--ring-r, 5rem) * -1);
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.32);
}
.gradient-studio .gs-node-resize {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.95rem;
  height: 0.95rem;
  min-width: 0;
  min-height: 0;
  margin: -0.475rem;
  translate: var(--ring-r, 5rem) 0; /* sits on the ring's right edge */
  padding: 0;
  box-sizing: border-box;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(10, 14, 22, 0.6);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: none;
}
.gs-hero.gs-focus .gs-node-ring { display: none; }

/* Drag-to-delete bin: hidden until a node drag starts, then it floats in at the
   bottom-right of the stage. Arms (red) when a deletable color hovers it. */
.gs-trash {
  position: absolute;
  right: 1.4rem;
  bottom: 1.4rem;
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 1rem;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(8, 11, 17, 0.7);
  border: 1px dashed rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(0.6rem) scale(0.9);
  pointer-events: none; /* never intercepts; hit-testing is done in JS */
  transition: opacity 180ms ease, transform 180ms ease, background 160ms ease,
    border-color 160ms ease, color 160ms ease;
  z-index: 7;
}
.gs-trash.is-live {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.gs-trash.is-armed {
  color: #fff;
  background: rgba(220, 38, 38, 0.9);
  border-color: #fff;
  border-style: solid;
  transform: translateY(0) scale(1.12);
  box-shadow: 0 12px 36px rgba(220, 38, 38, 0.5);
}
/* Node being dragged toward the bin: warn it's about to be removed. */
.gs-mesh-node.is-trashing {
  border-color: rgba(255, 160, 160, 0.95);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.85), 0 8px 26px rgba(0, 0, 0, 0.65);
  opacity: 0.6;
}
.gs-hero.gs-focus .gs-trash { display: none; }
@media (prefers-reduced-motion: reduce) {
  .gs-trash { transition: opacity 120ms ease; transform: none; }
  .gs-trash.is-live, .gs-trash.is-armed { transform: none; }
}

/* X / Y position fields for the active node */
.gs-xy-field {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-secondary);
}
.gs-xy-field input[type="number"] { width: 3.2rem; }

/* Blob size slider for the active mesh node */
.gs-size-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-secondary);
}
.gs-size-field input[type="range"] { width: 5rem; accent-color: #fff; cursor: pointer; }

/* Z-order (front/back) buttons */
.gradient-studio .gs-z-btn {
  min-height: 0;
  height: 1.7rem;
  padding: 0 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: var(--font-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.gradient-studio .gs-z-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.gradient-studio .gs-z-btn:disabled { opacity: 0.4; cursor: default; }

/* ── On-stage geometry handles (linear angle / radial+conic origin) ──────────
   Rendered into the full-stage node layer; pointer-transparent except the
   handles. The orbit is a 0-size point at the origin that rotates to swing the
   angle puck around it on a 7rem arm. */
.gs-geo { position: absolute; inset: 0; z-index: 4; pointer-events: none; }

.gs-geo-orbit { position: absolute; width: 0; height: 0; }

.gs-geo-arm {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 7rem;
  margin-left: -1px;
  translate: 0 -7rem;
  border-radius: 2px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.12));
  pointer-events: none;
}

.gradient-studio .gs-geo-handle {
  position: absolute;
  min-width: 0;
  min-height: 0;
  width: 1.5rem;
  height: 1.5rem;
  aspect-ratio: 1;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(10, 14, 22, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  cursor: grab;
  pointer-events: auto;
  line-height: 0;
  touch-action: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.gradient-studio .gs-geo-handle:hover { box-shadow: 0 2px 14px rgba(0, 0, 0, 0.6), 0 0 0 5px rgba(255, 255, 255, 0.16); }
.gradient-studio .gs-geo-handle:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.gradient-studio .gs-geo-handle.is-dragging { cursor: grabbing; box-shadow: 0 0 0 3px #fff, 0 8px 26px rgba(0, 0, 0, 0.65); }

/* Angle puck sits at the end of the arm (7rem up in the orbit's local frame) */
.gradient-studio .gs-geo-handle--angle { left: 0; top: 0; margin: -0.75rem; translate: 0 -7rem; }
/* Origin puck centres on the center%; a crosshair dot marks the exact point */
.gradient-studio .gs-geo-handle--center { margin-left: -0.75rem; margin-top: -0.75rem; }
.gradient-studio .gs-geo-handle--center::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: #fff;
}

/* Reserve the active-stop detail row's height up front so selecting or
   dragging a stop never grows the dock (the old layout shift). */
.gs-stop-detail-slot { min-height: 2.4rem; }
/* Toolbar detail row moved to the colour panel → collapse when empty */
.gs-stop-detail-slot:empty { min-height: 0; }

.gs-stop-detail {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.gs-stop-detail input[type="color"] {
  inline-size: 2.1rem;
  block-size: 2.1rem;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 0;
  background: none;
  cursor: pointer;
}

.gs-stop-detail input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.gs-stop-detail input[type="color"]::-webkit-color-swatch { border: 1px solid var(--color-border); border-radius: var(--border-radius-sm); }

.gs-stop-detail input[type="text"],
.gs-stop-detail input[type="number"] {
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.82rem;
  color: var(--color-text-primary);
  background: color-mix(in oklab, var(--color-bg-muted) 70%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 0.4rem 0.55rem;
}

.gs-stop-detail input[type="text"] { width: 5.8rem; }
.gs-stop-detail input[type="number"] { width: 4rem; }

.gs-stop-detail .gs-stop-remove,
.gs-add-stop {
  border: none;
  background: none;
  color: var(--color-text-secondary);
  font-family: var(--font-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: var(--border-radius-sm);
  transition: color 140ms ease, background 140ms ease;
}

.gs-add-stop:hover { color: var(--color-text-primary); background: var(--color-bg-hover); }
.gs-stop-detail .gs-stop-remove { margin-left: auto; }
.gs-stop-detail .gs-stop-remove:hover { color: var(--color-danger); background: var(--accent-red-bg); }

/* ── Controls row ─────────────────────────────────────────── */

.gs-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.gs-control--type,
.gs-control--space,
.gs-tools {
  display: inline-flex;
  background: color-mix(in oklab, var(--color-bg-muted) 70%, transparent);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

/* Icon actions live in the same segmented well as the mode/space controls, so the
   whole bar speaks one language instead of mixing wells with floating circles. */
.gs-seg--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  width: auto;
  color: var(--color-text-secondary);
}
.gs-seg--icon svg { display: block; }
.gs-seg--icon:hover {
  background: color-mix(in oklab, var(--color-text-primary) 8%, transparent);
  color: #fff;
}

.gs-seg {
  border: none;
  background: none;
  font-family: var(--font-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.gs-seg.active {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  box-shadow: 0 1px 4px var(--color-shadow);
}

.gs-control--angle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.gs-angle-dial {
  position: relative;
  width: 2.75rem; /* 44px: minimum comfortable touch target */
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--color-border-strong);
  background: color-mix(in oklab, var(--color-bg-muted) 70%, transparent);
  cursor: grab;
  touch-action: none;
  padding: 0;
}

.gs-angle-dial:active { cursor: grabbing; }

.gs-angle-dial__needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 44%;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 2px;
  transform-origin: 50% 0%;
  transform: translateX(-50%) rotate(var(--gs-angle, 135deg));
}

.gs-angle-label {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.gs-angle-label input {
  width: 3.4rem;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.82rem;
  color: var(--color-text-primary);
  background: color-mix(in oklab, var(--color-bg-muted) 70%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 0.35rem 0.45rem;
}

/* Angle is irrelevant for mesh + radial → hide it entirely to keep the bar minimal */
.gs-hero.is-angleless .gs-control--angle { display: none; }

/* ── Action buttons ───────────────────────────────────────── */

.gs-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.gs-actions__spacer { flex: 1; }

.gs-btn {
  font-family: var(--font-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, color 140ms ease;
}
/* The button's own display rule outranks the [hidden] attribute, so make hiding explicit. */
.gs-btn[hidden] { display: none; }

.gs-btn:hover { box-shadow: 0 6px 18px var(--color-shadow); filter: brightness(1.08); }
.gs-btn:active { filter: brightness(0.96); }

.gs-btn--ghost {
  background: none;
  border-color: color-mix(in oklab, var(--color-text-primary) 18%, transparent);
}

.gs-btn--primary {
  background: var(--accent-color-extractly);
  border-color: transparent;
  color: #fff;
}

.gs-btn--icon {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border-radius: 50%;
}

.gs-btn--save { color: var(--accent-color-extractly); }
.gs-btn--save svg { transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1); }
.gs-btn--save.is-saved svg { transform: scale(1.3); }

/* The main CTA wears the user's gradient */
.gs-btn--gradient {
  position: relative;
  border: none;
  color: #fff;
  font-weight: 600;
  background: var(--gs-gradient, var(--accent-color-extractly));
  /* The inset overlay guarantees text contrast on ANY user gradient */
  box-shadow: inset 0 0 0 100vmax rgba(8, 11, 17, 0.42), 0 4px 14px var(--color-shadow);
  text-shadow: 0 1px 6px rgba(8, 11, 17, 0.55);
}

.gs-btn--gradient:hover { box-shadow: inset 0 0 0 100vmax rgba(8, 11, 17, 0.3), 0 8px 22px var(--color-shadow); }

.gs-btn--gradient.is-copied,
.gs-output__copy.is-copied { box-shadow: inset 0 0 0 100vmax rgba(8, 11, 17, 0.05); }

/* ── Always-visible code line (the job-to-be-done) ────────── */

.gs-codeline {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-md);
  padding: 0.4rem 0.4rem 0.4rem 0.5rem;
}

.gs-codeline__tabs {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
}

.gs-codetab {
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  box-shadow: none;
  transition: background 140ms ease, color 140ms ease;
}

.gs-codetab:hover { color: #fff; }
.gs-codetab.active { background: rgba(255, 255, 255, 0.14); color: #fff; }

.gs-codeline__code {
  flex: 1;
  min-width: 0;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.76rem;
  color: rgba(232, 240, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-codeline__copy {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
}

/* Headline fades out while sculpting so the light owns the stage. */
.gs-hero__copy {
  transition: opacity 450ms cubic-bezier(0.22, 1, 0.36, 1);
}
.gs-hero.is-engaged .gs-hero__copy { opacity: 0; }

/* ── Starter chips + trust line under the dock ────────────── */

.gs-starters {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  justify-content: center;
  position: relative;
  z-index: 6; /* above the full-stage node layer */
}

.gs-starters__label {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  margin-right: 0.2rem;
}

/* High specificity + aspect-ratio: global button min-heights otherwise
   stretch these into ovals (same bleed as the dock controls) */
.gradient-studio .gs-starter {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: var(--card-gradient);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 14px rgba(8, 11, 17, 0.25);
  transition: box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* No levitation: the chip's ring brightens in place. */
.gradient-studio .gs-starter:hover,
.gradient-studio .gs-starter:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.gs-trustline {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.78);
  position: relative;
  z-index: 6;
}

.gs-trustline a {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Output drawer ────────────────────────────────────────── */

.gs-output { display: grid; gap: var(--space-xs); overflow: hidden; }
.gs-output[hidden] { display: none; }

.gs-output__block {
  background: var(--shade-500, #080b11);
  color: var(--shade-000, #f9f9f9);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.gs-output__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.8rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gs-output__copy {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease;
}

.gs-output__copy:hover { background: rgba(255, 255, 255, 0.22); }

.gs-code {
  margin: 0;
  padding: 0.8rem;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Your Inspirations rail ───────────────────────────────── */

/* Ambient color washes keep the dark sections alive instead of flat black */
.gs-rail {
  padding-block: var(--space-xxl);
  background: radial-gradient(56rem 28rem at 8% 0%, color-mix(in oklab, var(--accent-color-extractly) 9%, transparent), transparent 70%);
}

.gs-rail__track {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-block: var(--space-xs) var(--space-sm);
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

/* The Saved section stays hidden until the first save (JS removes [hidden]) */
.gs-rail[hidden] { display: none; }

.gs-rail__item {
  position: relative;
  flex: 0 0 12rem;
  scroll-snap-align: start;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.gs-rail__swatch {
  display: block;
  width: 100%;
  height: 6.5rem;
  border: none;
  cursor: pointer;
  background: var(--card-gradient);
  transition: filter 160ms ease;
}

.gs-rail__swatch:hover { filter: saturate(1.2) brightness(1.04); }

.gs-rail__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.gs-rail__delete {
  border: none;
  background: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
}

.gs-rail__delete:hover { color: var(--color-danger); background: var(--accent-red-bg); }

.gs-rail__nudge {
  max-width: 34rem;
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: color-mix(in oklab, var(--accent-color-extractly) 8%, var(--color-bg-elevated));
  border: 1px solid color-mix(in oklab, var(--accent-color-extractly) 30%, transparent);
  border-radius: var(--border-radius-lg);
}

.gs-rail__nudge p { margin: 0 0 var(--space-xs); line-height: 1.55; }

.gs-rail__nudge-actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; }

/* ── Curated grid ─────────────────────────────────────────── */

.gs-curated {
  padding-block: var(--space-xxl);
  background: radial-gradient(64rem 32rem at 92% 4%, color-mix(in oklab, var(--accent-blue) 7%, transparent), transparent 72%);
}

.gs-curated__grid {
  display: grid;
  /* 4 fixed columns on desktop: bigger tiles, and ramps stretch the full row.
     Narrower viewports fall back to an auto-fill flow. */
  grid-template-columns: repeat(4, 1fr);
  grid-auto-flow: dense; /* 2-col ramps must not leave holes beside 1-col cards */
  gap: var(--space-sm);
  /* Shared vanishing point so neighbouring cards tilt as one coherent plane */
  perspective: 1100px;
}
@media (max-width: 64rem) {
  .gs-curated__grid { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
}

/* Card = gradient swatch + a real-text caption (names and hex values are
   content, not decoration: visible, selectable, crawlable) */
.gs-card {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  background: var(--color-bg-elevated);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  text-align: left;
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gs-card__swatch {
  display: block;
  position: relative; /* hosts the breakdown overlay */
  width: 100%;
  flex: 1;
  min-height: 7rem;
  background: var(--card-gradient);
  transition: filter 200ms ease;
}

.gs-card:hover .gs-card__swatch { filter: saturate(1.18) brightness(1.03); }

.gs-card__caption {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  padding: 0.55rem 0.75rem;
  min-width: 0;
}

.gs-card__name {
  font-family: var(--font-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-card__hex {
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The first gradient gets editorial weight */
@media (min-width: 48rem) {
  .gs-card--featured { grid-column: span 2; grid-row: span 2; }
  .gs-card--featured .gs-card__name { font-size: 1rem; }
}

/* Staggered cascade riding on the site's .section-appear reveal: each card
   waits (--i * 35ms) once the section becomes visible. CSS only, no JS. */
.gs-curated.section-appear .gs-card {
  opacity: 0;
  translate: 0 16px;
}

.gs-curated.section-appear.section-visible .gs-card {
  opacity: 1;
  translate: 0 0;
  transition:
    opacity 520ms ease calc(var(--i, 0) * 38ms),
    translate 620ms cubic-bezier(0.22, 1, 0.36, 1) calc(var(--i, 0) * 38ms),
    border-color 300ms ease,
    box-shadow 300ms ease,
    filter 300ms ease;
}

/* No lift. The card brightens and its border catches light in place.
   transform: none cancels the global :is(button):hover move (it's a <button>). */
.gs-card:hover,
.gs-card:focus-visible {
  transform: none;
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.gs-card:active {
  transform: none;
}

.gs-card:focus-visible {
  outline: 3px solid var(--accent-color-extractly);
  outline-offset: 3px;
}

/* ── Swatch ramps: curated hue ramps + your saved library ────────────────── */
/* The Color Extractly model (tools/ramp-strategy-demo.html): a swatch is a named
   HUE RAMP — a horizontal strip of cells with the hex under each. Cells are
   click-to-copy buttons built by modules/swatches.js. Ramps share the curated
   grid with the gradient cards and span two of its columns. */
/* Ramps span two of the four columns — two ramps per row. */
.gs-curated__grid .gs-ramp { grid-column: span 2; }
/* Both card types have their own display, which outranks [hidden] — the filter
   chips rely on it, so make hiding explicit. */
.gs-card[hidden],
.gs-ramp[hidden] { display: none; }

/* Filter chips: the same segmented-well language as the editor's controls. */
.gs-filter {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: var(--space-sm);
  background: color-mix(in oklab, var(--color-bg-muted) 70%, transparent);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}
.gs-filter__chip {
  border: none;
  background: none;
  font-family: var(--font-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.gs-filter__chip.active {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  box-shadow: 0 1px 4px var(--color-shadow);
}

/* Library sub-blocks (saved gradients / saved colour ramps in one section). */
.gs-lib-block { margin-bottom: var(--space-md); }
.gs-lib-block[hidden] { display: none; }
.gs-lib-subhead {
  font-family: var(--font-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin: 0 0 0.6rem;
}

/* Both card types are <gs-color-card class="gs-card"> with one anatomy:
   [colour media (.gs-card__swatch)] → [caption]. Ramps add .gs-ramp and use the
   cells strip as their media; gradients overlay a breakdown bar on theirs. */

/* Gradient cards: hard-stop breakdown of the used colours (plugin-style),
   laid over the bottom edge of the gradient media. */
.gs-card__stops {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0.85rem;
}

/* The caption hosts the ramp's action (save/remove) on its right edge. */
.gs-card__caption { position: relative; }
.gs-ramp .gs-card__caption { padding-right: 5.4rem; /* room for the action */ }

.gs-ramp__save,
.gs-ramp__del {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  min-height: 0;
  height: 1.6rem;
  padding: 0 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-text-secondary);
  font-family: var(--font-secondary);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.gs-ramp__del { width: 1.6rem; padding: 0; font-size: 0.95rem; line-height: 1; }
.gs-ramp__save:hover,
.gs-ramp__del:hover {
  color: var(--color-text-primary);
  border-color: rgba(255, 255, 255, 0.3);
}
.gs-ramp__save.is-copied {
  color: #fff;
  border-color: var(--accent-color-extractly);
  background: var(--accent-color-extractly);
}

/* The strip is the ramp card's media. It IS a .gs-card__swatch (same sizing as
   the gradient media, so heights align by construction); the flex override lets
   the cells fill it — the demo's .ramp pattern, flush to the card edges. */
.gs-ramp__strip { display: flex; }
.gs-ramp__cells {
  display: flex;
  flex: 1;
  width: 100%;
}
.gs-ramp__cell {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: filter 160ms ease;
}
.gs-ramp__cell:hover { filter: saturate(1.15) brightness(1.08); }
.gs-ramp__cell.is-copied { filter: brightness(1.2); }
.gs-ramp__cell:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.gs-ramp__hex {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

.gs-swatch-save { margin-top: var(--space-sm); }

.gs-swatch-lib__track {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: var(--space-sm);
}

/* ── Bridge section ───────────────────────────────────────── */

.gs-bridge {
  padding: var(--space-xxl) var(--space-md);
}

/* Gradient-border panel: the section's content sits in a glowing card */
.gs-bridge__inner {
  max-width: 44rem;
  margin-inline: auto;
  text-align: center;
  padding: var(--space-xl) clamp(var(--space-md), 5vw, var(--space-xl));
  border-radius: calc(var(--border-radius-lg) + 10px);
  border: 1px solid transparent;
  background:
    linear-gradient(color-mix(in oklab, var(--color-bg-elevated) 55%, var(--color-bg)), color-mix(in oklab, var(--color-bg-elevated) 35%, var(--color-bg))) padding-box,
    linear-gradient(135deg, color-mix(in oklab, var(--accent-color-extractly) 55%, transparent), transparent 38%, color-mix(in oklab, var(--accent-blue) 40%, transparent)) border-box;
  box-shadow: 0 24px 70px color-mix(in oklab, var(--accent-color-extractly) 10%, transparent);
}

.gs-bridge__inner p { color: var(--color-text-secondary); line-height: 1.65; }

.gs-bridge__actions {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* ── FAQ ──────────────────────────────────────────────────── */

.gs-faq {
  max-width: 42rem;
  margin-inline: auto;
  padding: var(--space-xxl) var(--space-md);
}

/* Override site-wide <details> box styling: quiet dividers, readable Geist */
.gradient-studio .gs-faq__item {
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  margin: 0;
  padding: var(--space-sm) 0;
  box-shadow: none;
}

.gradient-studio .gs-faq__item summary {
  cursor: pointer;
  font-family: var(--font-secondary);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text-primary);
  list-style-position: outside;
  padding: 0;
  background: none;
  border: none;
}

.gradient-studio .gs-faq__item summary:hover { color: var(--accent-color-extractly); }

.gs-faq__item p {
  color: var(--color-text-secondary);
  line-height: 1.65;
  margin-bottom: 0;
}

/* ── Neutralize site-global button chrome inside the dock ─────────────────
   The global stylesheet gives <button> borders, min-heights, and shadows
   (handles rendered as stretched ovals, segs got double rings). These
   high-specificity resets restore the dock's own geometry. */

.gradient-studio .gs-editor .gs-seg,
.gradient-studio .gs-editor .gs-add-stop,
.gradient-studio .gs-editor .gs-stop-remove,
.gradient-studio .gs-editor .gs-angle-dial,
.gradient-studio .gs-editor .gs-compare-toggle {
  min-width: 0;
  min-height: 0;
  box-shadow: none;
  line-height: 1.2;
}

/* Pucks/nodes: reset global chrome but KEEP their own ring shadow (set via the
   high-specificity rules below so they win the cascade). */
.gradient-studio .gs-mesh-node {
  min-width: 0;
  min-height: 0;
  padding: 0;
  width: 1.7rem;
  height: 1.7rem;
  aspect-ratio: 1;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  line-height: 0;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}
.gradient-studio .gs-mesh-node.is-active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 3px 16px rgba(0, 0, 0, 0.55);
}
.gradient-studio .gs-mesh-node.is-dragging {
  box-shadow: 0 0 0 3px #fff, 0 8px 26px rgba(0, 0, 0, 0.65);
}

.gradient-studio .gs-editor .gs-seg { border: 0; background: none; }
.gradient-studio .gs-editor .gs-seg.active { background: rgba(255, 255, 255, 0.16); }

.gradient-studio .gs-editor .gs-stop-handle {
  padding: 0;
  /* min-height:0 + aspect-ratio:1 stop the global button min-height from
     stretching the puck into an oval inside the stripe. */
  min-width: 0;
  min-height: 0;
  width: 1.6rem;
  height: 1.6rem;
  aspect-ratio: 1;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  line-height: 0;
  /* Dragging must never start a scroll or native drag */
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}
.gradient-studio .gs-editor .gs-stop-handle.is-active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 2px 14px rgba(0, 0, 0, 0.5);
}

.gradient-studio .gs-editor .gs-add-stop {
  border: 1px dashed rgba(255, 255, 255, 0.22);
  padding: 0.35rem 0.6rem;
}

.gradient-studio .gs-editor .gs-angle-dial {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
}

/* ── Dark-dock control surfaces ───────────────────────────────────────────
   The editor card is always dark (it floats on the bright gradient), so its
   inner controls use white-translucent surfaces instead of theme tokens.
   Scoped under .gs-editor so they win over the base control styles. */

.gs-editor .gs-control--type,
.gs-editor .gs-control--space {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.gs-editor .gs-seg { color: rgba(255, 255, 255, 0.62); }

.gs-editor .gs-seg.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: none;
}

.gs-editor .gs-seg:hover:not(.active) { color: #fff; }

.gs-editor .gs-angle-dial {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}

.gs-editor .gs-angle-label { color: rgba(255, 255, 255, 0.6); }

.gs-editor .gs-angle-label input,
.gs-editor .gs-stop-detail input[type="text"],
.gs-editor .gs-stop-detail input[type="number"] {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.gs-editor .gs-add-stop,
.gs-editor .gs-stop-detail .gs-stop-remove { color: rgba(255, 255, 255, 0.6); }
.gs-editor .gs-add-stop {
  border: 1px dashed rgba(255, 255, 255, 0.22);
}
.gs-editor .gs-add-stop:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.gs-editor .gs-btn--ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.gs-editor .gs-btn--ghost:hover { background: rgba(255, 255, 255, 0.08); }

.gs-editor .gs-btn--icon {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}
.gs-editor .gs-btn--save { color: #fff; }
.gs-editor .gs-btn--save svg { color: rgba(255, 255, 255, 0.9); }

/* Flying save swatch (GSAP moves it; this defines its look) */
.gs-fly-swatch {
  position: fixed;
  z-index: 1300;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.gs-noscript { color: var(--color-warning); }

/* ── Short viewports: compress the hero so the whole tool fits ── */

@media (max-height: 800px) {
  .gs-hero {
    gap: var(--space-sm);
    padding-top: calc(var(--space-sm) + 3.25rem);
  }

  .gs-title { font-size: clamp(1.9rem, 1.2rem + 3vw, 3rem); }
  .gs-subtitle { font-size: 0.95rem; }
  .gs-eyebrow { margin-bottom: var(--space-xs); padding: 0.35rem 0.85rem; }

  .gs-preview,
  .gs-preview__compare { height: clamp(5.5rem, 14vh, 8rem); }

  .gs-editor { padding: var(--space-sm); gap: var(--space-xs); }
}

/* ── Keyboard focus: every dock control needs a visible ring ──
   The cards/starters already had :focus-visible; the dock controls (on the
   dark glass) did not, leaving keyboard users with no focus indicator. */
.gs-editor .gs-seg:focus-visible,
.gs-editor .gs-codetab:focus-visible,
.gs-editor .gs-compare-toggle:focus-visible,
.gs-editor .gs-angle-dial:focus-visible,
.gs-editor .gs-stop-handle:focus-visible,
.gs-editor .gs-add-stop:focus-visible,
.gs-editor .gs-stop-remove:focus-visible,
.gs-editor .gs-btn:focus-visible,
.gs-editor input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.gs-editor .gs-stop-handle:focus-visible {
  outline-offset: 3px;
  scale: 1.2;
}

/* Visually-hidden but available to screen readers (live status region) */
.gs-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Motion safety ────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .gradient-studio *,
  .gradient-studio *::before,
  .gradient-studio *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .gs-hero__backdrop { animation: none; }
}

@media (max-width: 40rem) {
  .gs-actions__spacer { display: none; }
  .gs-actions { justify-content: center; }
}

/* ── Extract-from-image panel ─────────────────────────────────────────────
   Drop an image, pull dominant colors, use them as stops. Mirrors the layer
   panel's glass styling but centred (it is a focused task, not a side rail). */
.gs-extract {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  width: min(40rem, calc(100vw - 2rem));
  max-height: 90svh;
  overflow-y: auto;
  padding: 1rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 22, 0.74);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
  backdrop-filter: blur(26px) saturate(1.4);
  box-shadow: 0 2rem 5rem -1rem rgba(0, 0, 0, 0.7);
}
.gs-extract[hidden] { display: none; }
.gs-extract.is-busy { cursor: progress; }

.gs-extract__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.gs-extract__title {
  font-family: var(--font-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.gs-extract__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 0.4rem;
}
.gs-extract__close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

/* Drop zone */
.gs-extract__drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.7rem 1rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.gs-extract__drop:hover { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.06); }
.gs-extract__drop.is-over {
  border-color: #fff;
  border-style: solid;
  background: rgba(54, 201, 240, 0.14);
  transform: scale(1.02);
}
.gs-extract__drop.is-hidden { display: none; }
.gs-extract__drop svg { color: rgba(255, 255, 255, 0.7); }
.gs-extract__drop-text { font-size: 0.85rem; font-weight: 600; }
.gs-extract__hint { font-size: 0.7rem; color: rgba(255, 255, 255, 0.5); }

/* Result */
.gs-extract__result[hidden] { display: none; }

/* Interactive image stage: hosts the <img>, the sampling-dot overlay, the
   click/pan layer and the dots. The module positions the image absolutely. */
.gs-extract__stage {
  position: relative;
  width: 100%;
  height: min(52svh, 24rem);
  border-radius: 0.85rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  touch-action: none;
}
.gs-extract__stage img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.gs-extract__bar {
  margin: 0.7rem 0 0.55rem;
  min-height: 1.75rem;
}

.gs-extract__tip {
  margin: 0 0 0.85rem;
  font-size: 0.7rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.5);
}

/* ── Sampling dots (ported from Color Extractly) ─────────────────────────── */
.sampling-dots-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.sampling-dots-click-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  cursor: crosshair;
  z-index: 1;
}
.sampling-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--dot-border, #fff);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto;
  transition: width .2s ease, height .2s ease, background-color .2s, box-shadow .2s, border-width .2s, border-color .2s,
              opacity .25s cubic-bezier(.4, 0, .2, 1), filter .25s cubic-bezier(.4, 0, .2, 1), transform .25s cubic-bezier(.4, 0, .2, 1);
  will-change: left, top;
  z-index: 3;
}
.sampling-dot:hover {
  width: 50px;
  height: 50px;
  background-color: transparent !important;
  border-width: 8px;
  border-color: var(--dot-color, #fff);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 10px rgba(0, 0, 0, 0.3);
}
.sampling-dot.dragging {
  width: 54px;
  height: 54px;
  cursor: grabbing;
  background-color: transparent !important;
  border-width: 8px;
  border-color: var(--dot-color, #fff);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 4;
}
.sampling-dot.pulse { animation: dotPulse .6s ease-out; }
.sampling-dot.glow-bounce { animation: dotGlowBounce 1s ease-in-out; }
.sampling-dot.dot-faded {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.55);
  filter: blur(2px);
}
@keyframes dotPulse {
  0%   { transform: translate(-50%, -50%) scale(1); }
  40%  { transform: translate(-50%, -50%) scale(1.35); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes dotGlowBounce {
  0%   { transform: translate(-50%, -50%) scale(1);   box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .3); }
  20%  { transform: translate(-50%, -50%) scale(1.5); box-shadow: 0 0 12px 4px var(--dot-color, #fff), 0 0 0 1px rgba(0, 0, 0, .35); }
  50%  { transform: translate(-50%, -50%) scale(0.9); box-shadow: 0 0 6px 2px var(--dot-color, #fff), 0 0 0 1px rgba(0, 0, 0, .35); }
  75%  { transform: translate(-50%, -50%) scale(1.15); box-shadow: 0 0 8px 3px var(--dot-color, #fff), 0 0 0 1px rgba(0, 0, 0, .35); }
  100% { transform: translate(-50%, -50%) scale(1);   box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .3); }
}

/* Color bar: reorderable stripes, one per dot */
.sampling-color-bar {
  position: relative;
  display: flex;
  height: 28px;
  z-index: 5;
  pointer-events: auto;
  overflow: visible;
  border-radius: 0.5rem;
}
.sampling-color-bar__stripe {
  flex: 1;
  cursor: grab;
  position: relative;
  min-width: 18px;
  background: transparent;
  transition: background-color .25s, opacity .16s ease, transform .16s ease;
  will-change: transform;
}
.sampling-color-bar.reordering .sampling-color-bar__stripe { border-radius: 6px; }
.sampling-color-bar__stripe.dragging {
  cursor: grabbing;
  z-index: 6;
  animation: samplingChipWobble .68s ease-in-out infinite;
  transition: none;
}
.sampling-color-bar__stripe:first-child { border-radius: 0.5rem 0 0 0.5rem; }
.sampling-color-bar__stripe:last-child  { border-radius: 0 0.5rem 0.5rem 0; }
.sampling-color-bar__stripe::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  background: var(--sampling-swatch-bg, transparent);
  transform: scaleY(1);
  transform-origin: bottom center;
  transition: transform .16s ease, border-radius .16s ease;
  border-radius: inherit;
}
.sampling-color-bar__stripe:hover::before {
  transform: scaleY(1.5);
  border-radius: 6px 6px 0 0;
}
.sampling-color-bar__hex {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 4px)) scale(.98);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
  font-size: 9px;
  line-height: 1;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--sampling-hex-fg, #fff);
  transition: opacity .16s ease, transform .16s ease;
}
.sampling-color-bar__stripe:hover .sampling-color-bar__hex,
.sampling-color-bar__stripe:focus-visible .sampling-color-bar__hex,
.sampling-color-bar.reordering .sampling-color-bar__stripe .sampling-color-bar__hex {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.sampling-color-bar__drag-handle {
  position: absolute;
  inset: 0;
  cursor: grab;
  z-index: 6;
  background: transparent;
  touch-action: none;
}
.sampling-color-bar__stripe.dragging .sampling-color-bar__drag-handle { cursor: grabbing; }
@keyframes samplingChipWobble {
  0%, 100% { rotate: -.7deg; }
  50% { rotate: .7deg; }
}

.gs-extract__count {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 0.9rem;
}
.gs-extract__count input[type="range"] { flex: 1; }
.gs-extract__count output { min-width: 1.2rem; text-align: right; font-variant-numeric: tabular-nums; }

.gs-extract__actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}
.gs-extract__actions .gs-btn[disabled] { opacity: 0.45; pointer-events: none; }

body.gs-focus .gs-extract { display: none; }
@media (prefers-reduced-motion: reduce) {
  .gs-extract__drop, .gs-extract__drop.is-over { transition: none; transform: none; }
}
