.modal { color: inherit;
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content { color: inherit;
  background: var(--card);
  border:1px solid var(--card-border);
  border-radius: 20px;
  padding: 20px;
  width: 350px;
  max-height: 90vh;   /* ограничим высоту окна */
  height: auto;       /* убираем растягивание */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-shadow:0 28px 60px rgba(5,7,18,0.42);
  transition:background-color .25s ease,border-color .25s ease,color .25s ease;
}
body.theme-light .modal-content{box-shadow:0 18px 38px rgba(136,150,230,0.22);}
body.theme-retro .modal-content{box-shadow:0 18px 40px rgba(14,16,28,0.38);}
body.theme-sepia .modal-content{box-shadow:0 18px 40px rgba(60,32,18,0.36);}

.auth-feedback-modal { z-index: 1201; }
.auth-feedback-modal .modal-content {
  width: min(320px, calc(100% - 48px));
  text-align: center;
  gap: 16px;
  align-items: center;
}
.auth-feedback-message {
  margin: 8px 0 0;
  font-size: 16px;
  line-height: 1.5;
}
.auth-feedback-footer {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}
.auth-feedback-footer .ios-button {
  width: auto;
  min-width: 96px;
}

.tabs {
  display: flex;
  gap: 10px;                 /* расстояние только между кнопками */
  width: 90%;                /* те же края, что у инпутов */
  margin: 0;       /* центрируем как поля */
  justify-content: center;   /* без внешних полей по краям */
}
.tab {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
}

.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: 10px;
  cursor: pointer;
  transition:background-color .2s ease,color .2s ease,border-color .2s ease;
}
.tab:hover{background:var(--btn-bg-hover);}
.tab.active {
  background: var(--primary-bg);
  color: var(--primary-fg);
  border-color: transparent;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="search"],
input[type="number"]{
  width: 90%;
  margin: 8px auto;
  display:block;
}
.btn {
  background: var(--primary-bg);
  color: var(--primary-fg);
  padding: 10px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  transition:background-color .2s ease,color .2s ease,box-shadow .2s ease,transform .1s ease;
  box-shadow:0 6px 16px color-mix(in srgb, var(--primary-bg) 35%, transparent);
}
.btn:hover{background:var(--primary-hover);box-shadow:0 8px 22px color-mix(in srgb, var(--primary-bg) 45%, transparent);}
.btn:active{transform:translateY(1px);}
.error {
  font-size: 12px;
  color: #ff3b30;
}
.code-container {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 0;
}

.code-input {
  width: 40px;
  height: 50px;
  text-align: center;
  font-size: 20px;
  border-radius: 10px;
  outline: none;
  background: var(--input-bg);
  border:1px solid var(--input-border);
  color:var(--input-fg);
  transition: all 0.2s ease;
}

.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* iOS-стиль для кнопки */
.ios-button {
  width: 100%;
  margin-top: 15px;
}
/* === disabled buttons === */
.btn[disabled], .ios-button[disabled] { opacity: .6; cursor: not-allowed; }

/* note under the send code button during countdown */
.resend-note { width: 90%; margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--muted); }

