:root {
  --bg-center: #1e2126;
  --bg-mid: #151a22;
  --bg-edge: #0f1115;
  --text-primary: #f2f5fb;
  --text-secondary: #8c92a0;
  --text-tertiary: #6b7280;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --button-bg: rgba(0, 0, 0, 0.4);
  --button-border: rgba(255, 255, 255, 0.12);
  --button-border-hover: rgba(255, 255, 255, 0.2);
  --button-text: rgba(230, 237, 248, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  position: relative;
  overflow: hidden;
  font-family: 'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 50% 40%, var(--bg-center) 0%, var(--bg-mid) 46%, var(--bg-edge) 100%),
    linear-gradient(160deg, #1a1f28 0%, #0f1115 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 28px 28px, rgba(210, 225, 248, 0.2) 0 1px, transparent 1.5px),
    linear-gradient(58deg, transparent 47%, rgba(192, 207, 228, 0.08) 50%, transparent 53%),
    linear-gradient(-58deg, transparent 47%, rgba(192, 207, 228, 0.07) 50%, transparent 53%);
  background-size: 140px 140px, 220px 220px, 220px 220px;
  opacity: 0.38;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(640px 420px at 18% 50%, rgba(78, 116, 178, 0.15), transparent 72%),
    radial-gradient(620px 420px at 86% 18%, rgba(129, 162, 203, 0.12), transparent 75%);
  z-index: 0;
}

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

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.node {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(220, 231, 246, 0.42);
  box-shadow: 0 0 20px rgba(203, 217, 238, 0.32);
  animation: nodeFloat 14s ease-in-out infinite, nodeGlow 4s ease-in-out infinite;
}

.node::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 110px;
  height: 1px;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(203, 218, 240, 0.2), transparent 78%);
}

.node-1 {
  top: 14%;
  left: 12%;
}

.node-2 {
  top: 12%;
  left: 32%;
  animation-delay: 0.5s;
}

.node-3 {
  top: 22%;
  left: 82%;
  animation-delay: 1.1s;
}

.node-4 {
  top: 42%;
  left: 7%;
  animation-delay: 1.6s;
}

.node-5 {
  top: 56%;
  left: 90%;
  animation-delay: 0.8s;
}

.node-6 {
  top: 74%;
  left: 18%;
  animation-delay: 2.1s;
}

.node-7 {
  top: 82%;
  left: 42%;
  animation-delay: 1.2s;
}

.node-8 {
  top: 70%;
  left: 72%;
  animation-delay: 1.9s;
}

.node-9 {
  top: 30%;
  left: 58%;
  animation-delay: 0.3s;
}

.node-10 {
  top: 88%;
  left: 84%;
  animation-delay: 2.4s;
}

.auth-root {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(94vw, 900px);
  border-radius: 34px;
  border: 1px solid var(--glass-border);
  background:
    linear-gradient(165deg, var(--glass-highlight) 0%, rgba(255, 255, 255, 0.018) 52%, rgba(255, 255, 255, 0.01) 100%),
    var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: clamp(34px, 7vw, 72px) clamp(22px, 6vw, 74px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 16px);
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s cubic-bezier(0.22, 1, 0.36, 1), transform 1s cubic-bezier(0.22, 1, 0.36, 1);
  isolation: isolate;
}

body.is-ready .auth-card {
  opacity: 1;
  transform: translateY(0);
}

.brand-logo-shell {
  width: min(100%, 700px);
  max-width: 100%;
  min-height: clamp(158px, 22vw, 230px);
  display: grid;
  justify-items: center;
  align-content: center;
  row-gap: clamp(8px, 1.6vw, 16px);
  opacity: 0.98;
}

.brand-logo-sign {
  width: clamp(78px, 11vw, 132px);
  aspect-ratio: 560 / 487;
  background-image: url('./logo-sign-crisp-560-lossless.webp?v=20260315r16');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  filter: saturate(0.94) contrast(1.05) brightness(1.02);
  opacity: 0.96;
}

