/* =========================================================
   Daryger Doctor — Auth UI
   Mobile first · Light/Dark · RU/EN
   ========================================================= */

/* ---------- 1. Дизайн-токены ---------- */
:root {
  /* Палитра — светлая тема */
  --bg:            #EEF2F5;
  --bg-2:          #E4EAEF;
  --surface:       #FFFFFF;
  --surface-2:     #F6F8FA;
  --surface-3:     #EDF1F5;
  --border:        #E1E7ED;
  --border-2:      #CDD7E1;
  --text:          #0D1620;
  --text-2:        #59697C;
  --text-3:        #8C9BAC;

  --brand:         #0E7C74;
  --brand-2:       #14A79C;
  --brand-3:       #38CFC0;
  --brand-soft:    rgba(14, 124, 116, .08);
  --brand-ink:     #FFFFFF;
  --ring:          rgba(20, 167, 156, .30);

  --danger:        #D14343;
  --danger-soft:   rgba(209, 67, 67, .09);
  --warn:          #C98A12;
  --ok:            #17916B;

  --deep-1:        #072A2C;
  --deep-2:        #0B4C4A;
  --deep-3:        #0E7C74;

  /* Геометрия */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Тени */
  --sh-1: 0 1px 2px rgba(13, 22, 32, .05);
  --sh-2: 0 4px 16px -4px rgba(13, 22, 32, .10), 0 1px 3px rgba(13, 22, 32, .05);
  --sh-3: 0 24px 60px -20px rgba(13, 22, 32, .22), 0 2px 8px rgba(13, 22, 32, .05);
  --sh-brand: 0 10px 26px -10px rgba(14, 124, 116, .60);

  /* Типографика */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text",
          Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* Анимации */
  --ease: cubic-bezier(.22, .68, .32, 1);
  --dur: .28s;
}

html[data-theme="dark"] {
  --bg:            #05090F;
  --bg-2:          #0A111B;
  --surface:       #0D1622;
  --surface-2:     #121D2C;
  --surface-3:     #172436;
  --border:        #1D2B3D;
  --border-2:      #2A3B51;
  --text:          #E9EFF7;
  --text-2:        #94A6BD;
  --text-3:        #6B7E96;

  --brand:         #21B5A6;
  --brand-2:       #2FC7B9;
  --brand-3:       #5CE3D4;
  --brand-soft:    rgba(47, 199, 185, .10);
  --brand-ink:     #04211F;
  --ring:          rgba(47, 199, 185, .28);

  --danger:        #EF7B7B;
  --danger-soft:   rgba(239, 123, 123, .12);
  --warn:          #E3B155;
  --ok:            #3ECFA0;

  --deep-1:        #04121A;
  --deep-2:        #06282E;
  --deep-3:        #0A4A48;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .40);
  --sh-2: 0 4px 18px -4px rgba(0, 0, 0, .55);
  --sh-3: 0 28px 70px -24px rgba(0, 0, 0, .80), 0 2px 10px rgba(0, 0, 0, .40);
  --sh-brand: 0 10px 26px -12px rgba(47, 199, 185, .55);
}

/* ---------- 2. Сброс ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--brand-2); color: #fff; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
  font-size: 13px;
  text-decoration: none;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- 3. Каркас ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Бренд-панель (скрыта на мобильных) --- */
.brand { display: none; }

/* --- Панель форм --- */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  background:
    radial-gradient(120% 60% at 50% -10%, var(--brand-soft) 0%, transparent 60%),
    var(--bg);
}

.panel__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 20px 0 8px;
  min-width: 0;
}

/* ---------- 4. Топбар ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  border-radius: 12px;
  transition: opacity .2s var(--ease);
}
a.logo:hover { opacity: .82; }
a.logo:hover .logo__img { transform: scale(1.04); }
a.logo:active { opacity: .7; }

.logo__img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  box-shadow: var(--sh-1);
  transition: transform .25s var(--ease);
}

.logo__text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }

.logo__name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.logo__sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand);
}

.logo--invert .logo__name { color: #fff; }
.logo--invert .logo__sub { color: rgba(255, 255, 255, .62); }
.logo--invert .logo__img { box-shadow: 0 6px 20px -6px rgba(0, 0, 0, .55); }

.controls { display: flex; align-items: center; gap: 8px; }

/* --- Выбор языка --- */
.lang { position: relative; }