/* password strength meter */
.strength-wrap { width: 90%; margin: 4px auto 0; }
.strength-meter { height: 6px; background: var(--btn-border); border-radius: 999px; overflow: hidden; }
.strength-meter > span { display: block; height: 100%; width: 0; transition: width .25s ease; }
.strength-weak { background: #ff3b30; }
.strength-medium { background: #f59e0b; }
.strength-strong { background: #22c55e; }
.hint { width: 90%; margin: 4px auto 0; font-size: 12px; color: var(--muted); }


.modal-pass-tools{
  width: 90%;
  margin: 8px auto 0;
  display:flex;
  gap:8px;
  align-items:stretch;
}
.modal-pass-tools__btn{
  flex:1 1 calc(50% - 4px);
  width:auto;
  min-width:0;
  margin-top:0;
  min-height:44px;
  padding:8px 10px;
  border-radius:12px;
  white-space:normal;
  word-break:break-word;
  line-height:1.2;
  text-align:center;
  font-size:14px;
  display:inline-flex;
  justify-content:center;
  align-items:center;
}
.modal-pass-tools__feedback{
  display:block;
  width:90%;
  margin:6px auto 0;
  min-height:16px;
  font-size:12px;
  color:var(--muted);
}
@media (max-width: 520px){
  .modal-pass-tools{
    flex-wrap:wrap;
  }
  .modal-pass-tools__btn{
    flex:1 1 calc(50% - 4px);
    font-size:13px;
    padding:8px;
  }
}


/* даём полю место под глазик только там, где он есть */
.input-group.with-eye > input {
  padding-right: 44px;              /* было 40px — добавили ещё 4px запаса */
  box-sizing: border-box;
}

/* сам глазик — внутри поля, без рамок и системных стилей */
.toggle-pass{
  position: absolute;
  right: 12px;                      /* отступ от правого края поля */
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  z-index: 1;                       /* поверх фона инпута */
}


/* 1) БАЗОВАЯ ОБЁРТКА ДЛЯ ПОЛЯ С ГЛАЗИКОМ */
.input-group{
  position: relative;       /* <-- обязательно, иначе глазик позиционируется от модалки */
  width: 90%;
  margin: 0;
}
.input-group > input{
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

/* 2) ОТСТУП ПОД ГЛАЗИК ТОЛЬКО ТАМ, ГДЕ ОН ЕСТЬ */
.input-group.with-eye > input{
  padding-right: 44px;
}

/* 3) САМ ГЛАЗИК — КАК ИКОНКА ВНУТРИ ПОЛЯ */
.toggle-pass{
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; outline: 0;
  -webkit-appearance: none; appearance: none;
  z-index: 1;
}

/* 4) КРАСНЫЕ ОШИБКИ: ПОДПИСЬ + РАМКА */
.field-error{
  display: block;
  width: 90%;
  margin: 0;
  font-size: 12px;
  color: #ff3b30;
}
input.input-error{
  border-color: #ff3b30;
}


#register .input-group + .input-group {
  margin-top: 16px;            /* доп. зазор между Пароль и Повторите пароль */
}


/* --- Единая колонка внутри модалки --- */
.modal-content .tabs,
.modal-content .input-group,
.modal-content .btn,
.modal-content .code-container,
.modal-content .field-error {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  box-sizing: border-box;
}

/* Инпуты на всю ширину колонки */
.modal-content input:not(.code-input) {
  width: 100%;
  margin: 8px 0;
  box-sizing: border-box;
}

/* Вкладки по тем же краям, что и поля */
.tabs {
  width: 100%;
  margin: 0 0 15px; /* только нижний отступ */
}

/* Кнопка «Зарегистрироваться» — как и все остальные элементы */
.modal-footer .ios-button {
  width: 100%;
  margin: 8px auto;
  display: block;
  box-sizing: border-box;
}

/* Контейнер поля с глазиком не сужаем */
.input-group {
  width: 100%;
  margin: 8px 0;  /* равные вертикальные отступы с остальными */
}

/* Отступ под глазик — только там, где он есть */
.input-group.with-eye > input { padding-right: 44px; }

/* Registration terms confirmation modal */
.reg-terms-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(6px);
  z-index: 1250;
  padding: 16px;
}

.reg-terms-modal-open {
  overflow: hidden;
}

.reg-terms-modal__dialog {
  width: min(760px, 100%);
  max-height: min(90vh, 860px);
  background: var(--card);
  color: inherit;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 28px 66px rgba(7, 12, 24, 0.45);
  display: flex;
  flex-direction: column;
  padding: 18px;
  outline: none;
}

.reg-terms-modal__subtitle,
.reg-terms-modal__version {
  margin: 0 0 8px;
}

.reg-terms-modal__version {
  font-size: 12px;
  color: var(--muted);
}

.reg-terms-modal__content {
  margin-top: 6px;
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 12px;
  overflow-y: auto;
  max-height: min(56vh, 480px);
  background: color-mix(in srgb, var(--card) 94%, transparent);
}

.reg-terms-modal__content h2 {
  font-size: 16px;
  margin: 14px 0 8px;
}

.reg-terms-modal__content p,
.reg-terms-modal__content li {
  font-size: 14px;
  line-height: 1.45;
}

.reg-terms-modal__error {
  min-height: 18px;
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 10px;
}

.reg-terms-modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.reg-terms-modal__btn {
  flex: 1 1 0;
  min-height: 42px;
  margin-top: 0;
}

.reg-terms-modal__btn--ghost {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  box-shadow: var(--btn-shadow);
}

.reg-terms-modal__btn--ghost:hover {
  background: var(--btn-bg-hover);
}

@media (max-width: 640px) {
  .reg-terms-modal__dialog {
    max-height: 92vh;
    padding: 14px;
  }

  .reg-terms-modal__content {
    max-height: 52vh;
  }

  .reg-terms-modal__actions {
    flex-direction: column;
  }
}

@media (max-width: 960px) {
  .modal-content {
    width: min(420px, calc(100vw - 36px));
    max-height: calc(100vh - 36px);
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .modal {
    padding: 12px;
    box-sizing: border-box;
  }
  .modal-content {
    width: 100%;
    border-radius: 16px;
    padding: 14px;
    max-height: calc(100vh - 24px);
  }
  .tabs {
    gap: 8px;
    margin-bottom: 10px;
  }
  .tab {
    padding: 9px 8px;
    font-size: 14px;
  }
  .code-container {
    gap: 8px;
  }
  .code-input {
    width: calc((100% - 5 * 8px) / 6);
    min-width: 34px;
    height: 46px;
    font-size: 18px;
  }
  .auth-feedback-modal .modal-content {
    width: min(320px, calc(100vw - 24px));
  }
}
