:root[data-theme-effective="dark"] {
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, var(--line)) var(--page);
}

:root[data-theme-effective="dark"] .calendar-content,
:root[data-theme-effective="dark"] .events-content,
:root[data-theme-effective="dark"] .settings-content {
  background: var(--page);
}

:root[data-theme-effective="dark"] .restriction-card.is-error {
  border-bottom-color: #87505b;
  background: #2c2529;
}

:root[data-theme-effective="dark"] .restriction-auth-section { border-top-color: var(--line); }
:root[data-theme-effective="dark"] .restriction-group-heading h2,
:root[data-theme-effective="dark"] .restriction-auth-copy h3 { color: var(--text); }
:root[data-theme-effective="dark"] .restriction-group-heading p,
:root[data-theme-effective="dark"] .restriction-auth-copy p,
:root[data-theme-effective="dark"] .restriction-auth-fields > label { color: var(--muted); }
:root[data-theme-effective="dark"] .restriction-auth-card {
  border-color: var(--line);
  background: var(--theme-field);
}
:root[data-theme-effective="dark"] .restriction-auth-fields .restriction-number-control b {
  border-left-color: var(--line);
  background: var(--theme-raised);
  color: var(--muted);
}
:root[data-theme-effective="dark"] .restriction-auth-note {
  background: var(--theme-field);
  color: var(--muted);
}

/* Check marks stay white in every appearance and palette. */
:root[data-theme-effective][data-theme-palette] .active-search-option input:checked + .checkmark::after {
  border: solid #fff;
  border-width: 0 2px 2px 0;
}

:root[data-theme-effective][data-theme-palette] .notification-options input:checked + .checkmark::after,
:root[data-theme-effective][data-theme-palette] .choice-options input:checked + .checkmark::after {
  border-bottom-color: #fff;
  border-left-color: #fff;
}

:root[data-theme-effective="dark"] .skills-tag-editor .skills-editor-tag {
  border: 1px solid var(--line);
  background: var(--theme-chip);
  color: var(--text);
}

:root[data-theme-effective="dark"] .skills-tag-editor .skills-editor-tag:hover {
  border-color: var(--orange);
}

:root[data-theme-effective="dark"] .identity-kyc-prompt {
  border-color: var(--line);
  background: var(--theme-raised);
}

:root[data-theme-effective="dark"] .identity-kyc-icon {
  background: #234159;
  color: #8bc6ff;
}

:root[data-theme-effective="dark"] .identity-kyc-copy strong { color: var(--text); }
:root[data-theme-effective="dark"] .identity-kyc-copy span { color: var(--muted); }

:root[data-theme-effective="dark"] .theme-control-segments {
  border-color: var(--line);
  background: var(--theme-field);
}

:root[data-theme-effective="dark"] .theme-control-segments button,
:root[data-theme-effective="dark"] .account-menu-list .theme-control-segments button {
  color: var(--muted);
}

:root[data-theme-effective="dark"] .theme-control-segments button:hover,
:root[data-theme-effective="dark"] .account-menu-list .theme-control-segments button:hover {
  background: var(--theme-raised);
  color: var(--text);
}

:root[data-theme-effective="dark"] .theme-control-segments button[aria-pressed="true"],
:root[data-theme-effective="dark"] .account-menu-list .theme-control-segments button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--orange) 24%, var(--theme-raised));
  color: #fff;
}

:root[data-theme-effective="dark"] .account-theme-control .theme-control-icon {
  color: var(--text);
}

:root[data-theme-effective="dark"] .admin-theme-control .theme-control-segments {
  background: rgba(255,255,255,.06);
}

:root[data-theme-effective="dark"] input,
:root[data-theme-effective="dark"] textarea,
:root[data-theme-effective="dark"] select {
  color-scheme: dark;
}

:root[data-theme-effective="dark"] input::placeholder,
:root[data-theme-effective="dark"] textarea::placeholder {
  color: var(--muted);
}
:root[data-theme-effective="dark"] { --su-badge-edge: var(--theme-surface); }

/* Keep the events sort control as a single field in dark mode. */
:root[data-theme-effective="dark"] .events-heading .history-sort-select select {
  padding-left: 8px;
  border: 0;
  border-radius: 0;
  outline: 0;
  appearance: none;
  background: transparent;
  box-shadow: none;
}

