:root {
  color-scheme: dark;
  --page-bg: #212121;
  --surface-border: #323232;
  --field-border: #363636;
  --text-main: #ffffff;
  --text-muted: #a8a8a8;
  --accent: #8774e1;
  --control-height: 54px;
  --control-radius: 14px;
  --control-padding-x: 18px;
  --control-font-size: clamp(18px, 2.4vw, 22px);
  --control-gap: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text-main);
}

button,
input {
  font: inherit;
}

button {
  padding: 0;
}

.screen {
  min-height: 100vh;
  padding:
    calc(28px + var(--safe-top))
    24px
    calc(48px + var(--safe-bottom));
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.auth-layout {
  width: min(100%, 720px);
  min-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 76px);
  display: grid;
}

.step {
  display: none;
  width: 100%;
}

.step.is-active {
  display: grid;
}

.step-phone {
  align-content: start;
  justify-items: center;
}

.step-code,
.step-twfa,
.step-success {
  align-content: start;
  justify-items: center;
  text-align: center;
}

.step-success {
  align-content: center;
  gap: 28px;
  padding-top: min(4vh, 32px);
}

.brand-mark {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 68px;
}

.brand-orb {
  width: min(124px, 15vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
}

.brand-orb svg {
  width: 92%;
  height: 92%;
}

.emoji-mark {
  margin-bottom: 46px;
  font-size: clamp(132px, 21vw, 180px);
  line-height: 1;
}

.loader-stage {
  position: relative;
  width: clamp(116px, 18vw, 148px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.loader-stage[hidden],
.success-badge[hidden] {
  display: none !important;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-right-color: rgba(255, 255, 255, 0.36);
  animation: loader-spin 1.08s linear infinite;
}

.loader-ring-secondary {
  inset: 18px;
  border-width: 3px;
  border-top-color: rgba(255, 255, 255, 0.92);
  border-right-color: transparent;
  border-bottom-color: rgba(135, 116, 225, 0.35);
  border-left-color: transparent;
  animation-direction: reverse;
  animation-duration: 1.7s;
}

.success-badge {
  width: clamp(116px, 18vw, 148px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.success-badge-core {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent 55%),
    linear-gradient(145deg, #9d8cff, #6b57d9);
  box-shadow:
    0 18px 48px rgba(135, 116, 225, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.success-badge svg {
  width: 56%;
  height: 56%;
}

.success-badge circle,
.success-badge path {
  stroke: #ffffff;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy-block {
  width: min(100%, 760px);
  display: grid;
  gap: 22px;
  text-align: center;
  justify-items: center;
  margin-bottom: 86px;
}

.copy-block-compact {
  margin-bottom: 62px;
}

.copy-block-success {
  margin-bottom: 0;
}

.title {
  margin: 0;
  max-width: 100%;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.subtitle {
  margin: 0;
  max-width: 15.5em;
  color: var(--text-muted);
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 400;
  line-height: 1.26;
  text-wrap: balance;
}

.subtitle-wide {
  max-width: 20em;
}

.subtitle-code {
  max-width: 12em;
}

.form-block {
  width: min(100%, 720px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.form-block-compact {
  gap: 20px;
}

.country-picker {
  position: relative;
  display: grid;
  gap: 14px;
}

.country-field-label {
  position: absolute;
  left: var(--control-padding-x);
  top: 50%;
  z-index: 2;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--control-font-size);
  line-height: 1;
  transform: translateY(-50%);
  transform-origin: left center;
  pointer-events: none;
  transition:
    top 180ms ease,
    transform 180ms ease,
    font-size 180ms ease,
    color 180ms ease,
    padding 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.country-picker.is-filled .country-field-label {
  top: 0;
  padding: 0 8px;
  background: var(--page-bg);
  color: var(--accent);
  font-size: 13px;
  transform: translateY(-50%);
}

.country-picker.is-open .country-field-label {
  opacity: 0;
}

.country-field-label-inline {
  color: var(--accent);
}

.country-trigger,
.country-search-shell {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--field-border);
  border-radius: var(--control-radius);
  background: transparent;
}

.country-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 var(--control-padding-x);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}

.country-picker.is-filled .country-trigger {
  padding-top: 4px;
}

.country-trigger-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.country-flag {
  flex: 0 0 auto;
  font-size: clamp(20px, 2.5vw, 24px);
  line-height: 1;
}

.country-name,
.country-option-name {
  min-width: 0;
  font-size: var(--control-font-size);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-option-code {
  color: var(--text-muted);
  font-size: var(--control-font-size);
  line-height: 1.2;
  white-space: nowrap;
}

.country-chevron,
.country-search-close {
  color: var(--text-muted);
}

.country-chevron {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.country-search-close {
  border: 0;
  background: transparent;
  line-height: 0;
}

.country-chevron svg,
.country-search-close svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.country-dropdown {
  display: grid;
  gap: 14px;
}

.country-trigger[hidden],
.country-dropdown[hidden] {
  display: none;
}

.country-search-shell {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 var(--control-padding-x);
  border-color: var(--accent);
}

.country-search-input {
  padding-top: 4px;
  padding-right: 34px;
}

.country-search-close {
  position: absolute;
  right: 14px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--accent);
  cursor: pointer;
}

.country-list {
  max-height: min(48vh, 520px);
  overflow: auto;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

.country-option {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: var(--control-height);
  gap: 12px;
  padding: 10px var(--control-padding-x);
  border: 0;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}

.country-option + .country-option {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.country-option:hover,
.country-option.is-selected {
  background: rgba(135, 116, 225, 0.1);
}

.country-empty {
  padding: 22px 24px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.4;
}

.input-shell,
.password-shell {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--control-padding-x);
  border: 1px solid var(--field-border);
  border-radius: var(--control-radius);
  background: transparent;
  transition: border-color 180ms ease;
}

.password-shell:focus-within,
.input-shell:focus-within {
  border-color: var(--accent);
}

.field-label {
  position: absolute;
  left: var(--control-padding-x);
  top: 50%;
  z-index: 1;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--control-font-size);
  line-height: 1;
  transform: translateY(-50%);
  transform-origin: left center;
  pointer-events: none;
  transition:
    top 180ms ease,
    transform 180ms ease,
    font-size 180ms ease,
    color 180ms ease,
    padding 180ms ease,
    background 180ms ease;
}

.input-shell.is-filled .field-label,
.input-shell:focus-within .field-label {
  top: 0;
  padding: 0 8px;
  background: var(--page-bg);
  color: var(--accent);
  font-size: 13px;
  transform: translateY(-50%);
}

.text-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font-size: var(--control-font-size);
  line-height: 1.2;
  text-align: left;
}

.text-input::placeholder {
  color: var(--text-muted);
}

.step-phone .text-input {
  padding-top: 4px;
}

.step-phone .text-input::placeholder {
  color: var(--text-muted);
}

.phone-input-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  padding-top: 4px;
}

.phone-prefix {
  display: none;
}

.phone-input-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

.phone-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  color: var(--text-main);
  font-size: var(--control-font-size);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
}

.phone-mask-group {
  display: inline-flex;
  align-items: center;
}

.phone-mask-group-prefix {
  flex: 0 0 auto;
}

.phone-mask-code-gap {
  flex: 0 0 auto;
  width: 0.24em;
}

.phone-mask-gap {
  flex: 0 0 auto;
  width: 0.32em;
}

.phone-mask-char {
  width: 0.68em;
  min-width: 0.68em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.phone-mask-char.is-empty {
  color: var(--text-muted);
}

.phone-mask-char.is-empty::before {
  content: "";
  width: 0.62em;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.92;
}

.phone-caret {
  --phone-caret-left: 0px;
  position: absolute;
  top: 50%;
  left: 0;
  width: 2px;
  height: 1.28em;
  border-radius: 999px;
  background: var(--text-main);
  opacity: 0;
  pointer-events: none;
  transform: translate(var(--phone-caret-left), -50%);
  transition: opacity 120ms ease;
}

.phone-caret.is-visible {
  opacity: 1;
  animation: caret-blink 1s step-end infinite;
}

.phone-input {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  color: transparent;
  caret-color: transparent;
  font-variant-numeric: tabular-nums;
}

.phone-input::placeholder {
  color: transparent;
}

.password-input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 14px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.next-button {
  width: 100%;
  min-height: var(--control-height);
  border: 0;
  border-radius: var(--control-radius);
  background: var(--accent);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    background-color 180ms ease;
}

.next-button.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

.success-button {
  align-self: stretch;
}

.phone-display {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  border: 0;
  background: transparent;
  color: var(--text-main);
  font-size: clamp(44px, 7vw, 68px);
  font-weight: 700;
  letter-spacing: -0.05em;
  margin-bottom: 26px;
  cursor: pointer;
}

.phone-display-icon {
  color: var(--text-muted);
  font-size: 0.62em;
  transform: translateY(6%);
}

.code-block {
  margin-top: 58px;
  width: 100%;
  display: grid;
  justify-items: center;
  position: relative;
}

.code-inputs {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.code-slot {
  width: clamp(54px, 11vw, 60px);
  aspect-ratio: 1;
  border-radius: var(--control-radius);
  border: 2px solid rgba(255, 255, 255, 0.09);
  background: transparent;
  color: var(--text-main);
  font-size: clamp(24px, 4vw, 30px);
  line-height: 1;
  display: grid;
  place-items: center;
  position: relative;
  cursor: text;
  transition:
    border-color 180ms ease,
    background-color 180ms ease;
}

.code-slot.is-filled {
  border-color: rgba(255, 255, 255, 0.14);
}

.code-slot.is-current {
  border-color: var(--accent);
}

.code-slot.is-current:empty::after {
  content: "";
  width: 2px;
  height: 24px;
  background: #ffffff;
  border-radius: 999px;
  animation: caret-blink 1s step-end infinite;
}

.sr-only-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.ghost-link {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 18px;
  line-height: 1.2;
  cursor: pointer;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

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

@media (max-width: 900px) {
  .screen {
    padding-top: calc(24px + var(--safe-top));
  }

  .brand-mark {
    margin-bottom: 54px;
  }

  .copy-block {
    margin-bottom: 64px;
  }

  .copy-block-compact {
    margin-bottom: 52px;
  }

  .emoji-mark {
    margin-bottom: 38px;
  }

  .step-success {
    padding-top: 0;
  }
}

@media (max-width: 640px) {
  .screen {
    padding-left: 18px;
    padding-right: 18px;
    padding-bottom: calc(28px + var(--safe-bottom));
  }

  .auth-layout {
    min-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 52px);
  }

  .brand-orb {
    width: min(96px, 25vw);
  }

  .emoji-mark {
    margin-bottom: 30px;
    font-size: 126px;
  }

  .loader-stage {
    width: 112px;
  }

  .success-badge {
    width: 112px;
  }

  .copy-block {
    gap: 16px;
    width: min(100%, 380px);
    margin-bottom: 46px;
  }

  .copy-block-compact {
    margin-bottom: 38px;
  }

  .title {
    font-size: 32px;
  }

  .subtitle {
    font-size: 17px;
    max-width: 18em;
  }

  .subtitle-code {
    max-width: 14em;
  }

  .input-shell,
  .country-trigger,
  .country-search-shell,
  .password-shell {
    min-height: var(--control-height);
    padding: 0 var(--control-padding-x);
    border-radius: var(--control-radius);
  }

  .field-label {
    left: var(--control-padding-x);
  }

  .country-option {
    gap: 12px;
    padding: 10px var(--control-padding-x);
  }

  .country-list {
    border-radius: 16px;
  }

  .next-button {
    min-height: var(--control-height);
    border-radius: var(--control-radius);
    font-size: 18px;
  }

  .phone-display {
    gap: 10px;
    font-size: 34px;
    margin-bottom: 20px;
  }

  .code-block {
    margin-top: 48px;
  }

  .code-inputs {
    gap: 12px;
  }

  .code-slot {
    width: clamp(54px, 16vw, 60px);
    border-radius: var(--control-radius);
    font-size: 28px;
  }

  .password-toggle {
    right: 14px;
    width: 24px;
    height: 24px;
  }
}
