.gate-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.72;
  mask-image: radial-gradient(circle at 50% 42%, #000 10%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 10%, transparent 72%);
}

.gate-theme-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  width: 38px;
  height: 38px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--sh-1);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.gate-theme-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.gate-theme-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.gate {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.gate__notice {
  width: min(400px, 100%);
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--info-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  color: var(--brand);
  font-size: var(--fs-sm);
  text-align: center;
  transition: opacity var(--dur-slow) var(--ease);
}

.gate__notice.is-fading {
  opacity: 0;
}

.gate__card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-2);
  padding: 40px;
}

.gate__logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--brand);
  color: var(--text-inv);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.gate__title {
  margin: 20px 0 6px;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
}

.gate__sub {
  margin: 0 0 28px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.warn-box {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.field {
  position: relative;
}

.field__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-3);
  pointer-events: none;
}

.field input {
  width: 100%;
  height: 52px;
  padding: 0 52px 0 42px;
  font: 16px / 1.2 var(--mono);
  letter-spacing: 0.08em;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

.field input::placeholder {
  font-family: var(--font);
  letter-spacing: normal;
  color: var(--text-3);
}

.field input:focus-visible {
  outline: 0;
  border-color: var(--focus);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent);
}

.field input[aria-invalid="true"] {
  border-color: var(--down);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--down) 15%, transparent);
}

.field input:disabled,
.field input[readonly] {
  opacity: 0.72;
  cursor: not-allowed;
}

.field__toggle {
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.field__toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.field__toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.gate__err {
  margin: 8px 0 16px;
  min-height: 20px;
  font-size: var(--fs-sm);
  color: var(--down);
  display: flex;
  align-items: center;
  gap: 6px;
}

.gate__err:empty {
  min-height: 16px;
  margin-top: 0;
}

.btn-primary {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--brand);
  color: #ffffff;
  font-weight: 600;
  font-size: var(--fs-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary:disabled {
  opacity: 0.68;
  cursor: not-allowed;
}

.btn-primary.is-success {
  background: var(--up);
  opacity: 1;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 0.35);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
}

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

.gate__trust {
  margin: 20px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: center;
}

.gate__footer {
  margin-top: 24px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: center;
}

.is-shake {
  animation: shake 360ms var(--ease);
}

@keyframes shake {
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-shake {
    animation: none;
  }
}

@media (max-width: 640px) {
  .gate {
    justify-content: flex-start;
    padding: clamp(24px, 10dvh, 80px) 16px 24px;
  }

  .gate__card {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 8px;
  }

  .gate__sub {
    margin-bottom: 22px;
  }

  .gate__footer {
    margin-top: 20px;
  }
}
