.theme-switcher {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(128, 128, 128, 0.2);
  border-radius: 999px; /* pill-форма, экономит углы */
  width: fit-content;
  max-width: 100%;
}

/* Скрываем стандартный радио-инпут */
.theme-switcher input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Узкая кнопка */
.theme-switcher label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: #444;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  user-select: none;
  white-space: nowrap;
  min-width: 0;
}

.theme-icon {
  font-size: 13px;
  line-height: 1;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.theme-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Наведение */
.theme-switcher label:hover {
  background: rgba(128, 128, 128, 0.15);
}
.theme-switcher label:hover .theme-icon {
  transform: scale(1.12);
}

/* Активное состояние */
.theme-switcher input[type="radio"]:checked + label {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 6px rgba(102, 126, 234, 0.35);
}

/* Фокус для доступности */
.theme-switcher input[type="radio"]:focus-visible + label {
  outline: 2px solid #667eea;
  outline-offset: 1px;
}

/* Нажатие */
.theme-switcher label:active {
  transform: scale(0.95);
}

/* --- Адаптивность --- */

/* На средних экранах — чуть меньше отступы */
@media (max-width: 480px) {
  .theme-switcher label {
    padding: 4px 6px;
    font-size: 10px;
    gap: 3px;
  }
  .theme-icon {
    font-size: 12px;
  }
}

/* На узких экранах — скрываем текст, оставляем только иконки */
@media (max-width: 360px) {
  .theme-switcher label {
    padding: 5px;
    gap: 0;
  }
  .theme-label {
    display: none;
  }
  .theme-icon {
    font-size: 14px;
  }
}

/* Если контейнер очень узкий — иконки чуть крупнее для тапа */
@media (max-width: 260px) {
  .theme-switcher {
    gap: 1px;
    padding: 2px;
  }
  .theme-switcher label {
    padding: 5px 6px;
  }
}

/* Адаптация под тёмную тему (системную) */
@media (prefers-color-scheme: dark) {
  .theme-switcher {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.08);
  }
  .theme-switcher label {
    color: #d0d0d0;
  }
  .theme-switcher label:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

/* Адаптация под Dark Reader */
html[data-darkreader-scheme="dark"] .theme-switcher {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.08);
}
html[data-darkreader-scheme="dark"] .theme-switcher label {
  color: #d0d0d0;
}
html[data-darkreader-scheme="dark"] .theme-switcher label:hover {
  background: rgba(255, 255, 255, 0.08);
}
html[data-darkreader-scheme="dark"] .theme-switcher input[type="radio"]:checked + label {
  background: linear-gradient(135deg, #7c8ff0 0%, #9b6bc4 100%);
  color: #fff;
}