.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2rem);
}

.auth-shell {
  width: min(100%, 420px);
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.auth-back:hover,
.auth-back:focus-visible {
  color: var(--blue);
  outline: none;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(1.35rem, 4vw, 2rem);
  box-shadow:
    0 18px 48px var(--shadow-medium),
    0 2px 0 rgba(255, 255, 255, 0.04) inset;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.35rem;
}

.auth-logo-wrap {
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  box-shadow: 0 8px 24px var(--shadow-soft);
}

.auth-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.auth-site-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--blue-dark);
  letter-spacing: 0.02em;
}

.auth-title {
  margin: 0 0 0.35rem;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.auth-subtitle {
  margin: 0 0 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-field-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  inset-inline-start: 0.85rem;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--blue);
  pointer-events: none;
}

.auth-input {
  width: 100%;
  min-height: 2.85rem;
  padding-block: 0.65rem;
  padding-inline-start: 2.55rem;
  padding-inline-end: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}


.auth-input::placeholder {
  color: var(--muted);
}

.auth-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  background: var(--search-focus-bg);
}

.auth-input-toggle {
  position: absolute;
  inset-inline-end: 0.55rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}

.auth-input-toggle:hover,
.auth-input-toggle:focus-visible {
  color: var(--blue);
  background: var(--blue-soft);
  outline: none;
}

.auth-submit {
  width: 100%;
  min-height: 2.85rem;
  margin-top: 0.25rem;
  border: none;
  border-radius: 14px;
  background: var(--primary-gradient);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.auth-submit:hover,
.auth-submit:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.34);
  outline: none;
}

.auth-link-row {
  text-align: center;
  margin-top: 0.15rem;
}

.auth-text-link {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.auth-text-link:hover,
.auth-text-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.auth-secondary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.auth-secondary-btn:hover,
.auth-secondary-btn:focus-visible {
  background: var(--bg-soft);
  border-color: rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
  outline: none;
}

.auth-message {
  min-height: 1.1rem;
  margin-top: 0.15rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.auth-message.is-error {
  color: #dc2626;
}

.auth-message.is-success {
  color: #16a34a;
}

.auth-field-hint {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--muted);
}

.auth-field-error {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: #dc2626;
}

.auth-field-error.hidden {
  display: none;
}

.auth-input.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.auth-password-rules {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.auth-password-rules li {
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.auth-password-rules li::before {
  content: '○';
  font-size: 0.55rem;
  line-height: 1;
}

.auth-password-rules li.is-valid {
  color: #16a34a;
}

.auth-password-rules li.is-valid::before {
  content: '●';
}

.auth-password-rules li.is-invalid {
  color: #dc2626;
}

.auth-password-rules li.is-invalid::before {
  content: '●';
}

.auth-shell-wide {
  width: min(100%, 460px);
}

.auth-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.auth-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 3.5rem;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.auth-step.is-active,
.auth-step.is-done {
  opacity: 1;
}

.auth-step-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}

.auth-step.is-active .auth-step-num {
  background: var(--blue-soft);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--blue);
}

.auth-step.is-done .auth-step-num {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.auth-step-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.auth-step-line {
  flex: 1;
  max-width: 2.5rem;
  height: 2px;
  background: var(--border);
  margin-bottom: 1rem;
}

.auth-panel[hidden] {
  display: none !important;
}

.auth-otp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
}

.auth-otp-digit {
  width: 100%;
  aspect-ratio: 1;
  min-height: 2.6rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-otp-digit:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  background: var(--search-focus-bg);
}

.auth-otp-digit.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.15rem 0 0.85rem;
  font-size: 0.92rem;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  user-select: none;
}

.auth-remember input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--blue, #2563eb);
}

.auth-otp-timer {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted, #64748b);
  text-align: center;
}

.auth-otp-timer.is-expired {
  color: #dc2626;
}

.auth-lockout {
  text-align: center;
  padding: 0.5rem 0 0.25rem;
}

.auth-lockout-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 0.85rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
}

.auth-lockout-timer {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0.75rem 0 0.35rem;
  color: var(--blue, #2563eb);
  font-variant-numeric: tabular-nums;
}

.auth-lockout-done {
  margin: 0.75rem 0 1rem;
  color: var(--text-muted, #64748b);
  line-height: 1.6;
}

.auth-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #059669;
  color: #fff;
  padding: 0.8rem 1.35rem;
  border-radius: 12px;
  font-weight: 600;
  z-index: 1200;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  animation: auth-toast-in 0.28s ease;
  max-width: min(92vw, 420px);
  text-align: center;
}

.auth-toast--error {
  background: #dc2626;
}

@keyframes auth-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.auth-text-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.auth-submit--optional {
  margin-top: 0.35rem;
}

#register-step-2 .auth-submit--optional {
  display: none;
}

.otp-copy-card {
  text-align: center;
}

.otp-copy-logo {
  display: block;
  margin: 0 auto 0.85rem;
  border-radius: 16px;
  object-fit: contain;
}

.otp-copy-code {
  margin: 1rem 0 0.65rem;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 2px dashed #93c5fd;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.28em;
  color: #1d4ed8;
  font-family: 'Courier New', monospace;
  user-select: all;
}

.otp-copy-hint {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.6;
}

#otp-copy-status.is-success {
  color: #059669;
  font-weight: 700;
}

/* ─── Auth error alert (center screen) ─── */

.auth-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.24s ease;
}

.auth-alert-overlay.hidden {
  display: none;
}

.auth-alert-dialog {
  position: relative;
  width: min(100%, 22rem);
  padding: 1.35rem 1.25rem 1.15rem;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.22),
    0 8px 24px rgba(37, 99, 235, 0.08);
  text-align: center;
  animation: auth-alert-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes auth-alert-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-alert-close {
  position: absolute;
  top: 0.75rem;
  inset-inline-end: 0.75rem;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-alert-close:hover,
.auth-alert-close:focus-visible {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  outline: none;
}

.auth-alert-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.auth-alert-title {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.auth-alert-message {
  margin: 0 0 1.1rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

.auth-alert-ok {
  width: 100%;
  min-height: 2.75rem;
  border: none;
  border-radius: 14px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.24);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-alert-ok:hover,
.auth-alert-ok:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.3);
  outline: none;
}

body.auth-alert-open {
  overflow: hidden;
}
