@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@100;300;400;500;700;800;900&display=swap');

:root {
  --purple-900: #4a3f6e;
  --purple-700: #6d5cb8;
  --purple-600: #7a68c4;
  --purple-500: #9587d6;
  --purple-300: #bcb0ea;
  --purple-200: #d6cdf5;
  --purple-100: #ede8fb;
  --purple-50:  #f6f3fd;

  --green-300: #a6dcb8;
  --green-200: #c7ead2;
  --green-100: #e0f5e6;

  --ink:    #3d3654;
  --muted:  #948bb0;
  --line:   #e9e4f7;
  --white:  #ffffff;
  --danger: #e2637a;
  --danger-bg: #fdeaee;
  --success: #4fae7c;

  --radius-card:  28px;
  --radius-field: 14px;
  --radius-pill:  999px;

  --shadow-card: 0 20px 50px -12px rgba(109, 92, 184, 0.28), 0 4px 12px rgba(109, 92, 184, 0.08);
  --shadow-btn:  0 10px 24px -6px rgba(109, 92, 184, 0.55);

  --ease-out-back: cubic-bezier(.34, 1.56, .64, 1);
  --ease-smooth: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'M PLUS Rounded 1c', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfaff 0%, #f4f1fc 100%);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------- */
/* Page wrap + background blobs                                           */
/* ---------------------------------------------------------------------- */

.auth-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  overflow: hidden;
}

.blob {
  position: absolute;
  filter: blur(18px);
  z-index: 0;
  pointer-events: none;
}

.blob-green {
  top: -50px;
  left: -70px;
  width: 240px;
  height: 240px;
  background: var(--green-300);
  opacity: .75;
  border-radius: 58% 42% 65% 35% / 45% 60% 40% 55%;
  animation: blob-float-a 9s ease-in-out infinite, blob-morph-a 14s ease-in-out infinite;
}

.blob-purple {
  top: -40px;
  right: -80px;
  width: 280px;
  height: 280px;
  background: var(--purple-200);
  opacity: .8;
  border-radius: 42% 58% 38% 62% / 55% 40% 60% 45%;
  animation: blob-float-b 11s ease-in-out infinite, blob-morph-b 16s ease-in-out infinite;
}

.blob-purple-soft {
  bottom: -90px;
  left: -60px;
  width: 210px;
  height: 210px;
  background: var(--purple-100);
  opacity: .65;
  border-radius: 50% 50% 60% 40% / 40% 55% 45% 60%;
  animation: blob-float-a 13s ease-in-out infinite reverse, blob-morph-a 18s ease-in-out infinite;
}

@keyframes blob-float-a {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  50%      { transform: translate(10px, 14px) rotate(6deg) scale(1.04); }
}

@keyframes blob-float-b {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  50%      { transform: translate(-12px, 10px) rotate(-5deg) scale(1.03); }
}

@keyframes blob-morph-a {
  0%, 100% { border-radius: 58% 42% 65% 35% / 45% 60% 40% 55%; }
  50%      { border-radius: 40% 60% 45% 55% / 60% 45% 55% 40%; }
}

@keyframes blob-morph-b {
  0%, 100% { border-radius: 42% 58% 38% 62% / 55% 40% 60% 45%; }
  50%      { border-radius: 60% 40% 55% 45% / 40% 60% 35% 65%; }
}

@media (prefers-reduced-motion: reduce) {
  .blob-green, .blob-purple, .blob-purple-soft { animation: none; }
}

/* ---------------------------------------------------------------------- */
/* Card                                                                    */
/* ---------------------------------------------------------------------- */

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 56px 32px 32px;
  animation: card-enter .6s var(--ease-out-back) both;
}

