/* Custom color picker — intentionally independent of the native color input. */
.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: auto;
}

.picker-popover {
  position: fixed;
  width: 300px;
  padding: 18px 16px 16px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
  color: #1b1b1b;
  opacity: 0;
  transform: scale(.96) translateY(-5px);
  transform-origin: top center;
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: auto;
  font-family: var(--font, 'Montserrat', system-ui, sans-serif);
}

.picker-backdrop.is-open .picker-popover {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.picker-backdrop.is-closing .picker-popover {
  opacity: 0;
  transform: scale(.96) translateY(-5px);
}

.picker-header,
.picker-footer,
.picker-hex-row {
  display: flex;
  align-items: center;
}

.picker-header {
  min-height: 28px;
  gap: 8px;
  margin-bottom: 12px;
}

.picker-title {
  flex: 1;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.picker-close,
.picker-eyedropper {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #777;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.picker-close {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.picker-close:hover,
.picker-eyedropper:hover {
  background: #f2f2f2;
  color: #1b1b1b;
  transform: translateY(-1px);
}

.picker-eyedropper {
  background: #f4f5f5;
  margin-left: 0;
}

.picker-eyedropper svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.picker-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.picker-saturation {
  position: relative;
  width: 268px;
  height: 200px;
  border-radius: 12px;
  overflow: visible;
  cursor: crosshair;
  touch-action: none;
  isolation: isolate;
}

.picker-saturation::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
  pointer-events: none;
}

.picker-saturation-handle,
.picker-hue-thumb {
  position: absolute;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(0, 0, 0, .36), 0 0 0 1px rgba(0, 0, 0, .12);
  pointer-events: none;
}

.picker-saturation-handle {
  transform: translate(-50%, -50%);
}

.picker-hue {
  position: relative;
  width: 268px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f00 0%, #ff0 16.67%, #0f0 33.33%, #0ff 50%, #00f 66.67%, #f0f 83.33%, #f00 100%);
  cursor: ew-resize;
  touch-action: none;
}

.picker-hue-thumb {
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
}

.picker-preview {
  display: flex;
  width: 100%;
  height: 42px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  text-align: center;
  cursor: pointer;
}

.picker-preview span {
  display: grid;
  flex: 1;
  place-items: center;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .22);
}

.picker-preview-before { background: var(--picker-before); }
.picker-preview-after { background: var(--picker-after); }

.picker-hex-row {
  gap: 10px;
}

.picker-field-label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #888;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
}

.picker-hex-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  outline: none;
  color: #555;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.picker-hex-input:focus {
  border-color: var(--teal, #00c9a7);
  box-shadow: 0 0 0 3px rgba(0, 201, 167, .13);
}

.picker-hex-input.is-invalid { border-color: #e5484d; }

.picker-rgb-readout {
  width: 82px;
  flex: 0 0 82px;
  color: #888;
  font-size: 9px;
  line-height: 1.55;
  letter-spacing: .08em;
  text-align: right;
  text-transform: uppercase;
}

.picker-recent-section { min-height: 28px; }

.picker-section-label {
  display: block;
  margin-bottom: 7px;
  color: #999;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
}

.picker-recent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.picker-recent-color {
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18), 0 0 0 1px rgba(0, 0, 0, .08);
  transition: transform 150ms ease;
}

.picker-recent-color:hover { transform: scale(1.12); }

.picker-footer {
  gap: 8px;
  margin-top: 15px;
}

.picker-button {
  min-height: 40px;
  flex: 1;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.picker-button:hover { transform: translateY(-1px); }
.picker-button-ghost { border: 1px solid #ddd; color: #777; }
.picker-button-ghost:hover { background: #f7f7f7; }
.picker-button-ok { background: var(--teal, #00c9a7); color: #fff; box-shadow: 0 5px 13px rgba(0, 201, 167, .24); }
.picker-button-ok:hover { background: var(--teal-dark, #00a383); }

@media (max-width: 639px) {
  .picker-backdrop {
    display: flex;
    align-items: flex-end;
    background: rgba(13, 20, 19, .36);
    pointer-events: auto;
    opacity: 0;
    transition: opacity 150ms ease;
  }

  .picker-backdrop.is-open { opacity: 1; }

  .picker-popover {
    position: relative;
    width: 100%;
    max-height: min(92vh, 690px);
    overflow: auto;
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    transform: translateY(24px);
    transition: opacity 150ms ease, transform 150ms ease;
  }

  .picker-backdrop.is-open .picker-popover { transform: translateY(0); }
  .picker-backdrop.is-closing .picker-popover { transform: translateY(24px); }
  .picker-header { margin-bottom: 14px; }
  .picker-saturation,
  .picker-hue { width: 100%; }
  .picker-saturation { height: min(56vw, 238px); min-height: 190px; }
  .picker-footer { gap: 10px; margin-top: 18px; }
  .picker-button { min-height: 48px; }
  .picker-close,
  .picker-eyedropper { width: 44px; height: 44px; }
}
