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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 10% 20%, #f5f7fb 0, #e9eef8 30%, #e5ecff 60%, #f7f9ff 100%);
  color: #0f172a;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  transition: background 0.3s ease, color 0.3s ease;
}

body[data-theme="dark"] {
  background: linear-gradient(to bottom right, #000000, #2a2a2a);
  color: #ffffff;
}

.auth {
  width: min(440px, 100%);
}

.auth-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 28px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 20px;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body[data-theme="dark"] .auth-card {
  background: #000000;
  border-color: #1a1a1a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.brand {
  font-size: 52px;
  font-weight: 800;
  text-align: center;
  color: var(--brand-color, #5d5fef);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: color 0.5s ease;
}

.brand-logo {
  height: 64px;
  width: auto;
  transform: rotate(0deg);
  transition: transform 0.5s ease;
}

.switcher {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 8px;
  background: #f1f5f9;
  border-radius: 12px;
  transition: background 0.3s ease;
}

body[data-theme="dark"] .switcher {
  background: #1a1a1a;
}

.tab {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  color: #334155;
}

body[data-theme="dark"] .tab {
  color: #ffffff;
}

.tab:hover {
  transform: translateY(-1px);
}

.tab.active {
  background: linear-gradient(135deg, var(--brand-color, #5d5fef), #7c3aed);
  color: #fff;
  box-shadow: 0 8px 20px rgba(93, 95, 239, 0.25);
  transition: background 0.5s ease;
}

.form {
  display: grid;
  gap: 14px;
}

.form.hidden {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 14px;
  color: #334155;
  font-weight: 600;
  transition: color 0.3s ease;
}

body[data-theme="dark"] .field span {
  color: #ffffff;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, color 0.3s ease;
}

body[data-theme="dark"] .field input {
  background: #1a1a1a;
  border-color: #2a2a2a;
  color: #ffffff;
}

body[data-theme="dark"] .field input::placeholder {
  color: #888888;
}

.field input:focus {
  border-color: var(--brand-color, #5d5fef);
  box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.15);
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.primary {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-color, #5d5fef), #7c3aed);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(93, 95, 239, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.5s ease;
}

.primary:hover {
  transform: translateY(-1px);
}

.primary:active {
  transform: translateY(0);
}

.link {
  font-weight: 600;
  color: var(--brand-color, #5d5fef);
  text-decoration: none;
  transition: color 0.5s ease;
}


.link:hover {
  text-decoration: underline;
}

.theme-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1000;
}

.theme-switch {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

.theme-switch:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
}

.theme-switch:active {
  transform: scale(0.95);
}

body[data-theme="dark"] .theme-switch {
  background: #000000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body[data-theme="dark"] .theme-switch:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Мобильные стили */
@media (max-width: 480px) {
  body {
    padding: 16px;
  }

  .auth {
    width: 100%;
  }

  .auth-card {
    padding: 20px;
    border-radius: 16px;
    gap: 16px;
  }

  .brand {
    font-size: 36px;
    gap: 10px;
  }

  .brand-logo {
    height: 48px;
  }

  .switcher {
    gap: 8px;
    padding: 6px;
  }

  .tab {
    padding: 10px 12px;
    font-size: 14px;
  }

  .field input {
    padding: 14px 16px;
    font-size: 16px; /* Предотвращает зум на iOS */
  }

  .primary {
    padding: 14px 20px;
    font-size: 16px;
    min-height: 48px; /* Минимальный размер для тач-интерфейса */
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .link {
    text-align: center;
    font-size: 14px;
    padding: 8px;
  }

  .theme-toggle {
    bottom: 16px;
    left: 16px;
  }

  .theme-switch {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}

/* Стили для очень маленьких экранов */
@media (max-width: 360px) {
  body {
    padding: 12px;
  }

  .auth-card {
    padding: 16px;
    gap: 14px;
  }

  .brand {
    font-size: 32px;
    gap: 8px;
  }

  .brand-logo {
    height: 40px;
  }

  .tab {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* Улучшение для тач-интерфейсов */
@media (hover: none) and (pointer: coarse) {
  .tab:hover {
    transform: none;
  }

  .primary:hover {
    transform: none;
  }

  .theme-switch:hover {
    transform: none;
  }

  .tab:active {
    transform: scale(0.98);
  }

  .primary:active {
    transform: scale(0.98);
  }
}