/* Warm charcoal surfaces and soft text for night reading.
   Attribute specificity keeps course-level :root colors from overriding night mode. */
:root[data-theme="dark"] {
  --color-bg: #18171c;
  --color-bg-alt: #1e1d23;
  --color-bg-rgb: 24, 23, 28;
  --color-surface: #222127;
  --color-surface-hover: #2c2a33;
  --color-surface-raised: #2c2a33;
  --color-border: #403b49;
  --color-text: #ded9e3;
  --color-text-secondary: #bcb5c5;
  --color-text-muted: #a59dad;
  --color-text-tertiary: #a59dad;
  --color-primary: #b3a0dc;
  --color-primary-light: #c0afe5;
  --color-primary-dark: #ad96d4;
  --color-primary-rgb: 179, 160, 220;
  --color-primary-glow: rgba(179, 160, 220, .10);
  --color-on-primary: #211b2e;
  --color-accent: #c4a778;
  --color-accent-rgb: 196, 167, 120;
  --color-warning: #d1b275;
  --color-danger: #dc9398;
  --color-success: #8bbda0;
  --color-switcher-from: #201e26;
  --color-switcher-to: #282430;
  --gratitude-accent: #d8a17d;
  --gratitude-accent-soft: #b88a6d;
  --gratitude-bg-start: var(--color-bg);
  --gratitude-bg-end: var(--color-bg-alt);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .16);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, .22);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, .28);
  --shadow-glow: 0 2px 12px rgba(0, 0, 0, .16);
  background: var(--color-bg);
  color-scheme: dark;
}

:root[data-theme="dark"] body {
  background: var(--color-bg);
}

