:root {
  --auth-ink: var(--product-text);
  --auth-muted: var(--product-muted);
  --auth-line: var(--product-line);
  --auth-surface: var(--product-surface);
  --auth-field: var(--product-surface-soft);
  --auth-telegram: #229ed9;
}

body.telegram-auth-page {
  min-height: 100vh;
  color: var(--auth-ink);
  background: var(--product-bg);
}

.telegram-auth-page .grid-layer,
.telegram-auth-page .noise { display: none; }
.telegram-auth-page .page { max-width: none; padding: 0; }

.telegram-auth-shell {
  width: min(100% - 36px, 1040px);
  min-height: calc(100dvh - var(--product-header-height));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.telegram-auth-stage {
  width: min(440px, 100%);
  margin: auto;
  padding: 34px 0 58px;
  display: grid;
  justify-items: center;
  text-align: center;
  animation: telegram-stage-in .42s cubic-bezier(.2,.82,.25,1) both;
}

@keyframes telegram-stage-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
}

.telegram-auth-loader {
  width: 76px;
  height: 76px;
  position: relative;
  display: grid;
  place-items: center;
}

.telegram-auth-loader > span {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--auth-telegram);
  border-radius: 50%;
  box-shadow: 0 10px 25px rgba(34, 158, 217, .22);
}
.telegram-auth-loader svg { width: 28px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
.telegram-auth-loader i {
  position: absolute;
  inset: 2px;
  border: 4px solid rgba(34, 158, 217, .15);
  border-right-color: var(--auth-telegram);
  border-radius: 50%;
  animation: telegram-loader 1.15s linear infinite;
}
@keyframes telegram-loader { to { transform: rotate(360deg); } }

.telegram-auth-stage h1 {
  margin: 17px 0 25px;
  color: var(--auth-ink);
  font: 620 28px/1.05 "Space Grotesk", sans-serif;
  letter-spacing: -.04em;
}

.telegram-auth-hint { margin: 13px 0 17px; color: var(--auth-muted); font: 500 11px/1 "Space Grotesk", sans-serif; }

.telegram-auth-status {
  min-height: 17px;
  margin: 12px 0 0;
  color: var(--auth-muted);
  font: 500 12px/1.4 "Space Grotesk", sans-serif;
}
.telegram-auth-status.is-error { color: #c34856; }
.telegram-auth-shell.is-approved .telegram-open-button { background: #28a36d; }

.telegram-web-fallback {
  margin-top: 2px;
  color: var(--auth-muted);
  font: 500 11px/1.4 "Space Grotesk", sans-serif;
  text-underline-offset: 3px;
}

.telegram-auth-alternatives { width: min(320px, 100%); margin-top: 17px; }
.telegram-auth-alternatives summary {
  width: max-content;
  margin: 0 auto;
  color: var(--auth-muted);
  cursor: pointer;
  list-style: none;
  font: 500 11px/1.4 "Space Grotesk", sans-serif;
}
.telegram-auth-alternatives summary::-webkit-details-marker { display: none; }
.telegram-auth-alternatives summary::after { content: " ›"; }
.telegram-auth-alternatives[open] summary::after { content: " ×"; }
.telegram-auth-alternative-body { margin-top: 15px; padding: 16px; background: var(--auth-surface); border: 1px solid var(--auth-line); border-radius: 18px; text-align: left; }
.telegram-auth-alternative-body label { display: block; margin: 0 0 5px; color: var(--auth-muted); font-size: 11px; }
.telegram-auth-alternative-body input { width: 100%; min-height: 42px; margin-bottom: 10px; padding: 0 12px; color: var(--auth-ink); background: var(--auth-field); border: 1px solid var(--auth-line); border-radius: 12px; }
.telegram-password-submit,
.telegram-google-button { width: 100%; min-height: 43px; display: grid; place-items: center; border-radius: 12px; font: 550 13px/1 "Space Grotesk", sans-serif; text-decoration: none; }
.telegram-password-submit { color: #fff; background: var(--product-primary); border: 0; }
.telegram-google-button { color: var(--auth-ink); background: var(--auth-surface); border: 1px solid var(--auth-line); }
.telegram-auth-divider { margin: 10px 0; color: var(--auth-muted); text-align: center; font-size: 10px; }
.telegram-auth-errors { margin: 0 0 10px; padding: 0; color: #c34856; list-style: none; font-size: 11px; }

@media (max-width: 640px) {
  .telegram-auth-shell { width: calc(100% - 28px); }
  .telegram-auth-stage { padding-top: 24px; padding-bottom: 40px; }
  .telegram-auth-stage h1 { margin: 14px 0 21px; font-size: 25px; }
}

@media (max-width: 640px) and (max-height: 680px) {
  .telegram-auth-shell { width: calc(100% - 24px); }

  .telegram-auth-stage {
    padding-top: 10px;
    padding-bottom: 12px;
  }

  .telegram-auth-loader {
    width: 48px;
    height: 48px;
  }

  .telegram-auth-loader > span {
    width: 38px;
    height: 38px;
    box-shadow: 0 7px 18px rgba(34, 158, 217, .2);
  }

  .telegram-auth-loader svg { width: 20px; }

  .telegram-auth-loader i {
    inset: 1px;
    border-width: 3px;
  }

  .telegram-auth-stage h1 {
    margin: 7px 0 10px;
    font-size: 22px;
  }

  .telegram-qr-card {
    width: 198px;
    height: 198px;
    padding: 8px;
    border-radius: 21px;
    box-shadow: 0 16px 40px rgba(34, 37, 47, .12);
  }

  .telegram-qr-card img {
    width: 182px;
    height: 182px;
    border-radius: 14px;
  }

  .telegram-auth-hint {
    margin: 8px 0 10px;
    font-size: 10.5px;
  }

  .telegram-open-button {
    min-width: 220px;
    min-height: 44px;
    border-radius: 14px;
    font-size: 13px;
  }

  .telegram-open-button svg { width: 18px; }

  .telegram-auth-status {
    min-height: 16px;
    margin-top: 5px;
    font-size: 11px;
  }

  .telegram-web-fallback {
    margin-top: 0;
    font-size: 10.5px;
  }

  .telegram-auth-alternatives { margin-top: 6px; }
  .telegram-auth-alternatives summary { font-size: 10.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .telegram-auth-stage,
  .telegram-auth-loader i { animation: none; }
  .telegram-qr-card,
  .telegram-open-button { transition: none; }
}
