/* Preferência global; as regras claras não alteram a paleta escura existente. */
:root { color-scheme: dark; }

.profile-theme-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 4px 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-hover);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.profile-theme-toggle > svg { flex-shrink: 0; }
.profile-theme-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.profile-theme-switch {
  flex: 0 0 38px;
  height: 23px;
  margin-left: auto;
  padding: 3px;
  border-radius: 999px;
  background: var(--text-faint);
}
.profile-theme-switch::before {
  content: '';
  display: block;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
}
.profile-theme-toggle[aria-checked="true"] .profile-theme-switch { background: var(--sarau-on); }
.profile-theme-toggle[aria-checked="true"] .profile-theme-switch::before { transform: translateX(15px); }

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-hover: #e5e7ec;
  --border: #d9dce2;
  --text: #202127;
  --text-dim: #5f6470;
  --text-faint: #707580;
  --accent: #262931;
  --sarau-playhead: #a66f00;
  --theme-subtle: #edeef2;
}

html[data-theme="light"] .topbar { background: rgba(245, 245, 247, 0.92); }
html[data-theme="light"] :is(.modal-card, .room-menu, .queue-popover, .volume-popover,
  .drop-pill, .sync-prompt, .sarau-tooltip) {
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(30, 35, 50, 0.12);
}
html[data-theme="light"] .studio-head { background: var(--surface); }
html[data-theme="light"] .modal-tabs::after { background: var(--text); }
html[data-theme="light"] :is(.floating-player, .fab, .sarau-controls) {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(30, 35, 50, 0.13);
}
html[data-theme="light"] :is(.icon-btn, .add-track-btn, .modal-field, .home-search-field,
  .home-search-close, .room-settings-list, .cover-action-btn, .login-btn, .member-avatar.extra,
  .room-settings-tabs, .settings-section .badge, .footer-btn, .track-info-icon-btn,
  .queue-close-btn, .queue-track-kebab, .fx-btn, .room-settings-value,
  .studio-btn.is-ghost, .studio-chip, .studio-icon-btn, .studio-layer-btn, .studio-bypass,
  .studio-saved, .eq-bypass-btn, .control-toast button.accept) {
  background: var(--theme-subtle);
  color: var(--text);
}
html[data-theme="light"] :is(.home-search-field input, .floating-time, .floating-transport-btn,
  .floating-player.is-expanded .floating-transport-btn, .home-search-close, .track-action) { color: var(--text); }
