/* ============================================================
   Hueflow — components
   ============================================================ */

/* ---------------- nav ---------------- */

.nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 26px;
  border-bottom: 1px solid var(--edge);
  background: rgba(8, 9, 11, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: grid;
  grid-template-columns: 13px 13px;
  gap: 3px;
}
.brand-mark span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
}
.brand-mark span:nth-child(1) { background: #3a7fff; }
.brand-mark span:nth-child(2) { background: #ff6b6b; }
.brand-mark span:nth-child(3) { background: #00d4a6; }
.brand-mark span:nth-child(4) { background: #ffd7a0; }

.brand-name {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.is-active { color: var(--text); background: var(--panel-2); }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
  background: var(--face-accent);
  border: 1px solid var(--edge);
  box-shadow: var(--raise-accent);
  cursor: default;
}

/* ---------------- buttons ---------------- */

/* RAISED — gradient face, near-black border, drop shadow + top highlight */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 20px;
  border-radius: var(--r-md);
  background: var(--face);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
  color: var(--text);
  font-weight: 500;
  font-size: 14.5px;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
/* press flips the shadow inward — that is what makes a click feel physical */
.btn:active { box-shadow: var(--press); }
.btn:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
  box-shadow: var(--raise);
}

/* the accent uses the identical recipe, only different stops */
.btn-primary {
  background: var(--face-accent);
  border: 1px solid var(--edge);
  color: #fff;
  box-shadow: var(--raise-accent);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { box-shadow: var(--press); }

/* a toggle that is currently off */
.btn.is-off { color: var(--text-3); }
.btn.is-off .i { opacity: 0.65; }

.btn-ghost {
  background: var(--panel-2);
  border-color: var(--line);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: var(--face);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
}
.icon-btn:hover { color: var(--text); filter: brightness(1.15); }
.icon-btn:active { box-shadow: var(--press); }

/* an icon-only button carrying the primary accent treatment */
.icon-btn.is-primary {
  background: var(--face-accent);
  border: 1px solid var(--edge);
  color: #fff;
  box-shadow: var(--raise-accent);
}
.icon-btn.is-primary:hover { filter: brightness(1.08); color: #fff; }

/* ---------------- mode row ---------------- */

/* both toolbars sit on their own card surface */
.mode-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--stroke);
  border-radius: var(--r-xl);
}

/* No active state: these are actions, not a mode you sit in. */
.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  isolation: isolate;
  padding: 11px 18px;
  border-radius: var(--r-md);
  background: var(--face);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
}
.mode-btn:hover { filter: brightness(1.15); }
.mode-btn:hover .i { color: #fff; }
.mode-btn:active { box-shadow: var(--press); }

/* The confirmation flash is an accent layer that fades over the button face.
   Cross-fading the two gradients directly interpolated in visible steps —
   animating one overlay's opacity is what makes it read as smooth. The -1
   keeps it above the button's own face but under its label. */
.mode-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--face-accent);
  opacity: 0;
  pointer-events: none;
}

/* momentary confirmation — see the mode-confirm keyframes in animations.css */
.mode-btn .i { color: var(--text-2); }

/* ---------------- swatch row ---------------- */

.swatch-row {
  display: flex;
  gap: 0;
  align-items: stretch;
  min-height: 310px;
  /* absorbs whatever the collapsed editor gives back */
  flex: 1 1 auto;
  /* the strip owns its rounded corners, so they hold in every state —
     wrapped rows, a card mid-collapse, a card being dragged */
  border-radius: var(--r-lg);
  overflow: hidden;
  /* framed like a SCREEN, but deliberately without the styleguide's inner
     vignette: an overlay would tint the colours, and showing them exactly is
     the whole point of the app */
  border: 1px solid var(--edge);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.swatch {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  /* the row reads as one continuous strip — only its ends are rounded */
  border-radius: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  user-select: none;
  /* let vertical page scrolling through, but claim sideways drags */
  touch-action: pan-y;
}
/* Assigned in JS rather than :first/:last-of-type, so a card that is
   collapsing on its way out hands the rounded end to its neighbour. */
.swatch.is-edge-first {
  border-top-left-radius: var(--r-lg);
  border-bottom-left-radius: var(--r-lg);
}
.swatch.is-edge-last {
  border-top-right-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}
/* a single border, raised above its neighbours so they cannot clip it */
.swatch.is-selected {
  border-color: #fff;
  z-index: 3;
}
.swatch.is-dragging {
  z-index: 6;
  cursor: grabbing;
  transition: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3), 0 0 0 3px rgba(255, 255, 255, 0.22);
}

/* Insert and delete animate by width: the card unfurls from nothing and its
   neighbours give up the space, rather than everything jumping a slot. */
.swatch.is-appearing,
.swatch.is-leaving {
  flex-grow: 0;
  flex-basis: 0;
  min-width: 0;
  /* padding and borders survive a zero flex-basis, which would otherwise
     leave a 44px stub to disappear abruptly */
  padding-left: 0;
  padding-right: 0;
  border-left-width: 0;
  border-right-width: 0;
}
.swatch.is-appearing { opacity: 0; }
/* A leaving card keeps full opacity all the way down. Fading it out while it
   still had width was what showed the page background through the gap. */
.swatch.is-leaving {
  pointer-events: none;
  transition:
    flex-grow 300ms var(--ease-out),
    flex-basis 300ms var(--ease-out),
    padding 300ms var(--ease-out),
    border-width 300ms var(--ease-out);
}
.swatch.is-sizing { overflow: hidden; }
.swatch.is-sizing > * { white-space: nowrap; }

/* No hover or selection tint: a palette is only useful if every card shows
   its exact colour at all times. Affordances live in the controls instead. */

/* Labels off: the strip becomes pure colour, and a card only names itself
   when you hover it or it is the one being edited. */
.swatch-row.hide-labels .swatch-hex,
.swatch-row.hide-labels .swatch-name {
  opacity: 0;
  pointer-events: none;
}
.swatch-row.hide-labels .swatch:hover .swatch-hex,
.swatch-row.hide-labels .swatch.is-selected .swatch-hex {
  opacity: 1;
  pointer-events: auto;
}
.swatch-row.hide-labels .swatch:hover .swatch-name,
.swatch-row.hide-labels .swatch.is-selected .swatch-name { opacity: 0.72; }

.swatch-name {
  position: relative;
  z-index: 1;
}

/* Click-to-copy, so it is a real button dressed as the label. */
.swatch-hex {
  position: relative;
  z-index: 1;
  background: none;
  border: 0;
  padding: 2px 8px;
  border-radius: 8px;
  color: inherit;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.swatch:hover .swatch-hex { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.28); }
.swatch.on-light:hover .swatch-hex { box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.18); }
.swatch-hex:hover { background: rgba(255, 255, 255, 0.18); }
.swatch.on-light .swatch-hex:hover { background: rgba(0, 0, 0, 0.1); }
.swatch-name {
  font-size: 13.5px;
  opacity: 0.72;
}

