/* The color popup, in the app's own look wherever it opens. The library sets some of these with
   !important or longer selectors, so the rules that must win match them. */
.sp-container {
  box-sizing: border-box;
  width: min(280px, calc(100vw - 32px));
  padding: 12px;
  overflow: visible;
  border: 1px solid var(--line-3);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 6px 22px var(--shadow);
  font-family: inherit;
}

.sp-container .sp-picker-container {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "initial input"
    "buttons buttons";
  gap: 10px;
  float: none;
  width: auto;
  margin: 0;
  padding: 0;
  border: none;
}

.sp-container .sp-top {
  position: relative;
  display: block;
  grid-area: top;
  height: min(150px, 34vh);
  margin: 0;
}

.sp-container .sp-fill {
  display: none;
}

.sp-container .sp-top-inner {
  inset: 0;
}

.sp-container .sp-color {
  position: absolute;
  inset: 0 34px 0 0 !important;
  border: none;
  border-radius: 8px;
  overflow: hidden;
}

.sp-container .sp-sat,
.sp-container .sp-val {
  border-radius: 8px;
}

.sp-container .sp-hue {
  position: absolute;
  inset: 0 0 0 auto;
  width: 22px;
  height: 100%;
  border: none;
  border-radius: 8px;
}

/* A color that can be cleared: "no color" gets its own square at the end of the field's row,
   clear of the hue bar. */
.sp-container.sp-clear-enabled .sp-picker-container {
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  grid-template-areas:
    "top top top"
    "initial input ."
    "buttons buttons buttons";
}

.sp-container.sp-clear-enabled .sp-clear {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  bottom: auto;
  left: auto;
  display: block;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-4);
  border-radius: 8px;
  background-size: 22px;
  cursor: pointer;
}

.sp-container.sp-clear-enabled .sp-hue {
  top: 0;
  height: 100%;
}

.sp-container .sp-slider {
  left: -3px;
  right: -3px;
  height: 8px;
  border: 2px solid var(--surface);
  border-radius: 4px;
  background: var(--ink);
  opacity: 1;
}

.sp-container .sp-dragger {
  width: 18px;
  height: 18px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px var(--ink);
}

.sp-container .sp-input-container.sp-cf {
  grid-area: input;
  height: 44px;
  float: none;
  width: auto;
  margin: 0;
}

.sp-container .sp-input {
  box-sizing: border-box;
  width: 100%;
  height: 44px !important;
  margin: 0;
  padding: 0 10px !important;
  border: 1px solid var(--line-4) !important;
  border-radius: 8px !important;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.sp-container .sp-initial.sp-thumb.sp-cf {
  grid-area: initial;
  box-sizing: border-box;
  float: none;
  height: 44px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line-4);
  border-radius: 8px;
}

.sp-container .sp-initial .sp-thumb-el,
.sp-container .sp-initial .sp-thumb-inner {
  display: block;
  float: left;
  width: 21px;
  height: 44px;
  border: none;
}

.sp-container .sp-initial .sp-clear-display {
  background-size: 16px;
}

.sp-container .sp-button-container.sp-cf {
  grid-area: buttons;
  display: flex;
  gap: 8px;
  float: none;
  height: auto;
  margin: 0;
}

/* The library's clearfix boxes would take a share of the gap as flex items. */
.sp-container .sp-button-container.sp-cf::before,
.sp-container .sp-button-container.sp-cf::after {
  display: none;
}

.sp-container .sp-button-container button {
  flex: 1 1 0;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  border: none;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--ink);
  font: inherit;
  text-shadow: none;
  box-shadow: none;
  cursor: pointer;
}

.sp-container .sp-button-container button.sp-choose {
  background: var(--brand);
  color: var(--surface);
}
