.sf-theme-toggle {
  width: 72px;
  height: 38px;
  flex: 0 0 72px;
  padding: 3px;
  border: 1px solid #c7d5e8;
  border-radius: 999px;
  background: #edf4fd;
  cursor: pointer;
  box-shadow:
    inset 0 1px 2px rgba(27, 48, 82, 0.06),
    0 4px 12px rgba(42, 55, 101, 0.08);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.sf-theme-toggle[hidden] {
  display: none !important;
}

.sf-theme-toggle-floating {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 1100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

html.dark-mode .sf-theme-toggle-floating {
  background: rgba(15, 24, 39, 0.92);
}

.sf-theme-toggle:hover {
  transform: translateY(-1px);
  border-color: #8fb1e5;
  box-shadow:
    inset 0 1px 2px rgba(27, 48, 82, 0.06),
    0 7px 18px rgba(42, 55, 101, 0.14);
}

.sf-theme-toggle:focus-visible {
  outline: 3px solid rgba(76, 97, 239, 0.28);
  outline-offset: 3px;
}

.sf-theme-toggle-track {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  overflow: hidden;
  border-radius: inherit;
  background: transparent;
  transition: color 220ms ease, background 220ms ease;
}

.sf-theme-toggle-track > i {
  position: absolute;
  top: 1px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  line-height: 1;
  font-size: 13px;
  text-align: center;
  transition: color 220ms ease, opacity 220ms ease;
}

.sf-theme-toggle-sun {
  left: 1px;
  color: #1266f1;
}

.sf-theme-toggle-moon {
  right: 1px;
  color: #687a96;
}

.sf-theme-toggle-thumb {
  position: absolute;
  z-index: 2;
  top: 1px;
  left: 1px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 2px 7px rgba(28, 42, 84, 0.2),
    0 0 0 1px rgba(118, 141, 174, 0.12);
  transition:
    transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background 220ms ease,
    box-shadow 220ms ease;
}

html.dark-mode .sf-theme-toggle {
  border-color: #40526d;
  background: #202c40;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.22),
    0 5px 14px rgba(0, 0, 0, 0.2);
}

html.dark-mode .sf-theme-toggle-track {
  background: transparent;
}

html.dark-mode .sf-theme-toggle-sun {
  color: #91a0b8;
  opacity: 0.78;
}

html.dark-mode .sf-theme-toggle-moon {
  color: #dbe6ff;
}

html.dark-mode .sf-theme-toggle-thumb {
  transform: translateX(32px);
  background: #536b96;
  box-shadow:
    0 3px 9px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(180, 201, 239, 0.16);
}

@media (prefers-reduced-motion: reduce) {
  .sf-theme-toggle,
  .sf-theme-toggle-track,
  .sf-theme-toggle-track > i,
  .sf-theme-toggle-thumb {
    transition: none;
  }
}

@media print {
  .sf-theme-toggle {
    display: none !important;
  }
}
