/* Shared feedback for hosted and legacy authentication controls. */
:root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select) {
  --auth-control-bg: #171717;
  --auth-control-hover: #303030;
  --auth-control-pressed: #101010;
  --auth-control-border: #171717;
  --auth-control-hover-border: #171717;
  --auth-control-focus: #2563eb;
  background-color: var(--auth-control-bg);
  border-color: var(--auth-control-border);
  transform: none;
  scale: 1;
  touch-action: manipulation;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, scale 160ms ease-out;
}

:root .app .auth-main :is(.button.secondary,.providers .button,.qr-refresh):not(.subject-type-select) {
  --auth-control-bg: #fff;
  --auth-control-hover: #fafafa;
  --auth-control-pressed: #f0f0f0;
  --auth-control-hover-border: #b8b8b8;
}

:root .app .auth-main .button.secondary:not(.subject-type-select) {
  --auth-control-border: #d4d4d4;
}

:root .app .auth-main .providers .button:not(.subject-type-select) {
  --auth-control-border: #e1e1e1;
}

:root .app .auth-main .registration-form .providers .button:not(.subject-type-select) {
  --auth-control-border: #dedede;
}

:root .app .auth-main .qr-refresh:not(.subject-type-select) {
  --auth-control-border: #cfcfcf;
}

:root .app .auth-main .login-identifier-summary:not(.subject-type-select) {
  --auth-control-bg: transparent;
  --auth-control-hover: #f8f9fa;
  --auth-control-pressed: #f0f0f0;
  --auth-control-border: var(--account-border,#d0d5dd);
  --auth-control-hover-border: #b8b8b8;
}

:root[data-account-theme="dark"] .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select) {
  --auth-control-bg: #e8edf5;
  --auth-control-hover: #d4dfef;
  --auth-control-pressed: #c9d5e5;
  --auth-control-border: #e8edf5;
  --auth-control-hover-border: #d4dfef;
  --auth-control-focus: #fff;
}

:root[data-account-theme="dark"] .app .auth-main :is(.button.secondary,.providers .button,.qr-refresh):not(.subject-type-select) {
  --auth-control-bg: var(--account-panel,#242424);
  --auth-control-hover: var(--account-hover,#303030);
  --auth-control-pressed: #383838;
  --auth-control-border: var(--account-border,#484848);
  --auth-control-hover-border: #68758b;
}

:root[data-account-theme="dark"] .app .auth-main .login-identifier-summary:not(.subject-type-select) {
  --auth-control-bg: transparent;
  --auth-control-hover: var(--account-panel,#242424);
  --auth-control-pressed: var(--account-hover,#303030);
  --auth-control-border: var(--account-border,#484848);
  --auth-control-hover-border: #68758b;
}

/* Override the old registration-only lift and unrestricted hover rules. */
:root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):hover {
  background-color: var(--auth-control-bg);
  border-color: var(--auth-control-border);
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  :root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):hover:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]) {
    background-color: var(--auth-control-hover);
    border-color: var(--auth-control-hover-border);
  }
}

:root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):active:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]) {
  background-color: var(--auth-control-pressed);
  border-color: var(--auth-control-hover-border);
  transform: none;
  scale: .99;
  transition-duration: 80ms;
}

:root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):focus-visible {
  outline: 2px solid var(--auth-control-focus);
  outline-offset: 3px;
}

:root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):is(:disabled,[aria-disabled="true"],[aria-busy="true"]) {
  background-color: var(--auth-control-bg);
  border-color: var(--auth-control-border);
  transform: none;
  scale: 1;
  cursor: not-allowed;
}

:root .app .auth-main .qr-refresh:not(.subject-type-select):disabled {
  --auth-control-bg: #f6f6f6;
  --auth-control-border: #e8e8e8;
}

:root[data-account-theme="dark"] .app .auth-main .qr-refresh:not(.subject-type-select):disabled {
  --auth-control-bg: #222833;
  --auth-control-border: var(--account-border,#484848);
}

:root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select)[aria-busy="true"] {
  cursor: progress;
}

/* Keep inline actions in place, including vertically centered password toggles. */
:root .app .auth-main :is(.text-button,.input-action,.code-action,.provider-callback-retry) {
  touch-action: manipulation;
  transition: opacity 120ms ease-out;
}

:root .app .auth-main :is(.text-button,.input-action,.code-action,.provider-callback-retry):active:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]) {
  opacity: .7;
  transition-duration: 80ms;
}

:root .app .auth-main :is(.text-button,.input-action,.code-action,.provider-callback-retry):is(:disabled,[aria-disabled="true"],[aria-busy="true"]) {
  cursor: not-allowed;
}

:root .app .auth-main :is(.text-button,.input-action,.code-action,.provider-callback-retry)[aria-busy="true"] {
  cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
  :root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select),
  :root .app .auth-main :is(.text-button,.input-action,.code-action,.provider-callback-retry) {
    transition: none;
  }

  :root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):active:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]) {
    scale: 1;
  }
}

@media (forced-colors: active) {
  :root .app .auth-main :is(.button,.qr-refresh,.login-identifier-summary):not(.subject-type-select):focus-visible {
    outline-color: Highlight;
  }
}

/* Keep auth error dialogs on a neutral surface in both themes. */
:root .app.account-auth-app .feedback-error-dialog {
  --feedback-close-ink: #626262;
  --feedback-close-hover-ink: #171717;
  --feedback-close-hover: #f2f2f2;
  --feedback-close-pressed: #e7e7e7;
  --feedback-focus: #171717;
  background-color: #fff;
  border-color: #d4d4d4;
  box-shadow: 0 16px 48px rgb(0 0 0 / 16%);
}

:root[data-account-theme="dark"] .app.account-auth-app .feedback-error-dialog {
  --feedback-close-ink: #d4d4d4;
  --feedback-close-hover-ink: #fff;
  --feedback-close-hover: #303030;
  --feedback-close-pressed: #3a3a3a;
  --feedback-focus: #f2f2f2;
  background-color: #242424;
  border-color: #484848;
}

:root .app.account-auth-app .feedback-error-dialog::backdrop {
  background: rgb(0 0 0 / 22%);
}

:root .app.account-auth-app .feedback-error-dialog .feedback-error-close {
  background-color: transparent;
  color: var(--feedback-close-ink);
}

:root .app.account-auth-app .feedback-error-dialog .feedback-error-close:hover {
  background-color: var(--feedback-close-hover);
  color: var(--feedback-close-hover-ink);
}

:root .app.account-auth-app .feedback-error-dialog .feedback-error-close:active {
  background-color: var(--feedback-close-pressed);
  color: var(--feedback-close-hover-ink);
}

:root .app.account-auth-app .feedback-error-dialog .feedback-error-close:focus-visible {
  outline-color: var(--feedback-focus);
}

@media (forced-colors: active) {
  :root .app.account-auth-app .feedback-error-dialog .feedback-error-close:focus-visible {
    outline-color: Highlight;
  }
}
