/* Fill picker, gradient editor, color popover, and palette controls. */
/* Fill picker: tabs + gradient swatches */
.td-fill-picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee8f0;
}

.td-fill-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: #f5f2f7;
}

.td-fill-tab {
  min-height: 38px;
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #665e6f;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.td-fill-tab.is-active {
  background: #fff;
  color: #4f4264;
  box-shadow: 0 4px 14px rgba(54, 46, 68, .12);
}

.td-gradient-swatches {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  padding: 2px;
}

.td-gradient-extra-swatches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
}

.td-palette-groups {
  display: grid;
  gap: 18px;
  padding-top: 2px;
}

.td-palette-group {
  display: grid;
  gap: 9px;
}

.td-palette-group-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: #746d7b;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.td-palette-group-title.has-action {
  grid-template-columns: auto minmax(0, 1fr) 30px;
}

.td-palette-group-title::after {
  grid-column: 2;
  height: 1px;
  background: #eee8f0;
  content: "";
}

.td-palette-group-title.has-action .td-palette-settings-button {
  grid-column: 3;
  justify-self: end;
}

.td-palette-groups .td-swatches {
  grid-template-columns: repeat(8, 32px);
  gap: 10px;
  padding: 0;
}

.td-palette-groups .td-swatch {
  width: 32px;
  height: 32px;
}

.td-palette-groups .td-color-plus-button {
  width: 32px;
  height: 32px;
}

.td-palette-groups .td-color-plus-mark,
.td-palette-groups .td-color-plus-mark::before {
  width: 10px;
  height: 2px;
}

.td-grad-swatch {
  border: 0 !important;
  border-radius: 7px !important;
  width: 100% !important;
  height: 26px !important;
  background-clip: border-box;
  box-shadow: none !important;
}

.td-palette-groups .td-gradient-swatches {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
}

.td-palette-groups .td-grad-swatch {
  height: 22px !important;
  border-radius: 6px !important;
}

.td-solid-swatch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: start;
}

.td-gradient-position-label {
  color: #6d6675;
  font-size: 12px;
  font-weight: 900;
}

.td-color-plus-wrap {
  position: relative;
  display: inline-flex;
  width: max-content;
  margin-top: 0;
}

.td-color-plus-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid rgba(45, 39, 42, .12);
  border-radius: 999px;
  background: #d6dbe3;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}

.td-color-plus-button:hover {
  transform: translateY(-1px);
}

.td-color-plus-button.is-open {
  box-shadow: 0 0 0 3px #3b82f6, 0 3px 10px rgba(36, 31, 32, .16);
}

.td-color-plus-preview {
  position: absolute;
  inset: 0;
  opacity: .26;
}

.td-color-plus-mark,
.td-color-plus-mark::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 3px;
  border-radius: 999px;
  background: #4f5665;
  content: "";
  transform: translate(-50%, -50%);
}

.td-color-plus-mark::before {
  transform: translate(-50%, -50%) rotate(90deg);
}

.td-color-popover {
  box-sizing: border-box;
  width: 236px;
  padding: 12px;
  border: 1px solid rgba(36, 31, 32, .1);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(36, 31, 32, .2);
}

.td-color-popover.has-gradient {
  width: min(342px, calc(100vw - 16px));
}

.td-color-popover * {
  box-sizing: border-box;
}

.td-color-popover-tabs {
  margin-bottom: 12px;
}

.td-color-solid-panel,
.td-color-gradient-panel {
  display: grid;
  gap: 10px;
}

.td-color-gradient-panel {
  padding: 12px;
}

.td-color-area {
  position: relative;
  height: 164px;
  overflow: hidden;
  border-radius: 10px;
  cursor: crosshair;
  background-image:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, transparent);
  touch-action: none;
}

.td-color-area::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
  content: "";
}

.td-color-area::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
  content: "";
}

