* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  background: var(--login-bg);
  min-height: 100vh; overflow-x: hidden;
}

/* ---- animated background ---- */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: var(--blob-opacity); animation: drift 18s ease-in-out infinite alternate; }
.b1 { width: 440px; height: 440px; background: #7cc4ff; left: -120px; top: -100px; }
.b2 { width: 380px; height: 380px; background: #a9dcff; right: -100px; top: 25%; animation-duration: 22s; animation-delay: -6s; }
.b3 { width: 340px; height: 340px; background: #5aa9f0; left: 30%; bottom: -160px; animation-duration: 26s; animation-delay: -12s; opacity: .4; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }
.bub {
  position: absolute; bottom: -40px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.95), rgba(255,255,255,.25) 60%, rgba(120,190,250,.25));
  border: 1px solid rgba(255,255,255,.7);
  animation: rise var(--d) linear var(--t) infinite;
}
@keyframes rise { 0% { transform: translateY(0) translateX(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translateY(-110vh) translateX(30px); opacity: 0; } }

/* ---- card ---- */
.wrap { position: relative; min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px 16px; }
.card {
  width: min(420px, 100%); background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--line) 80%, #fff); border-radius: 24px;
  padding: 54px 30px 28px; position: relative;
  box-shadow: 0 24px 60px rgba(43, 138, 224, .22), 0 2px 6px rgba(43, 138, 224, .08);
  animation: cardIn .8s cubic-bezier(.2, .9, .2, 1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(.96); } }
.card.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

.logo {
  position: absolute; left: 50%; top: -32px; width: 64px; height: 64px; margin-left: -32px; border-radius: 20px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent) 60%, var(--accent-deep));
  box-shadow: 0 10px 24px rgba(43, 138, 224, .45); animation: logoIn .9s .2s cubic-bezier(.34, 1.56, .64, 1) both, bob 4.5s 1.2s ease-in-out infinite;
}
@keyframes logoIn { from { transform: scale(0) rotate(-120deg); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-5px); } }

h1 { margin: 0 0 6px; text-align: center; font-size: 24px; letter-spacing: -.02em; }
.lead { margin: 0 0 20px; text-align: center; color: var(--muted); }
.lead b { color: var(--ink); word-break: break-all; }

/* panes */
.panes { position: relative; }
.pane { display: none; }
.pane.on { display: block; animation: paneIn .5s cubic-bezier(.2, .9, .2, 1) both; }
.pane.out { display: block; animation: paneOut .25s ease-in both; }
@keyframes paneIn { from { opacity: 0; transform: translateX(34px); } }
@keyframes paneOut { to { opacity: 0; transform: translateX(-34px); } }
.pane.on > * { animation: rowUp .5s cubic-bezier(.2, .9, .2, 1) both; }
.pane.on > *:nth-child(2) { animation-delay: .05s } .pane.on > *:nth-child(3) { animation-delay: .1s }
.pane.on > *:nth-child(4) { animation-delay: .15s } .pane.on > *:nth-child(5) { animation-delay: .2s }
@keyframes rowUp { from { opacity: 0; transform: translateY(12px); } }

/* fields */
.field { display: block; margin-bottom: 6px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; transition: color .2s; }
.field:focus-within span { color: var(--accent-deep); }
input[type=email], input[type=password], input[type=text] {
  width: 100%; font: inherit; font-size: 16px; padding: 13px 14px; border-radius: 12px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); outline: none; transition: border-color .2s, box-shadow .25s, transform .2s;
}
input[type=email]:focus, input[type=password]:focus, input[type=text]:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); transform: translateY(-1px); }

.otp { display: flex; justify-content: center; gap: 8px; margin: 4px 0 6px; }
.otp .d {
  width: 46px; height: 56px; text-align: center; font: 700 24px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; outline: none; caret-color: var(--accent);
  transition: border-color .2s, box-shadow .25s, transform .2s, background .2s;
}
.otp .d:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); transform: translateY(-3px); }
.otp .d.filled { background: var(--accent-soft); border-color: var(--accent-2); animation: pop .25s; }
.otp.bad .d { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--surface)); }
@keyframes pop { 50% { transform: scale(1.12); } }
@media (max-width: 400px) { .otp { gap: 5px; } .otp .d { width: 40px; height: 50px; font-size: 21px; } .card { padding-inline: 18px; } }

