:root {
  --ink: #1a2a36;
  --text: #22303b;
  --muted: rgba(34, 48, 59, 0.62);
  --blue: #116cb5;
  --danger: #c24141;
  --surface: #fdfefc;
  --line: rgba(34, 48, 59, 0.12);
  --font: "Hanken Grotesk", "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  --display: "Hedvig Letters Serif", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 15% 10%, rgba(107, 164, 217, 0.3) 0%, transparent 58%),
    radial-gradient(ellipse 55% 45% at 85% 18%, rgba(215, 235, 232, 0.95) 0%, transparent 55%),
    radial-gradient(ellipse 50% 45% at 50% 100%, rgba(17, 108, 181, 0.1) 0%, transparent 55%),
    linear-gradient(180deg, #f4faf9 0%, #fdfefc 50%, #eef5f8 100%);
}

.mist {
  position: absolute;
  border-radius: 50%;
  filter: blur(52px);
  opacity: 0.5;
  animation: drift 20s ease-in-out infinite;
}

.mist-a {
  width: 40vmax;
  height: 40vmax;
  top: -10%;
  left: -6%;
  background: radial-gradient(circle, rgba(157, 206, 232, 0.55) 0%, transparent 70%);
}

.mist-b {
  width: 34vmax;
  height: 34vmax;
  right: -8%;
  bottom: 8%;
  background: radial-gradient(circle, rgba(97, 172, 168, 0.3) 0%, transparent 70%);
  animation-delay: -8s;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(2%, -3%) scale(1.05); }
}

.login-home {
  position: fixed;
  top: 18px;
  left: 22px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  backdrop-filter: blur(12px);
}

.login-home:hover {
  border-color: rgba(17, 108, 181, 0.35);
  color: var(--blue);
}

.login-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(32px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
}

.login-panel {
  width: min(420px, 100%);
  padding: 48px 40px 36px;
  border-radius: 24px;
  text-align: center;
  background: rgba(253, 254, 252, 0.78);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(26, 42, 54, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.brand-logo {
  width: 58px;
  height: 58px;
}

.brand-mark h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 2.15rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.tagline {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 400;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming the field on focus */
  color: var(--text);
  outline: none;
  transition: 0.2s ease;
}

.field input::placeholder {
  color: rgba(34, 48, 59, 0.35);
}

.field input:focus {
  border-color: rgba(17, 108, 181, 0.45);
  box-shadow: 0 0 0 3px rgba(17, 108, 181, 0.12);
}

.btn-continue {
  margin-top: 8px;
  width: 100%;
  min-height: 48px;
  padding: 15px 18px;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: #fafafa;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
  box-shadow: 0 4px 22px rgba(26, 42, 54, 0.18);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-continue:hover {
  transform: translateY(-1px);
  background: #243847;
}

.btn-continue:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(194, 65, 65, 0.08);
  border: 1px solid rgba(194, 65, 65, 0.18);
  color: var(--danger);
  font-size: 0.88rem;
}

.hidden { display: none !important; }

.auth-switch {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-switch a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.footnote {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 18px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(34, 48, 59, 0.05);
}

.auth-tab {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.auth-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(26, 42, 54, 0.08);
}

.face-panel {
  text-align: left;
}

.face-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.face-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #071018;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.face-stage video,
.face-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-stage video {
  transform: scaleX(-1);
}

.face-stage canvas {
  transform: scaleX(-1);
  pointer-events: none;
}

.face-reticle {
  position: absolute;
  inset: 12% 16%;
  pointer-events: none;
  z-index: 3;
}

.face-reticle .corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(125, 211, 252, 0.85);
}

.face-reticle .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.face-reticle .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.face-reticle .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.face-reticle .br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.face-reticle .scan-beam {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  top: 0;
  background: linear-gradient(90deg, transparent, rgba(125, 211, 252, 0.95), transparent);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.55);
  opacity: 0;
}

.face-stage.is-live .scan-beam {
  opacity: 1;
  animation: faceSweep 2.2s ease-in-out infinite;
}

.face-stage.is-locking {
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}

.face-stage.is-locking .corner {
  border-color: #7dd3fc;
  animation: cornerPulse 0.9s ease-in-out infinite;
}

.face-lock-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  padding: 5px 9px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: #dff6ff;
  background: rgba(7, 16, 24, 0.72);
  border: 1px solid rgba(125, 211, 252, 0.35);
}

.face-actions {
  display: grid;
  gap: 8px;
}

.face-status {
  min-height: 1.2em;
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.muted { color: var(--muted); }

.login-panel.is-dimmed {
  filter: blur(2px) brightness(0.85);
  transition: filter 0.4s ease;
}

@keyframes faceSweep {
  0% { top: 8%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

@keyframes cornerPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@media (max-width: 560px) {
  .login-home {
    top: 12px;
    left: 12px;
    font-size: 0.8rem;
    padding: 7px 12px;
  }

  .login-stage {
    padding-left: 14px;
    padding-right: 14px;
    justify-items: stretch;
    align-content: center;
  }

  .login-panel {
    width: 100%;
    max-width: none;
    padding: 32px 20px 24px;
    border-radius: 22px;
  }

  .brand-mark h1 {
    font-size: clamp(1.85rem, 8vw, 2.2rem);
  }

  .tagline {
    font-size: 0.98rem;
  }

  .face-hint {
    font-size: 0.86rem;
  }

  .face-stage {
    aspect-ratio: 3 / 4;
    max-height: min(58dvh, 420px);
    border-radius: 16px;
  }

  .face-reticle {
    inset: 14% 12%;
  }

  .face-actions .btn-continue {
    width: 100%;
  }

  .auth-switch,
  .footnote {
    font-size: 0.88rem;
  }
}

@media (max-width: 380px) {
  .login-panel {
    padding: 28px 16px 22px;
  }

  .auth-tabs {
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mist, .login-panel, .scan-beam {
    animation: none;
  }
  body.face-blur-out .login-stage {
    transition: none;
  }
}

@media (hover: none) {
  .btn-continue:hover {
    transform: none;
  }
}
