/* Sign-in stage. Reads the same theme tokens as the app. */

#auth[hidden] { display: none; }
.auth-stage {
  position: fixed; inset: 0; z-index: 45; overflow-y: auto;
  /* Bottom room keeps the fixed demo/preview note clear of the form. */
  display: grid; place-items: center; padding: 48px 28px calc(96px + env(safe-area-inset-bottom));
  background: var(--canvas);
}
.auth-backdrop {
  position: fixed; inset: -10%; pointer-events: none;
  background:
    radial-gradient(40% 36% at 18% 12%, var(--glow-a), transparent 70%),
    radial-gradient(36% 34% at 86% 8%, var(--glow-b), transparent 70%),
    radial-gradient(46% 40% at 50% 100%, color-mix(in srgb, var(--user) 75%, transparent), transparent 70%);
  animation: auth-drift 18s ease-in-out infinite alternate;
}
@keyframes auth-drift { to { transform: translate3d(14px, -10px, 0); } }

.auth-col {
  position: relative; width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center;
  animation: auth-step 260ms var(--ease);
}
@keyframes auth-step { from { opacity: 0; transform: translateX(18px); } }

.auth-halo { position: relative; width: var(--size); height: var(--size); margin-bottom: 18px; transition: width 260ms var(--ease), height 260ms var(--ease); }
.auth-halo img { position: relative; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; box-shadow: 0 10px 28px var(--shadow); }
.auth-halo .glow {
  position: absolute; inset: -22%; border-radius: 50%; filter: blur(14px); opacity: .8;
  background: conic-gradient(from 200deg, #F7C9B5, #CFC4F3, #BFE0F7, #F7C9B5);
}
html[data-scheme="dark"] .auth-halo .glow { opacity: .35; }
.auth-halo.is-busy .glow { animation: breathe 2.2s ease-in-out infinite; }
.auth-halo .arc {
  position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--accent); animation: spin 1.4s linear infinite;
}

.auth-hero { margin: 4px 0 0; font-size: 28px; font-weight: 600; letter-spacing: .2px; }
.auth-title { margin: 0 0 26px; font-size: 28px; font-weight: 600; }

.auth-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.auth-field {
  display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-radius: 18px;
  background: var(--card-solid); box-shadow: 0 0 0 .5px var(--line), 0 2px 10px color-mix(in srgb, var(--shadow) 50%, transparent);
  color: var(--muted); transition: box-shadow 160ms, color 160ms;
}
.auth-field:focus-within { color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent); }
.auth-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 17px; }
.auth-field input::placeholder { color: var(--faint); }

.auth-primary, .auth-secondary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 54px; border-radius: 999px; font-size: 16px; font-weight: 600;
  transition: transform 120ms, background 160ms, color 160ms;
}
.auth-primary {
  background: linear-gradient(rgba(255,255,255,.16), rgba(255,255,255,0) 60%), var(--primary); color: var(--on-primary);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--shadow) 140%, transparent);
}
.auth-primary:active:not(:disabled), .auth-secondary:active:not(:disabled) { transform: scale(.98); }
.auth-primary:disabled { background: var(--control); color: var(--muted); box-shadow: none; }
.auth-primary:disabled:has(.auth-spin) { background: var(--primary); color: var(--on-primary); }
.auth-secondary { background: var(--card-solid); box-shadow: 0 0 0 .5px var(--line), 0 3px 10px var(--shadow); }
.auth-actions { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.auth-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }

.auth-pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin: -12px 0 22px; padding: 4px 4px 4px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--card-solid) 70%, transparent); box-shadow: 0 0 0 .5px var(--line);
}
.auth-pill-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.auth-pill button { flex: none; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

.otp { position: relative; display: block; }
.otp input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px;
  /* Transparent but focusable and hit-testable, so paste, autofill and screen readers use the real field. */
}
.otp-cells { display: grid; grid-template-columns: repeat(6, minmax(0, 56px)); justify-content: center; gap: 8px; pointer-events: none; }
.otp-cells span {
  position: relative; height: 60px; border-radius: 16px; display: grid; place-items: center;
  background: var(--card-solid); box-shadow: 0 0 0 .5px var(--line);
  font: 600 26px/1 ui-rounded, var(--font); font-variant-numeric: tabular-nums; color: var(--ink);
  transition: box-shadow 140ms, background 140ms;
}
.otp-cells span.is-filled { animation: auth-pop 160ms var(--ease); }
@keyframes auth-pop { from { transform: scale(.86); } }
.otp-cells span.is-active { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent); }
.otp-cells span.is-active:empty::after { content: ""; width: 2px; height: 26px; background: var(--accent); animation: blink 1s steps(2) infinite; }
.otp.is-error .otp-cells span { background: var(--danger-fill); box-shadow: 0 0 0 1.5px var(--danger); color: var(--danger); }
.otp.is-expired .otp-cells span { color: var(--faint); background: color-mix(in srgb, var(--card-solid) 60%, transparent); }
.otp.shake { animation: auth-shake 360ms ease-in-out; }
@keyframes auth-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

.auth-resend { min-height: 44px; margin-top: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.auth-resend button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; color: var(--accent); font-weight: 500; }
.auth-countdown { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.auth-countdown .ring { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--muted) calc(var(--p) * 360deg), var(--line) 0); }
.auth-expired { color: var(--danger); }

.auth-msg { width: 100%; min-height: 0; margin-top: 14px; }
.auth-note {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-radius: 16px; text-align: left; font-size: 14px; line-height: 1.5;
  color: var(--ink); background: color-mix(in srgb, var(--accent) 8%, transparent); animation: fade 200ms ease-out;
}
.auth-note svg { flex: none; margin-top: 2px; color: var(--accent); }
.auth-note.is-error { background: var(--danger-fill); }
.auth-note.is-error svg { color: var(--danger); }

.auth-switch { margin: 22px 0 0; font-size: 14px; color: var(--muted); }
.auth-switch button { min-height: 44px; padding: 0 4px; color: var(--accent); font-weight: 600; }

.auth-demo {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); translate: -50% 0; margin: 0;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; color: var(--muted);
  border: 1px dashed var(--faint); background: var(--card-solid);
}

.auth-preview {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); translate: -50% 0;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: 6px 6px 6px 8px; border-radius: 999px; font-size: 13px;
  background: var(--card-solid); box-shadow: 0 0 0 1px color-mix(in srgb, var(--moon) 45%, transparent), 0 6px 18px var(--shadow);
}
.auth-preview-tag { flex: none; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--moon); background: color-mix(in srgb, var(--moon) 14%, transparent); }
.auth-preview-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-variant-numeric: tabular-nums; }
.auth-preview button { flex: none; min-height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
@media (max-width: 420px) { .auth-preview { flex-wrap: wrap; justify-content: center; border-radius: 18px; } .auth-preview-text { white-space: normal; text-align: center; } }

.demo-chip {
  position: fixed; left: 12px; bottom: 12px; z-index: 40; display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border-radius: 999px; font-size: 12px; color: var(--muted);
  background: var(--card-solid); border: 1px dashed var(--faint);
}
body.auth-open .demo-chip { display: none; }

@media (max-width: 420px) {
  .otp-cells { gap: 6px; }
  .otp-cells span { height: 54px; font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-backdrop, .auth-col, .auth-halo .arc, .otp.shake { animation: none !important; }
}
