/* ---------- Color picker popup ---------- */
.cp-popup {
  position: absolute;
  z-index: 1000;
  width: 260px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  user-select: none;
}

.cp-popup[hidden] { display: none; }

.cp-body {
  display: flex;
  gap: 10px;
}

.cp-square {
  position: relative;
  flex: 1;
  height: 160px;
  border-radius: 6px;
  overflow: hidden;
  cursor: crosshair;
  background: hsl(0, 100%, 50%);
}

/* Saturation layer (white -> transparent, left to right) */
.cp-square::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #ffffff, rgba(255, 255, 255, 0));
}

/* Value layer (transparent -> black, top to bottom) */
.cp-square::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), #000000);
}

.cp-square-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}

.cp-hue {
  position: relative;
  width: 16px;
  height: 160px;
  border-radius: 6px;
  cursor: pointer;
  background: linear-gradient(
    to bottom,
    hsl(0, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(240, 100%, 50%),
    hsl(300, 100%, 50%),
    hsl(360, 100%, 50%)
  );
}

.cp-hue-marker {
  position: absolute;
  left: 50%;
  width: 24px;
  height: 6px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cp-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.cp-hex {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #000000;
  color: #ffffff;
  font: 600 14px "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.cp-hex:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}