:root {
  --theme-toggle-fg: #5f5e5a;
  --theme-toggle-bg: rgba(0, 0, 0, 0.05);
  --theme-toggle-border: rgba(0, 0, 0, 0.15);
  --controls-right-base: max(1.25rem, calc(50vw - 360px + 1.5rem));
}

:root[data-theme="dark"] {
  --theme-toggle-fg: #ece9e0;
  --theme-toggle-bg: rgba(255, 255, 255, 0.08);
  --theme-toggle-border: rgba(255, 255, 255, 0.18);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 1.25rem;
  right: var(--controls-right-base);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--theme-toggle-border);
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-fg);
  cursor: pointer;
  z-index: 60;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Icons show the *target* theme (what clicking switches to), matching the
   language switch button's convention — not the currently active theme. */
.theme-toggle .theme-toggle-icon--sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .theme-toggle-icon--moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .theme-toggle-icon--sun {
  display: block;
}
