.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-8) var(--gutter);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, color-mix(in srgb, var(--color-accent) 12%, transparent), transparent),
    var(--color-bg);
}

/* Animated ambient orbs */
.auth-page::before,
.auth-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(90px);
  z-index: 0;
}

.auth-page::before {
  width: 560px;
  height: 560px;
  background: var(--color-accent);
  opacity: 0.07;
  top: -15%;
  right: -12%;
  animation: orbDrift1 14s ease-in-out infinite;
}

.auth-page::after {
  width: 440px;
  height: 440px;
  background: var(--color-accent);
  opacity: 0.05;
  bottom: -15%;
  left: -10%;
  animation: orbDrift2 18s ease-in-out infinite;
}

@keyframes orbDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(-35px, 25px) scale(1.06); }
  66%       { transform: translate(25px, -30px) scale(0.95); }
}

@keyframes orbDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -20px) scale(0.96); }
  66%       { transform: translate(-25px, 28px) scale(1.04); }
}

.auth-card {
  width: min(440px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: relative;
  z-index: 1;
  /* Entrance animation */
  animation: cardEnter 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card__logo {
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.auth-card__logo span {
  color: var(--color-accent);
}

.auth-card__title {
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
}

.auth-card__subtitle {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: calc(-1 * var(--space-4));
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Staggered entrance for each child element */
.auth-form > * {
  animation: fieldSlide 0.4s ease both;
}
.auth-form > *:nth-child(1) { animation-delay: 0.08s; }
.auth-form > *:nth-child(2) { animation-delay: 0.13s; }
.auth-form > *:nth-child(3) { animation-delay: 0.18s; }
.auth-form > *:nth-child(4) { animation-delay: 0.23s; }
.auth-form > *:nth-child(5) { animation-delay: 0.28s; }
.auth-form > *:nth-child(6) { animation-delay: 0.33s; }

@keyframes fieldSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-card__footer {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-card__footer a {
  color: var(--color-accent);
  font-weight: 600;
}

.auth-card__footer a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.auth-card__hint {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* ── Centred / wide variants ─────────────────────────────────────── */

.auth-card--center {
  align-items: center;
  text-align: center;
}

.auth-card--center .auth-form {
  width: 100%;
}

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

/* ── Status icon (mail / success / error / lock) ─────────────────── */

.auth-status-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-status-icon svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.auth-status-icon--mail {
  background: rgba(124, 58, 237, 0.12);
  color: var(--color-accent);
}

.auth-status-icon--success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-success);
}

.auth-status-icon--error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-error);
}

.auth-status-icon--lock {
  background: rgba(124, 58, 237, 0.12);
  color: var(--color-accent);
}

/* ── Resend button (inline in error alert) ───────────────────────── */

.auth-resend-btn {
  background: none;
  border: 1px solid currentColor;
  border-radius: var(--radius-md);
  color: inherit;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.auth-resend-btn:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* ── TOTP code input ─────────────────────────────────────────────── */

.totp-input {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: 0.25em;
  text-align: center;
}

/* ── Role selector — equal 2-column grid ─────────────────────────── */

.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.role-card {
  /* Stacked / centred layout so both cards are identical in size */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  position: relative;
  background: var(--color-surface-2);
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  /* Ensure equal height regardless of content */
  min-height: 110px;
}

.role-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.role-card--selected {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface-2));
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.role-card__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.role-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.role-card:hover .role-card__icon {
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  transform: scale(1.08);
}

.role-card__icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Legacy .role-card__body — kept so other auth pages don't break */
.role-card__body {
  display: contents; /* flatten so title/desc are direct children */
}

.role-card__title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.role-card__desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--leading-snug);
}

/* Tick badge — absolute top-right corner */
.role-card__check {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 18px;
  height: 18px;
  color: var(--color-accent);
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  transform: scale(0.6);
}

.role-card__check svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.role-card--selected .role-card__check {
  opacity: 1;
  transform: scale(1);
}

/* ── Split layout (login / register full-viewport) ───────────────── */

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

/* ── Brand (left) panel ──────────────────────────────────────────── */

.auth-split__brand {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-12);
  background:
    radial-gradient(ellipse 100% 70% at 60% 40%, color-mix(in srgb, var(--color-accent) 22%, transparent), transparent),
    radial-gradient(ellipse 60% 50% at 10% 80%, color-mix(in srgb, var(--color-accent) 10%, transparent), transparent),
    var(--color-surface);
}

/* Decorative orbs on brand side */
.auth-split__brand::before,
.auth-split__brand::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

.auth-split__brand::before {
  width: 380px;
  height: 380px;
  background: var(--color-accent);
  opacity: 0.14;
  top: -15%;
  right: -10%;
  animation: orbDrift1 12s ease-in-out infinite;
}

.auth-split__brand::after {
  width: 300px;
  height: 300px;
  background: var(--color-accent);
  opacity: 0.09;
  bottom: -12%;
  left: -8%;
  animation: orbDrift2 16s ease-in-out infinite;
}

.auth-split__brand-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: 380px;
}

.auth-split__wordmark {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  text-decoration: none;
}

.auth-split__wordmark span {
  color: var(--color-accent);
}

.auth-split__tagline {
  font-size: clamp(var(--text-2xl), 3.2vw, var(--text-4xl));
  font-weight: 800;
  color: var(--color-text);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  margin: 0;
}

.auth-split__perks {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.auth-split__perks li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-split__perks li svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-accent);
  opacity: 0.85;
}

/* ── Form (right) panel ──────────────────────────────────────────── */

.auth-split__panel {
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-8);
  overflow-y: auto;
  /* Contain scroll within the panel so the page doesn't scroll */
  max-height: 100vh;
}

.auth-split__panel-inner {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: cardEnter 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

.auth-split__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.auth-split__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.auth-split__sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.auth-split__switch {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.auth-split__switch a {
  color: var(--color-accent);
  font-weight: 600;
}

.auth-split__switch a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* Password + confirm side-by-side on register */
.auth-split__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ── Mobile: stack brand above form ─────────────────────────────── */

@media (max-width: 767px) {
  .auth-split {
    grid-template-columns: 1fr;
  }

  .auth-split__brand {
    padding: var(--space-10) var(--space-8);
    min-height: 220px;
  }

  .auth-split__brand-inner {
    gap: var(--space-5);
  }

  .auth-split__tagline {
    font-size: var(--text-2xl);
  }

  .auth-split__perks {
    display: none; /* hide on very small screens to save vertical space */
  }

  .auth-split__panel {
    max-height: none;
    padding: var(--space-8) var(--space-6);
  }

  .auth-split__row {
    grid-template-columns: 1fr;
  }
}

/* bare main — no header/footer offset needed */
.site-main--bare {
  min-height: 0;
}
