/* Экран входа: фото на весь экран, поверх него название со слоганом и
   карточка с формой — как у QUOTA. Телефон: название над карточкой, всё по
   центру. От 1024: название слева, карточка справа.
   Цвета и отступы — токены style.css; здесь только то, чего там нет. */

:root {
  --on-photo: #FFFFFF;          /* текст поверх фото — в любой теме */
  --photo-fallback: #46525A;    /* фон, пока фото грузится */
  --auth-field: 48px;           /* высота поля, клетки кода и кнопки */
  --auth-gap: 48px;             /* между названием и карточкой на компьютере */
}

.auth-body { background: var(--photo-fallback); }

.auth-screen {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  /* сверху — место под переключатель темы (44 px с отступом): на низком экране
     название иначе уходит под него */
  padding: calc(var(--s5) + 44px + var(--s6) + env(safe-area-inset-top)) calc(var(--s6) + env(safe-area-inset-right))
           calc(var(--s7) + env(safe-area-inset-bottom)) calc(var(--s6) + env(safe-area-inset-left));
}

.auth-photo { position: fixed; inset: 0; }
.auth-photo img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: 45% 50%;
}
/* затемнение под названием: белый текст читается на любом участке фото */
.auth-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / 45%), rgb(0 0 0 / 0%) 45%);
}

.auth-stage {
  position: relative;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: var(--s7);
}

.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: var(--s4);
  text-align: center; color: var(--on-photo);
  text-shadow: 0 1px 16px rgb(0 0 0 / 40%);
}
.auth-wordmark { margin: 0; line-height: 0; }
.auth-wordmark .logomark {
  width: 200px; height: auto;
  filter: drop-shadow(0 1px 12px rgb(0 0 0 / 35%));
}
.auth-slogan { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; }

.auth-panel {
  width: 100%;
  display: flex; flex-direction: column; gap: var(--s6);
  padding: var(--s7) var(--s6);
  border-radius: var(--r-xl);
  background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow);
}
.auth-head { text-align: center; }
.auth-title { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.2; }

@media (min-width: 768px) {
  .auth-stage { max-width: 464px; }
  .auth-photo img { object-position: 35% 50%; }
  .auth-panel { padding: var(--s8); }
}

@media (min-width: 1024px) {
  .auth-screen {
    padding: calc(var(--s8) + env(safe-area-inset-top)) calc(var(--s8) + env(safe-area-inset-right))
             calc(var(--s8) + env(safe-area-inset-bottom)) calc(var(--s8) + env(safe-area-inset-left));
  }
  .auth-photo::after { background: linear-gradient(90deg, rgb(0 0 0 / 45%), rgb(0 0 0 / 0%) 55%); }
  .auth-stage {
    max-width: 1040px;
    display: grid; grid-template-columns: minmax(0, 1fr) 464px;
    align-items: center; gap: var(--auth-gap);
  }
  .auth-brand { align-items: flex-start; text-align: left; }
  .auth-wordmark .logomark { width: 320px; }
  .auth-slogan { font-size: 20px; }
}

/* ── форма ─────────────────────────────────────────────────────────── */
.auth-form { display: flex; flex-direction: column; gap: var(--s6); }
.auth-form .field { display: flex; flex-direction: column; gap: var(--s4); }
.auth-label { font-size: 16px; font-weight: 500; text-align: center; }

.auth-submit, .auth-alt .btn {
  width: 100%; height: var(--auth-field);
  border-radius: var(--r-lg); font-size: 16px; font-weight: 600;
}
.auth-alt .btn { height: 44px; font-size: 14px; font-weight: 500; }
.auth-submit[aria-busy="true"] { opacity: .6; cursor: progress; }

.field-error { color: var(--crit); font-size: 14px; text-align: center; }
.auth-notice {
  margin: 0; padding: var(--s5); border-radius: var(--r-lg);
  background: var(--crit-bg); color: var(--fg); font-size: 14px; text-align: center;
}
.auth-said { margin: 0; color: var(--muted); font-size: 14px; text-align: center; }
.auth-said:empty { display: none; }

/* номер и код меняются на одном месте */
.auth-swap { animation: auth-swap .18s ease-out; }
@keyframes auth-swap { from { opacity: 0; transform: translateY(4px); } }

