.theme-toggle {
  position: relative;
  width: 64px;
  height: 44px;
  flex: 0 0 64px;
  padding: 8px 4px;
  display: grid;
  grid-template-columns: 28px 28px;
  align-items: center;
  border: 0;
  border-radius: 999px;
  color: #7f8d84;
  background: transparent;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 4px 0;
  border: 1px solid rgba(190, 242, 100, .2);
  border-radius: inherit;
  background: rgba(255, 255, 255, .055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
  transition:
    border-color .28s ease,
    background-color .28s ease,
    box-shadow .28s ease;
}

.theme-toggle:hover::before {
  border-color: rgba(190, 242, 100, .42);
  background: rgba(255, 255, 255, .075);
}

.theme-toggle:active {
  transform: scale(.97);
}

.theme-toggle-sun,
.theme-toggle-moon {
  position: relative;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  opacity: .64;
  transition:
    color .28s ease,
    opacity .28s ease,
    transform .32s cubic-bezier(.2, .8, .2, 1);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.theme-toggle-thumb {
  position: absolute;
  z-index: 1;
  top: 8px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #25372c;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, .22),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  transform: translate3d(28px, 0, 0);
  transition:
    transform .34s cubic-bezier(.2, .8, .2, 1),
    background-color .28s ease,
    box-shadow .28s ease;
  will-change: transform;
}

html[data-theme="dark"] .theme-toggle-moon {
  color: #bef264;
  opacity: 1;
  transform: scale(1.04);
}

html[data-theme="light"] .theme-toggle {
  color: #718078;
}

html[data-theme="light"] .theme-toggle::before {
  border-color: rgba(64, 91, 47, .18);
  background: rgba(20, 32, 25, .055);
  box-shadow: inset 0 1px 1px rgba(20, 32, 25, .04);
}

html[data-theme="light"] .theme-toggle:hover::before {
  border-color: rgba(79, 118, 18, .36);
  background: rgba(20, 32, 25, .075);
}

html[data-theme="light"] .theme-toggle-thumb {
  background: #fff;
  box-shadow:
    0 2px 8px rgba(25, 48, 31, .14),
    0 0 0 1px rgba(25, 48, 31, .025);
  transform: translate3d(0, 0, 0);
}

html[data-theme="light"] .theme-toggle-sun {
  color: #527a10;
  opacity: 1;
  transform: scale(1.04);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .34s;
  animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}

html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition-property: background-color, border-color, color, fill, stroke, box-shadow;
  transition-duration: .34s;
  transition-timing-function: cubic-bezier(.2, .8, .2, 1);
}

html.theme-transition .theme-toggle-thumb {
  transition-property: transform, background-color, box-shadow;
}

html.theme-transition .theme-toggle-sun,
html.theme-transition .theme-toggle-moon {
  transition-property: color, opacity, transform;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle::before,
  .theme-toggle-thumb,
  .theme-toggle-sun,
  .theme-toggle-moon {
    transition: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0s;
  }

  html.theme-transition *,
  html.theme-transition *::before,
  html.theme-transition *::after {
    transition: none;
  }
}
