.profile-modal-overlay{
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.profile-modal-overlay.hidden{
  display: none !important;
}

.profile-modal-overlay.show{
  opacity: 1;
  visibility: visible;
}

.profile-modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 12, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: profileBackdropIn 0.25s ease;
}

@keyframes profileBackdropIn{
  from{
    opacity: 0;
  }
  to{
    opacity: 1;
  }
}

.profile-modal-sheet{
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(92vh, 920px);
  max-height: min(92dvh, 920px);
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--line-accent);
  border-radius: 24px;
  padding: 24px 28px 20px;
  box-shadow:
    var(--shadow),
    0 0 60px var(--accent-glow);
  animation: profileSheetIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
}

@keyframes profileSheetIn{
  from{
    opacity: 0;
    transform: scale(0.94) translateY(20px);
  }
  to{
    opacity: 1;
    transform: none;
  }
}

.profile-modal-close{
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--chrome);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
  transition:
    transform 0.15s ease,
    background 0.2s ease;
}

.profile-modal-close:hover{
  background: var(--chrome-hover);
}

.profile-modal-close:active{
  transform: scale(0.92);
}

.profile-modal-close svg{
  width: 18px;
  height: 18px;
}

.profile-modal-head{
  text-align: center;
  margin: 0 0 20px;
  padding: 4px 36px 0 0;
}

.profile-modal-title{
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text, #f3f1fa);
}

