:root {
  --auth-accent: #0a74ea;
  --auth-accent-2: #3aa3ff;
  --auth-bg: #ffffff;
  --auth-text: #1f2732;
  --auth-muted: #667688;
  --auth-border: #dbe5f0;
}

#auth-backdrop,
#auth-backdrop section,
#auth-backdrop header,
#auth-backdrop div {
  box-sizing: border-box;
}

#auth-backdrop section,
#auth-backdrop header,
#auth-backdrop div {
  display: block;
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 20, 36, 0.56);
  z-index: 1000;
}

.auth-backdrop.active {
  display: flex;
}

/* Основная модалка входа: scoped, чтобы не ломать другие .auth-modal */
#auth-backdrop .auth-modal {
  display: flex;
  flex-direction: column;
  width: min(640px, 94vw);
  max-height: 92vh;
  overflow: hidden;
  border-radius: 20px;
  background: var(--auth-bg);
  box-shadow: 0 20px 56px rgba(6, 22, 44, 0.35);
}

#auth-backdrop .auth-modal > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  width: 100%;
  min-height: 64px;
  padding: 12px 56px 12px 18px;
  color: #fff;
  background: linear-gradient(100deg, var(--auth-accent) 0%, var(--auth-accent-2) 100%);
}

#auth-backdrop .auth-modal > header h3 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

#auth-backdrop .auth-close {
  border: 0 !important;
  background: transparent;
  color: #fff;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  min-width: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem !important;
  line-height: 1;
  cursor: pointer;
  opacity: 0.92;
}

#auth-backdrop .auth-close:hover {
  opacity: 1;
}

#auth-backdrop .auth-modal > .content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
  overflow: auto;
}

#auth-backdrop .auth-intro {
  display: block;
  font-size: 1.08rem;
  line-height: 1.35;
  color: var(--auth-muted);
}

#auth-backdrop .auth-method {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--auth-border);
  border-radius: 14px;
  background: #f9fcff;
}

#auth-backdrop .auth-method-title {
  margin: 0;
  font-size: 1.26rem;
  line-height: 1.15;
  color: var(--auth-text);
  font-weight: 700;
}

#auth-backdrop .row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 10px;
  justify-content: start;
}

#auth-backdrop input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  background: #fff;
  color: var(--auth-text);
  font-size: 1.08rem;
}

#auth-backdrop input::placeholder {
  color: #9ba8b9;
}

#auth-backdrop input:focus {
  outline: none;
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 3px rgba(10, 116, 234, 0.12);
}

#auth-backdrop button {
  height: 42px;
  min-width: 176px;
  padding: 0 14px;
  border: 1px solid var(--auth-accent);
  border-radius: 999px;
  background: #fff;
  color: var(--auth-accent);
  font-size: 1.03rem;
  font-weight: 600;
  white-space: nowrap;
}

#auth-backdrop button.primary {
  background: var(--auth-accent);
  color: #fff;
}

#auth-backdrop .sep {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: #6f7d90;
}

#auth-backdrop .sep::before,
#auth-backdrop .sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

#auth-backdrop .messenger-picker {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 44px;
  gap: 10px;
  justify-content: start;
  position: relative;
  z-index: 8;
  pointer-events: auto;
}

#auth-backdrop .messenger-btn {
  min-width: 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  padding: 0;
  border-color: #c9d7ea;
  color: #31435b;
  background: #f2f7fe;
  font-size: 0;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  position: relative;
  z-index: 9;
}

#auth-backdrop .messenger-btn.active {
  color: #fff;
  border-color: transparent;
}

#auth-backdrop .messenger-btn:hover {
  border-color: #8eb5eb;
}

#auth-backdrop .messenger-btn[data-channel="whatsapp"].active {
  background: linear-gradient(90deg, #149d52 0%, #2cc26f 100%);
}

#auth-backdrop .messenger-btn[data-channel="telegram"].active {
  background: linear-gradient(90deg, #0989d8 0%, #24a7f0 100%);
}

#auth-backdrop .messenger-btn[data-channel="max"].active {
  background: linear-gradient(90deg, #5a3df6 0%, #6e5eff 100%);
}

#auth-backdrop .messenger-icon {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto;
  pointer-events: none;
}

#auth-backdrop .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#auth-backdrop .hint {
  font-size: 0.98rem;
  color: var(--auth-muted);
  overflow-wrap: anywhere;
}

#auth-backdrop .messenger-selected {
  display: block;
  font-size: 0.98rem;
  color: #3d4f66;
  min-height: 1.2em;
  overflow-wrap: anywhere;
}

#auth-backdrop .error,
#auth-backdrop .success {
  display: none;
  font-size: 0.96rem;
  border-radius: 12px;
  padding: 8px 10px;
}

#auth-backdrop .error {
  color: #b11226;
  background: #ffe9ec;
}

#auth-backdrop .success {
  color: #0f7c33;
  background: #e8f8ee;
}

#auth-backdrop .error.active,
#auth-backdrop .success.active {
  display: block;
}

/* прочие модалки с .auth-modal не трогаем */
.auth-modal {
  position: relative;
}

.auth-close {
  cursor: pointer;
}

@media (max-width: 900px) {
  #auth-backdrop .auth-modal {
    width: min(640px, 94vw);
  }
}

@media (max-width: 680px) {
  #auth-backdrop .auth-modal {
    border-radius: 16px;
    width: 96vw;
    max-height: 94vh;
  }

  #auth-backdrop .auth-modal > header {
    min-height: 56px;
    padding: 10px 14px;
  }

  #auth-backdrop .auth-modal > header h3 {
    font-size: 1.2rem;
  }

  #auth-backdrop .auth-modal > .content {
    padding: 12px;
    gap: 9px;
  }

  #auth-backdrop .auth-intro,
  #auth-backdrop .hint,
  #auth-backdrop .sep,
  #auth-backdrop .error,
  #auth-backdrop .success {
    font-size: 0.92rem;
  }

  #auth-backdrop .auth-method-title {
    font-size: 1.06rem;
  }

  #auth-backdrop .row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  #auth-backdrop input,
  #auth-backdrop button,
  #auth-backdrop .messenger-btn {
    height: 40px;
    font-size: 0.96rem;
  }

  #auth-backdrop button {
    min-width: 0;
  }

  #auth-backdrop .messenger-picker {
    grid-auto-columns: 40px;
  }

  #auth-backdrop .messenger-btn {
    width: 40px;
    min-width: 40px;
  }

  #auth-backdrop .messenger-icon {
    width: 19px;
    height: 19px;
  }

  #auth-backdrop .auth-close {
    top: 8px;
    right: 10px;
    min-width: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 2rem !important;
  }
}