.brand-logo-word {
  width: min(100%, clamp(186px, 34vw, 372px));
  height: clamp(46px, 8vw, 84px);
  background-image: url('./logo-vector.svg?v=20260315r16');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  filter: invert(1) sepia(9%) saturate(168%) hue-rotate(176deg) brightness(1.18) contrast(0.86);
  opacity: 0.95;
}

.brand-logo-image {
  display: none;
}

.subtitle {
  margin: 0;
  font-size: clamp(0.92rem, 2.2vw, 1.22rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.subtitle-secondary {
  margin: 0;
  font-size: clamp(0.84rem, 2vw, 1.03rem);
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
}

.tg-auth {
  width: min(100%, 780px);
  min-height: 64px;
  margin-top: clamp(14px, 2.8vw, 26px);
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid var(--button-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01)),
    var(--button-bg);
  color: var(--button-text);
  font-family: inherit;
  font-size: clamp(0.68rem, 1.46vw, 0.84rem);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    border-color 220ms ease,
    box-shadow 220ms ease,
    background-color 220ms ease,
    transform 120ms ease;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 28px rgba(6, 11, 18, 0.3);
}

.tg-auth__icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: rgba(236, 242, 251, 0.92);
}

.tg-auth__icon svg {
  width: 100%;
  height: 100%;
}

.tg-auth__label {
  white-space: nowrap;
}

.tg-auth:hover {
  border-color: var(--button-border-hover);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 10px 28px rgba(162, 186, 221, 0.24),
    0 0 30px rgba(155, 183, 224, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.tg-auth:active {
  transform: scale(0.98);
}

.tg-auth:focus-visible {
  outline: 2px solid rgba(233, 240, 252, 0.45);
  outline-offset: 2px;
}

.tg-auth[disabled] {
  cursor: default;
}

.tg-auth__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.loader-rail {
  position: absolute;
  width: min(180px, 64%);
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(238, 245, 255, 0.34), transparent);
  transform: translateX(-100%);
  animation: railShift 1.25s linear infinite;
}

.loader-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(244, 249, 255, 0.98), rgba(180, 195, 217, 0.9));
  box-shadow: 0 0 12px rgba(215, 228, 245, 0.52);
  animation: dotPulse 1.1s ease-in-out infinite;
}

.loader-dot:nth-of-type(3) {
  animation-delay: 120ms;
}

.loader-dot:nth-of-type(4) {
  animation-delay: 240ms;
}

.tg-auth.is-loading .tg-auth__icon,
.tg-auth.is-loading .tg-auth__label {
  opacity: 0;
}

.tg-auth.is-loading .tg-auth__loader {
  opacity: 1;
}

.toast {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 18px);
  width: min(92vw, 560px);
  padding: 13px 18px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(23, 28, 39, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(235, 242, 252, 0.94);
  text-align: center;
  font-size: 0.84rem;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 240ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes nodeFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -12px, 0);
  }
}

@keyframes nodeGlow {
  0%,
  100% {
    opacity: 0.28;
  }
  50% {
    opacity: 0.72;
  }
}

@keyframes dotPulse {
  0%,
  100% {
    transform: scale(0.72);
    opacity: 0.45;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes railShift {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@media (min-width: 920px) {
  .auth-card {
    width: min(72vmin, 700px);
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    padding: clamp(40px, 6vmin, 78px);
  }
}

@media (max-width: 680px) {
  .auth-root {
    padding: 20px;
  }

  .auth-card {
    width: 90vw;
    border-radius: 32px;
    padding: 30px 20px 28px;
  }

  .brand-logo-shell {
    min-height: clamp(148px, 34vw, 210px);
    row-gap: clamp(6px, 2vw, 12px);
  }

  .brand-logo-sign {
    width: clamp(70px, 22vw, 104px);
  }

  .brand-logo-word {
    width: min(100%, clamp(164px, 58vw, 260px));
    height: clamp(40px, 12vw, 68px);
  }

  .subtitle {
    letter-spacing: 0.08em;
  }

  .tg-auth {
    min-height: 56px;
    letter-spacing: 0.1em;
    font-size: 0.7rem;
  }

  .node::before {
    width: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .toast {
    transition: none;
  }

  .node,
  .loader-dot,
  .loader-rail {
    animation: none;
  }
}