html[data-theme="light"] :is(.floating-player-sub, .home-search-field) { color: var(--text-dim); }
/* Esses elementos recebem branco diretamente do template/atualizações da fila. */
html[data-theme="light"] :is(.room-kebab, .queue-track-title) { color: var(--text) !important; }
html[data-theme="light"] #volumeBtn.is-muted { color: var(--text); }
html[data-theme="light"] #volumeBtn .volume-icon-off path { fill: currentColor; }
html[data-theme="light"] #floatingPlayPause { color: var(--text); }
html[data-theme="light"] .track-num-playing i { background: var(--text); }
html[data-theme="light"] .modal-field:focus { border-color: var(--text-dim); }
html[data-theme="light"] .home-genre-chip { background: #e8e3f1; color: #514162; }
html[data-theme="light"] .home-genre-chip[aria-pressed="true"] { background: #514162; color: #fff; }

html[data-theme="light"] :is(.modal-btn.primary, .modal-btn-full.is-white,
  .modal-btn-full.is-secondary, .modal-btn-full.is-primary, .studio-btn.is-save,
  .eq-bypass-btn.active, .fx-btn.is-playing, .studio-icon-btn.is-metro.is-on,
  .studio-layer-btn.is-on, .studio-icon-btn.is-play.is-playing) {
  background: var(--text);
  color: #fff;
}
html[data-theme="light"] :is(.modal-btn.primary, .modal-btn-full.is-white,
  .modal-btn-full.is-secondary, .modal-btn-full.is-primary, .play-btn):hover:not(:disabled) {
  background: #3a3d45;
  color: #fff;
}
html[data-theme="light"] :is(.room-menu button.danger, .modal-error, .track-date.is-failed,
  .modal-btn-full.is-red, .profile-logout-btn:hover) { color: #b62d35; }
html[data-theme="light"] .control-note.is-warning { color: #946000; }
html[data-theme="light"] :is(.member-avatar.is-host, .track-uploader.is-mine, .queue-count) { color: #fff; }
html[data-theme="light"] .track-list .track-uploader { opacity: 1; border-color: var(--border); }
html[data-theme="light"] .track-list .track-uploader:not(.is-mine) {
  background: var(--theme-subtle);
  color: var(--text-dim);
}
html[data-theme="light"] .waveform-container { color: var(--text-dim); }
html[data-theme="light"] .wave-head { stroke: var(--sarau-playhead); }
html[data-theme="light"] .login-toggle:hover { color: var(--text); }
html[data-theme="light"] .sarau-switch:not(.is-on) { background: #b1b6c0; }
html[data-theme="light"] .studio-row input[type="range"],
html[data-theme="light"] .studio-fx-foot input[type="range"],
html[data-theme="light"] .control-group input[type="range"] { accent-color: var(--text); }
html[data-theme="light"] .studio-layer { background: var(--theme-subtle); }
html[data-theme="light"] .studio-layer.is-selected.is-base {
  background: var(--surface-hover);
  border-color: var(--text-dim);
}
html[data-theme="light"] .studio-layer.is-selected:not(.is-base) { background: #fce9e9; }
html[data-theme="light"] .cover-thumb:is(.is-current, .is-focused) { border-color: var(--text); }
html[data-theme="light"] .floating-player.is-expanded .floating-player-handle::before { background: #9499a4; }
html[data-theme="light"] .volume-popover input[type="range"] {
  background: linear-gradient(to top, var(--sarau-playhead) var(--vol-pct, 100%), #d2d5dc var(--vol-pct, 100%));
}
html[data-theme="light"] :is(.queue-scroll-area, .room-settings-list,
  .studio-layers, .studio-fx-body)::-webkit-scrollbar-thumb { background: #b6bbc5; }

@media (hover: hover) {
  html[data-theme="light"] :is(.icon-btn, .add-track-btn, .track-item, .fab, .cover-action-btn,
    .footer-btn, .queue-close-btn, .queue-track-item, .queue-track-kebab, .track-action,
    .track-info-icon-btn, .fx-btn, .studio-btn.is-ghost, .studio-icon-btn, .eq-bypass-btn,
    .floating-transport-btn, .modal-tab, .home-genre-chip):hover:not(.active):not(.is-playing):not(.is-on):not([aria-pressed="true"]) {
    background: var(--surface-hover);
  }
}
/* A cor de ativo prevalece sobre o hover e sobre o player expandido. */
html[data-theme="light"] :is(#floatingShuffleBtn.active, .shuffle-btn.active) { color: var(--sarau-playhead); }
/* A capa e os painéis de áudio mantêm seu contraste e as cores das faixas. */
html[data-theme="light"] :is(.eq-stage, .studio-stage, .studio-eq-stage) {
  --text: #f5f5f6;
  --text-dim: #b0b3bc;
  --text-faint: #9397a2;
}
html[data-theme="light"] :is(.eq-stage, .studio-eq-stage) button.eq-bypass-btn {
  background: #303238;
  color: #f5f5f6;
}
html[data-theme="light"] :is(.eq-stage, .studio-eq-stage) button.eq-bypass-btn.active {
  background: #f5f5f6;
  color: #202127;
}
@media (max-width: 768px) {
  html[data-theme="light"] #leaveRoomLink { background: var(--theme-subtle); }
  html[data-theme="light"] .floating-player:not(.is-expanded) #floatingPlayPause {
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
  }
}

/* toast: a mesma pílula, invertida pro tema claro */
html[data-theme="light"] .control-toast {
  background: #e9e9ec;
  color: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .control-toast :is(strong, a) { color: #111; }
