.auth-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1200;
  align-items: center;
  justify-content: center;
}

.auth-modal.open { display: flex; }

.auth-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(46, 38, 48, 0.44);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: amOverlay 0.22s ease both;
}

@keyframes amOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.auth-modal__window {
  position: relative;
  z-index: 1;
  background: #faf8f8;
  border-radius: 12px;
  width: 100%;
  /* Сделать такую же максимальную ширину и внутренние отступы, как у других модалок */
  /* увеличим максимальную ширину, чтобы форма не меняла размер при появлении сообщений */
  max-width: 720px;
  /* минимальная ширина, чтобы не становилось слишком узким на больших экранах */
  min-width: 460px;
  margin: 0 16px;
  padding: 36px 32px; /* выровнял отступы по бокам для единообразия с authMessage */
  /* дополнительный нижний паддинг чтобы место для абсолютного сообщения не перекрывало кнопку */
  padding-bottom: 88px;
  box-shadow: 0 20px 60px rgba(46, 38, 48, 0.16);
  animation: amWindow 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
  overflow: hidden;
}

/* Всегда резервируем место под сообщение об ошибке и выравниваем ширину */
/* показываем сообщение поверх содержимого (не меняя высоту модального окна) */
#authMessage {
  position: absolute;
  left: 32px;
  right: 32px;
  bottom: 24px; /* чуть выше нижнего края модального окна */
  box-sizing: border-box;
  color: #8a3a3a;
  font-family: 'Jost', sans-serif;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  text-align: center;
  padding: 0;
  margin: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none; /* текст не мешает кликам */
}

/* Когда сообщение пусто — убираем высоту/паддинг, чтобы не было большого отступа снизу */
#authMessage:empty { display: none; }
#authMessage:not(:empty) {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

@keyframes amWindow {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}

.auth-modal__close:hover { background: #ede6ed; }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid #ede6ed;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  font-family: 'Jost', sans-serif;
  font-size: 0.83rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: #9a8a9a;
  background: transparent;
  border: none;
  padding: 14px 0;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.auth-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 2px;
  background: #4a3d4a;
  transition: width 0.25s ease;
}

.auth-tab.active {
  color: #3e323e;
  font-weight: 400;
}

.auth-tab.active::after { width: 100%; }

.auth-tab:hover:not(.active) { color: #6a5a6a; }

.auth-panel {
  /* Паддинги перенесены в .auth-modal__window для единообразия ширины содержимого */
  padding: 0;
  animation: amPanel 0.22s ease both;
}

.auth-panel.hidden { display: none; }

@keyframes amPanel {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.auth-panel__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #3e323e;
  margin-bottom: 6px;
}

.auth-panel__sub {
  font-family: 'Jost', sans-serif;
  font-size: 0.82rem;
  font-weight: 300;
  color: #9a8a9a;
  margin-bottom: 22px;
}

.auth-panel__step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-panel__step-header .auth-panel__title { margin-bottom: 0; }

.af-back {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid #ddd0dd;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.af-back:hover {
  background: #f3eef3;
  border-color: #8B7B8B;
}

.auth-form {
  display: flex;
  flex-direction: column;
  /* Более ровные отступы между группами полей */
  gap: 18px;
}

.af-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.af-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.af-label {
  font-family: 'Jost', sans-serif;
  font-size: 0.78rem;
  font-weight: 300;
  color: #5a4d5a;
  letter-spacing: 0.02em;
}

.af-input-wrap {
  position: relative;
}

.af-input-wrap .af-input { padding-right: 40px; }

.af-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.af-eye:hover { opacity: 1; }

.af-input {
  font-family: 'Jost', sans-serif;
  font-size: 0.88rem;
  font-weight: 300;
  color: #3e323e;
  background: #f3eef3;
  border: 1px solid transparent;
  /* Более округлые и просторные поля как в макете */
  border-radius: 8px;
  padding: 12px 14px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  transition: border-color 0.2s, background 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.af-input::placeholder { color: #c0b0c0; }

.af-input:focus {
  border-color: #8B7B8B;
  background: #fff;
}

.af-input.error {
  border-color: #c07070;
  background: #fff8f8;
}

.af-input--date { cursor: pointer; }

.af-input--date::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
}

.af-link {
  font-family: 'Jost', sans-serif;
  font-size: 0.78rem;
  font-weight: 300;
  color: #8B7B8B;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.af-link:hover { color: #4a3d4a; }

.af-link--right {
  align-self: flex-end;
  margin-top: -8px;
}

.af-submit {
  font-family: 'Jost', sans-serif;
  font-size: 0.88rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: #3e323e;
  background: #f3eef3;
  border: 1px solid #ddd0dd;
  border-radius: 8px;
  padding: 13px;
  width: 100%;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.22s, border-color 0.22s, color 0.22s;
}

.af-submit:hover {
  background: #4a3d4a;
  border-color: #4a3d4a;
  color: #fff;
}

.af-submit:disabled { opacity: 0.6; cursor: default; }

.af-switch {
  font-family: 'Jost', sans-serif;
  font-size: 0.78rem;
  font-weight: 300;
  color: #9a8a9a;
  text-align: center;
  margin-top: 8px;
}

/* Button-like link "На главную" */
.btn-home {
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ddd0dd;
  background: #f3eef3;
  color: #3e323e;
  text-decoration: none;
  font-family: 'Jost', sans-serif;
  margin-top: 6px;
}
.btn-home:hover { background: #e9e0e9; }

.auth-success {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 12px 32px 8px;
  animation: amPanel 0.25s ease both;
}

.auth-success.visible { display: flex; }

.auth-success__icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e0f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.auth-success__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: #3e323e;
}

.auth-success__sub {
  font-family: 'Jost', sans-serif;
  font-size: 0.83rem;
  font-weight: 300;
  color: #7a6a7a;
  line-height: 1.65;
}

@media (max-width: 480px) {
  .auth-modal__window {
    border-radius: 10px 10px 0 0;
    max-width: 100%;
    margin: 0;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: 28px;
  }

  .auth-modal {
    align-items: flex-end;
  }

  @keyframes amWindow {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .auth-panel { padding: 0 20px; }

  .auth-tabs { margin-bottom: 22px; }

  .af-row { grid-template-columns: 1fr; }
}