/* Auth modal — global login popup */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-2);
  padding-top: calc(var(--space-3) + var(--safe-top));
  padding-bottom: calc(var(--space-3) + var(--safe-bottom));
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.auth-modal__dialog {
  position: relative;
  width: min(400px, 100%);
  max-height: min(90dvh, 640px);
  overflow-y: auto;
  padding: clamp(24px, 4vw, 32px);
  border-radius: calc(var(--radius-xl) + 2px);
  background: var(--glass-bg, rgba(255, 255, 255, 0.92));
  border: 1px solid var(--surface-border, rgba(15, 23, 42, 0.08));
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
  animation: auth-modal-in 0.28s ease;
}

[data-theme="dark"] .auth-modal__dialog {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(255, 255, 255, 0.08);
}

@keyframes auth-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-modal__close {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  background: var(--color-gray-soft, #f1f5f9);
}

.auth-modal__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: var(--space-3);
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
}

.auth-modal__title {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
}

.auth-modal__subtitle {
  margin: 0 0 var(--space-3);
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-muted);
  text-align: center;
}

.auth-modal__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.auth-modal__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-md);
  background: var(--color-bg, #fff);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-modal__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.auth-modal__hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.auth-modal__password-wrap {
  position: relative;
}

.auth-modal__password-wrap .auth-modal__input {
  padding-inline-end: 44px;
}

.auth-modal__toggle-pass {
  position: absolute;
  top: 50%;
  inset-inline-end: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
}

.auth-modal__submit {
  margin-top: var(--space-3);
}

.auth-modal__form .auth-modal__label + .auth-modal__input {
  margin-bottom: var(--space-2);
}

.auth-modal__alert {
  margin-bottom: var(--space-2);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
}

.auth-modal__alert--error {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.auth-modal__alert--info {
  background: rgba(99, 102, 241, 0.1);
  color: var(--color-primary);
}

.auth-modal__alert--success {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}

.auth-modal__link {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.auth-modal__footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.auth-modal__footer .auth-modal__link {
  width: auto;
  margin-top: 0;
}

.auth-modal__otp {
  display: flex;
  justify-content: center;
  gap: 8px;
  direction: ltr;
  margin-bottom: var(--space-2);
}

.auth-modal__otp-box {
  width: 42px;
  height: 48px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-md);
  background: var(--color-bg, #fff);
}

.auth-modal__otp-box:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.auth-modal__submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .auth-modal__dialog {
    animation: none;
  }
}
