/* Вход по номеру телефона: карточка в духе мессенджера Rudmal на токенах редактора. */
html.auth-modal-open, html.auth-modal-open body { overflow: hidden; }
#authRoot[hidden], .auth-root[hidden] { display: none !important; }
#authRoot, .auth-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
  animation: auth-fade 0.18s ease-out;
}
.auth-root.closing { animation: auth-fade-out 0.16s ease-in forwards; }
.auth-root.closing .auth-card { animation: auth-sink 0.16s ease-in forwards; }
.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 13, 16, 0.46);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.auth-card {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  max-width: 400px;
  min-width: 0;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 18px 28px 22px;
  font-family: var(--font);
  overflow-wrap: anywhere;
  animation: auth-rise 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.auth-card *, .auth-card *::before, .auth-card *::after { box-sizing: border-box; }
.auth-card:focus { outline: none; }
@keyframes auth-fade { from { opacity: 0; } }
@keyframes auth-fade-out { to { opacity: 0; } }
@keyframes auth-rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes auth-sink { to { opacity: 0; transform: translateY(8px) scale(0.985); } }
@keyframes auth-step { from { opacity: 0; transform: translateX(10px); } }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-card.step-in .auth-step:not([hidden]) { animation: auth-step 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }

/* Top row: back, brand, close. */
.auth-top {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  margin: 0 -12px 18px;
}
.auth-brand { grid-column: 2; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.auth-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, #6b78ff, #4554e0 60%, #3a46c4); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 4px 12px -4px rgba(69, 84, 224, 0.6);
}
.auth-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.auth-brand-name { font: 800 19px/1 var(--font); letter-spacing: -0.03em; color: var(--text); }
.auth-icon-btn {
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; display: grid; place-items: center;
  background: transparent; color: var(--text-3); cursor: pointer; transition: background 0.12s, color 0.12s;
}
.auth-icon-btn:first-child { grid-column: 1; }
.auth-icon-btn:last-child { grid-column: 3; }
.auth-icon-btn[hidden] { display: grid !important; visibility: hidden; }
.auth-icon-btn:hover { background: var(--hover); color: var(--text); }
.auth-icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.auth-icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.auth-step[hidden], .auth-register[hidden], .auth-error[hidden], .auth-wait[hidden], .auth-lead[hidden], .auth-legal[hidden] { display: none !important; }
.auth-step { text-align: center; }
.auth-card h2 { margin: 0 0 8px; font: 700 21px/1.25 var(--font); letter-spacing: -0.02em; color: var(--text); }
.auth-lead { margin: 0 auto 20px; max-width: 320px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.auth-lead b { color: var(--text); font-weight: 600; white-space: nowrap; }
.auth-note { margin: 2px 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--hover); color: var(--text-2); font-size: 13px; line-height: 1.45; text-align: left; }

.auth-field { display: block; margin: 0 0 14px; text-align: left; }
.auth-field > span { display: block; margin: 0 0 6px 2px; font: 500 13px/1.3 var(--font); color: var(--text-2); }
.auth-card input[type="tel"], .auth-card input[type="text"] {
  display: block; width: 100%; height: 48px; margin: 0; padding: 0 16px;
  border: 1px solid var(--input-line); border-radius: 12px;
  background: var(--input); color: var(--text); font: 500 17px/1.3 var(--font);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.auth-card input::placeholder { color: var(--text-3); font-weight: 400; }
.auth-card input[type="tel"]:focus, .auth-card input[type="text"]:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.auth-card input.auth-code {
  height: 58px; margin: 0 0 14px; text-align: center; font: 600 28px/1 var(--font);
  letter-spacing: 0.42em; padding: 0 0 0 0.42em; font-variant-numeric: tabular-nums;
}
.auth-card input.auth-code::placeholder { letter-spacing: 0.42em; }

.auth-register { text-align: left; animation: auth-step 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }
.auth-check { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; margin: 0 0 10px; color: var(--text-2); font: 400 12.5px/1.5 var(--font); cursor: pointer; }
.auth-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.auth-check a, .auth-legal a { color: var(--accent); text-decoration: none; }
.auth-check a:hover, .auth-legal a:hover { text-decoration: underline; }

.auth-error {
  margin: 0 0 12px; padding: 9px 12px; border-radius: 10px; text-align: left;
  color: var(--danger); background: var(--danger-soft); font-size: 13px; line-height: 1.45;
}

.auth-primary {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 48px; margin: 4px 0 0; padding: 0 20px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 600 15px/1 var(--font);
  text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(40, 50, 160, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: background 0.12s, transform 0.12s, opacity 0.12s;
}
.auth-primary[hidden] { display: none; }
.auth-primary:hover:not([disabled]) { background: var(--accent-hover); }
.auth-primary:active:not([disabled]) { transform: scale(0.985); }
.auth-primary:focus-visible { outline: none; box-shadow: var(--ring); }
.auth-primary[disabled] { opacity: 0.55; cursor: default; }
.auth-primary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.auth-primary.loading { opacity: 1; color: transparent; }
.auth-primary.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: auth-spin 0.7s linear infinite;
}

.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 12px; }
.auth-link {
  padding: 6px 4px; border: 0; background: none; color: var(--accent); font: 500 14px/1.3 var(--font);
  cursor: pointer; border-radius: 6px;
}
.auth-link:hover:not([disabled]) { text-decoration: underline; }
.auth-link[disabled] { color: var(--text-3); cursor: default; }
.auth-link:focus-visible { outline: none; box-shadow: var(--ring); }
.auth-link-muted { color: var(--text-2); }

.auth-call-number {
  margin: 0 0 18px; font: 700 27px/1.2 var(--font); letter-spacing: 0.01em; color: var(--text);
  font-variant-numeric: tabular-nums; user-select: all; white-space: nowrap;
}
.auth-hint { margin: 12px 0 0; color: var(--text-3); font-size: 12.5px; line-height: 1.45; }
.auth-wait { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 0; color: var(--text-2); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.auth-wait + .auth-error { margin-top: 14px; }
.auth-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: auth-spin 0.8s linear infinite; }
.auth-call .auth-error { margin-top: 14px; }

.auth-in { padding-top: 4px; }
.auth-avatar {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg, #8a94ff, #4c59de); color: #fff; font: 700 24px/1 var(--font); letter-spacing: 0.02em;
}

.auth-legal { margin: 18px 0 0; text-align: center; font-size: 11.5px; line-height: 1.5; color: var(--text-3); }

@media (max-width: 599px) {
  #authRoot, .auth-root { place-items: end stretch; padding: 0; }
  .auth-card {
    max-width: none; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
    animation-name: auth-sheet;
  }
  .auth-root.closing .auth-card { animation-name: auth-sheet-out; }
}
@keyframes auth-sheet { from { transform: translateY(40px); opacity: 0; } }
@keyframes auth-sheet-out { to { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .auth-root, .auth-card, .auth-card .auth-step, .auth-register { animation: none !important; }
}
@media print {
  #authRoot, .auth-root { display: none !important; }
}
