.theme-toggle {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 16px;
  color: var(--color-primary-hover, var(--color-primary-dark, #15803d));
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(220, 252, 231, 0.82));
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.16);
  transition: var(--transition, all 0.3s cubic-bezier(0.4, 0, 0.2, 1));
}

.theme-toggle:hover {
  color: #ffffff;
  border-color: rgba(34, 197, 94, 0.34);
  background:
    linear-gradient(
      135deg,
      var(--color-primary-hover, var(--color-primary-dark, #15803d)),
      var(--color-primary, #22c55e)
    );
  transform: translateY(-1px);
}

.theme-toggle__track {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.theme-toggle__icon {
  position: absolute;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 17px;
  line-height: 1;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.theme-toggle__icon--sun {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(0deg);
}

.theme-toggle__icon--moon {
  opacity: 0;
  font-size: 0;
  transform: translateY(12px) scale(0.8) rotate(-25deg);
}

.theme-toggle__icon--moon::before,
.theme-toggle__icon--moon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.theme-toggle__icon--moon::before {
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask:
    radial-gradient(circle at 68% 32%, transparent 0 8px, #000 8.4px);
  mask:
    radial-gradient(circle at 68% 32%, transparent 0 8px, #000 8.4px);
  box-shadow:
    0 0 0 1px rgba(187, 247, 208, 0.12),
    0 3px 10px rgba(5, 46, 30, 0.18);
}

.theme-toggle__icon--moon::after {
  content: none;
}

html.theme-dark .theme-toggle {
  color: #bbf7d0;
  border-color: rgba(134, 239, 172, 0.28);
  background:
    radial-gradient(circle at 30% 20%, rgba(134, 239, 172, 0.22), transparent 42%),
    linear-gradient(135deg, #0f3d2a, #052e1e);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
}

html.theme-dark .theme-toggle:hover {
  color: #ffffff;
  border-color: rgba(187, 247, 208, 0.46);
  background: linear-gradient(135deg, #166534, var(--color-primary, #34d399));
}

html.theme-dark .theme-toggle__icon--sun {
  opacity: 0;
  transform: translateY(-12px) scale(0.8) rotate(28deg);
}

html.theme-dark .theme-toggle__icon--moon {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(0deg);
}

@media (max-width: 720px) {
  .theme-toggle {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    border-radius: 14px;
  }
}
