/* Страница входа: слева панель с описанием сервиса, справа форма. */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}


/* Панель сервиса */

.auth-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  overflow: hidden;
  background: var(--ink);
  color: var(--on-ink);
}

/* Тонкая сетка, как на бланке, - без пятен и свечений. */
.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
  pointer-events: none;
}

.brand-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.brand-mark {
  display: block;
  width: 84px;
  height: 84px;
  margin-bottom: 18px;
  object-fit: contain;
}

.brand-org {
  margin-bottom: 8px;
  color: var(--on-ink-muted);
  font-size: 14px;
  font-weight: 500;
}

.brand-title {
  font-size: clamp(30px, 3.2vw, 40px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.brand-lead {
  max-width: 400px;
  margin-top: 14px;
  color: var(--on-ink-muted);
  font-size: 16px;
  line-height: 1.55;
}


/* Пример: входящее письмо и проект ответа */

.demo {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 36px;
  text-align: left;
}

.demo-card {
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--ink-2);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07);
  animation: demo-in 600ms var(--ease-out) both;
}

.demo-card + .demo-card {
  animation-delay: 80ms;
}

@keyframes demo-in {
  from { opacity: 0; transform: translateY(12px); }
}

.demo-label {
  margin-bottom: 10px;
  color: var(--on-ink-muted);
  font-size: 13px;
  font-weight: 600;
}

.demo-file {
  display: flex;
  gap: 12px;
  align-items: center;
}

.demo-file-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 44px;
  border-radius: 8px;
  background: #f2f5fa;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.demo-file-name {
  font-size: 14px;
  font-weight: 500;
}

.demo-file-meta {
  color: var(--on-ink-muted);
  font-size: 13px;
}

.demo-reply {
  background: #f7f9fc;
  box-shadow: none;
  color: var(--text);
}

.demo-reply .demo-label {
  color: var(--accent);
}

.demo-reply p {
  font-size: 14px;
  line-height: 1.55;
}

.demo-reply p + p {
  margin-top: 8px;
}

.demo-reply .demo-ref {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 500;
  white-space: nowrap;
}

.demo-lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.demo-lines span {
  height: 8px;
  border-radius: 4px;
  background: var(--sunken);
}

.demo-lines span:nth-child(1) { width: 100%; }
.demo-lines span:nth-child(2) { width: 92%; }
.demo-lines span:nth-child(3) { width: 64%; }


/* Форма - в стиле входа чат-бота: белая колонка, узкая форма, поля 46px */

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
  background: var(--surface);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 360px;
}

.auth-heading {
  margin-bottom: 6px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.login-error {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--surface));
  border-radius: var(--radius-field);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
  animation: error-in 240ms var(--ease-out) both;
}

@keyframes error-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.login-success {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 24%, var(--surface));
  border-radius: var(--radius-field);
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
  color: var(--success);
  font-size: 14px;
  line-height: 1.45;
  animation: error-in 240ms var(--ease-out) both;
}

.login-success svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.auth-account {
  margin-top: -12px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.auth-account strong {
  color: var(--text);
  font-weight: 500;
}

.field-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Модалка "Сессия завершена" */
dialog.session-modal {
  width: min(400px, calc(100vw - 32px));
  padding: 28px;
  text-align: center;
}

.modal-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-icon svg {
  width: 24px;
  height: 24px;
}

.session-modal .modal-actions {
  margin-top: 22px;
}

.login-error svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.login-field label {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}

.login-field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  outline: none;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  /* 16px - иначе iPhone увеличивает страницу при фокусе на поле. */
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .login-field input:hover:not(:focus) {
    border-color: #aebbcb;
  }
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.login-field input[aria-invalid='true'] {
  border-color: var(--danger);
}

.password-wrap {
  position: relative;
  display: flex;
}

.password-wrap input {
  flex: 1;
  min-width: 0;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 150ms ease, background-color 150ms ease, transform var(--dur-press) var(--ease-out);
}

.password-toggle:active {
  transform: translateY(-50%) scale(0.92);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, transform 160ms var(--ease-out);
}

a.login-submit,
a.login-submit:hover {
  color: #fff;
  text-decoration: none;
}

.login-submit:active:not(:disabled) {
  transform: scale(0.97);
}

.login-submit:disabled {
  cursor: default;
  opacity: 0.75;
}

/* Подпись поля и ссылка справа от нее: "Пароль ... Забыли пароль?" */
.login-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.login-field-link {
  border-radius: 4px;
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: none;
  transition: color 150ms ease;
}

.login-field-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-help-link {
  align-self: center;
  margin-top: 2px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .password-toggle:hover {
    background: var(--sunken);
    color: var(--text);
  }

  .login-submit:hover:not(:disabled) {
    background: var(--accent-hover);
  }

  .login-help-link:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
  }

  .login-field-link:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}


/* Планшет: панель уже */

@media (max-width: 1024px) {
  .auth {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr);
  }

  .auth-brand {
    padding: 40px 28px;
  }
}


/* Телефон: панель сжимается в шапку */

@media (max-width: 760px) {
  .auth {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .auth-brand {
    justify-content: flex-start;
    /* Отступ под вырез экрана телефона. */
    padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left));
  }

  .auth-brand::before {
    display: none;
  }

  .brand-inner {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    align-items: center;
    max-width: none;
    text-align: left;
  }

  .brand-mark {
    grid-row: span 2;
    width: 44px;
    height: 44px;
    margin: 0;
  }

  .brand-org {
    margin: 0;
    font-size: 12.5px;
  }

  .brand-title {
    font-size: 19px;
    letter-spacing: -0.02em;
  }

  .brand-lead,
  .demo {
    display: none;
  }

  .auth-main {
    align-items: flex-start;
    padding: 36px 16px max(40px, env(safe-area-inset-bottom));
  }

  .auth-heading {
    font-size: 24px;
  }
}


@media (prefers-reduced-motion: reduce) {
  .demo-card,
  .login-error,
  .login-success {
    animation-name: fade-in !important;
  }
}


/* Модалка "Как получить доступ" */

dialog.help-modal {
  width: min(480px, calc(100vw - 32px));
  padding: 28px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 22px 0 26px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  min-height: 32px;
  padding-left: 46px;
  counter-increment: step;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  top: -2px;
  left: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}

/* Линия между номерами шагов */
.steps > li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 36px;
  bottom: -16px;
  left: 15.5px;
  width: 1px;
  background: var(--border);
}

.step-title {
  font-weight: 600;
  line-height: 1.4;
}

.step-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.step-list {
  margin: 6px 0 0;
  padding: 10px 14px 10px 30px;
  border-radius: var(--radius-field);
  background: var(--sunken);
  font-size: 14px;
}

.step-list li + li {
  margin-top: 2px;
}

@media (max-width: 760px) {
  dialog.help-modal {
    padding: 24px 20px;
  }
}