.lang__btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  transition: border-color .2s var(--ease), background-color .2s var(--ease),
              box-shadow .2s var(--ease), transform .14s var(--ease);
}
.lang__btn:hover { border-color: var(--border-2); }
.lang__btn:active { transform: scale(.94); }
.lang__btn[aria-expanded="true"] {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px var(--ring);
}

/* Флаг */
.flag {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .10) inset, 0 1px 2px rgba(13, 22, 32, .18);
}
html[data-theme="dark"] .flag { box-shadow: 0 0 0 1px rgba(255, 255, 255, .16) inset, 0 1px 3px rgba(0, 0, 0, .5); }
.flag svg { width: 100%; height: 100%; display: block; }

/* В кнопке показываем флаг текущего языка; в меню — оба */
html[lang="ru"] .lang__btn .flag--en,
html[lang="en"] .lang__btn .flag--ru { display: none; }

.lang__btn .flag { animation: flagIn .32s var(--ease); }
@keyframes flagIn {
  from { opacity: 0; transform: scale(.5) rotate(-25deg); }
  to   { opacity: 1; transform: none; }
}

.lang__menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  min-width: 178px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  animation: menuIn .2s var(--ease) both;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.lang__opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}
.lang__opt:hover,
.lang__opt:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.lang__opt[aria-selected="true"] { color: var(--text); font-weight: 620; }

.lang__opt .flag { transition: transform .2s var(--ease); }
.lang__opt:hover .flag { transform: scale(1.08); }

.lang__optName { flex: 1; }

.lang__tick {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--brand);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .18s var(--ease), transform .22s var(--ease);
}
.lang__opt[aria-selected="true"] .lang__tick { opacity: 1; transform: none; }

/* --- Иконочная кнопка (тема) --- */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  color: var(--text-2);
  overflow: hidden;
  transition: color .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn:active { transform: scale(.94); }

.icon-btn svg {
  position: absolute;
  width: 17px;
  height: 17px;
  transition: transform .45s var(--ease), opacity .3s var(--ease);
}
.icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
.icon-moon { opacity: 0; transform: rotate(-70deg) scale(.4); }
html[data-theme="dark"] .icon-sun  { opacity: 0; transform: rotate(70deg) scale(.4); }
html[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

/* ---------- 5. Карточка ---------- */
.card {
  position: relative;
  width: 100%;
  max-width: 440px;
  /* В колоночном флексе карточка не должна сжиматься:
     иначе вместо прокрутки её содержимое обрезается снизу. */
  flex-shrink: 0;
  padding: 26px 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

/* Плавное изменение высоты при переходе между экранами */
.card.is-resizing {
  transition: height .42s var(--ease);
  will-change: height;
}

/* Тонкая брендовая линия сверху */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand-3), transparent);
  opacity: .7;
}

