.auth-gate-modal {
  position: fixed;
  inset: 0;
  z-index: 560;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 18px calc(18px + var(--keyboard-inset, 0px));
  background: rgba(5, 20, 42, .5);
  transition: padding-bottom .22s ease;
}

.auth-gate-modal.open {
  display: flex;
}

.auth-gate-panel {
  position: relative;
  width: min(100%, 430px);
  max-height: min(82vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 18px 18px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 86% 0%, rgba(94, 214, 255, .2), transparent 120px),
    #fff;
  box-shadow: 0 24px 70px rgba(5, 28, 68, .26);
  transition: transform .22s ease;
  -webkit-overflow-scrolling: touch;
}

.auth-gate-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #edf5ff;
  color: #6a788d;
  font: inherit;
  font-size: 22px;
  line-height: 1;
}

.auth-gate-panel h2 {
  margin: 0;
  color: #052b64;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 950;
}

.auth-gate-subtitle,
.auth-gate-tips {
  margin: 7px 0 0;
  color: #6f7f95;
  font-size: 13px;
  line-height: 1.5;
}

.auth-gate-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 16px;
  padding: 4px;
  border-radius: 999px;
  background: #edf5ff;
}

.auth-gate-tabs button {
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #607083;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.auth-gate-tabs button.active {
  background: #fff;
  color: #1267ff;
  box-shadow: 0 8px 20px rgba(18, 103, 255, .12);
}

.auth-gate-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.auth-gate-form label {
  display: grid;
  gap: 7px;
}

.auth-gate-form label span {
  color: #052b64;
  font-size: 13px;
  font-weight: 900;
}

.auth-gate-form input {
  width: 100%;
  height: 44px;
  border: 1px solid #d9e8f6;
  border-radius: 12px;
  padding: 0 12px;
  outline: 0;
  background: #f8fbff;
  color: #17243a;
  font: inherit;
  font-size: 14px;
}

.auth-gate-form input:focus {
  border-color: rgba(18, 103, 255, .56);
  box-shadow: 0 0 0 3px rgba(18, 103, 255, .1);
}

.auth-gate-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 8px;
}

.auth-gate-code-btn {
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #eaf4ff;
  color: #1267ff;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.auth-gate-password-hint {
  margin-top: -2px;
  color: #6b7c91;
  font-size: 12px;
  line-height: 1.45;
}

.auth-gate-extra {
  display: none;
  justify-content: flex-end;
  margin-top: -4px;
}

.auth-gate-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1267ff;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.auth-gate-submit {
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #1267ff, #0f4dd8);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 950;
  box-shadow: 0 14px 26px rgba(18, 103, 255, .24);
}

.auth-gate-password-field {
  display: none !important;
}

.auth-gate-mode-password .auth-gate-code-field {
  display: none !important;
}

.auth-gate-mode-password .auth-gate-password-field,
.auth-gate-mode-register .auth-gate-password-field,
.auth-gate-mode-reset .auth-gate-password-field,
.auth-gate-mode-register .auth-gate-code-field,
.auth-gate-mode-reset .auth-gate-code-field {
  display: grid !important;
}

.auth-gate-mode-password .auth-gate-extra {
  display: flex;
}

.auth-gate-toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 580;
  max-width: calc(100vw - 40px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(5, 43, 100, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

.auth-gate-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.auth-required main.page {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

html[data-theme="dark"] .auth-gate-modal {
  background: rgba(1, 6, 14, .72);
}

html[data-theme="dark"] .auth-gate-panel {
  border: 1px solid rgba(127, 158, 196, .24);
  background:
    radial-gradient(circle at 86% 0%, rgba(74, 144, 255, .18), transparent 130px),
    rgba(13, 24, 41, .98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .48);
}

html[data-theme="dark"] .auth-gate-panel h2,
html[data-theme="dark"] .auth-gate-form label span {
  color: #f2f7ff;
}

html[data-theme="dark"] .auth-gate-subtitle,
html[data-theme="dark"] .auth-gate-tips,
html[data-theme="dark"] .auth-gate-password-hint {
  color: #a9b8ca;
}

html[data-theme="dark"] .auth-gate-tabs {
  background: rgba(255, 255, 255, .06);
}

html[data-theme="dark"] .auth-gate-tabs button {
  color: #b9c8dc;
}

html[data-theme="dark"] .auth-gate-tabs button.active,
html[data-theme="dark"] .auth-gate-close,
html[data-theme="dark"] .auth-gate-code-btn {
  background: rgba(47, 125, 246, .18);
  color: #8cb9ff;
  box-shadow: none;
}

html[data-theme="dark"] .auth-gate-form input {
  border-color: rgba(127, 158, 196, .22);
  background: rgba(9, 18, 32, .86);
  color: #eef6ff;
}

html[data-theme="dark"] .auth-gate-form input::placeholder {
  color: #72849d;
}

html[data-theme="dark"] .auth-gate-form input:focus {
  border-color: rgba(98, 162, 255, .72);
  box-shadow: 0 0 0 3px rgba(98, 162, 255, .16);
}
