*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --auth-blue: #1f5fe0;
  --auth-bg: #202226;
  --auth-surface: #2a2d32;
  --auth-surface-raised: #34383f;
  --auth-line: rgba(128, 128, 128, 0.3);
  --auth-line-strong: rgba(168, 172, 180, 0.4);
  --auth-text: #f5f6f7;
  --auth-text-soft: #c8ccd2;
  --auth-text-muted: #979da6;
  --auth-placeholder: #747b86;
  --auth-success: #4ed6a0;
  --auth-danger: #ff7a8a;
  --auth-shadow: 0 18px 42px rgba(10, 11, 13, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --auth-bg: #f4f6f9;
  --auth-surface: #ffffff;
  --auth-surface-raised: #edf0f4;
  --auth-line: rgba(70, 79, 94, 0.16);
  --auth-line-strong: rgba(31, 95, 224, 0.3);
  --auth-text: #101728;
  --auth-text-soft: #47526b;
  --auth-text-muted: #7c869c;
  --auth-placeholder: #9299a6;
  --auth-success: #178a5e;
  --auth-danger: #d63b52;
  --auth-shadow: 0 18px 42px rgba(31, 49, 79, 0.14);
}

body.authView {
  --auth-squeeze: 0px;
  --auth-gap-top: clamp(52px, 9vh, 92px);
  --auth-gap-bottom: clamp(48px, 8vh, 76px);
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--auth-bg);
  color: var(--auth-text);
  font-family: "Poppins", system-ui, sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-user-select: none;
  user-select: none;
}

.authView img { -webkit-user-drag: none; }

.authView .exoNick,
.authView input,
.authView textarea {
  -webkit-user-select: text;
  user-select: text;
}

body.authView--register {
  --auth-squeeze: clamp(0px, 860px - 100vh, 160px);
}

body.authView::before,
body.authView::after {
  display: none;
}

.authLayout {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.authVisual {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  --auth-visual-unit: min(0.5vw, 1dvh);
  border-left: 1px solid var(--auth-line);
  background-color: var(--auth-blue);
  background-image:
    linear-gradient(rgba(31, 95, 224, 0.74), rgba(31, 95, 224, 0.74)),
    url("/img/auth-visual-bg.png");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.authVisual::before {
  content: "";
  position: absolute;
  inset: calc(var(--auth-visual-unit) * 8);
  border: calc(var(--auth-visual-unit) * 0.108) solid rgba(255, 255, 255, 0.1);
  border-radius: calc(var(--auth-visual-unit) * 2.6);
  pointer-events: none;
}

.authVisualMark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--auth-visual-unit) * 92);
  height: calc(var(--auth-visual-unit) * 92);
  transform: translate(-50%, -50%);
}

.authVisualCrew {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter:
    drop-shadow(0 0 calc(var(--auth-visual-unit) * 0.86) rgba(255, 255, 255, 0.7))
    drop-shadow(0 0 calc(var(--auth-visual-unit) * 2.15) rgba(130, 188, 255, 0.65))
    drop-shadow(0 0 calc(var(--auth-visual-unit) * 4.5) rgba(85, 145, 255, 0.45));
  animation: authCrewGlowPulse 2.6s ease-in-out infinite;
}