/* ---------- 6. Экраны ---------- */
.view { display: none; }
.view.is-active { display: block; animation: viewIn .42s var(--ease) both; }
.view.is-active.is-back { animation-name: viewInBack; }
.view--center { text-align: center; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: none; }
}
@keyframes viewInBack {
  from { opacity: 0; transform: translateY(-8px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

/* Ступенчатое появление содержимого экрана.
   backwards, а не both: после анимации элемент возвращается к обычным
   стилям, иначе финальный transform заблокировал бы :active и :hover. */
.view.is-active .view__head,
.view.is-active .form > *,
.view.is-active .done > * {
  animation: riseIn .5s var(--ease) backwards;
}
.view.is-active .view__head    { animation-delay: .04s; }
.view.is-active .form > *:nth-child(1),
.view.is-active .done > *:nth-child(1) { animation-delay: .09s; }
.view.is-active .form > *:nth-child(2),
.view.is-active .done > *:nth-child(2) { animation-delay: .14s; }
.view.is-active .form > *:nth-child(3),
.view.is-active .done > *:nth-child(3) { animation-delay: .19s; }
.view.is-active .form > *:nth-child(4),
.view.is-active .done > *:nth-child(4) { animation-delay: .24s; }
.view.is-active .form > *:nth-child(5) { animation-delay: .29s; }
.view.is-active .form > *:nth-child(6) { animation-delay: .34s; }
.view.is-active .form > *:nth-child(7) { animation-delay: .39s; }
.view.is-active .form > *:nth-child(8) { animation-delay: .44s; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}

.view__head { margin-bottom: 22px; }

.title {
  font-size: 23px;
  font-weight: 720;
  letter-spacing: -.022em;
  line-height: 1.2;
}

.subtitle {
  margin-top: 7px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.subtitle__target {
  color: var(--text);
  font-weight: 650;
  word-break: break-word;
}

/* Индикатор шагов */
.steps { display: flex; gap: 5px; margin-bottom: 14px; }
.steps i {
  width: 22px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--border-2);
  transition: background-color .3s var(--ease), width .3s var(--ease);
}
.steps i.is-on { width: 30px; background: var(--brand-2); }

/* Бейдж канала */
.view__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 5px 11px 5px 8px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .01em;
}
.view__badge svg { width: 14px; height: 14px; }

/* ---------- 7. Формы ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.label {
  font-size: 12.5px;
  font-weight: 620;
  letter-spacing: .005em;
  color: var(--text-2);
}
.label--center { text-align: center; }

/* Подпись-разделитель над крупным выбором */
.label--section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.003em;
  color: var(--text);
  white-space: nowrap;
}
.label--section::before,
.label--section::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2));
}
.label--section::after { background: linear-gradient(90deg, var(--border-2), transparent); }

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.hint {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}

.error {
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.4;
  color: var(--danger);
  min-height: 0;
}
.error:empty { display: none; }
.error--center { text-align: center; }
.error--block { margin-top: -8px; }

/* --- Выбор способа регистрации --- */
.methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 1px;
}

.method {
  /* --m — акцент карточки: у Telegram он фирменный синий */
  --m: var(--brand);
  --m2: var(--brand-2);
  --m-soft: var(--brand-soft);

  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-2);
  overflow: hidden;
  transition: border-color .22s var(--ease), background-color .22s var(--ease),
              color .22s var(--ease), box-shadow .22s var(--ease), transform .16s var(--ease);
}
.method--telegram {
  --m: #229ED9;
  --m2: #2AABEE;
  --m-soft: rgba(42, 171, 238, .10);
}
html[data-theme="dark"] .method--telegram {
  --m: #38B6F0;
  --m2: #56C6F7;
  --m-soft: rgba(56, 182, 240, .13);
}

.method:hover { border-color: var(--border-2); color: var(--text); transform: translateY(-1px); }
.method:active { transform: scale(.985); }

.method.is-active {
  background: var(--m-soft);
  border-color: var(--m2);
  color: var(--text);
  box-shadow: 0 8px 20px -12px var(--m);
}

/* Мягкое свечение под выбранной карточкой */
.method::after {
  content: "";
  position: absolute;
  inset: auto -30% -70% -30%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--m-soft), transparent);
  opacity: 0;
  transition: opacity .35s var(--ease);
  pointer-events: none;
}
.method.is-active::after { opacity: 1; }

.method__ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--m-soft);
  color: var(--m);
  transition: color .22s var(--ease), background-color .22s var(--ease),
              transform .28s var(--ease), box-shadow .22s var(--ease);
}
.method__ico svg { width: 17px; height: 17px; }
.method:hover .method__ico { transform: scale(1.06); }
.method.is-active .method__ico {
  background: linear-gradient(135deg, var(--m) 0%, var(--m2) 100%);
  color: #fff;
  box-shadow: 0 6px 14px -6px var(--m);
}

.method__name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -.005em;
}

.method__tick {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--m);
  color: #fff;
  opacity: 0;
  transform: scale(.4);
  transition: opacity .2s var(--ease), transform .3s var(--ease);
}
.method__tick svg { width: 9px; height: 9px; }
.method.is-active .method__tick { opacity: 1; transform: none; }

