@keyframes progress-active {
  0% {
    opacity: 0.1;
    width: 0;
  }
  100% {
    opacity: 0;
    width: 100%;
  }
}
@keyframes label-pop {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@keyframes am-backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes am-backdrop-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes am-panel-in {
  0% {
    opacity: 0;
    transform: translateY(26px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes am-panel-out {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
}
@keyframes am-slide-from-right {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes am-slide-from-left {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes am-stagger-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes am-shake {
  0%, 100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-6px);
  }
  36% {
    transform: translateX(6px);
  }
  54% {
    transform: translateX(-4px);
  }
  72% {
    transform: translateX(4px);
  }
  86% {
    transform: translateX(-2px);
  }
}
@keyframes am-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes am-check-pop {
  0% {
    transform: scale(0.4);
  }
  60% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes am-alert-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes am-success-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  55% {
    transform: scale(1.03);
    opacity: 1;
  }
  100% {
    transform: scale(0.97);
    opacity: 0;
  }
}
.auth-modal {
  --am-surface: #FFFFFF;
  --am-surface-alt: #F5F8FB;
  --am-border: #DCE6EF;
  --am-border-strong: #57BBFF;
  --am-text: #1B242C;
  --am-text-muted: #6B7885;
  --am-heading: #13202B;
  --am-accent: #2C8FD0;
  --am-accent-hover: #3AA8F0;
  --am-accent-text: #0B2438;
  --am-accent-soft: rgba(87, 187, 255, 0.16);
  --am-btn-bg: #57BBFF;
  --am-btn-bg-hover: #3AA8F0;
  --am-btn-text: #0B2438;
  --am-link: #2C8FD0;
  --am-focus: #57BBFF;
  --am-danger: #EA3E2E;
  --am-danger-soft: rgba(234, 62, 46, 0.08);
  --am-danger-border: rgba(234, 62, 46, 0.26);
  --am-highlight: #F5CE82;
  --am-highlight-ink: #3A2E14;
  --am-highlight-soft: rgba(245, 206, 130, 0.20);
  --am-success: #9A7B2E;
  --am-success-soft: rgba(245, 206, 130, 0.22);
  --am-pw-track: rgba(19, 32, 43, 0.10);
  --am-backdrop: rgba(11, 20, 32, 0.72);
  --am-shadow: 0 24px 60px rgba(11, 20, 32, 0.28);
  --am-radius: 12px;
  --am-radius-sm: 10px;
  --am-topbar: linear-gradient(90deg, #57BBFF, #F5CE82, #EA3E2E);
  --am-glow: none;
}

.auth-modal--sand {
  --am-surface: #F6EFE2;
  --am-surface-alt: #FFFDF8;
  --am-border: #E2D5BE;
  --am-border-strong: #3AA8F0;
  --am-text: #2A2018;
  --am-text-muted: #857763;
  --am-heading: #241C14;
  --am-accent: #2680C0;
  --am-accent-hover: #3AA8F0;
  --am-accent-text: #0B2438;
  --am-accent-soft: rgba(87, 187, 255, 0.20);
  --am-btn-bg: #57BBFF;
  --am-btn-bg-hover: #3AA8F0;
  --am-btn-text: #0B2438;
  --am-link: #2680C0;
  --am-focus: #3AA8F0;
  --am-danger: #C22E1D;
  --am-danger-soft: rgba(234, 62, 46, 0.10);
  --am-danger-border: rgba(234, 62, 46, 0.28);
  --am-highlight: #E0B45F;
  --am-highlight-ink: #3A2E14;
  --am-highlight-soft: rgba(245, 206, 130, 0.34);
  --am-success: #8A6B22;
  --am-success-soft: rgba(245, 206, 130, 0.34);
  --am-pw-track: rgba(42, 32, 24, 0.12);
  --am-backdrop: rgba(36, 28, 20, 0.72);
  --am-shadow: 0 24px 60px rgba(58, 44, 26, 0.26);
  --am-topbar: linear-gradient(90deg, #F5CE82, #57BBFF, #EA3E2E);
  --am-glow: none;
}

.auth-modal--grey {
  --am-surface: #2B333B;
  --am-surface-alt: #222A31;
  --am-border: rgba(215, 222, 229, 0.12);
  --am-border-strong: rgba(87, 187, 255, 0.55);
  --am-text: #D7DEE5;
  --am-text-muted: #94A2AE;
  --am-heading: #FFFFFF;
  --am-accent: #57BBFF;
  --am-accent-hover: #3AA8F0;
  --am-accent-text: #0B2438;
  --am-accent-soft: rgba(87, 187, 255, 0.14);
  --am-btn-bg: #57BBFF;
  --am-btn-bg-hover: #3AA8F0;
  --am-btn-text: #0B2438;
  --am-link: #57BBFF;
  --am-focus: #57BBFF;
  --am-danger: #F07070;
  --am-danger-soft: rgba(234, 62, 46, 0.12);
  --am-danger-border: rgba(234, 62, 46, 0.30);
  --am-highlight: #F5CE82;
  --am-highlight-ink: #3A2E14;
  --am-highlight-soft: rgba(245, 206, 130, 0.16);
  --am-success: #F5CE82;
  --am-success-soft: rgba(245, 206, 130, 0.12);
  --am-pw-track: rgba(215, 222, 229, 0.12);
  --am-backdrop: rgba(16, 20, 25, 0.80);
  --am-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --am-topbar: linear-gradient(90deg, #57BBFF, #F5CE82, #EA3E2E);
  --am-glow: none;
}

.auth-modal--dark {
  --am-surface: #0C1628;
  --am-surface-alt: rgba(7, 11, 20, 0.70);
  --am-border: rgba(87, 187, 255, 0.15);
  --am-border-strong: rgba(87, 187, 255, 0.55);
  --am-text: #C8D8EE;
  --am-text-muted: #8BA4C4;
  --am-heading: #FFFFFF;
  --am-accent: #57BBFF;
  --am-accent-hover: #3AA8F0;
  --am-accent-text: #070B14;
  --am-accent-soft: rgba(87, 187, 255, 0.12);
  --am-btn-bg: linear-gradient(135deg, #57BBFF, #3AA8F0);
  --am-btn-bg-hover: linear-gradient(135deg, #7ACBFF, #57BBFF);
  --am-btn-text: #070B14;
  --am-link: #57BBFF;
  --am-focus: #57BBFF;
  --am-danger: #F07070;
  --am-danger-soft: rgba(234, 62, 46, 0.10);
  --am-danger-border: rgba(234, 62, 46, 0.28);
  --am-highlight: #F5CE82;
  --am-highlight-ink: #070B14;
  --am-highlight-soft: rgba(245, 206, 130, 0.14);
  --am-success: #F5CE82;
  --am-success-soft: rgba(245, 206, 130, 0.10);
  --am-pw-track: rgba(200, 216, 238, 0.08);
  --am-backdrop: rgba(3, 6, 12, 0.86);
  --am-shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
  --am-topbar: linear-gradient(90deg, #57BBFF, #F5CE82, #EA3E2E);
  --am-glow: 0 0 0 1px rgba(87, 187, 255, 0.06), 0 8px 40px rgba(87, 187, 255, 0.12);
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  font-family: "Work Sans", "Lato", "Helvetica Neue", Arial, sans-serif;
  color: var(--am-text);
}
.auth-modal.auth-modal--open, .auth-modal.auth-modal--closing {
  display: block;
}
.auth-modal [hidden] {
  display: none;
}
.auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--am-backdrop);
  backdrop-filter: blur(2px);
  animation: am-backdrop-in 0.28s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal__panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  margin: 5vh auto;
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  box-shadow: var(--am-shadow), var(--am-glow);
  animation: am-panel-in 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.auth-modal__panel::-webkit-scrollbar {
  width: 4px;
}
.auth-modal__panel::-webkit-scrollbar-track {
  background: transparent;
}
.auth-modal__panel::-webkit-scrollbar-thumb {
  background: var(--am-border);
  border-radius: 2px;
}
.auth-modal__topbar {
  height: 3px;
  background: var(--am-topbar);
  border-radius: var(--am-radius) var(--am-radius) 0 0;
}
.auth-modal__body {
  padding: 24px 28px 20px;
}
.auth-modal--closing .auth-modal__backdrop {
  animation: am-backdrop-out 0.24s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal--closing .auth-modal__panel {
  animation: am-panel-out 0.24s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal--success .auth-modal__panel {
  animation: am-success-pulse 0.55s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--am-text-muted);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.auth-modal__close:hover {
  background: var(--am-surface-alt);
  color: var(--am-text);
  transform: rotate(90deg);
}
.auth-modal__icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--am-accent-soft);
  border: 1px solid var(--am-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--am-accent);
  margin-bottom: 14px;
  animation: am-stagger-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) 0.05s both;
}
.auth-modal__title {
  margin: 0 0 5px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--am-heading);
  animation: am-stagger-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) 0.1s both;
}
.auth-modal__sub {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--am-text-muted);
  animation: am-stagger-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) 0.15s both;
}
.auth-modal__tabs {
  position: relative;
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--am-border);
  animation: am-stagger-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) 0.2s both;
}
.auth-modal__tab {
  flex: 1;
  padding: 11px 8px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--am-text-muted);
  cursor: pointer;
  transition: color 0.25s;
}
.auth-modal__tab:hover {
  color: var(--am-text);
}
.auth-modal__tab--active {
  color: var(--am-accent);
}
.auth-modal__tab-underline {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 50%;
  height: 1px;
  background: var(--am-accent);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.auth-modal__tab-underline--right {
  transform: translateX(100%);
}
.auth-modal__panes {
  position: relative;
  overflow: hidden;
  transition: height 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}
.auth-modal__pane {
  display: none;
}
.auth-modal__pane--active {
  display: block;
}
.auth-modal__pane--from-right {
  animation: am-slide-from-right 0.38s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal__pane--from-left {
  animation: am-slide-from-left 0.38s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal__alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 11px 13px;
  border-radius: var(--am-radius-sm);
  border: 1px solid var(--am-danger-border);
  background: var(--am-danger-soft);
  color: var(--am-danger);
  font-size: 13px;
  line-height: 1.5;
  animation: am-alert-in 0.3s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-modal__alert--success {
  background: var(--am-success-soft);
  border-color: var(--am-success);
  color: var(--am-success);
}
.auth-modal__foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--am-border);
  text-align: center;
}
.auth-modal__switch {
  margin: 0;
  font-size: 13px;
  color: var(--am-text-muted);
}
.auth-modal__switch button {
  border: none;
  background: none;
  padding: 0;
  margin-left: 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--am-link);
  cursor: pointer;
}
.auth-modal__switch button:hover {
  text-decoration: underline;
}
.auth-modal button:focus-visible,
.auth-modal a:focus-visible {
  outline: 2px solid var(--am-focus);
  outline-offset: 2px;
}

.auth-field {
  margin-bottom: 14px;
  animation: am-stagger-in 0.35s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--am-text-muted);
}
.auth-field__control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--am-surface-alt);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.auth-field__control:focus-within {
  border-color: var(--am-border-strong);
  box-shadow: 0 0 0 3px var(--am-accent-soft);
}
.auth-field__control:focus-within .auth-field__icon {
  color: var(--am-accent);
}
.auth-field__icon {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--am-text-muted);
  transition: color 0.2s;
}
.auth-field__input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 12px 0;
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--am-text);
}
.auth-field__input::placeholder {
  color: var(--am-text-muted);
  opacity: 0.75;
}
.auth-field__input:-webkit-autofill, .auth-field__input:-webkit-autofill:hover, .auth-field__input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--am-text);
  -webkit-box-shadow: 0 0 0 1000px var(--am-surface-alt) inset;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: var(--am-text);
}
.auth-field__reveal {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--am-text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.auth-field__reveal:hover {
  color: var(--am-text);
  background: var(--am-accent-soft);
}
.auth-field__error {
  display: none;
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--am-danger);
}
.auth-field__error--visible {
  display: block;
  animation: am-stagger-in 0.25s cubic-bezier(0.25, 1, 0.5, 1) both;
}
.auth-field--invalid .auth-field__control {
  border-color: var(--am-danger);
  box-shadow: 0 0 0 3px var(--am-danger-soft);
}
.auth-field--invalid .auth-field__icon {
  color: var(--am-danger);
}
.auth-field--shake {
  animation: am-shake 0.45s ease both;
}

