:root {
  --track: #e9ecef;
  --track-border: #2f2f2f;
  --thumb: #2b2d31;
  --icon-off: #ffffff;
  --icon-on: #2b2d31;
}

.icon-switch {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
}
.icon-switch > input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.icon-switch > input:focus-visible + .track {
  outline: 3px solid #6ea8fe;
  outline-offset: 4px;
}
.icon-switch > input:checked + .track .thumb {
  transform: translateX(22px);
}
.icon-switch > input:checked + .track .sun svg {
  fill: var(--icon-on);
}
.icon-switch > input:checked + .track .moon svg {
  fill: var(--icon-off);
}
.icon-switch > .track {
  position: relative;
  width: 50px;
  height: 27px;
  background: var(--track);
  border: 1px solid var(--track-border);
  border-radius: 999px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 0;
  gap: 0;
}
.icon-switch > .track > .thumb {
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  border-radius: 999px;
  background: var(--thumb);
  transition: transform 180ms ease;
  will-change: transform;
}
.icon-switch > .track > .icon {
  z-index: 1;
  display: grid;
  place-items: center;
}
.icon-switch > .track > .icon.moon {
  width: 100%;
  height: 100%;
  padding-right: 2px;
}
.icon-switch > .track > .icon.moon svg {
  width: 12px;
  height: 12px;
  fill: var(--icon-on);
}
.icon-switch > .track > .icon.sun {
  width: 100%;
  height: 100%;
  padding-left: 2px;
}
.icon-switch > .track > .icon.sun svg {
  width: 15px;
  height: 15px;
  fill: var(--icon-off);
}

@media (prefers-reduced-motion: reduce) {
  .icon-switch .thumb {
    transition: none;
  }
}