.theme-picker {
  position: relative;
  display: inline-flex;
}

.theme-picker-toggle {
  cursor: pointer;
  align-items: center;
  display: inline-flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
}

.theme-picker-toggle__text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
  gap: 2px;
}

.theme-picker-toggle__hint {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
}

.theme-picker-toggle__label {
  font-weight: 800;
  font-size: 0.94rem;
}

.theme-picker-toggle__chevron {
  font-size: 0.74rem;
  opacity: 0.7;
  transition: transform var(--transition-duration) var(--transition-easing);
}

.theme-picker.open .theme-picker-toggle__chevron {
  transform: rotate(180deg);
}

.theme-picker-menu {
  position: absolute;
  top: calc(100% + var(--space-3));
  right: 0;
  z-index: 1100;
  min-width: 360px;
  max-width: min(560px, calc(100vw - 24px));
  max-height: min(60vh, 540px);
  overflow: auto;
  padding: var(--space-5);
  border-radius: var(--radius-2xl);
  border: 1px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
  background: color-mix(in srgb, var(--background-color) 88%, transparent);
  backdrop-filter: var(--site-surface-blur, blur(28px) saturate(1.25));
  -webkit-backdrop-filter: var(--site-surface-blur, blur(28px) saturate(1.25));
  box-shadow: var(--shadow-xl);
  animation: themePickerOpen 200ms var(--transition-easing) both;
}

.theme-picker-menu[hidden] {
  display: none;
}

@keyframes themePickerOpen {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* One column: groups stack vertically, items flow horizontally inside each group */
.theme-picker-columns {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.theme-picker-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.theme-picker-group-label {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 var(--space-3);
  color: color-mix(in srgb, var(--text-color) 65%, transparent);
}

.theme-picker-group-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.theme-picker-item {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  flex: 0 0 auto;
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-color);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--transition-duration) var(--transition-easing),
    border-color var(--transition-duration) var(--transition-easing),
    background var(--transition-duration) var(--transition-easing);
}

.theme-picker-item:hover,
.theme-picker-item:focus-visible {
  border-color: color-mix(in srgb, var(--accent-color) 28%, transparent);
  background: color-mix(in srgb, var(--accent-color) 8%, transparent);
  transform: translateY(-1px);
  outline: none;
}

.theme-picker-item[aria-checked="true"] {
  border-color: color-mix(in srgb, var(--accent-color) 40%, transparent);
  background: color-mix(in srgb, var(--accent-color) 14%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, white 10%, transparent);
}

.theme-picker-item-swatch {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--text-color) 18%, transparent);
  background: var(--background-color);
  display: inline-block;
  overflow: hidden;
  flex: 0 0 auto;
}

.theme-picker-item-swatch-dot {
  position: absolute;
  display: block;
  width: 60%;
  height: 60%;
  border-radius: 50%;
}

.theme-picker-item-swatch-dot--primary {
  left: -10%;
  top: -10%;
  background: var(--primary-color);
}

.theme-picker-item-swatch-dot--accent {
  right: -10%;
  bottom: -10%;
  background: var(--accent-color);
}

.theme-picker-item-swatch-dot--bg {
  left: 30%;
  top: 30%;
  width: 40%;
  height: 40%;
  background: color-mix(in srgb, var(--secondary-color) 70%, var(--background-color));
}

.theme-picker-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.theme-picker-item-label {
  font-weight: 800;
  font-size: 0.94rem;
}

.theme-picker-item-description {
  display: none;
}

/* Tooltip: show description on hover via data attribute */
.theme-picker-item {
  position: relative;
}

.theme-picker-item:hover .theme-picker-item-description,
.theme-picker-item:focus-visible .theme-picker-item-description {
  display: block;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.74rem;
  color: color-mix(in srgb, var(--text-color) 80%, transparent);
  background: color-mix(in srgb, var(--background-color) 96%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 1200;
}

@media (max-width: 620px) {
  .theme-picker {
    width: 100%;
  }

  .theme-picker-toggle {
    width: 100%;
    justify-content: center;
  }

  .theme-picker-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 12px;
    bottom: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100dvh - 24px);
  }

  .theme-picker-menu {
    min-width: 280px;
  }
}
