/* Экраны входа и регистрации — перенос «Вход / Desktop / Light» (1440×900).
 * Слева тёмная витрина с терминалом, справа белая форма на 520px.
 * Тёмные цвета сцены — локальные: в макете это иллюстрация продукта,
 * а не тема интерфейса, поэтому в tokens.css они не выносятся. */

.auth {
  --term-bg: #0b1210;
  --term-chrome: #101b17;
  --term-line: #244038;
  --term-text: #e9f3ef;
  --term-body: #d8e8e2;
  --term-dim: #789089;
  --term-dim-2: #9fb4ad;
  --term-ok: #4ade9d;
  --term-warn: #f0c674;
  --tg: #229ed9;

  background: var(--canvas);
}

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

/* ================= Тёмная сцена с терминалом ================= */
.term-scene {
  position: relative;
  background: var(--term-bg);
  overflow: hidden;
}

/* Сетка 48px — фон сцены, как в макете. */
.term-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--term-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--term-line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.45;
}

.term-chrome {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 72px;
  padding: 0 52px;
  background: var(--term-chrome);
}

.term-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--term-text);
}

.term-conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--term-dim-2);
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--term-ok);
}

/* Пока идёт запрос — индикатор пульсирует. */
.dot-live[data-busy="true"] {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.3; transform: scale(0.8); }
}

.term-host {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--term-dim);
}

.term-body {
  position: relative;
  padding: 48px 52px 40px;
}

.term-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--term-dim);
}

.term-label-agent {
  margin-top: 40px !important;
}

.term-cmd {
  margin: 13px 0 0;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--term-text);
  /* Строка «↵ запрос отправлен» приходит переводом строки. */
  white-space: pre-line;
  /* Две строки заранее: команда не дёргает вёрстку при отправке. */
  min-height: 56px;
}

/* Курсор мигает — признак живого терминала. */
.caret {
  display: inline-block;
  width: 9px;
  height: 20px;
  margin-left: 4px;
  vertical-align: text-bottom;
  background: var(--term-ok);
  animation: blink 1.1s steps(1) infinite;
}

.caret[hidden] {
  display: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

.term-status {
  margin: 16px 0 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--term-warn);
  white-space: pre-line;
  min-height: 25px;
}

/* Ожидание — жёлтый, готово — зелёный, покой — приглушённый. */
.term-status[data-tone="done"] {
  color: var(--term-ok);
}

.term-status[data-tone="idle"] {
  color: var(--term-dim);
}

.term-res-lead,
.term-res {
  margin: 16px 0 0;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.57;
  white-space: pre-line;
  /* Блоки проявляются по мере генерации ответа. */
  animation: rise 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.term-res-lead:empty,
.term-res:empty,
.term-foot:empty {
  animation: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
}

/* Область ответа держит высоту, чтобы счётчики не прыгали. */
.term-answer {
  min-height: 318px;
}

/* Вывод агента — акцентный, детали ответа приглушены. */
.term-res-lead {
  font-weight: 700;
  color: var(--term-ok);
}

.term-res {
  color: var(--term-body);
}

.term-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 34px;
  padding: 17px 20px 20px;
  background: var(--term-chrome);
  border: 1px solid var(--term-line);
  border-radius: 10px;
}

.term-meta small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--term-dim);
}

.term-meta b {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--term-text);
}

.term-foot {
  margin: 26px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--term-dim);
  /* Подпись появляется только в финале — место под неё есть всегда. */
  min-height: 20px;
  animation: rise 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ================= Форма ================= */
.auth-surface {
  display: flex;
  justify-content: center;
  padding: 78px 40px;
  background: var(--surface);
}

.auth-form {
  width: 100%;
  max-width: 520px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* Логотип из brand/ вместо прежней литеры на акцентной плашке. */
.auth-logo {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  flex: 0 0 auto;
}

.auth-form h1 {
  margin: 40px 0 0;
  font-size: 32px;
  line-height: 1.44;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-2);
}

/* Кнопка Telegram — фирменный синий, белый текст даёт 3.6:1
   при 15px/600, что удовлетворяет AA для крупного текста. */
.tg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  margin-top: 30px;
  border-radius: 8px;
  background: var(--tg);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
}

.tg-btn svg {
  width: 22px;
  height: 22px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 23px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.divider span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.field {
  display: block;
  margin-top: 22px;
}

.field-name {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-sans);
  /* 16px — иначе iOS зумит форму при фокусе. */
  font-size: 16px;
  font-weight: 500;
}

.field input::placeholder {
  color: var(--text-2);
}

.field-help {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-2);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 4px;
  accent-color: var(--accent-strong);
}

.link {
  color: var(--accent-strong);
  font-weight: 600;
}

.auth-submit {
  width: 100%;
  height: 52px;
  margin-top: 28px;
  border: 0;
  border-radius: 14px;
  background: var(--accent-strong);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.auth-switch {
  margin: 24px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-align: center;
}

/* Виджет Telegram рисует свою кнопку внутри iframe — ширину он задаёт сам,
   поэтому просто центрируем и держим тот же вертикальный ритм, что у формы. */
.tg-widget {
  display: flex;
  justify-content: center;
  min-height: 52px;
  margin-top: 30px;
}

/* Telegram-вход недоступен — форма с ником и паролем остаётся рабочей. */
.tg-btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Ошибка формы: появляется над кнопкой, до этого места не занимает. */
.auth-alert {
  margin: 22px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--down-soft);
  color: var(--down);
  font-size: 13px;
  font-weight: 600;
}

.auth-alert[hidden] {
  display: none;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ================= Мобильный 393px ================= */
@media (max-width: 900px) {
  /* Терминал уходит: на телефоне важна форма, а не витрина. */
  .auth-split {
    grid-template-columns: 1fr;
  }

  .term-scene {
    display: none;
  }

  .auth-surface {
    padding: 28px 16px 40px;
  }

  .auth-form h1 {
    margin-top: 28px;
    font-size: 27px;
  }

  .auth-sub {
    font-size: 14px;
  }

  .tg-btn {
    margin-top: 24px;
    font-size: 14px;
    padding: 0 12px;
    text-align: center;
  }

  .divider span {
    font-size: 12px;
    text-align: center;
  }

  .form-row {
    flex-wrap: wrap;
    gap: 12px;
  }
}