.swatch-tools {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30px;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Drag affordance: three dots that fade in on hover. The card itself is the
   drag surface — a press that travels far enough becomes a reorder. */
.drag-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13px;
  display: flex;
  justify-content: center;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.drag-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.swatch:hover .drag-dots { opacity: 0.55; }
.swatch.is-dragging .drag-dots { opacity: 0.9; }

/* ---------- shade ramp ---------- */

/* Fills the card with tints and shades of its colour. Only the close button
   stays on top; everything else is covered while the ramp is open. */
.shade-stack {
  position: absolute;
  /* -2px so it covers the card's border as well: the ramp runs edge to edge,
     with no frame of the original colour left around it */
  inset: -2px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  /* clips its own bands while they slide in, so the card needs no overflow
     rule of its own (which would have cropped this -2px bleed) */
  overflow: hidden;
}

/* Each shade slides into its slot in turn, bottom band first, so the ramp
   assembles rather than appearing all at once. */
.shade-band {
  flex: 1;
  min-height: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(100%);
  transition:
    opacity 260ms var(--ease-out),
    transform 340ms var(--ease-out);
}
.shade-stack.is-open .shade-band { opacity: 1; transform: none; }
/* on the way out they leave together, no cascade */
.shade-stack:not(.is-open) .shade-band { transition-delay: 0s !important; }

/* Hovering a band offers the two things you can do with that shade. */
.shade-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity var(--fast) var(--ease-out);
}
.shade-band:hover .shade-actions,
.shade-band:focus-within .shade-actions { opacity: 1; }
.shade-stack.is-full .shade-btn.add { display: none; }

