/* ── 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: the page's ink, so the only colour on the
   stage is the user's gradient. */
.gs-editor-actions .gs-code-open {
  border: none;
  color: #0a0e16;
  font-weight: 600;
  padding: 0.5rem 1.15rem;
  background: var(--color-text-primary);
  box-shadow: 0 4px 14px var(--color-shadow);
}
.gs-editor-actions .gs-code-open:hover { background: #fff; }

.gs-tool--save.is-saved { color: var(--color-text-primary); }
.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); }

/* 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; }


/* 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 > :not(.gs-sr-only) { min-width: 0; position: relative; z-index: 1; }

/* ── Stop bar ─────────────────────────────────────────────── */

/* 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;
}
/* Hit area: a transparent pseudo-element (outlines are never hit-tested). */
.gs-stop-handle::before {
  content: '';
  position: absolute;
  inset: -0.6rem;
  border-radius: 50%;
}

/* 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);
}

/* 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; }

/* ── 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));
}

/* Angle is irrelevant for mesh + radial → hide it entirely to keep the bar minimal */
.gs-hero.is-angleless .gs-control--angle { display: none; }

/* ── 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;
}


.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); }

/* ── 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;
}

/* Phone: the color list opens as a sheet from here (hidden on wider screens,
   where the panel is always docked beside the stage). */
.gradient-studio .gs-editor .gs-colors-toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-weight: 600;
}
.gs-colors-toggle__dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--gs-gradient-bar);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.gs-colors-toggle__count {
  min-width: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

/* The code window lives on <body> and the color panel beside the dock, so the
   dock's focus rule above does not reach their controls. */
.gs-code-menu button:focus-visible,
.gs-layer-panel :is(button, input[type="text"]):focus-visible,
.gradient-studio .gs-editor .gs-colors-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