:root[data-theme-effective="dark"] .events-heading .history-sort-select .ui-select-trigger,
:root[data-theme-effective="dark"] .events-heading .history-sort-select .ui-select-trigger:hover,
:root[data-theme-effective="dark"] .events-heading .history-sort-select .ui-select-trigger:focus-visible,
:root[data-theme-effective="dark"] .events-heading .history-sort-select .ui-select.is-open .ui-select-trigger {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

:root[data-theme-effective="dark"] .events-heading .history-sort-select:focus-within {
  box-shadow: none;
}

/* Palette accents stay consistent across fields, selected cards and admin tools. */
:root[data-theme-effective="light"][data-theme-palette="midnight"] {
  --theme-accent-soft: #eaf1fc;
  --theme-accent-text: #245c99;
  --theme-accent-on: #fff;
}

:root[data-theme-effective="dark"][data-theme-palette="midnight"] {
  --theme-accent-soft: color-mix(in srgb, var(--orange) 18%, var(--theme-surface));
  --theme-accent-text: #bcd9ff;
  --theme-accent-on: #071a34;
}

:root[data-theme-effective="light"][data-theme-palette="forest"] {
  --theme-accent-soft: #e8f4ed;
  --theme-accent-text: #2d6a4e;
  --theme-accent-on: #fff;
}

:root[data-theme-effective="dark"][data-theme-palette="forest"] {
  --theme-accent-soft: color-mix(in srgb, var(--orange) 18%, var(--theme-surface));
  --theme-accent-text: #a7efd2;
  --theme-accent-on: #0b261a;
}

:root[data-theme-effective="light"][data-theme-palette="amethyst"] {
  --theme-accent-soft: #f0ebfb;
  --theme-accent-text: #6847ad;
  --theme-accent-on: #fff;
}

:root[data-theme-effective="dark"][data-theme-palette="amethyst"] {
  --theme-accent-soft: color-mix(in srgb, var(--orange) 18%, var(--theme-surface));
  --theme-accent-text: #dacdff;
  --theme-accent-on: #211a36;
}

:root[data-theme-effective="dark"][data-theme-palette="amethyst"] :is(
  .header-search-button,
  .nav-event-badge,
  .notification-badge,
  .free-minutes-value,
  .free-minutes-notification button,
  .event-claim-button,
  .identity-kyc-action,
  .avatar-editor-apply,
  .save-profile,
  .scheduler-save,
  .scheduler-reschedule,
  .scheduler-delete,
  .scheduler-open-room,
  .primary-create,
  .button-save,
  .bonus-distribute-button,
  .store-admin-actions button,
  .quick-avatar-editor-card > footer button.is-primary
) {
  color: var(--theme-accent-on);
}

:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .ui-select.is-open .ui-select-trigger,
:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .form-field input:focus,
:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .form-field textarea:focus,
:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .form-field select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--orange) 18%, transparent);
}

:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .ui-select.is-open .ui-select-arrow,
:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .ui-select-option.is-selected,
:root:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .ui-select-option.is-selected::after {
  color: var(--orange);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .ui-select-option.is-selected,
:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .role-option:has(input:checked),
:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .notification-options label:has(input:checked),
:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .account-quick-button[aria-pressed="true"],
:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .account-quick-role-options button.is-active,
:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .role-choice input:checked + span {
  border-color: var(--orange);
  background: var(--theme-accent-soft);
  color: var(--theme-accent-text);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .role-option:has(input:checked) {
  box-shadow: 0 8px 24px color-mix(in srgb, var(--orange) 13%, transparent);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .active-search-option:has(input:checked) {
  border-color: var(--orange);
  background: var(--theme-accent-soft);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--orange) 10%, transparent);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .active-search-option:has(input:checked) strong {
  color: var(--theme-accent-text);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .active-search-option input:checked + .checkmark {
  border-color: var(--orange);
  background: var(--orange);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .notification-options label:has(input:checked) strong {
  color: var(--theme-accent-text);
}

:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .role-option:has(input:checked) .role-icon,
:root[data-theme-effective]:is([data-theme-palette="midnight"], [data-theme-palette="forest"], [data-theme-palette="amethyst"]) .account-dialog .role-choice input:checked + span i {
  background: var(--orange);
  color: var(--theme-accent-on);
}

/* Keep the switch states distinguishable in every dark palette. */
:root[data-theme-effective="dark"] :is(.restriction-toggle, .external-api-switch) input:checked + span {
  background: #15966a;
}

:root[data-theme-effective="dark"] :is(.restriction-toggle, .external-api-switch) input + span::after {
  background: #fff;
}
