.auth-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1200;
}

.auth-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 24, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.auth-modal.is-open .auth-modal__overlay {
  opacity: 1;
}

.auth-modal__panel {
  position: relative;
  width: min(520px, 100%);
  background: var(--surface-card, #ffffff);
  color: var(--color-text, #0f172a);
  border-radius: clamp(1rem, 2vw, 1.25rem);
  border: 1px solid var(--surface-border, #e5e7eb);
  box-shadow: 0 22px 60px rgba(6, 10, 24, 0.2);
  padding: clamp(1.5rem, 4vw, 2.2rem);
  transform: translateY(28px) scale(0.98);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1;
}

.auth-modal__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(15, 23, 42, 0.06), transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(76, 96, 255, 0.07), transparent 45%);
  mask-image: none;
  opacity: 1;
  pointer-events: none;
}

.auth-modal__panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--auth-logo, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60%;
  opacity: 0.1;
  filter: saturate(0.3);
  pointer-events: none;
}

.auth-modal.is-open .auth-modal__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.auth-modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--color-text, #0f172a);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.auth-modal__close:hover,
.auth-modal__close:focus-visible {
  border-color: var(--surface-border, #e5e7eb);
  background: color-mix(in srgb, var(--surface-muted, #f5f6fb) 70%, #ffffff);
  outline: none;
  transform: translateY(-1px);
}

.auth-modal__header {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
  text-align: left;
}

.auth-modal__eyebrow {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--color-text-muted, #6b7280);
}

.auth-modal__title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 700;
  color: var(--color-text, #0f172a);
}

.auth-modal__subtitle {
  margin: 0;
  color: var(--color-text-muted, #6b7280);
}

.auth-modal__tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--surface-muted, #f3f4f8);
  padding: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--surface-border, #e5e7eb);
}

.auth-modal__tab {
  border: none;
  background: transparent;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  color: var(--color-text-muted, #6b7280);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal__tab.is-active {
  background: var(--surface-card, #ffffff);
  color: var(--color-text, #0f172a);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.auth-modal__body {
  display: grid;
}

.auth-modal__form {
  display: grid;
  gap: 0.75rem;
}

.auth-modal__form:not(.is-active) {
  display: none;
}

.auth-modal__label {
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.auth-modal__input {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 0.75rem;
  border: 1px solid var(--surface-border, #e5e7eb);
  background: var(--surface-card, #ffffff);
  color: inherit;
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.auth-modal__input:focus {
  outline: none;
  border-color: var(--color-primary, #4c60ff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #4c60ff) 25%, transparent);
}

.auth-modal__actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.auth-modal__actions .button {
  width: 100%;
  justify-content: center;
}

.auth-modal__alert {
  margin: 0;
  padding: 0.8rem 0.95rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--color-danger, #c92a2a) 35%, var(--surface-border, #e5e7eb));
  background: color-mix(in srgb, var(--color-danger, #c92a2a) 10%, var(--surface-card, #ffffff));
  color: color-mix(in srgb, var(--color-danger, #c92a2a) 70%, var(--color-text, #0f172a));
  font-weight: 600;
  display: grid;
  gap: 0.3rem;
}

.auth-modal__alert ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.auth-modal .button {
  background: var(--surface-card, #ffffff);
  color: var(--color-text, #0f172a);
  border: 1px solid var(--surface-border, #e5e7eb);
  box-shadow: 0 10px 24px rgba(6, 10, 24, 0.08);
}

.auth-modal .button:hover,
.auth-modal .button:focus-visible {
  background: color-mix(in srgb, var(--surface-muted, #f5f6fb) 70%, #ffffff);
  border-color: color-mix(in srgb, var(--color-primary, #4c60ff) 35%, var(--surface-border, #e5e7eb));
  box-shadow: 0 12px 28px rgba(6, 10, 24, 0.12);
}

.auth-modal__helper {
  margin: 0;
  text-align: center;
  color: var(--color-text-muted, #6b7280);
  font-size: 0.95rem;
}

.auth-modal__helper a {
  color: var(--color-text, #0f172a);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

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

@media (max-width: 640px) {
  .auth-modal {
    align-items: flex-end;
  }

  .auth-modal__panel {
    width: 100%;
    border-radius: 1rem 1rem 0.75rem 0.75rem;
    padding: clamp(1.25rem, 5vw, 1.8rem);
  }
}
