:root {
  color-scheme: light;
  --bg-top: #eef3fb;
  --bg-bottom: #e4ebf7;
  --surface: rgba(248, 251, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --text: #18243a;
  --text-soft: #62748f;
  --text-faint: #8090aa;
  --accent: #506bff;
  --accent-hover: #415ce9;
  --line: rgba(193, 206, 226, 0.84);
  --line-strong: rgba(194, 207, 226, 0.62);
  --shell-shadow: 18px 18px 40px rgba(170, 184, 208, 0.25), -14px -14px 32px rgba(255, 255, 255, 0.84);
  --radius-shell: 30px;
  --radius-soft: 18px;
  --status-error: #b42318;
  --status-error-bg: rgba(255, 234, 234, 0.88);
  --status-ok: #0f6b46;
  --status-ok-bg: rgba(231, 248, 239, 0.92);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html[data-login-render-pending="1"] .auth-card { visibility: hidden; }

body {
  margin: 0;
  padding: 24px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.88), transparent 28%),
    radial-gradient(circle at right 18%, rgba(80, 107, 255, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.auth-page {
  min-height: calc(100vh - 48px);
  display: grid;
  justify-items: center;
  align-content: start;
  min-width: 0;
  padding-top: clamp(20px, 8vh, 72px);
}
.auth-shell { width: 100%; max-width: 468px; min-width: 0; display: grid; gap: 18px; }
.topline { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 0 4px; }
.topline > * { min-width: 0; }
.brand { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; white-space: nowrap; }
.back-link {
  appearance: none; border: 0; background: transparent; padding: 0; color: var(--text-soft);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.back-link:hover { color: var(--accent); }

.auth-card {
  position: relative; overflow: hidden; border: 1px solid rgba(211,222,238,0.88);
  border-radius: var(--radius-shell); background: var(--surface); box-shadow: var(--shell-shadow);
  backdrop-filter: blur(14px); padding: 28px;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  min-height: 0;
}
.auth-card,
.auth-stage,
.providers,
.provider,
.form,
.meta {
  min-width: 0;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at top right, rgba(80,107,255,0.08), transparent 24%),
    radial-gradient(circle at bottom left, rgba(255,255,255,0.74), transparent 32%);
  pointer-events: none;
}
.auth-card > * { position: relative; z-index: 1; }

.status {
  display: none; margin-bottom: 16px; padding: 12px 14px; border-radius: 16px; border: 1px solid transparent;
  font-size: 14px; line-height: 1.45; font-weight: 600;
}
.status.is-visible { display: block; }
.status.is-error { color: var(--status-error); background: var(--status-error-bg); border-color: rgba(180,35,24,0.16); }
.status.is-ok { color: var(--status-ok); background: var(--status-ok-bg); border-color: rgba(15,107,70,0.14); }

.auth-stage {
  min-height: 0;
  align-content: start;
  animation: authStageIn 150ms ease both;
}
.auth-card[data-step="email"] .auth-stage { min-height: 338px; }
.auth-card[data-step="chooser"] .auth-stage { min-height: 356px; }
.auth-card[data-step="registration"] .auth-stage,
.auth-card[data-step="reset"] .auth-stage { min-height: 244px; }
.auth-card[data-step="password"] .auth-stage { min-height: 182px; }
.auth-card[data-step="recovery"] .auth-stage { min-height: 170px; }
@keyframes authStageIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

h1 {
  margin: 0 0 22px; font-size: clamp(28px, 4vw, 34px); line-height: 1.12;
  letter-spacing: -0.04em; text-align: center; text-wrap: balance;
}
.step-copy, .step-email {
  margin: 0 0 22px; text-align: center; color: var(--text-soft); font-size: 16px; line-height: 1.55;
}
.step-email { margin-top: -8px; font-weight: 600; }

.providers { display: grid; gap: 12px; }
.provider {
  display: grid; place-items: center; width: 100%; border: 1px solid rgba(202,214,231,0.92);
  border-radius: var(--radius-soft); background: var(--surface-strong); color: var(--text);
  padding: 14px 18px; cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.provider:hover { transform: translateY(-1px); border-color: rgba(80,107,255,0.28); box-shadow: 0 12px 24px rgba(165,178,199,0.18); }
.provider--secondary { background: rgba(255,255,255,0.68); }
.provider--secondary .provider__content { grid-template-columns: minmax(0, 1fr); width: 100%; }
.provider__content { display: inline-grid; grid-template-columns: 24px auto; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.provider__icon { width: 24px; height: 24px; display: inline-grid; place-items: center; }
.provider__icon svg { display: block; width: 18px; height: 18px; }
.provider__label { min-width: 0; font-size: 16px; font-weight: 700; text-align: center; overflow-wrap: anywhere; }

.divider {
  display: flex; align-items: center; gap: 14px; margin: 24px 0 18px; color: var(--text-faint);
  font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
}
.divider::before, .divider::after { content: ""; flex: 1 1 auto; height: 1px; background: rgba(194,207,226,0.76); }

.form { display: grid; gap: 12px; }
.field__input {
  width: 100%; border: 1px solid rgba(202,214,231,0.92); border-radius: var(--radius-soft);
  background: var(--surface-strong); color: var(--text); padding: 16px 20px;
}
.field__input:focus { outline: 2px solid rgba(80,107,255,0.18); border-color: rgba(80,107,255,0.48); }

.btn {
  appearance: none; border: 0; border-radius: var(--radius-soft); padding: 16px 20px;
  font-weight: 700; cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { cursor: default; opacity: 0.76; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent) 0%, #6b7fff 100%); box-shadow: 0 18px 30px rgba(80,107,255,0.28); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent-hover) 0%, #6176ff 100%); }

.btn-link {
  appearance: none; border: 0; background: transparent; padding: 0; justify-self: center;
  color: var(--text-soft); font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-link:hover { color: var(--accent); }

.recent-list {
  display: grid;
  gap: 12px;
}

.recent-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border: 1px solid rgba(202,214,231,0.92);
  border-radius: 24px;
  background: var(--surface-strong);
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(165,178,199,0.12);
}

.recent-account__main,
.recent-account__remove {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text);
}

.recent-account__main {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  text-align: left;
}

.recent-account__main:hover {
  background: rgba(80,107,255,0.03);
}

.recent-account__avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1f8cff 0%, #1370dc 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.recent-account__body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.recent-account__name,
.recent-account__email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-account__name {
  font-size: 17px;
  font-weight: 700;
}

.recent-account__email {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
}

.recent-account__remove {
  width: 58px;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  font-size: 28px;
  line-height: 1;
}

.recent-account__remove:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

.chooser-actions {
  display: grid;
  gap: 12px;
}

.meta {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-top: 18px;
  padding-top: 20px;
  border-top: 1px solid var(--line-strong);
}
.shell-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 6px;
  border: 1px solid rgba(202,214,231,0.92);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(247, 251, 255, 0.96), rgba(233, 241, 250, 0.92));
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.88),
    inset -1px -1px 0 rgba(196,208,225,0.34);
}
.shell-action {
  appearance: none; border: 0; background: transparent; min-width: 104px; padding: 10px 18px;
  border-radius: 999px; color: var(--text-soft); font-size: 14px; line-height: 1.2; font-weight: 700;
  cursor: pointer; transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.shell-action:hover { color: var(--text); }
.shell-action.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #6b7fff 100%);
  box-shadow:
    0 12px 22px rgba(80,107,255,0.24),
    inset 1px 1px 0 rgba(255,255,255,0.18);
  cursor: default;
}
.shell-divider { color: rgba(128,144,170,0.72); font-size: 14px; font-weight: 700; }

@media (max-width: 640px) {
  body { padding: 16px; }
  .auth-page { min-height: calc(100vh - 32px); padding-top: 28px; }
  .auth-shell { gap: 14px; }
  .topline { padding: 0 2px; }
  .brand { font-size: 24px; }
  .back-link { font-size: 12px; }
  .auth-card {
    padding: 22px;
    border-radius: 26px;
    min-height: 0;
    grid-template-rows: auto auto auto;
  }
  .auth-card[data-step="email"] .auth-stage { min-height: 300px; }
  .auth-card[data-step="chooser"] .auth-stage { min-height: 324px; }
  .auth-card[data-step="registration"] .auth-stage,
  .auth-card[data-step="reset"] .auth-stage { min-height: 224px; }
  .auth-card[data-step="password"] .auth-stage { min-height: 168px; }
  .auth-card[data-step="recovery"] .auth-stage { min-height: 158px; }
  h1 { margin-bottom: 20px; font-size: 30px; }
  .provider__label { font-size: 15px; }
  .shell-action { min-width: 92px; padding-inline: 14px; font-size: 13px; }
}

@media (max-width: 420px) {
  body { padding: 12px; }
  .auth-page { min-height: calc(100vh - 24px); align-items: start; }
  .topline { gap: 8px; }
  .brand { font-size: 20px; }
  .back-link {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    text-align: right;
  }
  .auth-card {
    padding: 18px;
    border-radius: 24px;
    min-height: 0;
    grid-template-rows: auto auto auto;
  }
  .auth-stage { min-height: 0; }
  h1 { font-size: 24px; margin-bottom: 18px; }
  .step-copy,
  .step-email { font-size: 15px; margin-bottom: 18px; }
  .provider { padding: 13px 16px; }
  .provider__content { gap: 10px; }
  .provider__label { font-size: 14px; }
  .recent-account { border-radius: 22px; }
  .recent-account__main { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 14px 16px; }
  .recent-account__avatar { width: 42px; height: 42px; font-size: 15px; }
  .recent-account__name { font-size: 16px; }
  .recent-account__email { font-size: 13px; }
  .recent-account__remove { width: 52px; font-size: 26px; }
  .field__input,
  .btn { padding: 15px 18px; }
  .meta { margin-top: 16px; padding-top: 14px; }
}