/* --- Поле ввода --- */
.control {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
}
.control:hover { border-color: var(--border-2); }
.control:focus-within {
  background: var(--surface);
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px var(--ring);
}
.control.has-error { border-color: var(--danger); }
.control.has-error:focus-within { box-shadow: 0 0 0 4px var(--danger-soft); }

.control__icon {
  display: grid;
  place-items: center;
  width: 42px;
  flex-shrink: 0;
  color: var(--text-3);
  transition: color .2s var(--ease);
}
.control__icon svg { width: 17px; height: 17px; }
.control:focus-within .control__icon { color: var(--brand); }

.control__prefix {
  display: grid;
  place-items: center;
  width: 42px;
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text-3);
}
.control--prefixed:focus-within .control__prefix { color: var(--brand); }

.input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px 13px 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  letter-spacing: .005em;
  outline: none;
}
.input::placeholder { color: var(--text-3); opacity: .85; }

/* Автозаполнение браузера */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 60px var(--surface-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out;
}

/* Кнопка «показать пароль» */
.control__eye {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  margin-right: 2px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: color .2s var(--ease);
}
.control__eye:hover { color: var(--text); }
.control__eye svg { width: 17px; height: 17px; }
.control__eye .eye-off { display: none; }
.control__eye.is-on .eye-on { display: none; }
.control__eye.is-on .eye-off { display: block; }

/* Авто-метка типа контакта (email / telegram / phone) */
.control__tag {
  flex-shrink: 0;
  margin-right: 10px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  animation: tagIn .25s var(--ease) both;
}
@keyframes tagIn { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }

/* ---------- 8. Надёжность пароля ---------- */
.strength {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 3px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .38s var(--ease), opacity .3s var(--ease), margin-top .3s var(--ease);
}
.strength.is-open { max-height: 190px; opacity: 1; margin-top: 5px; }

.strength__bars { display: flex; gap: 4px; }
.strength__bars i {
  flex: 1;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--border-2);
  transition: background-color .3s var(--ease);
}

.strength__row { display: flex; justify-content: flex-end; }
.strength__label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  color: var(--text-3);
  transition: color .3s var(--ease);
}

.strength[data-score="1"] .strength__bars i:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] .strength__bars i:nth-child(-n+2) { background: var(--warn); }
.strength[data-score="3"] .strength__bars i:nth-child(-n+3) { background: #3E9BD6; }
.strength[data-score="4"] .strength__bars i { background: var(--ok); }

.strength[data-score="1"] .strength__label { color: var(--danger); }
.strength[data-score="2"] .strength__label { color: var(--warn); }
.strength[data-score="3"] .strength__label { color: #3E9BD6; }
.strength[data-score="4"] .strength__label { color: var(--ok); }

.strength__rules {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}
.strength__rules li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-3);
  transition: color .25s var(--ease);
}
.strength__rules li.is-ok { color: var(--ok); }

.tick {
  position: relative;
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--border-2);
  transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
.tick::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 5px;
  height: 2.5px;
  border-left: 1.6px solid #fff;
  border-bottom: 1.6px solid #fff;
  transform: rotate(-45deg) translate(.5px, -.5px) scale(.4);
  opacity: 0;
  transition: opacity .2s var(--ease), transform .25s var(--ease);
}
.strength__rules li.is-ok .tick { background: var(--ok); border-color: var(--ok); }
.strength__rules li.is-ok .tick::after { opacity: 1; transform: rotate(-45deg) translate(.5px, -.5px) scale(1); }