@keyframes card-enter {
  0%   { opacity: 0; transform: translateY(28px) scale(.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* directional transitions used when hopping between login / register */
.auth-card.card-exit-left  { animation: card-exit-left .28s var(--ease-smooth) forwards; }
.auth-card.card-exit-right { animation: card-exit-right .28s var(--ease-smooth) forwards; }
.auth-card.card-enter-left  { animation: card-enter-left .5s var(--ease-out-back) both; }
.auth-card.card-enter-right { animation: card-enter-right .5s var(--ease-out-back) both; }

@keyframes card-exit-left  { to { opacity: 0; transform: translateX(-36px) scale(.97); } }
@keyframes card-exit-right { to { opacity: 0; transform: translateX(36px) scale(.97); } }
@keyframes card-enter-left  { 0% { opacity: 0; transform: translateX(-36px) scale(.97); } 100% { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes card-enter-right { 0% { opacity: 0; transform: translateX(36px) scale(.97); } 100% { opacity: 1; transform: translateX(0) scale(1); } }

/* ---------------------------------------------------------------------- */
/* Cat mascot                                                              */
/* ---------------------------------------------------------------------- */

.mascot {
  position: absolute;
  top: -65px;
  left: 50%;
  transform: translateX(-50%);
  width: 108px;
  height: auto;
  z-index: 2;
  animation: cat-bob 4.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 10px rgba(109, 92, 184, .18));
}

@keyframes cat-bob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
  50%      { transform: translateX(-50%) translateY(-6px) rotate(-1.5deg); }
}

.mascot .cat-eye {
  transform-origin: center;
  animation: cat-blink 5.5s ease-in-out infinite;
}
.mascot .cat-eye.right { animation-delay: .08s; }

@keyframes cat-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(.15); }
}

@media (prefers-reduced-motion: reduce) {
  .mascot, .mascot .cat-eye { animation: none; }
}

/* ---------------------------------------------------------------------- */
/* Segmented tabs (Вход / Регистрация)                                    */
/* ---------------------------------------------------------------------- */

.tabs {
  position: relative;
  display: flex;
  background: var(--purple-50);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 26px;
}

.tab-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: var(--purple-100);
  border-radius: var(--radius-pill);
  box-shadow: 0 3px 10px rgba(109, 92, 184, .16);
  transition: left .38s var(--ease-out-back), width .38s var(--ease-out-back);
}

.auth-card.page-register .tab-indicator {
  left: calc(50% + 0px);
}

.tab {
  position: relative;
  z-index: 1;
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color .25s var(--ease-smooth);
}

.tab.active {
  color: var(--purple-700);
}

.tab:hover:not(.active) {
  color: var(--purple-500);
}

.tab:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------- */
/* Heading                                                                 */
/* ---------------------------------------------------------------------- */

h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--purple-900);
}

.sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}

.sub strong { color: var(--ink); }

/* ---------------------------------------------------------------------- */
/* Form fields                                                            */
/* ---------------------------------------------------------------------- */

.field {
  margin-bottom: 16px;
  animation: field-in .5s var(--ease-smooth) both;
}

.field:nth-of-type(1) { animation-delay: .05s; }
.field:nth-of-type(2) { animation-delay: .1s; }
.field:nth-of-type(3) { animation-delay: .15s; }

@keyframes field-in {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 7px;
}

.input-wrap { position: relative; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"] {
  width: 100%;
  border: 1.5px solid transparent;
  background: var(--purple-50);
  border-radius: var(--radius-field);
  padding: 13px 16px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  transition: border-color .22s var(--ease-smooth), background .22s var(--ease-smooth), box-shadow .22s var(--ease-smooth);
}

.field input.has-toggle { padding-right: 44px; }

.field input::placeholder { color: var(--muted); }

.field input:hover {
  background: var(--purple-100);
}

.field input:focus {
  outline: none;
  border-color: var(--purple-300);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--purple-100);
}

.field.has-error input {
  border-color: var(--danger);
  background: var(--danger-bg);
  animation: field-shake .38s var(--ease-smooth);
}

@keyframes field-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}

.field-error {
  min-height: 0;
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 6px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s var(--ease-smooth), transform .2s var(--ease-smooth);
}

.field-error:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

.toggle-pass {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  border-radius: 50%;
  transition: color .2s var(--ease-smooth), background .2s var(--ease-smooth);
}