.msg { min-height: 22px; margin: 8px 0 8px; text-align: center; font-size: 13.5px; color: var(--red); }
.msg.ok { color: var(--accent-deep); }
.msg:not(:empty) { animation: rowUp .3s both; }

/* buttons */
.btn {
  position: relative; width: 100%; font: inherit; font-weight: 700; font-size: 16px; color: #fff; cursor: pointer; border: 0;
  padding: 13px 16px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 55%, var(--accent-deep)); background-size: 160% 100%;
  box-shadow: 0 8px 18px rgba(43, 138, 224, .35); transition: transform .2s, box-shadow .2s, background-position .5s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(43, 138, 224, .42); background-position: 100% 0; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { cursor: default; opacity: .85; }
.btn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%); transform: translateX(-120%); }
.btn:hover:not(:disabled)::after { transform: translateX(120%); transition: transform .7s; }
.btn .spin { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; margin-left: -4px; vertical-align: -3px; }
.btn.busy .spin { display: inline-block; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.row { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.link { background: none; border: 0; font: inherit; font-size: 13.5px; color: var(--accent-deep); cursor: pointer; padding: 4px 2px; border-radius: 6px; transition: opacity .2s, transform .15s; }
.link:hover:not(:disabled) { text-decoration: underline; transform: translateY(-1px); }
.link:disabled { color: var(--muted); cursor: default; }

/* envelope */
.envelope { width: 64px; height: 44px; margin: 0 auto 14px; position: relative; border-radius: 8px; background: linear-gradient(160deg, var(--accent-2), var(--accent)); box-shadow: 0 8px 18px rgba(43,138,224,.35); animation: envIn .7s cubic-bezier(.34, 1.56, .64, 1) both; }
.envelope i { position: absolute; left: 0; right: 0; top: 0; height: 24px; background: color-mix(in srgb, var(--accent-deep) 80%, #fff); clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 8px 8px 0 0; transform-origin: top; animation: flap .8s .35s ease both; }
@keyframes envIn { from { transform: translateY(-30px) scale(.5); opacity: 0; } }
@keyframes flap { from { transform: scaleY(-1); } }

/* success */
.check { display: block; width: 84px; height: 84px; margin: 4px auto 14px; }
.check circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 152; stroke-dashoffset: 152; animation: draw .7s ease forwards; }
.check path { fill: none; stroke: var(--accent-deep); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 42; stroke-dashoffset: 42; animation: draw .45s .55s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.card.leave { animation: leave .55s .5s ease-in both; }
@keyframes leave { to { opacity: 0; transform: translateY(-24px) scale(1.04); } }

.foot { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; animation: rowUp .8s .5s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bub { display: none; }
}

/* authenticator panes */
.phone { width: 40px; height: 64px; margin: 0 auto 12px; border-radius: 10px; border: 3px solid var(--accent); position: relative; background: var(--accent-soft); animation: envIn .7s cubic-bezier(.34, 1.56, .64, 1) both; }
.phone::before { content: ""; position: absolute; left: 50%; top: 5px; width: 12px; height: 3px; margin-left: -6px; border-radius: 3px; background: var(--accent); }
.phone i { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; border: 3px solid var(--accent-2); border-right-color: transparent; animation: spin 2.4s linear infinite; }
.qrbox { width: max-content; margin: 0 auto 8px; padding: 6px; background: #fff; border-radius: 14px; border: 1.5px solid var(--line); box-shadow: 0 8px 20px rgba(43, 138, 224, .18); animation: pop .5s both; }
.qrbox canvas { display: block; width: 168px; height: 168px; image-rendering: pixelated; }
.keyline { margin: 0 0 12px; text-align: center; font-size: 12.5px; color: var(--muted); }
.keyline code { display: block; margin-top: 4px; font: 600 13px ui-monospace, Menlo, Consolas, monospace; color: var(--ink); letter-spacing: .5px; word-break: break-all; }

.hint { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }

.pwbox { position: relative; display: block; }
.pwbox input { padding-right: 46px; letter-spacing: .04em; }
.pwbox input::placeholder { letter-spacing: 0; font-size: 13.5px; color: color-mix(in srgb, var(--muted) 80%, transparent); }
.pwbox .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: background .2s, color .2s; }
.pwbox .eye:hover, .pwbox .eye.on { background: var(--accent-soft); color: var(--accent-deep); }