/* ---------- 9. Чекбокс ---------- */
.check {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
/* Настоящий input лежит поверх нарисованного квадрата:
   остаётся в дереве доступности и кликабелен, но невидим. */
.check input {
  position: absolute;
  left: 0;
  top: 1px;
  width: 19px;
  height: 19px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.check__box {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  margin-top: 1px;
  border: 1.6px solid var(--border-2);
  border-radius: 6px;
  background: var(--surface-2);
  color: transparent;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .12s var(--ease);
}
.check__box svg { width: 11px; height: 11px; }
.check:hover .check__box { border-color: var(--brand-2); }
.check:active .check__box { transform: scale(.9); }
.check input:checked + .check__box {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.check input:focus-visible + .check__box {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}
.check__text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}

/* ---------- 10. Кнопки и ссылки ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px 22px;
  border-radius: var(--r-md);
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: .005em;
  white-space: nowrap;
  transition: transform .14s var(--ease), box-shadow .25s var(--ease), filter .2s var(--ease), opacity .2s var(--ease);
  overflow: hidden;
}
.btn--block { width: 100%; }

.btn--primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 55%, var(--brand-3) 140%);
  color: var(--brand-ink);
  box-shadow: var(--sh-brand);
}
.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), transparent 55%);
  pointer-events: none;
}
/* Блик, пробегающий по кнопке при наведении */
.btn--primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .30) 50%, transparent 62%);
  transform: translateX(-130%);
  pointer-events: none;
}
.btn--primary:hover::before { transform: translateX(130%); transition: transform .85s var(--ease); }
.btn--primary:hover { filter: brightness(1.06); box-shadow: 0 14px 32px -12px rgba(14, 124, 116, .7); }
.btn--primary:active { transform: translateY(1px) scale(.995); }

/* Подпись и спиннер — поверх декоративных слоёв */
.btn__label { position: relative; z-index: 1; }

.btn.is-loading { pointer-events: none; opacity: .9; }
.btn.is-loading .btn__label { opacity: 0; }
.btn__spinner { display: none; }
.btn.is-loading .btn__spinner {
  display: block;
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: inherit;
  font-weight: 650;
  color: var(--brand);
  text-decoration: none;
  border-radius: 5px;
  transition: color .18s var(--ease), opacity .18s var(--ease);
}
.link:hover { color: var(--brand-2); text-decoration: underline; text-underline-offset: 3px; }
.link--sm { font-size: 12px; font-weight: 600; }
.link--muted { color: var(--text-2); font-weight: 600; }
.link--muted:hover { color: var(--brand); }
.link__ico { width: 14px; height: 14px; }

.form__foot {
  margin-top: 2px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}
.form__foot .link { margin-left: 3px; }

/* ---------- 11. OTP ---------- */
.otp {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  margin: 4px auto 0;
  width: 100%;
  max-width: 330px;
}

.otp__cell {
  width: 100%;
  aspect-ratio: 3 / 3.7;
  padding: 0;
  text-align: center;
  font-size: 21px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease),
              background-color .18s var(--ease), transform .14s var(--ease);
}
.otp__cell:hover { border-color: var(--border-2); }
.otp__cell:focus {
  background: var(--surface);
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px var(--ring);
  transform: translateY(-1px);
}
.otp__cell.is-filled {
  background: var(--surface);
  border-color: var(--brand-2);
  color: var(--brand);
  animation: cellPop .3s var(--ease);
}
@keyframes cellPop {
  0%   { transform: scale(.84); }
  55%  { transform: scale(1.07); }
  100% { transform: none; }
}
.otp.has-error .otp__cell { border-color: var(--danger); }
.otp.shake { animation: shake .42s var(--ease); }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* Привязка чата Telegram: показывается вместо кода, пока нет chat_id */
.tg-link {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(42, 171, 238, .08);
  border: 1px solid rgba(42, 171, 238, .28);
  animation: riseIn .4s var(--ease) backwards;
}
html[data-theme="dark"] .tg-link {
  background: rgba(56, 182, 240, .10);
  border-color: rgba(56, 182, 240, .30);
}

.tg-link__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-2);
}

.btn--telegram {
  background: linear-gradient(135deg, #229ED9 0%, #2AABEE 100%);
  color: #fff;
  box-shadow: 0 10px 26px -12px rgba(34, 158, 217, .8);
}
.btn--telegram svg { width: 18px; height: 18px; }
.btn--telegram:hover { filter: brightness(1.06); }
.btn--telegram:active { transform: translateY(1px) scale(.995); }

.resend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 22px;
  font-size: 13px;
}
.resend__timer {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
#resend-btn[disabled] {
  color: var(--text-3);
  cursor: default;
  pointer-events: none;
}