@keyframes authCrewGlowPulse {
  0%, 100% { opacity: 0.86; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .authVisualCrew { animation: none; opacity: 1; }
}

.authVisualFooter {
  position: absolute;
  left: clamp(32px, 5vw, 76px);
  right: clamp(32px, 5vw, 76px);
  bottom: clamp(34px, 6vh, 72px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.authVisualLegal {
  margin: 0;
  max-width: 480px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.authVisualCredit {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 600;
}

.authVisualCredit svg {
  flex-shrink: 0;
}

.authAccessPanel {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 3.5vh, 40px) clamp(32px, 7vw, 92px);
  background: var(--auth-bg);
}

.authAccessInner {
  flex: 1 0 auto;
  width: min(100%, 410px);
  display: flex;
  flex-direction: column;
}

.authAccessInner::before,
.authAccessInner::after {
  content: "";
  flex: 1 1 0;
}

.authIdentity {
  flex: 100 1 auto;
  display: grid;
  grid-auto-flow: column;
  justify-content: start;
  align-content: start;
  align-items: center;
  column-gap: 11px;
  min-height: calc(48px + 24px - var(--auth-squeeze) / 13);
  max-height: calc(48px + var(--auth-gap-top));
}

.authBrandBadge {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(100, 151, 244, 0.3);
  border-radius: 14px;
  background: rgba(39, 100, 231, 0.1);
  color: #80abff;
}

.authBrandBadgeImage {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
}

.authIdentityCopy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.authIdentityCopy strong {
  color: var(--auth-text);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.authIdentityCopy small {
  margin-top: 5px;
  color: var(--auth-text-muted);
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.authIntro {
  margin-bottom: calc(28px - var(--auth-squeeze) / 10);
}

.authKicker {
  color: var(--auth-blue);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.authIntro h1 {
  margin: calc(8px - var(--auth-squeeze) / 40) 0 calc(7px - var(--auth-squeeze) / 40);
  color: var(--auth-text);
  font-size: min(clamp(30px, 3.1vw, 42px), 42px - var(--auth-squeeze) / 10);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.055em;
}

.authIntro h1.fx-typewriter {
  --fx-typewriter-duration: 13s;
  --fx-typewriter-caret: var(--auth-blue);
  position: relative;
  width: max-content;
  max-width: none;
  color: transparent;
  font-size: clamp(20px, 6vw, 30px);
  white-space: nowrap;
}

.authIntro h1.fx-typewriter::before {
  content: attr(data-text);
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  overflow: hidden;
  color: var(--auth-text);
  white-space: nowrap;
  clip-path: inset(0 100% 0 0);
  animation: authTypewriterReveal var(--fx-typewriter-duration) steps(25, end) infinite;
}

.authIntro h1.fx-typewriter::after {
  content: "";
  position: absolute;
  top: 0.08em;
  bottom: 0.08em;
  left: 0;
  width: 0.08em;
  min-width: 2px;
  border-radius: 999px;
  background: var(--fx-typewriter-caret);
  box-shadow: 0 0 12px rgba(31, 95, 224, 0.34);
  animation:
    authTypewriterCaretMove var(--fx-typewriter-duration) steps(25, end) infinite,
    authTypewriterCaretBlink 0.65s steps(1, end) infinite;
}

@keyframes authTypewriterReveal {
  0%, 4% { clip-path: inset(0 100% 0 0); }
  23%, 100% { clip-path: inset(0 0 0 0); }
}

@keyframes authTypewriterCaretMove {
  0%, 4% { left: 0; }
  23%, 100% { left: 100%; }
}

@keyframes authTypewriterCaretBlink {
  50% { opacity: 0; }
}

.authIntro p {
  margin: 0;
  color: var(--auth-text-muted);
  font-size: 12px;
}

.surfaceNotice {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--auth-line);
  border-radius: 11px;
  background: var(--auth-surface);
  color: var(--auth-text-soft);
  font-size: 11px;
}

.surfaceNotice--success { border-color: rgba(81, 215, 160, 0.3); color: var(--auth-success); }
.surfaceNotice--error { border-color: rgba(255, 120, 136, 0.3); color: var(--auth-danger); }

.authForm {
  display: grid;
  gap: calc(15px - var(--auth-squeeze) * 0.0375);
}

.authField {
  display: flex;
  flex-direction: column;
  gap: calc(7px - var(--auth-squeeze) / 40);
}

.authLabel {
  color: var(--auth-text-soft);
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.authInputWrap {
  position: relative;
  display: flex;
  align-items: center;
}

.authInputWrap > i {
  position: absolute;
  left: 13px;
  z-index: 1;
  color: var(--auth-text-muted);
  font-size: 15px;
  pointer-events: none;
}

.authInput {
  width: 100%;
  min-height: calc(50px - var(--auth-squeeze) / 16);
  padding: calc(13px - var(--auth-squeeze) / 32) 14px;
  border: 1px solid var(--auth-line);
  border-radius: 12px;
  background: var(--auth-surface);
  color: var(--auth-text);
  font: inherit;
  font-size: 11px;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.authInputWrap .authInput {
  padding-left: 40px;
}

.authInputWrap .has-password-toggle { padding-right: 48px; }
.authInputWrap .passwordToggle {
  position: absolute;
  right: 3px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--auth-text-soft);
  font-size: 18px;
  cursor: pointer;
}
.authInputWrap .passwordToggle[hidden] { display: none; }
.authInputWrap .passwordToggle:hover { background: var(--auth-surface-raised); }
.authInputWrap .passwordToggle:focus-visible {
  outline: 2px solid var(--auth-text-soft);
  outline-offset: -3px;
}

.authInput::placeholder { color: var(--auth-placeholder); }

.authInput:focus {
  border-color: rgba(85, 142, 244, 0.6);
  background: var(--auth-surface-raised);
  box-shadow: 0 0 0 3px rgba(39, 100, 231, 0.1);
}

.authPrimaryButton {
  position: relative;
  z-index: 0;
  min-height: calc(48px - var(--auth-squeeze) / 32);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: calc(5px - var(--auth-squeeze) / 32);
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  background: #2764e7;
  color: #fff;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--auth-shadow);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.authPrimaryButton::before {
  content: "";
  position: absolute;
  inset: -3px;
  z-index: -1;
  border-radius: inherit;
  background-image: linear-gradient(135deg, #123c96 0%, #1f5fe0 40%, #46b6ff 70%, #1f5fe0 100%);
  background-size: 260% 260%;
  background-position: 0% 50%;
  animation: authBtnDrift 7s ease infinite;
}

.authPrimaryButton:hover,
.authPrimaryButton:focus-visible {
  transform: scale(1.035);
  box-shadow: var(--auth-shadow), 0 0 20px rgba(70, 182, 255, 0.55);
  outline: none;
}

.authPrimaryButton > i:last-child { margin-left: auto; }

.authPrimaryButton:disabled {
  opacity: .6;
  cursor: progress;
  transform: none;
  box-shadow: var(--auth-shadow);
}

@keyframes authBtnDrift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .authPrimaryButton::before { animation: none; }
}

.authFootnote {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: calc(16px - var(--auth-squeeze) / 27);
  border-top: 1px solid var(--auth-line);
}

.authFootnote span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--auth-text-muted);
  font-size: 8px;
}

.authFootnote span i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--auth-success);
}

.authFootnote small {
  color: var(--auth-text-muted);
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 1000px) {
  .authAccessPanel { padding: clamp(16px, 3.5vh, 40px) clamp(30px, 6vw, 64px); }
}

@media (max-width: 760px) {
  body.authView { --auth-gap-top: 56px; --auth-gap-bottom: 48px; }
  .authLayout { grid-template-columns: 1fr; }
  .authVisual { display: none; }
  .authAccessPanel { min-height: 100dvh; padding: clamp(16px, 3.5vh, 30px) 22px; }
  .authAccessInner { width: min(100%, 430px); }
  .authIntro h1 { font-size: min(34px, 42px - var(--auth-squeeze) / 10); }
}

@media (max-width: 430px) {
  body.authView { --auth-gap-top: 44px; }
  .authAccessPanel { padding: clamp(14px, 2.5vh, 24px) 16px; }
  .authIntro h1 { font-size: min(30px, 42px - var(--auth-squeeze) / 10); }
  .authFootnote small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .authInput,
  .authPrimaryButton { transition: none; }

  .authIntro h1.fx-typewriter { color: var(--auth-text); }
  .authIntro h1.fx-typewriter::before,
  .authIntro h1.fx-typewriter::after { content: none; animation: none; }
}

.authAltAction {
  flex: 100 1 auto;
  min-height: calc(18px + 20px - var(--auth-squeeze) / 16);
  min-height: calc(1lh + 20px - var(--auth-squeeze) / 16);
  max-height: calc(18px + var(--auth-gap-bottom));
  max-height: calc(1lh + var(--auth-gap-bottom));
  margin: calc(14px - var(--auth-squeeze) / 27) 0 0;
  color: var(--auth-text-muted);
  font-size: 12px;
  text-align: center;
}

.authAltAction a { color: var(--auth-blue); font-weight: 600; text-decoration: none; }
.authAltAction a:hover { text-decoration: underline; }

.regSteps {
  display: flex;
  gap: 8px;
  margin: 0 0 calc(18px - var(--auth-squeeze) / 20);
  padding: 0;
  list-style: none;
}

.regStep {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: calc(8px - var(--auth-squeeze) / 64) 10px;
  border: 1px solid rgba(31, 95, 224, .18);
  border-radius: 10px;
  color: var(--auth-text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.regStep span {
  display: grid;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(31, 95, 224, .18);
  color: inherit;
  font-size: 11px;
  place-items: center;
}

.regStep.is-active {
  border-color: var(--auth-blue);
  color: var(--auth-blue);
}

.regStep.is-active span { background: var(--auth-blue); color: #fff; }
.regStep.is-done span { background: #178a5e; color: #fff; }

.regPanel[hidden] { display: none !important; }

.regHint { margin: 0 0 calc(10px - var(--auth-squeeze) / 32); color: var(--auth-text-soft); font-size: 12px; line-height: 1.5; }
.regHint--muted { color: var(--auth-text-muted); font-size: 11px; }

.regCode {
  margin: 0 0 calc(8px - var(--auth-squeeze) / 40);
  padding: calc(14px - var(--auth-squeeze) / 20) 14px;
  border: 1px dashed var(--auth-blue);
  border-radius: 12px;
  background: rgba(31, 95, 224, .06);
  color: var(--auth-blue);
  font-family: "Poppins", ui-monospace, monospace;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .18em;
  text-align: center;
  user-select: all;
}

.regActions { display: flex; gap: 10px; align-items: stretch; }
.regActions .authPrimaryButton { flex: 1; margin-top: 0; }

.authGhostButton {
  min-height: calc(48px - var(--auth-squeeze) / 32);
  padding: 0 22px;
  border: 1px solid var(--auth-line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--auth-text-soft);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.authGhostButton:hover,
.authGhostButton:focus-visible { border-color: var(--auth-blue); color: var(--auth-blue); outline: none; }
.authGhostButton:disabled { opacity: .6; cursor: progress; }

.regPanel--done { text-align: center; }
.regPanel--done h2 { margin: 6px 0; font-size: 18px; }
.regPanel--done p { margin: 0 0 14px; color: var(--auth-text-soft); font-size: 12px; }
.regDoneIcon { color: #178a5e; font-size: 40px; }

.regFeedback {
  margin: calc(12px - var(--auth-squeeze) / 40) 0 0;
  padding: calc(10px - var(--auth-squeeze) / 40) 12px;
  border: 1px solid var(--auth-line);
  border-radius: 11px;
  background: var(--auth-surface);
  color: var(--auth-text-soft);
  font-size: 11px;
}

.regFeedback.is-error { border-color: rgba(255, 120, 136, 0.3); color: var(--auth-danger); }
.regFeedback.is-success { border-color: rgba(81, 215, 160, 0.3); color: var(--auth-success); }

@media (max-height: 640px) {
  .authView--register .authAccessPanel { padding-block: 10px; }
  .authView--register .authIdentity { min-height: 56px; }
  .authView--register .authAltAction { min-height: 24px; min-height: calc(1lh + 6px); }
  .authView--register .authIntro { margin-bottom: 8px; }
  .authView--register .authIntro p { font-size: 11px; line-height: 1.4; }
  .authView--register .regSteps { margin-bottom: 8px; }
}

@media (max-width: 560px) {
  .regSteps { gap: 6px; }
  .regStep { justify-content: center; gap: 6px; padding-inline: 6px; font-size: 10px; letter-spacing: .02em; }
  .regStep span { width: 18px; height: 18px; font-size: 10px; }
  .regActions { flex-direction: column-reverse; align-items: stretch; }
  .regCode { font-size: 21px; letter-spacing: .12em; }
}
