:root {
  color-scheme: dark;
  --entry-canvas: #080a0f;
  --entry-canvas-deep: #05070b;
  --entry-surface: rgba(17, 21, 31, 0.97);
  --entry-surface-soft: #171c28;
  --entry-field: #171c27;
  --entry-text: #f3eee5;
  --entry-muted: #aaa8aa;
  --entry-line: rgba(215, 185, 112, 0.34);
  --entry-line-strong: rgba(226, 197, 126, 0.58);
  --entry-gold: #d9b96f;
  --entry-blue: #7899cf;
  --entry-blue-deep: #446ba9;
  --entry-primary-gradient-start: #4268a3;
  --entry-primary-gradient-end: #355d9b;
  --entry-primary-hover-brightness: 1.08;
  --entry-gate-gradient-start: #fce8ac;
  --entry-gate-gradient-mid: #e9bc58;
  --entry-gate-gradient-end: #c49735;
  --entry-gate-label: #3a2606;
  --entry-gate-focus: #fff2af;
  --entry-focus: #c8d9ff;
  --entry-success: #9fd0ae;
  --entry-warning: #e3bc75;
  --entry-danger: #e0a29c;
  --entry-radius: 22px;
  --entry-control-radius: 15px;
  --entry-gutter: clamp(8px, 2vw, 18px);
  --entry-safe-top: max(var(--entry-gutter), env(safe-area-inset-top));
  --entry-safe-right: max(var(--entry-gutter), env(safe-area-inset-right));
  --entry-safe-bottom: max(var(--entry-gutter), env(safe-area-inset-bottom));
  --entry-safe-left: max(var(--entry-gutter), env(safe-area-inset-left));
  --entry-motion-ease: cubic-bezier(.22, .68, .24, 1);
  --entry-shadow: 0 24px 72px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--entry-canvas);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background:
    radial-gradient(circle at 50% 10%, rgba(72, 96, 146, 0.15), transparent 37rem),
    radial-gradient(circle at 80% 78%, rgba(217, 185, 111, 0.045), transparent 28rem),
    linear-gradient(180deg, var(--entry-canvas) 0%, var(--entry-canvas-deep) 100%);
  color: var(--entry-text);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.auth-body {
  position: static;
  inset: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: var(--entry-safe-top) var(--entry-safe-right) var(--entry-safe-bottom) var(--entry-safe-left);
  overflow: visible;
  background: transparent;
  color: var(--entry-text);
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.auth-document {
  display: grid;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  place-items: safe center center;
  padding-block: clamp(0px, 1.2vh, 10px);
}

.auth-document.auth-document--anchored {
  place-items: start center;
}

.auth-entry-surface {
  display: grid;
  width: min(100%, 560px);
  min-width: 0;
  gap: 11px;
  padding: clamp(14px, 3vw, 22px);
  border: 1px solid var(--entry-line);
  border-radius: var(--entry-radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.026), transparent 43%),
    var(--entry-surface);
  box-shadow: var(--entry-shadow);
  isolation: isolate;
}

.auth-identity {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 5px;
  text-align: center;
}

.auth-identity__picture {
  display: block;
  width: clamp(54px, 14vw, 68px);
  height: clamp(54px, 14vw, 68px);
}

.auth-identity__picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-identity__copy {
  min-width: 0;
}

.auth-identity h1 {
  margin: 0;
  color: #f8f1e5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 9vw, 42px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
}

.auth-identity p {
  margin: 4px 0 0;
  color: var(--entry-muted);
  font-size: clamp(12px, 3.2vw, 14px);
  font-weight: 650;
  line-height: 1.25;
}

.auth-workspace {
  display: grid;
  min-width: 0;
  gap: 9px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-width: 0;
  padding: 3px;
  border: 1px solid rgba(217, 185, 111, 0.2);
  border-radius: 999px;
  background: rgba(5, 7, 11, 0.52);
}