/* ---------- 12. Экран успеха ---------- */
.done { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 0; }

.done__mark { width: 76px; height: 76px; margin-bottom: 4px; }
.done__mark svg { width: 100%; height: 100%; overflow: visible; }

.done__circle {
  fill: none;
  stroke: var(--brand-2);
  stroke-width: 2.2;
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
  animation: drawCircle .7s var(--ease) forwards;
}
.done__check {
  fill: none;
  stroke: var(--brand-2);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawCheck .45s var(--ease) .5s forwards;
}
@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawCheck  { to { stroke-dashoffset: 0; } }

.done .subtitle { max-width: 320px; }
.done .btn { margin-top: 10px; }

/* ---------- 13. Подвал ---------- */
.foot {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-3);
}
.foot .link { font-size: 11.5px; font-weight: 550; }
.foot__dot { opacity: .5; }

/* ---------- 14. Тосты ---------- */
.toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  overflow: hidden;
  animation: toastIn .35s var(--ease) both;
}

/* Полоска обратного отсчёта до автозакрытия */
.toast::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: var(--brand-2);
  transform-origin: left;
  animation: toastBar var(--toast-ms, 2000ms) linear forwards;
}
.toast--error::after { background: var(--danger); }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast.is-out { animation: toastOut .3s var(--ease) forwards; }

.toast__ico {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
}
.toast__ico svg { width: 13px; height: 13px; }
.toast--error .toast__ico { background: var(--danger-soft); color: var(--danger); }

@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* На узких экранах уводим тосты наверх, чтобы они не перекрывали
   основную кнопку в конце длинной формы. */
@media (max-width: 699px) {
  .toasts {
    /* 16px отступ панели + 34px логотип + 10px зазор = ниже топбара */
    top: calc(60px + env(safe-area-inset-top));
    bottom: auto;
    flex-direction: column;
  }
  .toast { animation-name: toastInTop; }
  .toast.is-out { animation-name: toastOutTop; }
}