.td-color-area-handle {
  position: absolute;
  z-index: 1;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .32), 0 2px 8px rgba(0, 0, 0, .28);
  transform: translate(-50%, -50%);
}

.td-color-popover-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.td-color-popover-preview {
  position: relative;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border: 1px solid #ddd7e2;
  border-radius: 999px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d7d2dc 25%, transparent 25%),
    linear-gradient(-45deg, #d7d2dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d7d2dc 75%),
    linear-gradient(-45deg, transparent 75%, #d7d2dc 75%);
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  background-size: 10px 10px;
}

.td-color-popover-preview span {
  position: absolute;
  inset: 0;
}

.td-color-popover-input {
  min-width: 0;
  height: 34px;
  border: 1px solid #d7d2dc;
  border-radius: 7px;
  color: #4d4654;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  padding: 0 9px;
  text-transform: uppercase;
}

.td-color-popover-stop {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid #d4cfdb;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.td-color-popover-stop span {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: inherit;
}

.td-color-popover-stop::before,
.td-color-popover-stop::after {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 14px;
  height: 3px;
  border-radius: 999px;
  background: #4f4657;
  content: "";
  transform: translate(-50%, -50%);
}

.td-color-popover-stop::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.td-color-popover-stop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.td-color-popover-label,
.td-color-popover-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  color: #6d6675;
  font-size: 12px;
  font-weight: 900;
}

.td-color-hue-range,
.td-color-alpha-range {
  width: 100%;
  height: 28px;
  margin: 10px 0 2px;
  appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: pan-x;
}

.td-color-hue-range {
  border-radius: 999px;
  background: linear-gradient(to right, #ff0040 0%, #ff7a00 12%, #fff000 24%, #00f000 40%, #00f2c8 55%, #0094ff 68%, #3200ff 80%, #ff00ff 92%, #ff0040 100%);
}

.td-color-hue-range::-webkit-slider-runnable-track,
.td-color-alpha-range::-webkit-slider-runnable-track {
  height: 22px;
  border-radius: 999px;
  background: transparent;
}

.td-color-hue-range::-webkit-slider-thumb,
.td-color-alpha-range::-webkit-slider-thumb {
  width: 30px;
  height: 30px;
  margin-top: -4px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #e733ef;
  box-shadow: 0 1px 8px rgba(36, 31, 32, .28);
  appearance: none;
}

.td-color-hue-range::-moz-range-track,
.td-color-alpha-range::-moz-range-track {
  height: 22px;
  border-radius: 999px;
  background: transparent;
}

.td-color-hue-range::-moz-range-thumb,
.td-color-alpha-range::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #e733ef;
  box-shadow: 0 1px 8px rgba(36, 31, 32, .28);
}

.td-color-alpha-range {
  border-radius: 999px;
  background:
    linear-gradient(to right, rgba(112, 90, 130, 0), #705a82),
    linear-gradient(45deg, #d7d2dc 25%, transparent 25%),
    linear-gradient(-45deg, #d7d2dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d7d2dc 75%),
    linear-gradient(-45deg, transparent 75%, #d7d2dc 75%);
  background-position: 0 0, 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: auto, 12px 12px, 12px 12px, 12px 12px, 12px 12px;
}

.td-color-alpha-range::-webkit-slider-thumb,
.td-color-alpha-range::-moz-range-thumb {
  background: #705a82;
}

.td-alpha-range {
  width: 100%;
  accent-color: #705a82;
}

.td-gradient-preview {
  height: 42px;
  margin-top: 10px;
  border: 1px solid rgba(45, 39, 42, .1);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .38);
}

.td-gradient-detail-panel {
  display: grid;
  gap: 16px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #ece7ef;
  border-radius: 8px;
  background: #fbfafc;
}

.td-gradient-palette-view {
  display: grid;
  gap: 10px;
}

.td-gradient-palette-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 30px;
}

.td-palette-settings-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 30px;
  height: 30px;
  border: 1px solid #ded8e5;
  border-radius: 999px;
  background: #fff;
  color: #705a82;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.td-palette-settings-button.has-label {
  width: auto;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.td-palette-settings-button:hover {
  border-color: #cfc4d8;
  background: #f8f5fa;
}

.td-palette-settings-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex: 0 0 auto;
}

.td-palette-back-button {
  display: inline-flex;
  justify-self: start;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5d5269;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  padding: 0;
}

.td-palette-back-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex: 0 0 auto;
}

