.auth-dialog {
  width: min(470px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 26px;
  color: #18181b;
  background: transparent;
}

.auth-dialog::backdrop {
  background: rgba(24, 24, 27, .44);
  backdrop-filter: blur(7px);
}

.auth-card {
  position: relative;
  box-sizing: border-box;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 30px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #eeeeF0;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(24, 24, 27, .22);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: -68px;
  right: -62px;
  width: 150px;
  aspect-ratio: 1;
  border-radius: 42%;
  background: #eef4ff;
  transform: rotate(18deg);
}

.auth-head,
.auth-form,
.auth-signed-in,
.auth-status { position: relative; z-index: 1; }

.auth-head { padding-right: 44px; }
.auth-kicker { margin: 0 0 8px; color: #365fce; font-size: 13px; font-weight: 750; }
.auth-head h2 { margin: 0; font-size: 29px; letter-spacing: -.025em; }
.auth-head p { margin: 10px 0 0; max-width: 38ch; color: #666672; font-size: 14px; line-height: 1.65; }

.auth-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: #666672;
  background: #f4f4f5;
  cursor: pointer;
  font-size: 22px;
  transition: transform .2s ease-out, background-color .2s ease-out, color .2s ease-out;
}

.auth-close:hover { color: #18181b; background: #e9e9ec; transform: rotate(5deg) scale(1.04); }
.auth-close:active { transform: scale(.95); }

.auth-form { display: grid; gap: 16px; margin-top: 26px; }
.auth-form[hidden], .auth-signed-in[hidden], .auth-code-row[hidden], .auth-registration-fields[hidden], .auth-recovery-fields[hidden], .auth-field[hidden], .auth-head p[hidden] { display: none !important; }
.auth-field { display: grid; gap: 8px; }
.auth-field label { color: #52525b; font-size: 13px; font-weight: 700; }
.auth-field label span { color: #8b8b95; font-weight: 500; }

.auth-field input {
  width: 100%;
  min-height: 50px;
  padding: 12px 15px;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  outline: none;
  color: #18181b;
  background: #fafafa;
  font: inherit;
  transition: border-color .2s ease-out, box-shadow .2s ease-out, background-color .2s ease-out;
}

.auth-field input:focus { border-color: #4f74d7; background: #fff; box-shadow: 0 0 0 4px rgba(54, 95, 206, .14); }

.auth-submit,
.auth-secondary {
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 720;
  transition: transform .2s ease-out, box-shadow .2s ease-out, background-color .2s ease-out;
}

.auth-submit { border: 1px solid #18181b; color: #fff; background: #18181b; box-shadow: 0 8px 20px rgba(24, 24, 27, .16); }
.auth-submit:hover { background: #303038; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(24, 24, 27, .2); }
.auth-secondary { border: 1px solid #e4e4e7; color: #27272a; background: #f4f4f5; }
.auth-secondary:hover { background: #e9e9ec; transform: translateY(-2px); }
.auth-link-button { justify-self: start; padding: 2px 0; border: 0; color: #365fce; background: transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; }
.auth-link-button:hover { color: #254aa9; text-decoration: underline; }
.auth-mode-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 18px; }
.auth-recovery-fields { display: grid; gap: 16px; padding: 16px; border: 1px solid #dce8ff; border-radius: 16px; background: #f7f9ff; }
.auth-submit:active, .auth-secondary:active { transform: scale(.96); }
.auth-submit:focus-visible, .auth-secondary:focus-visible, .auth-close:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(54, 95, 206, .16); }
.auth-submit:disabled, .auth-secondary:disabled { cursor: not-allowed; opacity: .5; transform: none; }

.auth-code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.auth-status { min-height: 22px; margin: 14px 0 0; color: #666672; font-size: 13px; line-height: 1.55; }
.auth-status.is-error { color: #b44e5d; }
.auth-status.is-success { color: #2f7c62; }

.auth-signed-in {
  display: grid;
  gap: 16px;
  margin-top: 26px;
  padding: 20px;
  border: 1px solid #dce8ff;
  border-radius: 18px;
  background: #eef4ff;
}
.auth-signed-in strong, .auth-signed-in span { display: block; }
.auth-signed-in span { margin-top: 5px; color: #5e6573; font-size: 13px; overflow-wrap: anywhere; }
.auth-profile-summary { display: flex; align-items: center; gap: 12px; }
.auth-avatar { display: grid !important; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; margin: 0 !important; overflow: hidden; border-radius: 50%; color: #fff !important; background: #365fce center / cover no-repeat; font-size: 16px !important; font-weight: 800; }
.auth-avatar.has-image { color: transparent !important; }
.auth-avatar-picker { display: grid; grid-template-columns: 44px auto; gap: 7px 12px; align-items: center; }
.auth-avatar-picker small { grid-column: 2; color: #8b8b95; font-size: 12px; }
.auth-avatar-preview { grid-row: 1 / span 2; width: 44px; height: 44px; }
.auth-avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.auth-avatar-select { min-height: 40px; padding: 8px 14px; border: 1px solid #d8deea; border-radius: 12px; color: #365fce; background: #f7f9ff; cursor: pointer; font: inherit; font-size: 13px; font-weight: 720; transition: transform .2s ease-out, background-color .2s ease-out, box-shadow .2s ease-out; }
.auth-avatar-select:hover { background: #edf3ff; transform: translateY(-1px); }
.auth-avatar-select:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(54, 95, 206, .14); }
.auth-remove-avatar { justify-self: auto; color: #9b5260; }
.auth-field-hint { color: #8b8b95; font-size: 12px; line-height: 1.5; }
.account-icon.has-avatar { color: transparent; background-position: center; background-size: cover; }
.account-icon.has-avatar svg { opacity: 0; }

.auth-config-note {
  margin: 22px 0 0;
  padding: 14px 16px;
  border: 1px solid #f4dfb0;
  border-radius: 16px;
  color: #795018;
  background: #fff7e6;
  font-size: 13px;
  line-height: 1.6;
}

.account-button.is-signed-in { color: #276c55; background: #eaf7f1; box-shadow: 3px 3px 9px rgba(63, 155, 123, .14), -3px -3px 9px rgba(255, 255, 255, .9); }
#account-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 520px) {
  .auth-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .auth-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 25px 20px 22px;
    border-radius: 22px;
  }
  .auth-head h2 { font-size: 25px; }
  .auth-code-row { grid-template-columns: 1fr; gap: 12px; }
  #account-label { max-width: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-dialog *, .auth-dialog *::before, .auth-dialog *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