/* No ring or outline — just the tinted disc, so nothing frames the shade. */
.shade-btn {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: var(--pill-bg);
  cursor: pointer;
  transition: transform var(--med) var(--spring), background-color var(--fast) var(--ease-out);
}
.shade-btn:focus-visible { outline: none; }
.shade-btn:hover { background: var(--pill-bg-strong); }
.shade-btn:hover { transform: scale(1.16); }
.shade-btn:active { transform: scale(0.88); }
.shade-btn .i { width: 14px; height: 14px; }

.shades-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--fast) var(--ease-out), transform var(--med) var(--spring), background-color var(--fast) var(--ease-out);
}
.shades-close.is-open { opacity: 1; transform: scale(1); }
.shades-close:hover { background: rgba(0, 0, 0, 0.72); }
.shades-close:active { transform: scale(0.86); }
.shades-close .i { width: 16px; height: 16px; }

.swatch.is-shades { cursor: default; }
.swatch.is-shades .swatch-corner,
.swatch.is-shades .swatch-hex,
.swatch.is-shades .swatch-name,
.swatch.is-shades .swatch-tools,
.swatch.is-shades .drag-dots,
.swatch.is-shades .edge-add { display: none; }

/* Corner stack: delete on top, duplicate beneath it. */
.swatch-corner {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.swatch-corner-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  color: inherit;
  background: rgba(255, 255, 255, 0.16);
  opacity: 0;
  transform: scale(0.7);
}
.swatch-corner-btn .i { width: 15px; height: 15px; }
.swatch:hover .swatch-corner-btn,
.swatch-corner-btn:focus-visible { opacity: 1; transform: scale(1); }
.swatch-corner-btn:active { transform: scale(0.86); }
.swatch-corner-btn.delete:hover { background: var(--bad); color: #fff; }
.swatch-corner-btn.duplicate:hover { background: var(--accent); color: #fff; }
.swatch.on-light .swatch-corner-btn { background: rgba(0, 0, 0, 0.12); }
/* These need the background repeated: `.swatch.on-light .swatch-corner-btn`
   and `.swatch-corner-btn.delete:hover` carry equal specificity, so the
   neutral background was winning on light colours and the hover read as dead. */
.swatch.on-light .swatch-corner-btn.delete:hover { background: var(--bad); color: #fff; }
.swatch.on-light .swatch-corner-btn.duplicate:hover { background: var(--accent); color: #fff; }

/* only one colour pair left — nothing may be removed */
.swatch-row.is-minimal .swatch-corner-btn.delete { display: none; }
/* no room to copy anything into */
.swatch-row.is-full .swatch-corner-btn.duplicate { display: none; }

/* Edit opens the editor panel; it stays lit while that panel is open. */
.swatch-corner-btn.edit:hover { background: #fff; color: #16181c; }
.swatch.on-light .swatch-corner-btn.edit:hover { background: #16181c; color: #fff; }
.swatch.is-editing .swatch-corner-btn.edit {
  opacity: 1;
  transform: scale(1);
  background: #fff;
  color: #16181c;
}
.swatch.on-light.is-editing .swatch-corner-btn.edit { background: #16181c; color: #fff; }

/* Touch devices never hover, so the affordances stay put. */
@media (hover: none) {
  .swatch-corner-btn,
  .swatch-btn { opacity: 1; transform: scale(1); }
  .drag-dots { opacity: 0.55; }
}

.swatch-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  border: 0;
  /* revealed on hover, like every other control on the card */
  opacity: 0;
  transform: scale(0.7);
}
.swatch:hover .swatch-btn,
.swatch-btn:focus-visible { opacity: 1; transform: scale(1); }
/* a locked colour keeps its padlock showing as a status, not just a control */
.swatch.is-locked .swatch-btn.lock { opacity: 1; transform: scale(1); }
.swatch:hover .swatch-btn:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.14); }
.swatch-btn .i { width: 15px; height: 15px; }
.swatch.is-locked .swatch-btn.lock { background: rgba(255, 255, 255, 0.45); }

.swatch.on-dark { color: #fff; }
.swatch.on-light { color: #16181c; }
.swatch.on-light .swatch-btn { background: rgba(0, 0, 0, 0.12); }
.swatch.on-light .swatch-btn:hover { background: rgba(0, 0, 0, 0.22); }
.swatch.on-light.is-locked .swatch-btn.lock { background: rgba(0, 0, 0, 0.28); }

/* ---------- edge insertion (desktop) ---------- */

/* A hit strip straddling the gap between two cards. Only the first card
   shows its left strip, so every gap has exactly one button. */
/* Vertically limited to the middle of the card: the top 120px belongs to the
   delete/duplicate/edit stack and the bottom to lock/dice/swatches, so the +
   only shows when the pointer is over neither. */
.edge-add {
  position: absolute;
  top: 120px;
  bottom: 120px;
  width: 34px;
  z-index: 4;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  padding: 0;
}
.edge-add.left { left: -17px; }
.edge-add.right { right: -17px; }
/* the outermost two sit inside the strip, which now clips its corners */
.swatch.is-edge-first .edge-add.left { left: 0; }
.swatch.is-edge-last .edge-add.right { right: 0; }
.swatch:not(:first-child) .edge-add.left { display: none; }
.swatch-row.is-full .edge-add { display: none; }

.edge-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--glow);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}
.edge-add:hover .edge-dot,
.edge-add:focus-visible .edge-dot { opacity: 1; transform: scale(1); }
.edge-add:active .edge-dot { transform: scale(0.86); }
.edge-dot .i { width: 18px; height: 18px; }

.add-swatch {
  flex: 0 0 130px;
  border-radius: var(--r-lg);
  border: 2px dashed var(--line-strong);
  background: transparent;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 14px;
}
.add-swatch:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.add-swatch .plus {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
}
.add-swatch .i { width: 22px; height: 22px; }

/* ---------------- editor ---------------- */

/* Collapses by animating the grid row from 1fr to 0fr, which needs no
   measured height and so copes with the Similar strip opening inside it. */
.editor-wrap {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition:
    grid-template-rows var(--slow) var(--ease-out),
    margin-bottom var(--slow) var(--ease-out),
    opacity 220ms var(--ease-out) 60ms,
    visibility 0s;
}
.editor-wrap > .editor {
  overflow: hidden;
  min-height: 0;
}
/* A 0fr row only zeroes the content box — padding and borders would still
   leave the panel ~54px tall, so they have to collapse too. */
.editor-wrap.is-closed > .editor {
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
}
.editor-wrap.is-closed {
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  /* swallow the flex gap that would otherwise linger below it */
  margin-bottom: -18px;
  transition:
    grid-template-rows var(--slow) var(--ease-out),
    margin-bottom var(--slow) var(--ease-out),
    opacity 200ms var(--ease-out),
    visibility 0s linear var(--slow);
}

.editor {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 220px;
  gap: 24px;
  padding: 16px 22px;
  align-items: center;
  transition:
    padding var(--slow) var(--ease-out),
    border-width var(--slow) var(--ease-out);
}

/* preview on top, hex field beneath it. The explicit minmax(0,1fr) matters:
   an implicit `auto` column sizes to the hex input's max-content and would
   overflow this track, shoving the preview into the sliders' column. */
.editor-left {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-content: center;
}

.editor-preview {
  height: 84px;
  border-radius: var(--r-md);
  background: #ff6b6b;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.editor-fields { min-width: 0; }

/* Segmented control: an INSET track with a RAISED pill sliding under the
   labels. The pill is the old underline element, grown to full height — the
   JS that positions it is unchanged. */
.tabs {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--edge);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
  margin-bottom: 12px;
}
.tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 7px 6px;
  border-radius: 9px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: 0.4px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: #fff; font-weight: 600; }
.tab-underline {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 9px;
  background: var(--face-accent);
  box-shadow: 0 2px 3px rgba(3, 4, 5, 0.7), inset 0 2px 3px rgba(255, 255, 255, 0.3);
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  box-shadow: var(--sink);
  padding: 2px 5px 2px 12px;
}
.field:focus-within { box-shadow: var(--sink), 0 0 0 1px var(--accent); }
.field input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  padding: 9px 0;
  font-size: 15px;
  letter-spacing: 0.4px;
}
.field.is-invalid { border-color: var(--bad); }

.sliders {
  display: grid;
  gap: 9px;
}
.slider-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 14px;
}
.slider-row label {
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
}
.slider-val {
  font-size: 12.5px;
  color: var(--text-2);
  text-align: left;
  font-variant-numeric: tabular-nums;
}

/* INSET track, RAISED knob — that contrast is what sells it */
.hsl-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 99px;
  outline: none;
  background: var(--bg-2);
  border: 1px solid var(--edge);
  box-shadow: var(--sink);
}
/* hue is a fixed rainbow; the other two are painted from the current colour */
.hsl-range.hue {
  background: linear-gradient(90deg,
    #ff0000 0%, #ffff00 17%, #00ff00 33%,
    #00ffff 50%, #0059ff 67%, #ff00ff 83%, #ff0000 100%);
}

/* A raised cap with a small recessed disc set into its middle. The cap is
   lit from above; the inner disc reverses that — dark at its top edge, light
   at its bottom — which is what makes it read as pressed in. */
.hsl-range {
  /* A soft white torus with a pale grey hole through it. Neutral rather than
     violet, no hard rim — the form is carried by a bright top edge, a shaded
     lower edge and a diffuse shadow beneath. */
  --thumb-face:
    radial-gradient(circle 6px at 50% 50%, #aab0bc 0 92%, rgba(170, 176, 188, 0) 97%),
    radial-gradient(circle 6.5px at 50% 45%, rgba(113, 121, 136, 0.42) 0 78%, rgba(113, 121, 136, 0) 100%),
    /* white holds most of the face and only turns down at the very bottom;
       shading it from halfway made the cap read as a dome */
    linear-gradient(180deg, #ffffff 0%, #ffffff 76%, #e7eaf0 100%);
  --thumb-shadow:
    0 4px 7px rgba(3, 4, 5, 0.5),
    0 1px 2px rgba(3, 4, 5, 0.45),
    inset 0 1.5px 1.5px rgba(255, 255, 255, 0.95),
    /* tight blur on the lower inner edge: a wider one bulges the cap into a
       dome, this keeps the face reading flat */
    inset 0 -1.5px 1px rgba(141, 148, 162, 0.45);
  --thumb-shadow-press:
    0 1px 2px rgba(3, 4, 5, 0.6),
    inset 0 2px 3px rgba(141, 148, 162, 0.5);
}

.hsl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: var(--thumb-face);
  box-shadow: var(--thumb-shadow);
  cursor: grab;
}
.hsl-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: var(--thumb-face);
  box-shadow: var(--thumb-shadow);
  cursor: grab;
}
/* pressed, the whole cap sinks */
.hsl-range:active::-webkit-slider-thumb { box-shadow: var(--thumb-shadow-press); cursor: grabbing; }
.hsl-range:active::-moz-range-thumb { box-shadow: var(--thumb-shadow-press); cursor: grabbing; }

.editor-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.editor-actions .btn { padding: 12px 18px; }

/* The sliders and the Similar picker occupy the same cell and cross-fade, so
   the panel never changes height when you swap between them. */
.field-swap {
  display: grid;
  align-items: center;
}
.field-swap > .sliders,
.field-swap > .similar-strip { grid-area: 1 / 1; }

.sliders {
  transition:
    opacity 190ms var(--ease),
    transform 260ms var(--ease);
}
.field-swap.is-similar .sliders {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.similar-strip {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 190ms var(--ease),
    transform 260ms var(--ease);
}
.similar-strip.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.similar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.similar-chips {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.similar-chip {
  height: 52px;
  border-radius: var(--r-sm);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.similar-close { flex: none; align-self: center; }

/* ---------------- toolbar ---------------- */

/* Pinned to the bottom of the viewport; the gradient keeps the swatch row
   from colliding with the buttons as it scrolls underneath. */
.toolbar-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin-top: auto;
  /* bottom gap matches the Palette Assistant's, so both panels sit on the
     same visual floor */
  padding: 0 0 28px;
  display: grid;
  gap: 10px;
  background: linear-gradient(to top, var(--bg) 0%, var(--bg) 62%, rgba(8, 9, 11, 0) 100%);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--stroke);
  border-radius: var(--r-xl);
}

/* Anchored above the Info button rather than taking permanent space. */
.shortcuts-pop {
  position: absolute;
  bottom: calc(100% - 14px);
  right: 0;
  z-index: 30;
  width: min(560px, calc(100vw - 52px));
  padding: 14px 18px 16px;
  background: var(--panel-3);
  border: 1px solid var(--stroke-2);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(12px) scale(0.94);
  transition:
    opacity 170ms var(--ease-out),
    transform 300ms var(--spring);
}
.shortcuts-pop.is-open { opacity: 1; transform: none; }

.shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.shortcuts-head h3 { font-size: 14px; font-weight: 600; }

.shortcuts-pop kbd {
  background: var(--face-accent);
  border-color: var(--edge);
  box-shadow: var(--raise-accent);
  color: #fff;
}
.shortcuts-head .icon-btn { width: 30px; height: 30px; }
.shortcuts-head .icon-btn .i { width: 15px; height: 15px; }

.shortcuts-list {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 20px;
}
.shortcuts-list > div {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}
.shortcuts-list dt { flex: none; }
.shortcuts-list dd {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-2);
}

.shortcuts-note {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}
.shortcuts-note strong { color: var(--text-2); }
.toolbar .btn { flex: 1 1 auto; }

/* ---------------- sidebar ---------------- */

.sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 18px 20px;
  font-weight: 600;
  font-size: 15.5px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.sidebar-head .chev { margin-left: auto; color: var(--text-3); }

/* Collapsed, the header turns into a slim vertical rail so there is still
   something obvious to click to bring the assistant back. */
@media (min-width: 1181px) {
  .sidebar.is-collapsed .sidebar-head {
    flex-direction: column;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 0;
    height: 100%;
  }
  .sidebar.is-collapsed .sidebar-title {
    writing-mode: vertical-rl;
    letter-spacing: 0.3px;
  }
  .sidebar.is-collapsed .sidebar-head .chev { margin-left: 0; margin-top: auto; }
}

.sidebar-body {
  padding: 4px 20px 20px;
  max-height: calc(100vh - var(--nav-h) - 110px);
  overflow-y: auto;
}

.side-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.side-block:last-child { border-bottom: 0; }

.side-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.side-text {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.62;
}
.side-note {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 10px;
}

.name-row { display: flex; align-items: center; gap: 6px; }
.palette-name {
  flex: 1;
  min-width: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 3px 6px;
  margin-left: -6px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
  outline: none;
}
.palette-name:hover { border-color: var(--line); }
.palette-name:focus { border-color: var(--accent); background: var(--panel-2); }

.a11y { display: flex; align-items: center; gap: 14px; }
.ring { position: relative; width: 62px; height: 62px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring-track { stroke: var(--panel-3); }
.ring-fill { stroke: var(--good); stroke-dasharray: 188.5; stroke-dashoffset: 188.5; }
.ring-score {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.a11y-grade { font-weight: 600; font-size: 14.5px; }
.a11y-note { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }

.use-cases { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.use-case {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px;
  border-radius: var(--r-sm);
  background: var(--face);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}
.use-case .i { width: 22px; height: 22px; }

.pairing { display: flex; gap: 8px; }
.pairing span {
  flex: 1;
  height: 42px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ---------- decorative mockups ---------- */

.mockups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mock {
  position: relative;
  height: 96px;
  border-radius: 10px;
  padding: 9px;
  overflow: hidden;
  font-size: 8px;
  line-height: 1.25;
  background: var(--mock-bg, #eee);
  color: var(--mock-fg, #222);
}
.mock-h { font-weight: 700; font-size: 9px; }
.mock-p { opacity: 0.7; }
.mock-bar { height: 3px; width: 26px; border-radius: 2px; background: var(--mock-accent, #888); margin-bottom: 6px; }
.mock-objs { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 3px; align-items: flex-end; }
.mock-objs i { display: block; width: 9px; border-radius: 2px; background: var(--mock-accent, #888); }
.mock-objs i:nth-child(1) { height: 26px; }
.mock-objs i:nth-child(2) { height: 34px; opacity: 0.75; }
.mock-objs i:nth-child(3) { height: 20px; opacity: 0.55; }
.mock-chip {
  position: absolute;
  left: 9px;
  bottom: 9px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--mock-accent, #888);
  color: var(--mock-chip-fg, #fff);
  font-size: 7px;
  font-weight: 600;
}
.mock-list { display: grid; gap: 4px; margin-top: 6px; }
.mock-item { display: flex; align-items: center; gap: 5px; }
.mock-item i { width: 12px; height: 12px; border-radius: 4px; background: var(--mock-accent, #888); flex: none; }
.mock-item span { height: 4px; border-radius: 2px; background: currentColor; opacity: 0.3; flex: 1; }
.mock-jar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: 44px;
  height: 34px;
  border-radius: 6px;
  background: var(--mock-fg, #fff);
  opacity: 0.9;
}
.mock-lid { height: 9px; border-radius: 6px 6px 0 0; background: var(--mock-accent, #888); }
.mock-blob {
  position: absolute;
  right: -14px;
  bottom: -14px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--mock-accent, #888);
  opacity: 0.85;
}
.mock-dot {
  position: absolute;
  right: 26px;
  bottom: 26px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--mock-fg, #fff);
  opacity: 0.55;
}

/* ---------------- my palettes ---------------- */

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 6px 2px 4px;
}
.view-title { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.view-sub { color: var(--text-3); font-size: 13.5px; }

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.saved-card {
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--stroke);
  overflow: hidden;
}
.saved-card:hover { border-color: var(--stroke-2); }

.saved-strip {
  display: flex;
  height: 108px;
  cursor: pointer;
}
.saved-strip span { flex: 1; }

.saved-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
}
.saved-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14.5px;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 6px;
  margin-left: -6px;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-name:hover { border-color: var(--line); }
.saved-name:focus { border-color: var(--accent); background: var(--panel-2); }
.saved-date { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.saved-actions { display: flex; gap: 2px; }
.saved-actions .icon-btn { width: 32px; height: 32px; }
.saved-actions .icon-btn .i { width: 15px; height: 15px; }
.saved-actions .danger:hover { color: var(--bad); background: rgba(255, 107, 107, 0.1); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 70px 20px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-xl);
}
.empty-state h2 { font-size: 19px; }
.empty-state p { color: var(--text-3); font-size: 14px; }
.empty-state .btn { margin-top: 10px; }
.empty-art { display: flex; gap: 8px; margin-bottom: 8px; }
.empty-art span {
  width: 34px;
  height: 52px;
  border-radius: 9px;
  background: var(--panel-3);
}

/* ---------------- modals ---------------- */

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 8, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--edge);
  border-radius: var(--r-xl);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}
.modal-head .i { color: var(--accent-2); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}
.modal-lead { color: var(--text-2); font-size: 13.5px; margin-bottom: 16px; }
.muted { color: var(--text-3); font-size: 13px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 46px 20px;
  border: 1px dashed var(--stroke-2);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  box-shadow: var(--sink);
  cursor: pointer;
  color: var(--text-2);
  text-align: center;
}
.dropzone:hover,
.dropzone.is-over { border-color: var(--accent); color: var(--text); }
.dropzone .i { color: var(--accent-2); }

.image-result { margin-top: 16px; display: grid; gap: 12px; }
.image-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--panel-2);
}
/* column count follows however many colours were generated (5–7) */
.extracted { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.extracted span {
  height: 56px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.mood-card {
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--face);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
  text-align: left;
  display: grid;
  gap: 10px;
}
.mood-card:hover { filter: brightness(1.15); }
.mood-card:active { box-shadow: var(--press); }
.mood-swatches { display: flex; gap: 4px; }
.mood-swatches span { flex: 1; height: 30px; border-radius: 6px; }
.mood-name { font-weight: 600; font-size: 14px; }
.mood-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

.text-input {
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--edge);
  box-shadow: var(--sink);
  outline: none;
  font-size: 15px;
}
.text-input:focus { box-shadow: var(--sink), 0 0 0 1px var(--accent); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  padding: 7px 13px;
  border-radius: 99px;
  background: var(--face);
  border: 1px solid var(--edge);
  box-shadow: var(--raise);
  font-size: 12.5px;
  color: var(--text-2);
}
.chip:hover { filter: brightness(1.15); color: var(--text); }
.chip:active { box-shadow: var(--press); }

.feeling-preview {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-top: 18px;
}
.feeling-preview span { height: 60px; border-radius: var(--r-sm); }

.export-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; }
.export-list { display: grid; gap: 6px; align-content: start; }
.export-opt {
  text-align: left;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 13.5px;
}
.export-opt:hover { background: var(--panel-2); color: var(--text); }
.export-opt.is-active { background: var(--accent-soft); border-color: var(--accent); color: #bcd3ff; }
.export-preview { display: grid; gap: 12px; align-content: start; min-width: 0; }
.export-preview pre {
  background: var(--bg-2);
  border: 1px solid var(--edge);
  box-shadow: var(--sink);
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 12.5px;
  line-height: 1.65;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-2);
}
.export-actions { display: flex; gap: 10px; }

/* ---------------- tooltips ---------------- */

/* A small chat bubble in the panel palette, centred on whatever it describes
   with a tail pointing back at it. */
.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 400;
  max-width: 240px;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid var(--stroke-2);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.94);
  transform-origin: bottom center;
  transition:
    opacity 130ms var(--ease-out),
    transform 220ms var(--spring);
}
.tip.is-open { opacity: 1; transform: none; }

/* the tail: a rotated square borrowing two of the bubble's borders */
.tip::after {
  content: "";
  position: absolute;
  left: var(--tail-x, 50%);
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: var(--panel-3);
  border-right: 1px solid var(--stroke-2);
  border-bottom: 1px solid var(--stroke-2);
  border-bottom-right-radius: 3px;
  transform: translateX(-50%) rotate(45deg);
}
.tip.is-below { transform-origin: top center; }
.tip.is-below::after {
  bottom: auto;
  top: -6px;
  border-right: 0;
  border-bottom: 0;
  border-left: 1px solid var(--stroke-2);
  border-top: 1px solid var(--stroke-2);
  border-radius: 3px 0 0 0;
}

/* ---------------- toasts + confetti ---------------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 200;
  display: grid;
  gap: 10px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 99px;
  background: var(--panel-3);
  border: 1px solid var(--edge);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: 13.5px;
  white-space: nowrap;
}
.toast .i { color: var(--text); }
.toast.is-error .i { color: var(--bad); }

.confetti-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  overflow: hidden;
}
.confetti-bit {
  position: fixed;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

/* ---------------- responsive ---------------- */

@media (max-width: 1180px) {
  .sidebar { position: static; }
  .sidebar-body { max-height: none; }
}

/* The Add Color card is the mobile affordance; desktop uses the edge buttons. */
@media (min-width: 901px) {
  .add-swatch { display: none; }
}

@media (max-width: 900px) {
  .edge-add { display: none; }

  /* A wrapped dock would eat half a phone screen and sit on top of the
     colours, so it becomes one compact scrolling row. */
  .toolbar-dock { padding: 10px 0 6px; }
  .toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 8px;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar .btn {
    flex: 0 0 auto;
    padding: 12px 15px;
    font-size: 13.5px;
  }
  .shortcuts-list { grid-template-columns: 1fr; }

  .nav { gap: 14px; padding: 0 14px; }
  .nav-links { display: none; }
  .mode-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px; }
  .editor-actions { flex-direction: row; }
  .editor-actions .btn { flex: 1; }
  .swatch-row { flex-wrap: wrap; min-height: 0; }
  .swatch { flex: 1 1 140px; min-height: 190px; }
  .add-swatch { flex: 1 1 100%; min-height: 90px; }
  .export-row { grid-template-columns: minmax(0, 1fr); }
  .export-list { grid-auto-flow: column; overflow-x: auto; }
}

@media (max-width: 380px) {
  .nav { padding-inline: 12px; gap: 8px; }
  .nav-right { gap: 6px; }
  .nav-right .avatar { display: none; }
}
