:root {
  --bg: #0a0b0f;
  --card: rgba(22, 24, 32, 0.72);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #f4f5f7;
  --muted: #9aa0ac;
  --faint: #6b7280;
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --accent-grad: linear-gradient(135deg, #3b82f6, #6366f1);
  --danger: #f87171;
  --success: #34d399;
  --field-bg: rgba(255, 255, 255, 0.04);
  --field-border: rgba(255, 255, 255, 0.1);
  --radius: 18px;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: -30%;
  z-index: 0;
  background:
    radial-gradient(40% 40% at 20% 25%, rgba(59, 130, 246, 0.28), transparent 60%),
    radial-gradient(35% 45% at 80% 20%, rgba(99, 102, 241, 0.26), transparent 60%),
    radial-gradient(45% 40% at 65% 85%, rgba(16, 185, 129, 0.14), transparent 60%);
  filter: blur(30px);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(0, -3%, 0) scale(1.08); }
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  gap: 16px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  padding: 26px;
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(59, 130, 246, 0.6);
}
.brand__text h1 { margin: 0; font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.brand__text p { margin: 2px 0 0; font-size: 0.72rem; color: var(--muted); }

.pill {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--muted);
  white-space: nowrap;
}
.pill[data-tone="wait"] { color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
.pill[data-tone="ok"]   { color: var(--success); border-color: rgba(52, 211, 153, 0.3); }
.pill[data-tone="bad"]  { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fade 0.35s ease;
}
.view[hidden] { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.field__pw { position: relative; }
.field__pw input { padding-right: 44px; }
.pw-toggle {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.55;
  padding: 8px;
  border-radius: 8px;
}
.pw-toggle:hover { opacity: 1; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, filter 0.2s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn--primary { background: var(--accent-grad); color: #fff; box-shadow: 0 10px 24px -10px rgba(59,130,246,0.7); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn--ghost { background: rgba(255,255,255,0.05); color: var(--text); border-color: var(--field-border); }
.btn--ghost:hover { background: rgba(255,255,255,0.09); }

.link-btn {
  background: none; border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  align-self: center;
  padding: 4px;
}
.link-btn:hover { color: var(--text); text-decoration: underline; }

.error {
  color: var(--danger);
  font-size: 0.8rem;
  margin: 0;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  padding: 10px 12px;
  border-radius: 10px;
}
.error[hidden] { display: none; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.84rem; margin: 0; }
.fineprint { color: var(--faint); font-size: 0.72rem; text-align: center; margin: 2px 0 0; line-height: 1.5; }

.twofa__head, .success__head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.twofa__head h2, .success__head h2, [data-view="error"] h2 {
  margin: 4px 0 0; font-size: 1.1rem; font-weight: 600;
}
.twofa__icon, .success__badge, .error__badge {
  display: grid; place-items: center;
  width: 54px; height: 54px;
  border-radius: 16px;
}
.twofa__icon { background: rgba(99,102,241,0.14); color: var(--accent-2); }
.success__badge { background: rgba(52,211,153,0.14); color: var(--success); }
.success__badge--pop { animation: pop 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.error__badge { background: rgba(248,113,113,0.14); color: var(--danger); margin: 0 auto; }
[data-view="error"] { text-align: center; align-items: center; }

.code { display: flex; gap: 9px; justify-content: center; }
.code__box {
  width: 46px; height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.code__box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
  transform: translateY(-2px);
}
.code__box.filled { border-color: var(--accent-2); }

.alt { display: flex; flex-direction: column; gap: 12px; }
.alt__divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 0.72rem; }
.alt__divider::before, .alt__divider::after { content: ""; flex: 1; height: 1px; background: var(--card-border); }
.phones { display: flex; flex-direction: column; gap: 8px; }
.phone {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  cursor: pointer;
  font-size: 0.86rem;
  transition: background 0.15s, border-color 0.15s;
}
.phone:hover { background: rgba(255,255,255,0.07); border-color: var(--accent); }
.phone__send { color: var(--accent); font-weight: 600; font-size: 0.78rem; }

.seg {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--field-border);
  border-radius: 12px;
}
.seg__btn {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg__btn.is-active { background: var(--accent-grad); color: #fff; }

.preview {
  margin: 0;
  max-height: 190px;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--field-border);
  font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #cbd5e1;
  white-space: pre;
}
.actions { display: flex; gap: 10px; }
.actions .btn { width: auto; flex: 1; }

.spinner {
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.spinner--sm { width: 15px; height: 15px; }
.spinner--lg { width: 34px; height: 34px; margin: 20px auto 6px; border-width: 3px; border-top-color: var(--accent); }
[data-view="loading"] { align-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { color: var(--faint); font-size: 0.72rem; text-align: center; margin: 0; }
.footer__link { color: var(--muted); text-decoration: none; }
.footer__link:hover { color: var(--text); text-decoration: underline; }

.diag {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
}
.diag > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}
.diag > summary::-webkit-details-marker { display: none; }
.diag > summary::before { content: "▸ "; color: var(--faint); }
.diag[open] > summary::before { content: "▾ "; }
.diag__body { padding: 0 16px 16px; }
.diag__actions { display: flex; gap: 14px; margin-bottom: 8px; }
.diag__actions .link-btn { align-self: auto; }
.diag .preview { max-height: 220px; }

.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 22, 30, 0.95);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }
.toast[data-tone="ok"] { border-color: rgba(52,211,153,0.4); }
.toast[data-tone="bad"] { border-color: rgba(248,113,113,0.4); }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f6;
    --card: rgba(255,255,255,0.82);
    --card-border: rgba(15,23,42,0.08);
    --text: #0f172a;
    --muted: #52607a;
    --faint: #94a3b8;
    --field-bg: rgba(15,23,42,0.03);
    --field-border: rgba(15,23,42,0.12);
    --shadow: 0 30px 70px -30px rgba(15,23,42,0.35);
  }
  :root:not([data-theme="dark"]) .preview { background: rgba(15,23,42,0.05); color: #334155; }
}

@media (max-width: 440px) {
  .card { padding: 22px 18px; }
  .code__box { width: 42px; height: 52px; font-size: 1.3rem; }
}
