.ovren-theme-toggle {
  --ovren-toggle-width: 3.6rem;
  --ovren-toggle-height: 2.1rem;
  --ovren-toggle-pad: .18rem;
  --ovren-toggle-thumb-size: calc(var(--ovren-toggle-height) - (var(--ovren-toggle-pad) * 2));
  --ovren-toggle-shift: calc(var(--ovren-toggle-width) - var(--ovren-toggle-thumb-size) - (var(--ovren-toggle-pad) * 2));
  /* Icons use the same color as the track border by default. */
  --ovren-toggle-icon-size: calc(var(--ovren-toggle-height) * .42);
  --ovren-toggle-icon-inset: calc(var(--ovren-toggle-height) * .24);
  --ovren-toggle-icon-color: var(--ovren-switch-icon-color, var(--ovren-toggle-track-border));
  --ovren-toggle-speed: 260ms;
  --ovren-toggle-ease: cubic-bezier(.22, .8, .24, 1);
  --ovren-toggle-track-bg: var(--ovren-switch-track-bg, transparent);
  --ovren-toggle-track-border: var(--ovren-switch-track-border, currentColor);
  --ovren-toggle-thumb-bg: var(--ovren-switch-thumb-bg, currentColor);
  --ovren-toggle-thumb-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  position: relative;
  isolation: isolate;
}

.ovren-theme-toggle:focus {
  outline: none;
}

.ovren-theme-toggle:focus-visible {
  box-shadow: 0 0 0 6px rgba(127, 127, 127, .18);
  border-radius: 999px;
}

.ovren-theme-toggle__track {
  width: var(--ovren-toggle-width);
  height: var(--ovren-toggle-height);
  border-radius: 999px;
  border: 1.5px solid var(--ovren-toggle-track-border);
  background: var(--ovren-toggle-track-bg);
  position: relative;
  display: block;
  transition:
    border-color var(--ovren-toggle-speed) var(--ovren-toggle-ease),
    background-color var(--ovren-toggle-speed) var(--ovren-toggle-ease);
}

/* The sun and moon live in the track; the sliding thumb masks the active side.
   No markup or JavaScript changes are needed (including in the admin preview). */
.ovren-theme-toggle__track::before,
.ovren-theme-toggle__track::after {
  content: "";
  position: absolute;
  top: 50%;
  width: var(--ovren-toggle-icon-size);
  height: var(--ovren-toggle-icon-size);
  background-color: var(--ovren-toggle-icon-color);
  transform: translateY(-50%);
  pointer-events: none;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

/* Sun, visible when the thumb is on the right (night mode). */
.ovren-theme-toggle__track::before {
  left: var(--ovren-toggle-icon-inset);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2m0 16v2M2 12h2m16 0h2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42m0-14.14-1.42 1.42M6.35 17.65l-1.42 1.42'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2m0 16v2M2 12h2m16 0h2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42m0-14.14-1.42 1.42M6.35 17.65l-1.42 1.42'/%3E%3C/svg%3E");
}

/* Crescent moon, visible when the thumb is on the left (light mode). */
.ovren-theme-toggle__track::after {
  right: var(--ovren-toggle-icon-inset);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.6 15.2A9 9 0 0 1 8.8 3.4 9 9 0 1 0 20.6 15.2Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.6 15.2A9 9 0 0 1 8.8 3.4 9 9 0 1 0 20.6 15.2Z'/%3E%3C/svg%3E");
}

.ovren-theme-toggle__thumb {
  width: var(--ovren-toggle-thumb-size);
  height: var(--ovren-toggle-thumb-size);
  border-radius: 50%;
  background: var(--ovren-toggle-thumb-bg);
  box-shadow: var(--ovren-toggle-thumb-shadow);
  z-index: 1;
  position: absolute;
  top: 50%;
  left: var(--ovren-toggle-pad);
  transform: translate3d(0, -50%, 0) scale(1);
  transition:
    transform var(--ovren-toggle-speed) var(--ovren-toggle-ease),
    background-color var(--ovren-toggle-speed) var(--ovren-toggle-ease),
    box-shadow var(--ovren-toggle-speed) var(--ovren-toggle-ease);
  will-change: transform;
}

html[data-theme="night"] .ovren-theme-toggle__thumb,
html[data-theme="dark"] .ovren-theme-toggle__thumb {
  transform: translate3d(var(--ovren-toggle-shift), -50%, 0) scale(1);
}

.ovren-theme-toggle:active .ovren-theme-toggle__thumb {
  transform: translate3d(0, -50%, 0) scale(.92);
}

html[data-theme="night"] .ovren-theme-toggle:active .ovren-theme-toggle__thumb,
html[data-theme="dark"] .ovren-theme-toggle:active .ovren-theme-toggle__thumb {
  transform: translate3d(var(--ovren-toggle-shift), -50%, 0) scale(.92);
}

@media (prefers-reduced-motion: reduce) {
  .ovren-theme-toggle__track,
  .ovren-theme-toggle__thumb {
    transition: none;
  }
}