/* поле номера: код страны слева, номер справа */
.phone-input {
  display: flex; align-items: stretch; min-height: var(--auth-field);
  border: 1px solid var(--field-line); border-radius: var(--r-lg);
  background: var(--surface);
  font-size: 18px; font-weight: 600;
  transition: border-color .12s ease;
}
.phone-input:hover { border-color: var(--muted); }
.phone-input:focus-within { outline: 2px solid var(--fg); outline-offset: -1px; border-color: var(--fg); }
.phone-input[data-invalid] { border-color: var(--crit); }
.phone-prefix {
  position: relative; display: flex; align-items: center;
  padding: 0 var(--s5); border-right: 1px solid var(--field-line); color: var(--muted);
}
/* родной список стран лежит прозрачным поверх кода: нажал на +375, выбрал страну */
.phone-prefix select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: 0; border: 0; background: none; opacity: 0;
  cursor: pointer; font-size: 16px;
}
.phone-prefix:has(select:focus-visible) { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.auth-form .phone-input input {
  flex: 1; min-width: 0; height: auto;
  padding: 0 var(--s5); border: 0; background: none;
  font: inherit; letter-spacing: .02em; color: var(--fg); outline: none; box-shadow: none;
}
.phone-input input::placeholder { color: var(--muted-2); font-weight: 400; }

/* код: одно настоящее поле поверх шести клеток — работают вставка и автоподстановка */
.otp { position: relative; }
.auth-form .otp-input {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; padding: 0;
  border: 0; background: transparent; color: transparent; caret-color: transparent;
  font-size: 16px; outline: none; box-shadow: none;
}
.otp-input::selection { background: transparent; }
.otp-cells {
  display: grid; grid-template-columns: repeat(6, minmax(0, var(--auth-field)));
  justify-content: space-between; gap: var(--s4);
}
.otp-cell {
  position: relative; display: grid; place-items: center;
  height: var(--auth-field);
  border: 1px solid var(--field-line); border-radius: var(--r-lg);
  background: var(--surface);
  font: 700 24px/1 "JetBrains Mono", ui-monospace, monospace;
  transition: border-color .12s ease;
}
.otp-cell[data-filled] { border-color: var(--muted); }
.otp:focus-within .otp-cell[data-active] { outline: 2px solid var(--fg); outline-offset: -1px; border-color: var(--fg); }
.otp:focus-within .otp-cell[data-active]:not([data-filled])::after {
  content: ""; width: 2px; height: 24px; background: var(--fg);
  animation: otp-caret 1s steps(1) infinite;
}
@keyframes otp-caret { 50% { opacity: 0; } }
.otp[data-invalid] .otp-cell { border-color: var(--crit); }

/* номер и таймер: на узком экране друг под другом, шире — по краям */
.auth-meta {
  display: flex; flex-direction: column; align-items: center; gap: var(--s4);
  font-size: 14px;
}
@media (min-width: 768px) { .auth-meta { flex-direction: row; justify-content: space-between; } }
.auth-meta[hidden] { display: none; }
.auth-wait { color: var(--muted); white-space: nowrap; }
.auth-wait:empty { display: none; }

.auth-link {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s2);
  border: 0; background: none; color: var(--accent-ink);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: none;
}
.auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-link[disabled] { opacity: .5; cursor: not-allowed; }
.auth-phone { color: var(--fg); white-space: nowrap; }

/* ── запасные пути: отпечаток и код через бота ─────────────────────── */
.auth-alt { display: grid; gap: var(--s5); justify-items: center; }
.auth-alt form { width: 100%; }
.auth-alt .or {
  width: 100%; display: flex; align-items: center; gap: var(--s3);
  color: var(--muted); font-size: 13px;
}
.auth-alt .or::before, .auth-alt .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-alt .pk-login { width: 100%; }

/* код для бота — прежний блок «Отправьте этот код боту» */
.auth-panel .why { margin: 0; color: var(--muted); font-size: 14px; text-align: center; }
.code-box { display: grid; gap: var(--s5); justify-items: center; }
/* Код и есть кнопка «скопировать»: нажимают именно по нему. Значок справа
   говорит, что тут копируют, и он же превращается в галочку. */
.code {
  display: inline-flex; align-items: center; gap: var(--s5);
  min-height: 56px; padding: var(--s4) var(--s5) var(--s4) var(--s6);
  background: var(--surface-3); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.code .digits {
  font: 600 40px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .18em; font-variant-numeric: tabular-nums;
  margin-right: -.18em;            /* разрядка добавляет пустоту после последней цифры */
  -webkit-user-select: text; user-select: text;
}
.code .mark { display: flex; color: var(--muted); }
.code .i-ok { display: none; }
.code:hover { background: var(--line); }
.code:active { background: var(--line-2); }
.code.copied { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.code.copied .mark { color: var(--ok); }
.code.copied .i-copy { display: none; }
.code.copied .i-ok { display: block; }
@media (max-width: 360px) {
  .code { gap: var(--s4); padding: var(--s4); }
  .code .digits { font-size: 32px; }
  .otp-cells { gap: var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-swap { animation: none; }
  .otp:focus-within .otp-cell[data-active]:not([data-filled])::after { animation: none; }
}
