/* ════════════════════════════════════════════════════════════════════════
   auth-miniapp — same visual language as auth-center's login page, trimmed
   to what one screen needs. Deliberately NOT themed by Telegram's own
   variables: this page is the tail of a flow that starts on auth-center, and
   it should look like the same product rather than like the chat around it.
   Tokens below are copied from auth-center/build/web/style.css; keep them in
   step, since the two screens are seen one after the other.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #000000;
  --bg-soft:   #131315;
  --bg-sunk:   #0a0a0b;

  --ink:       #f5f5f7;
  --ink-soft:  #a1a1a6;
  --ink-faint: #6e6e73;
  --ink-read:  #cbcbd0;

  --line:      #2b2b2e;
  --line-soft: #1c1c1f;

  --accent:      #ffffff;
  --accent-bg:   rgba(255,255,255,.08);
  --accent-line: rgba(255,255,255,.22);

  --tile-ring:    rgba(255,255,255,.34);
  --tile-ring-on: rgba(255,255,255,.62);

  --err:      #f2706e;
  --err-bg:   rgba(242,112,110,.09);
  --err-line: rgba(242,112,110,.32);

  --glow:
    radial-gradient(30rem 20rem at 50% -2%, rgba(255,255,255,.13), transparent 70%),
    radial-gradient(64rem 40rem at 50% -8%, rgba(255,255,255,.09), transparent 66%);

  --radius:    18px;
  --radius-sm: 12px;
  --shadow: 0 1px 1px rgba(0,0,0,.5), 0 18px 48px -28px rgba(0,0,0,.9);
  --ease: cubic-bezier(.32,.72,0,1);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg:        #fbfbfd;
  --bg-soft:   #ffffff;
  --bg-sunk:   #f2f2f4;

  --ink:       #1d1d1f;
  --ink-soft:  #56565a;
  --ink-faint: #86868b;
  --ink-read:  #3b3b3f;

  --line:      #d8d8dc;
  --line-soft: #e6e6ea;

  --accent:      #1d1d1f;
  --accent-bg:   rgba(0,0,0,.06);
  --accent-line: rgba(0,0,0,.18);

  --tile-ring:    rgba(0,0,0,.2);
  --tile-ring-on: rgba(0,0,0,.45);

  --err:      #c0362f;
  --err-bg:   rgba(192,54,47,.08);
  --err-line: rgba(192,54,47,.3);

  --glow:
    radial-gradient(30rem 20rem at 50% -2%, rgba(0,0,0,.05), transparent 70%),
    radial-gradient(64rem 40rem at 50% -8%, rgba(0,0,0,.035), transparent 66%);
  --shadow: 0 1px 1px rgba(0,0,0,.04), 0 18px 48px -30px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* The `hidden` attribute is display:none from the browser's own stylesheet, and
   ANY author rule that sets display beats it. That is not hypothetical here:
   .action-btn.tall sets display:flex, so a hidden button kept its 80px and sat
   on the card as an empty rectangle — visible on a QR login, which has no
   button, and for a blink on every load. One !important costs less than
   remembering this at each new display rule. */
[hidden] { display: none !important; }

body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -.01em;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
}

body::before {
  content: ""; position: fixed; inset: 0; z-index: 0;
  pointer-events: none; background: var(--glow);
}

:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── card ───────────────────────────────────────────────────────────────── */

.card {
  position: relative;
  z-index: 1;
  width: min(100%, 25rem);
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem .9rem .95rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

/* ── who you are ────────────────────────────────────────────────────────── */

/* A caption and the framed value under it are one thing, so they sit closer to
   each other than the card's own rhythm allows. */
.who {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

/* Set exactly like "Войти через" on auth-center's card: the two screens open
   with the same line in the same voice. */
.card-label {
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.015em;
  user-select: none;
}

/* The frame holds whatever the page has to say — "проверяем…" first, then the
   name or the refusal. A sunk plate, the same one the QR sits in next door. */
.card-title {
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: .9rem 1.1rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.05rem;
  font-weight: 450;
  line-height: 1.3;
  letter-spacing: -.015em;
  user-select: none;
  word-break: break-word;
}

/* The name is the answer this screen exists to give: the only place anybody is
   told WHICH account signed in. It gets the card's brightest ink and its
   largest type — everything else here is quieter than it. */
.card-title.name {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -.025em;
}

/* Only the failure gets a colour of its own. Success is just the page working,
   and painting that green made the card louder than auth-center's, which says
   nothing in colour until something is wrong. */
.card-title.error {
  color: var(--err);
  background: var(--err-bg);
  border-color: var(--err-line);
}

/* ── failure detail ─────────────────────────────────────────────────────── */

/* The technical reason, kept quiet. The user gets the plain sentence above;
   this line is what makes the screenshot they send worth anything. */
.detail {
  text-align: center;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.7;
  letter-spacing: .01em;
  word-break: break-word;
}

/* ── waiting ────────────────────────────────────────────────────────────── */

/* Same box as .action-btn.tall, so the swap from spinner to button moves
   nothing on the card. Hidden by the [hidden] rule at the top of this file —
   the display:grid here is exactly the kind of author rule that would
   otherwise beat the attribute. */
.pending {
  min-height: 5rem;
  display: grid;
  place-items: center;
}

.spinner {
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid var(--line);
  border-top-color: var(--ink-soft);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* The global reduce rule collapses the duration rather than the animation, and
   a ring spinning at that speed is a smear. Drop the moving part and leave the
   ring: it still marks the place where something is happening. */
@media (prefers-reduced-motion: reduce) {
  .spinner { border-top-color: var(--line); }
}

/* ── action button ──────────────────────────────────────────────────────── */

.action-btn {
  display: block;
  width: 100%;
  font: inherit;
  font-size: .95rem;
  font-weight: 500;
  letter-spacing: .04em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  color: var(--ink);
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  transition: background .25s var(--ease), border-color .25s var(--ease),
              color .25s var(--ease);
}

.action-btn:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: var(--tile-ring);
}

.action-btn:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; }

/* Matched to the provider plates on auth-center's login page, which are 5rem
   (80px) square. The button under the greeting carries the same weight as the
   icon that started the login. */
.action-btn.tall {
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 400px) {
  .card { padding: .8rem .65rem .75rem; }
  .card-label { font-size: .95rem; }
  .card-title { font-size: .95rem; }
  .card-title.name { font-size: 1.2rem; }
}