.toggle-pass:hover { color: var(--purple-600); background: var(--purple-100); }
.toggle-pass svg { width: 20px; height: 20px; }
.toggle-pass .eye-off { display: none; }
.toggle-pass.is-visible .eye-on  { display: none; }
.toggle-pass.is-visible .eye-off { display: block; }

/* ---------------------------------------------------------------------- */
/* Checkbox row                                                           */
/* ---------------------------------------------------------------------- */

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 4px 0 18px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  animation: field-in .5s var(--ease-smooth) both;
  animation-delay: .2s;
}

.checkbox-row a {
  color: var(--purple-600);
  font-weight: 700;
  text-decoration: none;
}
.checkbox-row a:hover { text-decoration: underline; }

.checkbox-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  min-width: 19px;
  margin-top: 1px;
  border: 2px solid var(--purple-300);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: background .2s var(--ease-smooth), border-color .2s var(--ease-smooth), transform .12s var(--ease-smooth);
}

.checkbox-row input[type="checkbox"]:active { transform: scale(.9); }

.checkbox-row input[type="checkbox"]:checked {
  background: var(--purple-600);
  border-color: var(--purple-600);
}

.checkbox-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: check-pop .22s var(--ease-out-back);
}

@keyframes check-pop {
  0%   { transform: rotate(45deg) scale(0); }
  100% { transform: rotate(45deg) scale(1); }
}

.checkbox-row input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 2px;
}

.checkbox-row.has-error {
  color: var(--danger);
  animation: field-shake .38s var(--ease-smooth);
}

.checkbox-row.has-error input[type="checkbox"] {
  border-color: var(--danger);
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform .16s var(--ease-out-back), box-shadow .22s var(--ease-smooth), opacity .2s var(--ease-smooth), background .22s var(--ease-smooth);
}

.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple-600), var(--purple-700));
  color: var(--white);
  padding: 14px 20px;
  box-shadow: var(--shadow-btn);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,.35), transparent 60%);
  opacity: 0;
  transition: opacity .3s;
}

.btn-primary:hover::after { opacity: 1; }

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -6px rgba(109, 92, 184, .6);
}

.btn-primary:active { transform: translateY(0) scale(.98); }

.btn-primary:disabled {
  opacity: .72;
  cursor: default;
  transform: none;
}

.btn-primary:disabled::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-vk {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--purple-100);
  color: var(--purple-700);
  padding: 13px 18px;
  margin-top: 12px;
  font-weight: 800;
}

.btn-vk svg { width: 20px; height: 20px; }

.btn-vk:hover {
  background: var(--purple-200);
  transform: translateY(-2px);
}
.btn-vk:active { transform: translateY(0) scale(.98); }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  color: var(--muted);
  font-size: 12.5px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------------------------------------------------------------------- */
/* Links / footnotes                                                      */
/* ---------------------------------------------------------------------- */

.auth-links {
  text-align: center;
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--muted);
}

.auth-links a, .forgot-link {
  color: var(--purple-600);
  font-weight: 700;
  text-decoration: none;
}
.auth-links a:hover, .forgot-link:hover { text-decoration: underline; }

.forgot-row {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 18px;
}
.forgot-row .forgot-link { font-size: 13px; }

.agree-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 16px;
}
.agree-note a { color: var(--purple-600); font-weight: 700; text-decoration: none; }
.agree-note a:hover { text-decoration: underline; }

.resend-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--purple-600);
  cursor: pointer;
  text-decoration: none;
}
.resend-link:hover { text-decoration: underline; }
.resend-link:disabled {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--purple-700);
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  background: var(--purple-100);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  width: 100%;
  justify-content: center;
  transition: background .2s var(--ease-smooth), transform .16s var(--ease-out-back);
}
.back-link:hover { background: var(--purple-200); transform: translateY(-1px); }
.back-link svg { width: 16px; height: 16px; transition: transform .2s var(--ease-smooth); }
.back-link:hover svg { transform: translateX(-3px); }

/* ---------------------------------------------------------------------- */
/* Form message (success / error banner)                                  */
/* ---------------------------------------------------------------------- */