.auth-tab {
  display: grid;
  min-width: 0;
  min-height: 44px;
  place-items: center;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #b7b5b6;
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.auth-tab.active,
.auth-tab[aria-selected="true"] {
  border-color: rgba(139, 170, 220, 0.58);
  background: linear-gradient(180deg, rgba(114, 153, 211, 0.34), rgba(62, 96, 151, 0.42));
  color: #f8fbff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.auth-tab[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.58;
}

.auth-tab:focus-visible,
.auth-primary:focus-visible,
.auth-feedback__action:focus-visible,
.legal-check input:focus-visible,
.auth-footer a:focus-visible {
  outline: 2px solid var(--entry-focus);
  outline-offset: 3px;
}

.auth-zone,
.auth-pane-stack,
.auth-status-stack {
  min-width: 0;
}

.auth-zone--animating {
  overflow: hidden;
  transition: height 320ms var(--entry-motion-ease);
}

.auth-pane-stack,
.auth-status-stack {
  display: grid;
}

.auth-form,
.auth-mode-tail,
.auth-feedback,
.registration-code-gate--tail {
  grid-area: 1 / 1;
  min-width: 0;
}

.auth-form {
  display: grid;
  align-self: start;
  width: 100%;
  align-content: start;
  gap: 8px;
  visibility: hidden;
  opacity: 0;
  transform: scale(.97) translateY(6px);
  pointer-events: none;
  transition:
    opacity 180ms var(--entry-motion-ease),
    transform 180ms var(--entry-motion-ease),
    visibility 0s linear 180ms;
}

.auth-form[aria-hidden="false"] {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: none;
  animation: auth-pane-reveal 180ms var(--entry-motion-ease) both;
}

.auth-form[aria-hidden="true"] {
  display: none;
  visibility: hidden;
  opacity: 0;
  transform: scale(.97) translateY(6px);
  pointer-events: none;
}

.auth-form.auth-form--leaving[aria-hidden="true"] {
  display: grid;
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: none;
  animation: auth-pane-yield 180ms var(--entry-motion-ease) both;
}

.auth-field-control {
  position: relative;
  display: block;
  min-width: 0;
}

.auth-field-icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 14px;
  width: 17px;
  height: 17px;
  color: rgba(221, 225, 235, 0.48);
  transform: translateY(-50%);
  pointer-events: none;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 14px 11px 41px;
  border: 1px solid rgba(190, 196, 212, 0.23);
  border-radius: var(--entry-control-radius);
  outline: none;
  background: var(--entry-field);
  color: #f7f3ed;
  font-size: 16px;
  line-height: 1.25;
  caret-color: var(--entry-blue);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.auth-form input::placeholder {
  color: rgba(202, 203, 208, 0.64);
  opacity: 1;
}

.auth-form input:hover {
  border-color: rgba(197, 215, 255, 0.36);
}

.auth-form input:focus {
  border-color: rgba(139, 174, 230, 0.84);
  background: #1b2230;
  box-shadow: 0 0 0 3px rgba(112, 147, 207, 0.14);
}

.auth-form input:-webkit-autofill,
.auth-form input:-webkit-autofill:hover,
.auth-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f7f3ed;
  box-shadow: 0 0 0 1000px #1b2230 inset;
  caret-color: var(--entry-blue);
}

.auth-primary {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid rgba(156, 188, 239, 0.76);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    var(--entry-primary-gradient-start),
    var(--entry-primary-gradient-end)
  );
  color: #fff;
  box-shadow: 0 10px 24px rgba(33, 61, 111, 0.25);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.1;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.auth-primary:hover:not(:disabled) {
  filter: brightness(var(--entry-primary-hover-brightness));
}

.auth-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.auth-primary:disabled {
  cursor: progress;
  opacity: 0.58;
}

.auth-mode-tail,
.auth-feedback,
.registration-code-gate--tail {
  display: none;
}

.auth-mode-tail[aria-hidden="false"],
.auth-feedback[aria-hidden="false"],
.registration-code-gate--tail[aria-hidden="false"] {
  display: grid;
}

.auth-mode-tail--legal {
  gap: 6px;
  align-content: start;
  padding-top: 8px;
  border-top: 1px solid rgba(217, 185, 111, 0.16);
  animation: auth-pane-reveal 180ms var(--entry-motion-ease) both;
}

.legal-check {
  display: grid;
  grid-template-columns: 21px minmax(0, 1fr);
  min-width: 0;
  align-items: start;
  gap: 7px;
  color: #c7c2bc;
  font-size: 11.5px;
  line-height: 1.32;
}

.legal-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #5e83c2;
}

.legal-check span,
.legal-check a {
  overflow-wrap: anywhere;
}

.legal-check a {
  color: #dfc582;
  text-underline-offset: 2px;
}