@keyframes toastInTop  { from { opacity: 0; transform: translateY(-14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOutTop { to { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* =========================================================
   15. Адаптив
   ========================================================= */

/* --- Очень узкие экраны: способы регистрации в один столбец --- */
@media (max-width: 359px) {
  .methods { grid-template-columns: 1fr; }
  .lang__label { display: none; }
}

/* --- ≥ 420px: чуть больше воздуха --- */
@media (min-width: 420px) {
  .card { padding: 30px 26px 28px; }
  .title { font-size: 25px; }
  .otp { gap: 9px; }
}

/* --- ≥ 700px: центрированная карточка на подложке --- */
@media (min-width: 700px) {
  .panel { padding: 24px 28px calc(20px + env(safe-area-inset-bottom)); }
  .panel__body { gap: 26px; padding: 32px 0 12px; }
  .card { max-width: 452px; padding: 36px 36px 32px; }
  .title { font-size: 27px; }
  .subtitle { font-size: 14px; }
  .strength__rules { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .logo__img { width: 38px; height: 38px; }
  .logo__name { font-size: 16px; }
}

/* --- ≥ 1040px: две колонки, бренд-панель --- */
@media (min-width: 1040px) {
  /* Страница целиком занимает экран: левая колонка неподвижна,
     прокручивается только правая — со скроллом внутри .panel__body. */
  .app {
    grid-template-columns: minmax(0, 1.05fr) minmax(520px, .95fr);
    /* Без явной строки она растянулась бы по контенту, и height: 100%
       у колонок считался бы от высоты формы, а не от высоты экрана. */
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overflow: clip;
  }

  /* clip вместо hidden: hidden создаёт скролл-контейнер, который колесо
     мыши всё ещё может прокрутить, если что-то вылезло за границы. */
  .panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    overflow: clip;
  }

  .panel__body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* safe center не даёт срезать верх карточки, когда она выше экрана */
    justify-content: safe center;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
  }
  .panel__body::-webkit-scrollbar { width: 8px; }
  .panel__body::-webkit-scrollbar-track { background: transparent; }
  .panel__body::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border: 2px solid transparent;
    background-clip: content-box;
    border-radius: var(--r-pill);
  }
  .panel__body::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

  .brand {
    position: relative;
    display: block;
    height: 100%;
    min-height: 0;
    /* Декоративные пятна выходят за края и делали панель прокручиваемой */
    overflow: hidden;
    overflow: clip;
    isolation: isolate;
    background:
      radial-gradient(90% 70% at 15% 10%, var(--deep-3) 0%, transparent 55%),
      linear-gradient(160deg, var(--deep-2) 0%, var(--deep-1) 62%, #04161B 100%);
    color: #fff;
  }

  .brand__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
  }
  .brand__glow--1 {
    width: 46%;
    aspect-ratio: 1;
    top: -8%;
    right: -6%;
    background: rgba(56, 207, 192, .30);
    animation: float1 16s var(--ease) infinite alternate;
  }
  .brand__glow--2 {
    width: 40%;
    aspect-ratio: 1;
    bottom: -10%;
    left: -8%;
    background: rgba(20, 167, 156, .24);
    animation: float2 20s var(--ease) infinite alternate;
  }
  @keyframes float1 { to { transform: translate(-8%, 10%) scale(1.14); } }
  @keyframes float2 { to { transform: translate(10%, -8%) scale(1.1); } }

  .brand__grid {
    position: absolute;
    inset: 0;
    background-image:
      linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(80% 70% at 30% 30%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(80% 70% at 30% 30%, #000 0%, transparent 78%);
    pointer-events: none;
  }

  .brand__inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    /* auto-маржи делят свободное место поровну: логотип со списком
       образуют единый блок по центру, бейдж остаётся внизу */
    justify-content: flex-start;
    height: 100%;
    padding: 44px 44px 40px;
    max-width: 620px;
  }

  /* Логотип с названием — крупно и по центру левого блока */
  .brand__head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: auto;
  }
  .brand__mid { margin-bottom: auto; }
  .brand__bottom { display: flex; justify-content: center; }

  .logo--hero {
    position: relative;
    gap: 16px;
    animation: heroIn .7s var(--ease) both;
  }
  /* Мягкое свечение под логотипом */
  .logo--hero::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -30px -20px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(56, 207, 192, .26), transparent 72%);
    filter: blur(8px);
    animation: heroGlow 6s var(--ease) infinite alternate;
  }
  .logo--hero .logo__img {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    box-shadow: 0 18px 38px -14px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .08);
  }
  .logo--hero .logo__text { line-height: 1.1; }
  .logo--hero .logo__name {
    font-size: clamp(28px, 2.2vw, 34px);
    font-weight: 720;
    letter-spacing: -.028em;
  }
  .logo--hero .logo__sub {
    font-size: 12.5px;
    letter-spacing: .34em;
    margin-top: 2px;
  }

  @keyframes heroIn {
    from { opacity: 0; transform: translateY(-12px) scale(.96); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes heroGlow {
    from { opacity: .65; transform: scale(.94); }
    to   { opacity: 1; transform: scale(1.06); }
  }

  .brand__lead {
    margin-top: 18px;
    max-width: 44ch;
    font-size: 14.5px;
    line-height: 1.6;
    color: rgba(255, 255, 255, .66);
    animation: heroIn .7s var(--ease) .1s both;
  }

  /* Преимущества в двух столбцах */
  .brand__list {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 26px;
  }

  .brand__item {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    min-width: 0;
    /* backwards, а не both: иначе финальный кадр анимации
       перебил бы transform из :hover */
    animation: itemIn .6s var(--ease) backwards;
    transition: transform .3s var(--ease);
  }
  .brand__item:hover { transform: translateX(4px); }
  .brand__item:nth-child(1)  { animation-delay: .06s; }
  .brand__item:nth-child(2)  { animation-delay: .11s; }
  .brand__item:nth-child(3)  { animation-delay: .16s; }
  .brand__item:nth-child(4)  { animation-delay: .21s; }
  .brand__item:nth-child(5)  { animation-delay: .26s; }
  .brand__item:nth-child(6)  { animation-delay: .31s; }
  .brand__item:nth-child(7)  { animation-delay: .36s; }
  .brand__item:nth-child(8)  { animation-delay: .41s; }
  .brand__item:nth-child(9)  { animation-delay: .46s; }
  .brand__item:nth-child(10) { animation-delay: .51s; }
  @keyframes itemIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

  .brand__icon {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .10);
    color: var(--brand-3);
    backdrop-filter: blur(6px);
    transition: background-color .3s var(--ease), border-color .3s var(--ease),
                box-shadow .3s var(--ease);
  }
  .brand__icon svg { width: 18px; height: 18px; }
  .brand__item:hover .brand__icon {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(56, 207, 192, .38);
    box-shadow: 0 6px 18px -8px rgba(56, 207, 192, .5);
  }

  .brand__item b {
    display: block;
    font-size: 14px;
    font-weight: 650;
    letter-spacing: -.008em;
  }
  .brand__item em {
    display: block;
    margin-top: 3px;
    font-style: normal;
    font-size: 12.5px;
    line-height: 1.45;
    color: rgba(255, 255, 255, .58);
  }

  .brand__badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 15px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .10);
    font-size: 11.5px;
    letter-spacing: .01em;
    color: rgba(255, 255, 255, .70);
  }
  .brand__badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand-3);
    box-shadow: 0 0 0 0 rgba(56, 207, 192, .6);
    animation: pulse 2.4s var(--ease) infinite;
  }
  @keyframes pulse {
    50%  { box-shadow: 0 0 0 7px rgba(56, 207, 192, 0); }
    100% { box-shadow: 0 0 0 0 rgba(56, 207, 192, 0); }
  }

  /* На широких экранах логотип дублируется в бренд-панели */
  .logo--compact { visibility: hidden; }

  .panel { padding: 26px 40px calc(24px + env(safe-area-inset-bottom)); }
  .card { max-width: 448px; }
}

