/**
 * 首选项 / 快照 / 环境音 弹窗专用视觉层（不改 DOM 与脚本逻辑）
 * 加载于 ui-theme.css 之后
 */

/* ========== 首选项 #preferencesModal ========== */
#preferencesModal .modal-content {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

#preferencesModal .preferences-layout {
  padding-top: var(--space-1);
}

#preferencesModal .preferences-section + .preferences-section {
  margin-top: var(--space-4);
}

#preferencesModal .preferences-section-title {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-2xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-secondary);
}

#preferencesModal .preferences-panel {
  border: 1px solid var(--c-border-primary);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

#preferencesModal .preferences-panel .form-group {
  padding: var(--space-2-5) var(--space-3);
  border-bottom-color: var(--c-border-primary);
  gap: var(--space-2);
  transition: background-color var(--t-fast) var(--ease-ui);
}

#preferencesModal .preferences-panel .form-group:hover {
  background-color: var(--surface-subtle);
}

#preferencesModal .preferences-panel .form-group:last-child {
  border-bottom: 0;
}

#preferencesModal .preferences-panel .control-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: inherit;
}

#preferencesModal .theme-switcher {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border-primary);
  background: var(--surface-subtle);
  box-shadow: var(--shadow-sm);
  padding: 3px 2px;
  align-items: stretch;
}

/* 覆盖 global 固定 width，三等分与滑块对齐 */
#preferencesModal .theme-switcher label {
  flex: 1 1 0;
  width: auto !important;
  min-width: 0;
  max-width: none;
  display: flex;
  align-items: stretch;
  justify-content: center;
  color: color-mix(in srgb, var(--c-text-secondary) 82%, var(--c-text-primary) 18%);
  transition: color var(--t-fast) var(--ease-ui);
}

#preferencesModal .theme-switcher .slider {
  border-radius: var(--radius-sm);
  top: 3px;
  bottom: 3px;
  width: calc((100% - 4px) / 3);
}

#preferencesModal .theme-switcher label:hover {
  color: color-mix(in srgb, var(--c-text-primary) 55%, var(--c-text-secondary) 45%);
}

/* 竖排图标+文案：避免「跟随设备」与邻格横向重叠，文案仍单行不换行 */
#preferencesModal .theme-switcher label span {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 3px;
  padding: var(--space-1) 2px;
  white-space: nowrap;
  text-align: center;
  line-height: var(--leading-tight);
  font-size: var(--font-size-2xs);
  font-weight: 500;
  justify-content: center;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

#preferencesModal .theme-switcher label svg {
  margin-right: 0;
  margin-bottom: 0;
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0;
}

#preferencesModal .preferences-panel .form-control {
  min-height: 32px;
  height: auto;
  border-radius: var(--radius-md);
}

#preferencesModal #resetPreferences {
  float: none;
  display: inline-flex;
  align-items: center;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--c-accent);
  text-decoration: none;
  padding: var(--space-1) 0;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast) var(--ease-ui), opacity var(--t-fast) var(--ease-ui);
}

#preferencesModal #resetPreferences:hover,
#preferencesModal #resetPreferences:focus {
  color: var(--c-accent-hover);
  text-decoration: underline;
  outline: none;
}

#preferencesModal #resetPreferences:focus-visible {
  box-shadow: var(--focus-ring);
}

#preferencesModal .preferences-reset-row {
  margin-top: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--c-border-primary);
}

.dark #preferencesModal .preferences-panel {
  background: var(--c-bg-primary);
  border-color: var(--c-border-primary);
}

.dark #preferencesModal .preferences-panel .form-group:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dark #preferencesModal .theme-switcher {
  background: var(--c-bg-secondary);
  border-color: var(--c-border-primary);
}

/* ========== 环境音 #whiteNoiseModal ========== */
#whiteNoiseModal .modal-dialog {
  width: min(520px, calc(100vw - 24px));
  max-width: min(520px, calc(100vw - 24px));
}

@media (min-width: 768px) {
  #whiteNoiseModal .modal-dialog {
    width: min(520px, calc(100vw - 32px));
    max-width: min(520px, calc(100vw - 32px));
  }
}

#whiteNoiseModal .modal-body {
  padding: var(--space-3) var(--space-3-5);
  background: var(--surface-subtle);
}

.dark #whiteNoiseModal .modal-body {
  background: var(--c-bg-secondary);
}

#whiteNoiseModal .sound-buttons {
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}