.auth-feedback {
  align-content: center;
  gap: 5px;
  min-height: 46px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--entry-muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
}

.auth-feedback[hidden] {
  display: none;
}

.auth-feedback[data-tone="pending"] {
  border-color: rgba(159, 208, 174, 0.24);
  background: rgba(65, 112, 79, 0.12);
  color: var(--entry-success);
}

.auth-feedback[data-tone="error"] {
  border-color: rgba(224, 162, 156, 0.28);
  background: rgba(127, 57, 52, 0.13);
  color: var(--entry-danger);
}

.auth-feedback[data-tone="uncertain"] {
  border-color: rgba(227, 188, 117, 0.28);
  background: rgba(126, 91, 35, 0.14);
  color: var(--entry-warning);
}

.auth-feedback__action {
  justify-self: center;
  min-height: 44px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: rgba(227, 188, 117, 0.15);
  color: #f5d596;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 800;
}

.auth-noscript {
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(227, 188, 117, 0.28);
  border-radius: 12px;
  color: var(--entry-warning);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.auth-footer {
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(217, 185, 111, 0.18);
}

.auth-footer nav {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 13px;
}

.auth-footer a {
  color: #92939a;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.auth-footer a:hover {
  color: #dbd7cf;
}

/* Short viewports only: keep the fixed cookie notice clear of the footer links. */
@media (max-height: 620px) {
  body.auth-body:has(.apps-cookie-notice-v1:not([hidden])) .auth-document {
    padding-bottom: 76px;
  }
}

/* Заставка уходит растворением, а не срезом: общий рантайм гасит только сцену
   и через 120ms снимает секцию целиком, поэтому тёмное полотно исчезало рывком.
   Своим правилом гасим и полотно ровно в том же окне 120ms — чужие байты не
   трогаем и в его тайминг не лезем. */
body.auth-body .xapp-c3[data-xapp-c3-state="entry-leaving"] {
  opacity: 0;
  transition: opacity 120ms var(--entry-motion-ease);
}

/* Панель входа проявляется прозрачностью: внешнюю панель нельзя трансформировать,
   поэтому только opacity и та же кривая, что у смены вкладок. */
.auth-entry-surface {
  animation: auth-surface-enter 220ms var(--entry-motion-ease) both;
}

@keyframes auth-surface-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes auth-pane-reveal {
  from { opacity: 0; transform: scale(.97) translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes auth-pane-yield {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(.97) translateY(6px); }
}

@media (max-width: 420px) {
  .auth-entry-surface {
    gap: 9px;
    padding: 13px;
    border-radius: 18px;
  }

  .auth-identity__picture {
    width: 52px;
    height: 52px;
  }

  .auth-identity h1 {
    font-size: clamp(30px, 10.2vw, 38px);
  }
}

@media (max-height: 44rem) {
  :root {
    --entry-gutter: 6px;
  }

  .auth-document {
    padding-block: 0;
  }

  .auth-entry-surface {
    gap: 8px;
    padding: 12px;
  }

  .auth-identity {
    grid-template-columns: auto minmax(0, auto);
    justify-content: center;
    align-items: center;
    gap: 9px;
    text-align: left;
  }

  .auth-identity__picture {
    width: 46px;
    height: 46px;
  }

  .auth-identity h1 {
    font-size: clamp(29px, 8vw, 36px);
  }

  .auth-footer {
    padding-top: 8px;
  }
}

@media (max-width: 340px) {
  .auth-tab {
    min-height: 44px;
    padding-inline: 6px;
    font-size: 13px;
  }

  .auth-footer nav {
    gap: 7px 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-zone--animating {
    transition: none;
  }

  body.auth-body .xapp-c3[data-xapp-c3-state="entry-leaving"] {
    transition-duration: 80ms;
  }

  .auth-entry-surface {
    animation: none;
  }

  .auth-form,
  .auth-form[aria-hidden="false"],
  .auth-mode-tail--legal {
    animation: none;
    transition: none;
  }

  .auth-form.auth-form--leaving[aria-hidden="true"] {
    display: none;
    visibility: hidden;
    opacity: 0;
  }
}

@media (forced-colors: active) {
  .auth-entry-surface,
  .auth-tabs,
  .auth-tab,
  .auth-primary,
  .auth-form input,
  .auth-feedback {
    border: 1px solid CanvasText;
  }
}