/* These older components use literal light surfaces instead of shared tokens. */
:root[data-theme="dark"] :is(
  .exercise-thought-input,
  .exercise-thought-input:focus, .gr-goal-display-text, .gr-thought-input,
  .gr-thought-input:focus, .ws-section, .gratitude-quote-block,
  .gratitude-composer-card, .gratitude-entry-input, .gratitude-entry-input:focus,
  .gratitude-history-empty, .gratitude-entry-card, .gratitude-name-field input,
  .gratitude-shared-card, .gr-react-btn, .gr-react-btn.active, .gr-react-btn:hover,
  .gr-add-react:hover, .sr-delete-no, .sr-node-content, .sr-thought-main,
  .sr-inline-picker, .sr-why-input, .sr-custom-wanting-input, .sr-wanting-picker
) {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

:root[data-theme="dark"] .sr-delete-confirm {
  background: rgba(220, 147, 152, .08);
  border-color: var(--color-danger);
}

:root[data-theme="dark"] .gr-react-btn.active {
  border-color: var(--gratitude-accent);
  background: rgba(216, 161, 125, .12);
}

:root[data-theme="dark"] :is(.as-x-all-item:active, .as-y-btn:active, .as-rev-card-header:active) {
  background: var(--color-surface-hover);
}

:root[data-theme="dark"] ::selection {
  background: #514263;
  color: var(--color-text);
}

/* Account-menu preferences share the menu's light/dark surface tokens. */
.appearance-settings {
  flex-shrink: 0;
}
.appearance-switch-track {
  margin-left: auto;
  pointer-events: none;
}
.appearance-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Filled brand controls use an ink foreground on the soft night accent. */
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .session-preview-card.featured .featured-badge,
:root[data-theme="dark"] .session-nav-item.active,
:root[data-theme="dark"] .tab-btn.active,
:root[data-theme="dark"] .exercise-step-num,
:root[data-theme="dark"] .ix-btn-next,
:root[data-theme="dark"] .ix-btn-next:hover,
:root[data-theme="dark"] .intensity-btn.active,
:root[data-theme="dark"] .mood-btn.active,
:root[data-theme="dark"] .release-fab,
:root[data-theme="dark"] .release-fab-steps-item.checked .release-fab-steps-check,
:root[data-theme="dark"] .release-mode-tabs .release-mode-tab.active,
:root[data-theme="dark"] .release-assumption-add-btn,
:root[data-theme="dark"] .thought-add-btn.confirmed,
:root[data-theme="dark"] .thought-add-btn:hover,
:root[data-theme="dark"] .emotion-tab.active,
:root[data-theme="dark"] .sub-emotion-chip.selected,
:root[data-theme="dark"] .custom-sub-confirm,
:root[data-theme="dark"] .sub-emotion-confirm-btn.active,
:root[data-theme="dark"] .quick-count-badge,
:root[data-theme="dark"] .release-finish-btn:hover,
:root[data-theme="dark"] .release-login-nudge-btn,
:root[data-theme="dark"] .release-continue-btn,
:root[data-theme="dark"] .auth-login-btn,
:root[data-theme="dark"] .notif-reply-btn,
:root[data-theme="dark"] .auth-avatar,
:root[data-theme="dark"] .profile-editor-save,
:root[data-theme="dark"] .auth-dropdown-avatar,
:root[data-theme="dark"] .journey-badge,
:root[data-theme="dark"] .sw-update-banner-refresh,
:root[data-theme="dark"] .pwa-install-btn,
:root[data-theme="dark"] #xpageAudioPersist .xp-play,
:root[data-theme="dark"] .ws-start-btn,
:root[data-theme="dark"] .ws-picker-create-btn,
:root[data-theme="dark"] .audio-header-play-btn,
:root[data-theme="dark"] .audio-guide-play-all,
:root[data-theme="dark"] .audio-guide-play-pause,
:root[data-theme="dark"] .audio-seg-item.active .audio-seg-play,
:root[data-theme="dark"] .audio-mini-play,
:root[data-theme="dark"] .gr-goal-add-btn,
:root[data-theme="dark"] .gr-picker-add-btn,
:root[data-theme="dark"] .audio-inline-play.playing,
:root[data-theme="dark"] .audio-ctrl-btn.active,
:root[data-theme="dark"] .audio-seg-item .seg-toggle.checked,
:root[data-theme="dark"] .audio-mini-player .mini-btn,
:root[data-theme="dark"] .sr-add-btn,
:root[data-theme="dark"] .sr-wanting-chip:active,
:root[data-theme="dark"] .sr-wanting-chip.sr-chip-active,
:root[data-theme="dark"] .sr-fab-release,
:root[data-theme="dark"] .sr-six-steps-item.checked .sr-six-steps-check,
:root[data-theme="dark"] .fw-section-title .fw-num,
:root[data-theme="dark"] .fw-layer-num,
:root[data-theme="dark"] .about-howto-step-num,
:root[data-theme="dark"] .feedback-login-btn,
:root[data-theme="dark"] .feedback-submit-btn,
:root[data-theme="dark"] .release-step-num,
:root[data-theme="dark"] .category-btn.active,
:root[data-theme="dark"] .hootless-btn.active,
:root[data-theme="dark"] .df-add-btn,
:root[data-theme="dark"] .process-card-number,
:root[data-theme="dark"] .gr-phase-dot.active .gr-dot-icon,
:root[data-theme="dark"] .gr-step-num,
:root[data-theme="dark"] .gr2-start-btn,
:root[data-theme="dark"] .gr2-picker-create-btn,
:root[data-theme="dark"] .ws-failed-restart-btn,
:root[data-theme="dark"] .as-axiom-item.accepted .as-axiom-check,
:root[data-theme="dark"] .as-x-btn,
:root[data-theme="dark"] .as-y-btn.primary,
:root[data-theme="dark"] .as-primary-btn,
:root[data-theme="dark"] .as-complete-btn,
:root[data-theme="dark"] .as-assumption-save-btn,
:root[data-theme="dark"] .as-feeling-ref-chip.selected,
:root[data-theme="dark"] .as-secondary-btn:hover,
:root[data-theme="dark"] .mr-add-btn,
:root[data-theme="dark"] .mr-done-btn:hover,
:root[data-theme="dark"] .mr-entry-card.done .mr-done-btn,
:root[data-theme="dark"] .mr-generate-btn,
:root[data-theme="dark"] .mr-settings-save-btn,
:root[data-theme="dark"] .mr-voice-check-on,
:root[data-theme="dark"] .mr-rf-wanting-chip.selected,
:root[data-theme="dark"] .cap-ref-chip.selected,
:root[data-theme="dark"] .mr-release-start-btn:hover,
:root[data-theme="dark"] .mr-rf-opt-btn:hover,
:root[data-theme="dark"] .admin-gate button,
:root[data-theme="dark"] .time-filter-btn.active,
:root[data-theme="dark"] .refresh-btn:hover,
:root[data-theme="dark"] .fb-tab.active,
:root[data-theme="dark"] .fb-reply-btn,
:root[data-theme="dark"] .access-lookup-form button,
:root[data-theme="dark"] .access-action-btn,
:root[data-theme="dark"] .shares-tab.active,
:root[data-theme="dark"] .ach-empty-cta,
:root[data-theme="dark"] .ach-share-fab,
:root[data-theme="dark"] .ach-submit-btn {
  color: var(--color-on-primary);
}
