.theme-toggle-group {
  position: fixed;
  inset-block-start: 16px;
  inset-inline-end: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.theme-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-switch__slider {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background-color: color-mix(
    in srgb,
    var(--color-bg-panel) 75%,
    var(--color-text-main)
  );
  border: 1px solid var(--color-border-panel);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
  transition:
    background-color 150ms ease-out,
    border-color 150ms ease-out,
    box-shadow 150ms ease-out;
}

.theme-switch__slider::before {
  content: "";
  position: absolute;
  inset-block: 2px;
  inset-inline-start: 2px;
  width: 18px;
  border-radius: 999px;
  background-color: var(--color-bg-panel);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.25),
    0 0 0 1px rgb(0 0 0 / 0.12);
  transition:
    transform 150ms ease-out,
    background-color 150ms ease-out,
    box-shadow 150ms ease-out;
}

.theme-switch input[type="checkbox"]:focus-visible + .theme-switch__slider {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-switch input[type="checkbox"]:checked + .theme-switch__slider {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.25);
}

.theme-switch
  input[type="checkbox"]:checked
  + .theme-switch__slider::before {
  transform: translateX(18px);
  background-color: var(--color-bg-panel);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --color-bg-main: var(--color-bg-main-dark);
  --color-bg-panel: var(--color-bg-panel-dark);
  --color-border-panel: var(--color-border-panel-dark);
  --color-border-item: var(--color-border-item-dark);
  --color-text-main: var(--color-text-main-dark);
  --color-text-muted: var(--color-text-muted-dark);
  --color-accent: var(--color-accent-dark);
  --color-accent-soft: var(--color-accent-soft-dark);
  --color-border-photo: var(--color-border-photo-dark);
}

body[data-theme="light"] {
  color-scheme: light;
  --color-bg-main: var(--color-bg-main-light);
  --color-bg-panel: var(--color-bg-panel-light);
  --color-border-panel: var(--color-border-panel-light);
  --color-border-item: var(--color-border-item-light);
  --color-text-main: var(--color-text-main-light);
  --color-text-muted: var(--color-text-muted-light);
  --color-accent: var(--color-accent-light);
  --color-accent-soft: var(--color-accent-soft-light);
  --color-border-photo: var(--color-border-photo-light);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--color-border-panel);
  background-color: color-mix(in srgb, var(--color-bg-panel) 85%, var(--color-text-main));
  color: var(--color-text-main);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  transition:
    background-color 150ms ease-out,
    color 150ms ease-out,
    border-color 150ms ease-out,
    box-shadow 150ms ease-out,
    transform 120ms ease-out;
}

.theme-toggle:hover {
  background-color: color-mix(in srgb, var(--color-bg-panel) 70%, var(--color-text-main));
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.15);
}

.theme-toggle:active {
  transform: scale(0.96);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-toggle--auto {
  width: auto;
  min-width: 32px;
  padding-inline: 0.55rem;
  font-size: 0.8rem;
}

body[data-theme-mode="system"] .theme-toggle--auto {
  background-color: var(--color-accent);
  color: var(--color-bg-panel);
  border-color: var(--color-accent);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.2);
}

.theme-toggle__icon {
  display: inline-block;
}

.theme-toggle__icon--light {
  display: none;
}

body[data-theme="light"] .theme-toggle__icon--light {
  display: inline-block;
}

body[data-theme="light"] .theme-toggle__icon--dark {
  display: none;
}

.lang-switch {
  position: fixed;
  inset-block-start: 16px;
  inset-inline-start: 16px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  z-index: 10;
  font-size: 0.85rem;
}

.lang-switch a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--color-text-main);
  text-decoration: underline;
}

.lang-switch a[aria-current="page"] {
  color: var(--color-accent);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    transition: none;
  }
}

