/* ============ Base ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --accent-3: #ff6ec7;
  --danger: #ff4d6d;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.6);
  --glass-bg: rgba(20, 16, 48, 0.55);
  --glass-border: rgba(255, 255, 255, 0.14);
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-x: hidden;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  background-size: 400% 400%;
  animation: gradientShift 16s ease infinite;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============ Animated background ============ */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite;
}

.orb-1 {
  width: 480px;
  height: 480px;
  top: -120px;
  left: -120px;
  background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%);
}

.orb-2 {
  width: 420px;
  height: 420px;
  bottom: -120px;
  right: -100px;
  background: radial-gradient(circle at 70% 70%, var(--accent-2), transparent 70%);
  animation-delay: -6s;
}

.orb-3 {
  width: 320px;
  height: 320px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%, var(--accent-3), transparent 70%);
  animation-delay: -12s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.08); }
  66%      { transform: translate(-30px, 25px) scale(0.95); }
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 75%);
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ============ Card ============ */
.card-wrap {
  position: relative;
  z-index: 2;
  perspective: 1200px;
  width: 100%;
  max-width: 420px;
}

.card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 42px 36px 36px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: cardIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-style: preserve-3d;
  will-change: transform;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.6), rgba(0, 212, 255, 0.4), rgba(255, 110, 199, 0.5));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
  pointer-events: none;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ============ Brand ============ */
.brand {
  text-align: center;
  margin-bottom: 30px;
}

.logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 28px rgba(124, 92, 255, 0.45);
  animation: floatLogo 5s ease-in-out infinite;
}

.logo svg {
  width: 32px;
  height: 32px;
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-6px) rotate(2deg); }
}

.brand h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.brand p {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}

/* ============ Fields ============ */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.85);
}

.input-wrap {
  position: relative;
}

.input-wrap .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.3s;
}

.input-wrap input {
  width: 100%;
  padding: 14px 44px 14px 44px;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.input-wrap input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.input-wrap input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.22);
}

.input-wrap input:focus ~ .icon,
.input-wrap input:focus + .icon {
  color: var(--accent);
}

.field.error .input-wrap input {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 77, 109, 0.16);
}

.error-msg {
  display: none;
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--danger);
  animation: fadeSlide 0.3s ease;
}

.field.error .error-msg {
  display: block;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Password toggle */
.toggle-pass {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.3s, background 0.3s;
}

.toggle-pass:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.toggle-pass .eye {
  width: 19px;
  height: 19px;
  transition: opacity 0.25s, transform 0.25s;
}

.toggle-pass .eye-closed {
  position: absolute;
  opacity: 0;
  transform: rotate(-45deg) scale(0.6);
}

.toggle-pass.showing .eye-open {
  opacity: 0;
  transform: scale(0.6);
}

.toggle-pass.showing .eye-closed {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* ============ Row ============ */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 22px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  display: none;
}

.slider {
  position: relative;
  width: 38px;
  height: 21px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 99px;
  transition: background 0.3s;
  flex-shrink: 0;
}

.slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.switch input:checked + .slider::after {
  transform: translateX(17px);
}

.switch-label {
  font-size: 13.5px;
  color: var(--muted);
}

.link {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.3s, text-shadow 0.3s;
}

.link:hover {
  color: #fff;
  text-shadow: 0 0 12px rgba(0, 212, 255, 0.6);
}

/* ============ Button ============ */
.btn {
  position: relative;
  width: 100%;
  padding: 15px;
  font-size: 15.5px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-size: 200% auto;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: background-position 0.4s, transform 0.15s, box-shadow 0.4s;
  box-shadow: 0 10px 26px rgba(124, 92, 255, 0.4);
}

.btn:hover {
  background-position: right center;
  box-shadow: 0 14px 34px rgba(124, 92, 255, 0.55);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn.loading {
  pointer-events: none;
  opacity: 0.85;
}

.loading-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.loading .loading-spinner {
  display: block;
}

.btn.loading .btn-text {
  visibility: hidden;
}

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

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  animation: rippleAnim 0.65s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ============ Divider & social ============ */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0 20px;
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.social {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, transform 0.15s;
}

.social-btn svg {
  width: 18px;
  height: 18px;
}

.social-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.social-btn:active {
  transform: scale(0.97);
}

.signup {
  margin-top: 24px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 80px);
  z-index: 10;
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: rgba(30, 24, 60, 0.92);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
  pointer-events: none;
}

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

.toast.success { border-color: rgba(0, 212, 255, 0.5); }
.toast.error   { border-color: rgba(255, 77, 109, 0.5); }

/* ============ Responsive ============ */
@media (max-width: 480px) {
  .card { padding: 34px 22px 28px; }
  .social { grid-template-columns: 1fr; }
}