#whiteNoiseModal .sound-button {
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  border: 1px solid var(--c-border-primary);
  box-shadow: var(--shadow-sm);
  gap: var(--space-3);
  transition: border-color var(--t-normal) var(--ease-ui), box-shadow var(--t-normal) var(--ease-ui),
    background-color var(--t-normal) var(--ease-ui), transform var(--t-fast) var(--ease-ui);
}

#whiteNoiseModal .sound-button:hover {
  border-color: var(--c-accent-border);
  box-shadow: var(--shadow-md);
}

#whiteNoiseModal .sound-button:active {
  transform: scale(0.98);
}

#whiteNoiseModal .sound-button.playing {
  background: var(--c-accent-muted);
  border-color: var(--c-accent);
  box-shadow: 0 0 0 1px var(--c-accent-border);
}

#whiteNoiseModal .sound-button span {
  font-weight: 500;
  color: inherit;
}

#whiteNoiseModal .sound-button > div:first-child {
  color: inherit;
}

#whiteNoiseModal .sound-button svg path[fill='#000000'],
#whiteNoiseModal .sound-button svg path[fill='#000'],
#whiteNoiseModal .sound-button svg path[fill='black'] {
  fill: currentColor !important;
}

#whiteNoiseModal .sound-button.playing::after {
  background-color: var(--c-accent);
  box-shadow: 0 0 0 0 rgba(61, 106, 158, 0.45);
}

#whiteNoiseModal .volume-slider {
  height: 5px;
  border-radius: 999px;
  background: var(--c-border-primary);
}

#whiteNoiseModal .volume-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  background: var(--c-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--t-fast) var(--ease-ui);
}

#whiteNoiseModal .volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.08);
}

#whiteNoiseModal .volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--c-accent);
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ambient-noise-preset-trigger {
  height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--c-border-primary);
  border-radius: 999px;
  background: var(--surface-elevated);
  color: inherit;
  font-size: var(--font-size-xs);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast) var(--ease-ui), box-shadow var(--t-fast) var(--ease-ui),
    background-color var(--t-fast) var(--ease-ui);
}

.ambient-noise-preset-trigger:hover,
.ambient-noise-preset-trigger:focus,
.ambient-noise-preset-trigger.open {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-muted);
  outline: none;
}

.ambient-noise-preset-menu {
  border: 1px solid var(--c-border-primary);
  border-radius: var(--radius-xl);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-modal);
}

.ambient-noise-preset-menu::before {
  background: var(--surface-elevated);
  border-color: var(--c-border-primary);
}

.ambient-noise-preset-row {
  color: inherit;
}

.ambient-noise-preset-row:hover,
.ambient-noise-preset-row:focus {
  background: var(--c-accent-muted);
}

.ambient-noise-preset-row.active {
  background: var(--c-accent-muted);
}

.ambient-noise-preset-row-name {
  font-weight: 600;
}

.ambient-noise-preset-check {
  color: var(--c-accent);
}

.ambient-noise-preset-empty {
  color: var(--c-text-secondary);
}

.ambient-noise-preset-create {
  border-top-color: var(--c-border-primary);
  background: var(--surface-elevated);
  color: inherit;
}

.ambient-noise-preset-create:hover,
.ambient-noise-preset-create:focus {
  background: var(--surface-subtle);
}

#whiteNoiseModal .global-mute-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: inherit;
  transition: background-color var(--t-fast) var(--ease-ui), color var(--t-fast) var(--ease-ui);
}

#whiteNoiseModal .global-mute-button:hover,
#whiteNoiseModal .global-mute-button:focus-visible {
  background: var(--c-accent-muted);
  outline: none;
}

#whiteNoiseModal .global-mute-button:focus-visible {
  box-shadow: var(--focus-ring);
}

.dark .ambient-noise-preset-icon-button {
  color: var(--c-text-secondary);
}

.dark .ambient-noise-preset-icon-button:hover,
.dark .ambient-noise-preset-icon-button:focus {
  color: var(--c-text-primary);
}

@media (prefers-reduced-motion: reduce) {
  #createSnapshotBtn,
  #whiteNoiseModal .sound-button,
  #whiteNoiseModal .volume-slider::-webkit-slider-thumb {
    transition: none;
  }

  #whiteNoiseModal .sound-button:active {
    transform: none;
  }

  #createSnapshotBtn:active {
    transform: none;
  }
}
