:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

.theme-toggle {
  appearance: none;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink, CanvasText);
  cursor: pointer;
}

.theme-toggle::before {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.theme-toggle[aria-pressed="true"]::before { transform: rotate(180deg); }
.theme-toggle:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.theme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

@media (max-width: 55rem) {
  .header nav:has(.theme-toggle) { gap: clamp(.35rem, 1.7vw, 1rem); }
}

@media (forced-colors: active) {
  .theme-toggle::before { forced-color-adjust: none; color: ButtonText; }
}