@media (min-width: 1400px) {
  .brand__inner { padding: 56px 64px 52px; max-width: 780px; }
  .brand__list { gap: 24px 34px; }
  .panel { padding: 32px 56px calc(28px + env(safe-area-inset-bottom)); }
  .card { max-width: 468px; padding: 40px 40px 36px; }
}

/* --- Невысокие окна: бренд-панель не прокручивается, поэтому ужимаем её --- */
@media (min-width: 1040px) and (max-height: 900px) {
  .brand__inner { padding: 32px 40px 30px; }
  .logo--hero .logo__img { width: 52px; height: 52px; border-radius: 16px; }
  .logo--hero .logo__name { font-size: clamp(24px, 1.9vw, 30px); }
  .brand__lead { margin-top: 14px; font-size: 13.5px; }
  .brand__list { margin-top: 24px; gap: 15px 24px; }
}

@media (min-width: 1040px) and (max-height: 780px) {
  .brand__lead { display: none; }
  .brand__list { margin-top: 26px; gap: 13px 22px; }
  .brand__item em { font-size: 12px; line-height: 1.4; }
}

@media (min-width: 1040px) and (max-height: 680px) {
  .brand__item em { display: none; }
  .brand__list { gap: 12px 22px; }
  .brand__icon { width: 32px; height: 32px; border-radius: 10px; }
  .brand__icon svg { width: 16px; height: 16px; }
  .logo--hero .logo__img { width: 44px; height: 44px; border-radius: 14px; }
  .logo--hero .logo__name { font-size: 24px; }
}

/* --- Низкие экраны в альбомной ориентации --- */
@media (max-height: 620px) and (min-width: 700px) {
  .panel__body { justify-content: flex-start; padding-top: 18px; }
}

/* ---------- 16. Доступность и предпочтения ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  .control, .otp__cell, .card { border-width: 2px; }
  .hint, .foot { color: var(--text-2); }
}

@media print {
  .brand, .controls, .toasts, .foot { display: none !important; }
  .card { box-shadow: none; border: 1px solid #000; }
}