.auth-pw {
  align-self: center;
  position: relative;
  display: block;
  width: 100%;
  height: 38px;
  background: var(--am-pw-track);
  border-radius: 6px;
  margin: 12px 0 2px;
  overflow: visible;
}
.auth-pw .bar {
  width: 0;
  height: 50%;
  display: block;
  border-radius: 6px;
  transition: width 0.3s ease, background-color 0.3s ease;
  position: relative;
}
.auth-pw .bar::after {
  content: "";
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #FFFFFF;
  animation: progress-active 2s ease infinite;
}
.auth-pw .label {
  width: 100%;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 500;
  font-size: 12px;
  color: var(--am-text-muted);
  transition: color 0.3s ease;
  background-color: var(--am-surface);
}
.auth-pw .label.label-animate {
  animation: label-pop 0.3s ease-out;
}
.auth-pw[data-score="0"] .bar, .auth-pw[data-score="1"] .bar {
  background-color: #D95C5C;
}
.auth-pw[data-score="2"] .bar {
  background-color: #EFBC72;
}
.auth-pw[data-score="3"] .bar {
  background-color: #B4D95C;
}
.auth-pw[data-score="4"] .bar {
  background-color: #66DA81;
}
.auth-pw[data-score="0"] .label__text {
  color: #D95C5C;
}
.auth-pw[data-score="1"] .label__text {
  color: #D95C5C;
}
.auth-pw[data-score="2"] .label__text {
  color: #C8891F;
}
.auth-pw[data-score="3"] .label__text {
  color: #7FA326;
}
.auth-pw[data-score="4"] .label__text {
  color: #3FA75B;
}
.auth-pw[data-score=none] {
  background: transparent;
}
.auth-pw[data-score=none] .bar {
  width: 0%;
}

