* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter,
    Arial,
    Helvetica,
    sans-serif;
  color: #f8fafc;
  background:
    radial-gradient(
      circle at top left,
      rgba(124, 58, 237, 0.16),
      transparent 35%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(236, 72, 153, 0.12),
      transparent 35%
    ),
    #050513;
}

body.auth-checking {
  visibility: hidden;
}

body.auth-allowed {
  visibility: visible;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.profile-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 70px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 22px;
  color: #9ec5ff;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover {
  color: #fde047;
}

.profile-card {
  padding: 36px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 30px;
  background:
    linear-gradient(
      145deg,
      rgba(25, 25, 45, 0.96),
      rgba(15, 19, 36, 0.96)
    );
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.38);
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 28px;
  padding-bottom: 30px;
  margin-bottom: 30px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.profile-photo-area {
  display: flex;
  align-items: center;
  gap: 18px;
}

.profile-photo-wrapper {
  width: 128px;
  height: 128px;
  flex: 0 0 128px;
  overflow: hidden;
  border: 3px solid rgba(139, 92, 246, 0.55);
  border-radius: 36px;
  background:
    linear-gradient(
      135deg,
      #7c3aed,
      #3b82f6
    );
  box-shadow:
    0 18px 45px rgba(99, 102, 241, 0.3);
}

.profile-photo,
.profile-initial {
  width: 100%;
  height: 100%;
}

.profile-photo {
  display: block;
  object-fit: cover;
}

.profile-initial {
  display: grid;
  place-items: center;
  color: white;
  font-size: 48px;
  font-weight: 900;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.photo-upload-btn,
.delete-photo-btn {
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 13px;
  font-weight: 900;
}

.photo-upload-btn {
  border: none;
  color: white;
  background:
    linear-gradient(
      135deg,
      #7c3aed,
      #ec4899
    );
}

.delete-photo-btn {
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.delete-photo-btn:hover {
  background: rgba(239, 68, 68, 0.16);
}

.profile-identity h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 42px);
}

.profile-identity > p {
  margin: 5px 0;
  color: #cbd5e1;
}

.profile-email {
  color: #94a3b8 !important;
}

.profile-form {
  display: grid;
  gap: 22px;
}

.profile-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-group {
  position: relative;
  display: grid;
  gap: 9px;
}

.form-group label {
  color: #bfdbfe;
  font-size: 14px;
  font-weight: 900;
}

.form-group input,
.form-group textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.16);
  outline: none;
  border-radius: 17px;
  padding: 15px 17px;
  color: white;
  background: rgba(10, 15, 33, 0.85);
  transition: 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: rgba(139, 92, 246, 0.8);
  box-shadow:
    0 0 0 4px rgba(139, 92, 246, 0.12);
}

.form-group textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.bio-counter {
  justify-self: end;
  color: #64748b;
  font-size: 12px;
}

.selected-photo-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(139, 92, 246, 0.26);
  border-radius: 18px;
  padding: 12px;
  background: rgba(139, 92, 246, 0.08);
}

.selected-photo-preview img {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  object-fit: cover;
}

.selected-photo-preview div {
  min-width: 0;
  flex: 1;
}

.selected-photo-preview strong {
  display: block;
  margin-bottom: 5px;
}

.selected-photo-preview p {
  margin: 0;
  overflow: hidden;
  color: #94a3b8;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-photo-preview button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 11px;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
}

.save-profile-btn {
  border: none;
  border-radius: 17px;
  padding: 15px 20px;
  color: white;
  font-weight: 900;
  background:
    linear-gradient(
      90deg,
      #7c3aed,
      #ec4899
    );
  box-shadow:
    0 15px 35px rgba(139, 92, 246, 0.24);
}

.save-profile-btn:hover {
  transform: translateY(-2px);
}

.save-profile-btn:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.profile-message {
  min-height: 22px;
  margin: 0;
  text-align: center;
  font-weight: 800;
}

.profile-message.success {
  color: #86efac;
}

.profile-message.error {
  color: #fca5a5;
}

.profile-stats {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.stat-card {
  display: grid;
  place-items: center;
  min-height: 132px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 24px;
  padding: 22px;
  text-align: center;
  background:
    linear-gradient(
      145deg,
      rgba(25, 25, 45, 0.94),
      rgba(15, 19, 36, 0.94)
    );
}

.stat-card strong {
  color: white;
  font-size: 34px;
}

.stat-card span {
  color: #bfdbfe;
  font-size: 15px;
}

@media (max-width: 760px) {
  .profile-card {
    padding: 24px;
  }

  .profile-top,
  .profile-photo-area {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-grid,
  .profile-stats {
    grid-template-columns: 1fr;
  }

  .profile-photo-wrapper {
    width: 112px;
    height: 112px;
    flex-basis: 112px;
  }
}

.profile-message:empty {
  display: none;
}

.profile-message {
  margin-top: 16px;
  text-align: center;
}

.profile-message.error {
  color: #ff9b9b;
}