.form-message {
  display: none;
  font-size: 13.5px;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.form-message.show {
  display: block;
  animation: msg-in .3s var(--ease-out-back);
}

.form-message.is-error   { background: var(--danger-bg); color: var(--danger); }
.form-message.is-success { background: var(--green-100); color: #2f8f5c; }

@keyframes msg-in {
  0%   { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------------- */
/* Verification / reset — code boxes                                      */
/* ---------------------------------------------------------------------- */

.code-title {
  text-align: center;
  margin-bottom: 26px;
}
.code-title h1 { font-size: 20px; }
.code-title .sub { margin-bottom: 0; }
.code-title .phone { color: var(--purple-700); font-weight: 800; }

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  animation: field-in .5s var(--ease-smooth) both .05s;
}

.code-inputs input {
  width: 44px;
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  border: 1.5px solid transparent;
  background: var(--purple-50);
  border-radius: 12px;
  color: var(--ink);
  transition: border-color .2s var(--ease-smooth), background .2s var(--ease-smooth), box-shadow .2s var(--ease-smooth), transform .15s var(--ease-out-back);
}

.code-inputs input:hover { background: var(--purple-100); }

.code-inputs input:focus {
  outline: none;
  border-color: var(--purple-300);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--purple-100);
  transform: translateY(-2px);
}

.code-inputs input.filled { border-color: var(--purple-200); background: var(--white); }

.code-inputs.has-error input {
  border-color: var(--danger);
  background: var(--danger-bg);
  animation: field-shake .38s var(--ease-smooth);
}

.timer-row {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}

.timer-row .timer-count { font-weight: 800; color: var(--purple-700); }

.resend-row {
  text-align: center;
  margin-bottom: 22px;
  font-size: 13.5px;
}

/* ---------------------------------------------------------------------- */
/* Paw decoration                                                         */
/* ---------------------------------------------------------------------- */

.paw-deco {
  position: absolute;
  bottom: -14px;
  left: -14px;
  width: 54px;
  height: 54px;
  z-index: 0;
  opacity: .85;
  animation: paw-wiggle 5s ease-in-out infinite;
  transform-origin: 70% 70%;
}

@keyframes paw-wiggle {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(-8deg); }
}

@media (prefers-reduced-motion: reduce) {
  .paw-deco { animation: none; }
}

/* ---------------------------------------------------------------------- */
/* Mobile                                                                  */
/* ---------------------------------------------------------------------- */

@media (max-width: 480px) {
  .auth-wrap { padding: 32px 16px; }

  .auth-card {
    max-width: 100%;
    padding: 52px 22px 26px;
    border-radius: 24px;
  }

  .mascot { width: 88px; top: -38px; }

  h1 { font-size: 20px; }
  .sub { font-size: 13.5px; }

  .blob-green   { width: 150px; height: 150px; top: -30px; left: -40px; }
  .blob-purple  { width: 180px; height: 180px; top: -20px; right: -50px; }
  .blob-purple-soft { width: 140px; height: 140px; }

  .code-inputs { gap: 7px; }
  .code-inputs input { width: 38px; height: 48px; font-size: 19px; }

  .paw-deco { width: 42px; height: 42px; bottom: -10px; left: -10px; }
}

@media (max-width: 340px) {
  .code-inputs { gap: 5px; }
  .code-inputs input { width: 32px; height: 44px; font-size: 17px; }
}

.card-spots {
  position: absolute;
  inset: 0;                 
  border-radius: inherit;   
  overflow: hidden;        
  z-index: 0;
  pointer-events: none;
}

.spot {
  position: absolute;
  width: 160px;             
  height: 160px;
}

.spot-green {
  top: -45px;
  left: -45px;               
}

.spot-purple {
  right: -55px;
}

.spot-green-down {
  bottom: -30px;
  right: -55px;             
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--purple-50);
  z-index: 3;
  transition: color .2s var(--ease-smooth), background .2s var(--ease-smooth), transform .16s var(--ease-out-back);
}

.close-btn:hover {
  color: var(--purple-700);
  background: var(--purple-100);
  transform: scale(1.05);
}

.close-btn:active {
  transform: scale(.92);
}

.close-btn:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 2px;
}