.auth-pw__tips {
  margin: 8px 0 0;
  font-size: 0.8rem;
  opacity: 0.75;
}

.auth-pw__rules {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
}

.auth-pw__rule {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--am-text-muted);
  transition: color 0.25s;
}
.auth-pw__rule i {
  font-size: 6px;
  transition: font-size 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s;
}
.auth-pw__rule--met {
  color: var(--am-success);
}
.auth-pw__rule--met i {
  font-size: 10px;
  color: var(--am-success);
  animation: am-check-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  cursor: pointer;
}
.auth-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.auth-check__box {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1px solid var(--am-border);
  border-radius: 5px;
  background: var(--am-surface-alt);
  color: transparent;
  font-size: 9px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
input:checked + .auth-check__box {
  background: var(--am-highlight);
  border-color: var(--am-highlight);
  color: var(--am-highlight-ink);
  animation: am-check-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
input:focus-visible + .auth-check__box {
  outline: 2px solid var(--am-focus);
  outline-offset: 2px;
}
.auth-check__label {
  line-height: 1.45;
  color: var(--am-text-muted);
}
.auth-check__label a {
  color: var(--am-link);
  text-decoration: underline;
}

.auth-form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0 18px;
}
.auth-form__row--start {
  justify-content: flex-start;
}
.auth-form__link {
  font-size: 13px;
  color: var(--am-link);
  text-decoration: none;
  white-space: nowrap;
}
.auth-form__link:hover {
  text-decoration: underline;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 22px;
  border: none;
  border-radius: var(--am-radius-sm);
  background: var(--am-btn-bg);
  color: var(--am-btn-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s, opacity 0.2s;
}
.auth-btn:hover {
  background: var(--am-btn-bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--am-accent-soft);
}
.auth-btn:active {
  transform: translateY(0);
}
.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.auth-btn__spinner {
  display: none;
  animation: am-spin 0.85s linear infinite;
}
.auth-btn--loading .auth-btn__spinner {
  display: inline-block;
}

body.auth-modal-lock {
  overflow: hidden;
}

@media (max-width: 520px) {
  .auth-modal {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .auth-modal__panel {
    margin: 0;
    min-height: 100%;
    min-height: 100dvh;
    max-height: none;
    overflow-y: visible;
    border: none;
    border-radius: 0;
  }
  .auth-modal__topbar {
    border-radius: 0;
  }
  .auth-modal__body {
    padding: 46px 20px calc(26px + env(safe-area-inset-bottom, 0px) + 80px);
  }
  .auth-pw__rules {
    grid-template-columns: 1fr;
  }
  .auth-field__input {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .auth-modal,
  .auth-modal * {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