.profile-modal-sub{
  margin: 0;
  color: var(--text-dim, #a7a4ba);
  font-size: 13px;
}

.profile-modal-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.profile-modal-body::-webkit-scrollbar{
  width: 6px;
}

.profile-modal-body::-webkit-scrollbar-thumb{
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.profile-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  box-sizing: border-box;
}

.profile-card-title{
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #f3f1fa);
}

.profile-card-hint{
  margin: 0 0 14px;
  color: var(--text-dim, #a7a4ba);
  font-size: 12.5px;
  line-height: 1.45;
}

.profile-hero{
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 14px;
  align-items: stretch;
}

.profile-id-card{
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 18px;
  text-align: left;
  padding: 20px;
  background:
    radial-gradient(420px 220px at 20% 0%, var(--accent-glow), transparent 60%),
    var(--surface);
  border: 1px solid var(--line-accent);
  min-width: 0;
}

.profile-avatar-wrap{
  position: relative;
  flex-shrink: 0;
  width: 96px;
  height: 96px;
}

.profile-avatar{
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: var(--accent);
  box-shadow:
    0 0 0 4px var(--accent-glow),
    0 0 26px var(--accent-glow);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -0.5px;
  user-select: none;
}

.profile-avatar img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.profile-avatar.has-image img{
  display: block;
}

.profile-avatar.has-image .profile-avatar-initials{
  display: none;
}

.profile-avatar-edit{
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--accent-glow);
  transition: transform 0.15s ease;
}

.profile-avatar-edit:hover{
  transform: scale(1.06);
}

.profile-avatar-edit:active{
  transform: scale(0.94);
}

.profile-avatar-edit svg{
  width: 15px;
  height: 15px;
}

.profile-id-info{
  flex: 1;
  min-width: 0;
}

.profile-id-name{
  font-size: 20px;
  font-weight: 800;
  color: var(--text, #f3f1fa);
  line-height: 1.25;
  overflow-wrap: anywhere;
  margin-bottom: 2px;
}

.profile-id-login{
  font-size: 12px;
  color: var(--text-dim, #a7a4ba);
  font-family: "Monaco", "Consolas", monospace;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.profile-rank-badge{
  display: inline-block;
  max-width: 100%;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  background-image: var(
    --rank-gradient,
    linear-gradient(135deg, #9aa0b5, #6f7488)
  );
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 6px 18px rgba(0, 0, 0, 0.35);
  margin-bottom: 6px;
}

.profile-rank-tagline{
  font-size: 12.5px;
  color: var(--text-dim, #a7a4ba);
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}

.profile-stats-card{
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-stats-card .profile-card-title{
  margin-bottom: 12px;
}

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

.profile-stat{
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  min-width: 0;
}

.profile-stat-value{
  font-size: 20px;
  font-weight: 800;
  color: var(--text, #f3f1fa);
  line-height: 1.1;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.profile-stat-label{
  font-size: 11px;
  color: var(--text-dim, #a7a4ba);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
}

.profile-edit-row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-edit-row input{
  flex: 1 1 220px;
  min-width: 0;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  padding: 0 14px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
}

.profile-edit-row input:focus{
  border-color: var(--accent-2);
}

.profile-btn{
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.2s ease;
  box-shadow: var(--glow, 0 4px 16px rgba(124, 58, 237, 0.4));
  flex-shrink: 0;
}

.profile-btn-primary{
  color: #fff;
  background: var(--accent, #7c3aed);
}

.profile-btn-primary:hover{
  filter: brightness(1.08);
}

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

.profile-btn:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}

.profile-edit-hint{
  margin-top: 8px;
  font-size: 12.5px;
  min-height: 1em;
  color: var(--text-dim, #a7a4ba);
}

.profile-edit-hint.is-error{
  color: #fca5a5;
}

.profile-edit-hint.is-ok{
  color: #86efac;
}

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

.profile-rank-row{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  box-sizing: border-box;
  min-width: 0;
}

.profile-rank-row.is-current{
  border-color: var(--line-violet, rgba(124, 58, 237, 0.45));
  background: rgba(124, 58, 237, 0.1);
}

.profile-rank-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.profile-rank-chip{
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #fff;
  background-image: var(
    --rank-gradient,
    linear-gradient(135deg, #9aa0b5, #6f7488)
  );
  background-size: 100% 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}

.profile-rank-status{
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim, #a7a4ba);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.profile-rank-status.is-active{
  background: var(--green-soft, rgba(34, 197, 94, 0.14));
  color: var(--green, #22c55e);
}

.profile-rank-status.is-locked{
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-faint, #6b6781);
}

.profile-rank-status.is-pending{
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
}

.profile-rank-status.is-buy{
  cursor: pointer;
  border: none;
  font: inherit;
  background: rgba(124, 58, 237, 0.18);
  color: #c4b5fd;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.profile-rank-status.is-buy:hover:not(:disabled){
  background: rgba(124, 58, 237, 0.28);
  color: #ddd6fe;
}

.profile-rank-status.is-buy:disabled{
  opacity: 0.6;
  cursor: wait;
}

.profile-rank-meta{
  min-width: 0;
}

.profile-rank-name{
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #f3f1fa);
  margin-bottom: 4px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.profile-rank-desc{
  font-size: 12px;
  color: var(--text-dim, #a7a4ba);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.profile-rank-row .profile-rank-status.is-buy{
  align-self: stretch;
  padding: 10px 12px;
  font-size: 11px;
}

@media (max-width: 760px){
  .profile-modal-overlay{
    padding: 16px;
  }

  .profile-modal-sheet{
    width: 100%;
    padding: 22px 18px 18px;
  }

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

  .profile-ranks-list{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px){
  .profile-modal-overlay{
    align-items: flex-end;
    padding: 0;
  }

  .profile-modal-sheet{
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    animation: profileSheetInMobile 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes profileSheetInMobile{
    from{
      transform: translateY(100%);
    }
    to{
      transform: none;
    }
  }

  .profile-modal-head{
    padding-right: 28px;
  }

  .profile-modal-title{
    font-size: 20px;
  }

  .profile-card{
    padding: 16px;
  }

  .profile-id-card{
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .profile-id-info{
    width: 100%;
  }

  .profile-edit-row{
    flex-direction: column;
  }

  .profile-edit-row input,
  .profile-btn{
    width: 100%;
  }

  .profile-edit-row input{
    flex: 0 0 auto;
  }
}

.profile-privacy-actions{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.profile-btn-secondary{
  background: var(--chrome);
  border: 1px solid var(--line);
  color: var(--text);
}

.profile-btn-secondary:hover{
  border-color: var(--line-accent);
}

.profile-btn-danger{
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.profile-btn-danger:hover{
  background: rgba(239, 68, 68, 0.2);
}

.profile-privacy-card a{
  color: var(--accent-2);
  text-decoration: none;
}

.profile-privacy-card a:hover{
  text-decoration: underline;
}

.profile-danger-vault{
  margin-top: 18px;
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  padding-top: 10px;
}

.profile-danger-vault-sum{
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  opacity: 0.55;
  user-select: none;
}

.profile-danger-vault-sum::-webkit-details-marker{
  display: none;
}

.profile-danger-vault-sum:hover{
  opacity: 0.85;
  color: var(--text);
}

.profile-danger-vault-body{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--panel) 35%, transparent);
}

.profile-danger-vault-note{
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
}

.profile-danger-inner{
  margin-top: 4px;
}

.profile-danger-inner-sum{
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: color-mix(in srgb, #f87171 70%, var(--text-dim));
  opacity: 0.75;
}

.profile-danger-inner-sum::-webkit-details-marker{
  display: none;
}

.profile-danger-inner-sum:hover{
  opacity: 1;
}

.profile-danger-inner-body{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.profile-danger-inner-body .profile-btn-danger{
  width: auto;
  min-width: 0;
}

.delete-account-modal{
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.delete-account-modal.hidden{
  display: none !important;
}

.delete-account-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 12, 0.75);
  backdrop-filter: blur(10px);
}

.delete-account-sheet{
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--line-accent);
  background: var(--surface-card);
  box-shadow: var(--shadow);
}

.delete-account-title{
  font-size: 20px;
  margin: 0 0 8px;
}

.delete-account-lead{
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 16px;
}

.delete-account-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.delete-account-field input{
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.delete-account-actions{
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.delete-account-actions .profile-btn{
  flex: 1;
}
