:root {
  color-scheme: dark;
  --page: #0f0a18;
  --surface: rgba(28, 28, 30, .56);
  --surface-raised: #2c2c2e;
  --segmented-surface: rgba(24, 24, 30, .64);
  --text: #f5f5f7;
  --muted: #98989f;
  --line: rgba(84, 84, 88, .42);
  --glass-edge: rgba(255, 255, 255, .075);
  --accent: #a78bfa;
  --accent-deep: #8b5cf6;
  --accent-hover: #7c3aed;
  --focus-ring: rgba(196, 181, 253, .72);
  --danger: #ff7780;
  --danger-soft: rgba(255, 91, 102, .13);
  --success: #47d18c;
  --success-soft: rgba(71, 209, 140, .14);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--page);
}

body {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  color: var(--text);
  background:
    radial-gradient(circle at 50% 18%, rgba(91, 43, 170, .16), transparent 36rem),
    var(--page);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 32%);
}

button,
input { font: inherit; letter-spacing: inherit; }
button { color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
::selection { color: #fff; background: rgba(139,92,246,.62); }

:where(button, input):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.card {
  position: relative;
  width: min(100%, 380px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 22px 70px rgba(0,0,0,.34);
  backdrop-filter: blur(26px) saturate(145%);
  -webkit-backdrop-filter: blur(26px) saturate(145%);
  animation: login-enter 260ms cubic-bezier(.2,.8,.2,1) both;
}

@keyframes login-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(3px); }
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.login-logo {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border: 1px solid var(--glass-edge);
  border-radius: 50%;
  background: var(--segmented-surface);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.login-logo img {
  display: block;
  width: 42px;
  height: 42px;
}

h1 {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, sans-serif;
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -.032em;
  line-height: 1.06;
}

.sub {
  max-width: 280px;
  min-height: 20px;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.btn-passkey,
.btn-pw {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0;
  padding: 0 20px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,0) 32%),
    var(--accent-deep);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.20), 0 3px 10px rgba(76,29,149,.32);
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.btn-passkey:hover:not(:disabled),
.btn-pw:hover:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,0) 34%),
    var(--accent-hover);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 4px 12px rgba(76,29,149,.38);
}

.btn-passkey:active:not(:disabled),
.btn-pw:active:not(:disabled) { transform: scale(.97); }
.btn-passkey:disabled { opacity: .55; cursor: wait; }

.btn-passkey {
  width: calc(100% - 28px);
  margin-inline: auto;
}

.btn-passkey .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn-passkey.loading .spinner { display: block; }
.btn-passkey.loading .lbl { position: absolute; opacity: 0; }

.no-passkey-msg {
  display: none;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #777781;
  font-size: 12px;
}
.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.pw-section { display: none; }
.pw-section.open { display: block; }

.field { margin-bottom: 12px; }
label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.pw-wrap { position: relative; }
input[type=password],
input[type=text] {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 16px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  outline: 0;
  color: var(--text);
  background: var(--segmented-surface);
  box-shadow: none;
  font-size: 15px;
  -webkit-appearance: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
input::placeholder { color: #777781; }
input:focus {
  border-color: rgba(167,139,250,.46);
  box-shadow: 0 0 0 3px rgba(139,92,246,.14);
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 180ms ease, background 180ms ease;
}
.pw-toggle:hover { color: var(--text); background: rgba(118,118,128,.24); }

.toggle-link { margin-top: 14px; text-align: center; }
.toggle-link button,
.no-passkey-msg button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  color: var(--text);
  background: var(--segmented-surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}
.toggle-link button:hover,
.no-passkey-msg button:hover {
  color: #fff;
  border-color: rgba(167,139,250,.35);
  background: rgba(139,92,246,.20);
}
.toggle-link button:active,
.no-passkey-msg button:active { transform: scale(.97); }
.no-passkey-msg button { min-height: 32px; margin-left: 4px; }

.msg {
  display: none;
  margin-top: 14px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 13px;
  text-align: center;
}
.msg.show { display: block; }
.msg.err {
  color: var(--danger);
  border-color: rgba(255,119,128,.24);
  background: var(--danger-soft);
  animation: shake .32s cubic-bezier(.36,.07,.19,.97) both;
}
.msg.ok { color: var(--success); border-color: rgba(71,209,140,.26); background: var(--success-soft); }

.footer {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #777781;
  font-size: 11px;
}

@media (max-width: 480px) {
  body { align-items: flex-start; padding-inline: 14px; }
  .card { margin-block: auto; padding: 28px 22px 24px; }
  .login-logo { width: 60px; height: 60px; }
  .login-logo img { width: 38px; height: 38px; }
  h1 { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