.td-palette-back-button:hover {
  color: #3f3748;
}

.td-gradient-type-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.td-gradient-type-row label {
  margin: 0;
  color: #6d6675;
  font-size: 12px;
  font-weight: 900;
}

.td-gradient-type-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 3px;
  border-radius: 8px;
  background: #f4f1f5;
}

.td-gradient-type-option {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #655d69;
  font-size: 12px !important;
  font-weight: 900 !important;
  cursor: pointer;
}

.td-gradient-type-option.is-active {
  background: #fff;
  color: #3f3748;
  box-shadow: 0 2px 8px rgba(54, 46, 68, .12);
}

.td-gradient-type-option:hover {
  background: rgba(255, 255, 255, .72);
}

.td-gradient-range-control {
  display: grid;
  gap: 10px;
}

.td-gradient-range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.td-gradient-range-values {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #6d6675;
  font-size: 12px;
  font-weight: 900;
}

.td-gradient-dual-range {
  position: relative;
  height: 40px;
  border-radius: 999px;
}

.td-gradient-dual-range::before {
  position: absolute;
  top: 15px;
  right: 0;
  left: 0;
  height: 10px;
  border-radius: 999px;
  background: #ececf0;
  content: "";
}

.td-gradient-dual-range::after {
  position: absolute;
  top: 15px;
  left: var(--left-stop);
  width: calc(var(--right-stop) - var(--left-stop));
  height: 10px;
  border-radius: 999px;
  background: var(--gradient-preview);
  content: "";
}

.td-gradient-stop-range {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 40px;
  margin: 0;
  appearance: none;
  background: transparent;
  pointer-events: none;
}

.td-gradient-stop-range::-webkit-slider-runnable-track {
  height: 40px;
  background: transparent;
}

.td-gradient-stop-range::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: 9px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #705a82;
  box-shadow: 0 0 0 1px rgba(36, 31, 32, .24);
  appearance: none;
  pointer-events: auto;
}

.td-gradient-stop-range::-moz-range-track {
  height: 40px;
  background: transparent;
}

.td-gradient-stop-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #705a82;
  box-shadow: 0 0 0 1px rgba(36, 31, 32, .24);
  pointer-events: auto;
}

.td-gradient-stop-range-start::-webkit-slider-thumb {
  background: var(--gradient-left-color, #ff7a18);
}

.td-gradient-stop-range-start::-moz-range-thumb {
  background: var(--gradient-left-color, #ff7a18);
}

.td-gradient-stop-range-end::-webkit-slider-thumb {
  background: var(--gradient-right-color, #ff2d95);
}

.td-gradient-stop-range-end::-moz-range-thumb {
  background: var(--gradient-right-color, #ff2d95);
}

.td-fill-detail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 30px;
  margin-top: 8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #bd4a78;
  font-size: 11px !important;
  font-weight: 950 !important;
  line-height: 1 !important;
  cursor: pointer;
  align-self: flex-start;
  transition: background .15s, color .15s;
}

.td-fill-detail-button:hover {
  color: #9f315b;
  background: #fbedf3;
}

.td-expand-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  transition: transform .15s;
}

.td-fill-detail-chevron {
  position: relative;
  display: block;
  width: 9px;
  height: 9px;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  border-radius: 1px;
  transform: translateY(-2px) rotate(45deg);
}

.td-expand-icon.is-open {
  transform: rotate(180deg);
}

.td-grad-swatch.is-active {
  box-shadow: 0 0 0 3px #3b82f6 !important;
}
