:root {
  --bg: #0d1117;
  --card: #0f1623;
  --border: #263041;
  --text: #e6edf3;
  --muted: #9fb0c6;
  --primary: #4c7fff;
  --primary-2: #6ba0ff;
  --warn: #ffc96b;
  --error: #ff7b7b;
  --ok: #66d19e;
  --radius: 14px;
  --duration: 320ms;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;            /* убираем горизонтальную прокрутку */
  touch-action: pan-y;           /* разрешаем только вертикальные жесты */
  overscroll-behavior-x: none;   /* предотвращаем горизонтальный overscroll */
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 32px 16px;
  min-height: 100svh; /* мобильные браузеры с адресной строкой */
  background:
    radial-gradient(circle at top, rgba(76,127,255,.4), rgba(8,12,18,1) 65%);
}

.auth-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
}
.auth-bg .slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.06);
  animation: fadeSlide var(--slide-duration, 40s) infinite;
  animation-delay: var(--slide-delay, 0s);
  will-change: opacity, transform;
}

@keyframes fadeSlide {
  0%   { opacity: 0; transform: scale(1.06); }
  5%   { opacity: .9; transform: scale(1.02); }
  20%  { opacity: .9; transform: scale(1.0); }
  25%  { opacity: 0; transform: scale(1.02); }
  100% { opacity: 0; }
}

.auth-bg .bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8,12,18,.70), rgba(8,12,18,.70));
  pointer-events: none;
}

.auth-container {
  width: 100%;
  max-width: 460px;
  padding: 28px 24px 22px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02)),
    rgba(16,22,33,.65);
  border: 1px solid var(--border);
  box-shadow:
    0 20px 60px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(10px) saturate(120%);
  position: relative;
  text-align: center; /* весь текст по центру внутри карточки */
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: .2px;
  text-align: center;
}
.subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

label {
  display:block; margin: 10px 0 8px;
  font-size: 13px; color:#c9d4e3; letter-spacing:.2px;
  text-align: center;
}
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0c1220;
  color: var(--text);
  outline: none;
  transition: border-color var(--duration) ease, box-shadow var(--duration) ease, transform 120ms ease;
}
input.input--error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255,123,123,.18);
}
input::placeholder { color: #8ea0bb; opacity: .8; }
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(76,127,255,.18), inset 0 1px 0 rgba(255,255,255,.04);
}
input:active { transform: translateY(0.5px); }

button {
  margin-top: 14px; width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: white; font-weight: 700; letter-spacing:.2px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow var(--duration) ease, opacity 120ms ease;
  box-shadow: 0 10px 24px rgba(76,127,255,.28);
}
button:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(76,127,255,.34); }
button:active { transform: translateY(0); }
button:disabled { opacity: .6; cursor: not-allowed; }
button:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(76,127,255,.22), 0 10px 24px rgba(76,127,255,.28); }

button.link {
  background: transparent;
  border: 1px solid var(--border);
  color: #cdd8ea;
  box-shadow: none;
}
button.link:hover { border-color:#344255; background: rgba(255,255,255,.02); }

.hint { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.message { margin-top: 14px; min-height: 20px; font-size: 14px; color: var(--warn); text-align: center; }
.field-error { margin-top: 6px; color: var(--error); font-size: 12px; }

/* ======================== */
/*      Custom checkboxes    */
/* ======================== */
.consents { margin: 12px 0; display: grid; gap: 12px; justify-items: center; }
.consents label { display: grid; grid-template-columns: 20px auto; gap: 10px; align-items: center; color: var(--text); }
.consents a { color: #9db7ff; text-decoration: underline; text-underline-offset: 2px; }
.consents input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin: 2px 0 0 0;
  border-radius: 6px;
  border: 1.5px solid #344255;
  background: #0c1220;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  display: inline-grid; place-content: center;
  cursor: pointer;
  transition: border-color var(--duration) ease, background-color var(--duration) ease, box-shadow var(--duration) ease, transform 120ms ease;
}
.consents input[type="checkbox"]::after {
  content: '';
  width: 10px; height: 10px;
  transform: scale(0) rotate(10deg);
  border-radius: 3px;
  clip-path: polygon(14% 44%, 0 60%, 40% 100%, 100% 28%, 86% 14%, 40% 72%);
  background: transparent;
  box-shadow: inset 0 0 0 2px transparent;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}
.consents input[type="checkbox"]:hover { border-color: #3d4e67; }
.consents input[type="checkbox"]:active { transform: translateY(0.5px); }
.consents input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(76,127,255,.22); border-color: var(--primary); }
.consents input[type="checkbox"]:checked {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border-color: transparent;
}
.consents input[type="checkbox"]:checked::after {
  transform: scale(1) rotate(0deg);
  background: white;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.0);
}

/* Шаги с анимацией */
.steps {
  position: relative;
  overflow: visible;
}

.step { display: none; }
.step.active { display: block; animation: stepIn var(--duration) ease; }

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

/* Маленькие декоративные элементы */
.auth-container::after {
  content: '';
  position: absolute;
  top: -120px; right: -140px;
  width: 260px; height: 260px;
  background: radial-gradient(closest-side, rgba(76,127,255,.16), transparent 70%);
  filter: blur(14px);
  pointer-events: none;
}

/* ======================== */
/*        Mobile (≤480px)   */
/* ======================== */
@media (max-width: 480px) {
  body {
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
  }

  .auth-container {
    max-width: 100%;
    padding: 22px 16px 18px;
    border-radius: 12px;
  }

  h1 { font-size: 20px; }
  .subtitle { font-size: 13px; margin-bottom: 14px; }

  label { font-size: 13px; margin: 8px 0 6px; }
  input {
    padding: 14px 14px;
    font-size: 16px; /* предотвращает авто-зуум на iOS */
    border-radius: 10px;
  }
  button {
    padding: 14px 14px;
    font-size: 16px;
    border-radius: 10px;
  }

  .steps { min-height: 150px; }

  /* немного уменьшаем светящееся деко на маленьких экранах */
  .auth-container::after {
    top: -90px; right: -100px;
    width: 200px; height: 200px;
    filter: blur(12px);
  }
}

/* ======================== */
/*      PWA install banner  */
/* ======================== */
.pwa-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: calc(10px + env(safe-area-inset-bottom)) 12px  env(safe-area-inset-bottom);
  background: rgba(13,17,23,.85);
  border-top: 1px solid #263041;
  backdrop-filter: blur(8px) saturate(120%);
  transform: translateY(110%);
  transition: transform var(--duration) ease;
  z-index: 1000;
}
.pwa-banner.visible { transform: translateY(0); }
.pwa-banner__inner { max-width: 620px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.pwa-banner__text { font-size: 14px; color: var(--text); opacity: .95; text-align: left; }
.pwa-banner__actions { display: flex; gap: 8px; }
.pwa-install { min-width: 120px; }

@media (max-width: 520px) {
  .pwa-banner__inner { grid-template-columns: 1fr; }
  .pwa-banner__actions { justify-content: flex-start; }
}

/* ======================== */
/*    Small phones (≤360px) */
/* ======================== */
@media (max-width: 360px) {
  h1 { font-size: 19px; }
  .subtitle { font-size: 12px; }
  button { font-size: 15px; padding: 13px; }
  input  { font-size: 15px; padding: 13px; }
}

/* Гарантируем, что активный шаг не сохраняет смещения входа */
.step.active.enter-from-right,
.step.active.enter-from-left {
  transform: translateX(0) !important;
  opacity: 1 !important;
}