/* 头像裁剪上传 · 微信/QQ 风格全屏弹层 */

.avatar-crop-open {
  overflow: hidden;
}

.avatar-crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: color-mix(in srgb, #0a0c10 42%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  animation: avatarCropFadeIn 0.28s var(--ease-out, ease-out) both;
}

.avatar-crop-overlay[hidden] {
  display: none !important;
}

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

.avatar-crop-sheet {
  width: min(100%, 480px);
  max-height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px -12px rgba(0, 0, 0, 0.22);
  animation: avatarCropSlideUp 0.34s cubic-bezier(0.32, 0.72, 0, 1) both;
}

@media (min-width: 520px) {
  .avatar-crop-overlay {
    align-items: center;
    padding: 24px;
  }
  .avatar-crop-sheet {
    border-radius: 20px;
    box-shadow: var(--shadow-lg, 0 20px 50px -20px rgba(0, 0, 0, 0.28));
  }
}

@keyframes avatarCropSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar-crop-head {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-light);
}

.avatar-crop-head__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  letter-spacing: -0.02em;
}

.avatar-crop-head__btn {
  border: none;
  background: none;
  padding: 8px 4px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: color var(--duration-fast, 0.15s), background var(--duration-fast, 0.15s);
}

.avatar-crop-head__btn:hover {
  color: var(--text);
  background: var(--bg);
}

.avatar-crop-head__btn--primary {
  justify-self: end;
  color: var(--primary);
}

.avatar-crop-head__btn--primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.avatar-crop-stage {
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar-crop-viewport {
  position: relative;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  overflow: hidden;
  background: #111;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--border) 80%, transparent),
    0 12px 32px -16px rgba(0, 0, 0, 0.35);
  touch-action: none;
  cursor: grab;
}

.avatar-crop-viewport:active {
  cursor: grabbing;
}

.avatar-crop-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.avatar-crop-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.avatar-crop-tip {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.5;
}

.avatar-crop-zoom {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 300px);
}

.avatar-crop-zoom__icon {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-tertiary);
  user-select: none;
  width: 20px;
  text-align: center;
}

.avatar-crop-zoom__range {
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, var(--bg));
  outline: none;
}

.avatar-crop-zoom__range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.avatar-crop-zoom__range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.avatar-crop-foot {
  padding: 4px 20px 20px;
  display: flex;
  justify-content: center;
}

.avatar-crop-foot__remove {
  border: none;
  background: none;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--danger, #c0392b);
  cursor: pointer;
  border-radius: var(--radius-full, 999px);
  transition: background var(--duration-fast, 0.15s);
}

.avatar-crop-foot__remove:hover {
  background: color-mix(in srgb, var(--danger, #c0392b) 10%, transparent);
}

/* 微信/QQ 式：字母层常驻，照片叠在上方，加载中永不空白 */
.user-avatar {
  position: relative;
}

.user-avatar__letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  pointer-events: none;
}

.user-avatar__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.user-avatar__img[hidden] {
  display: none !important;
}

.user-avatar--photo {
  padding: 0 !important;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 88%, var(--primary-light));
}

.user-avatar--photo .user-avatar__letter {
  visibility: hidden;
}

.user-avatar--photo .user-avatar__img:not([hidden]) {
  display: block;
}

.settings-profile-avatar.user-avatar--photo {
  background: var(--bg);
}

.profile-studio__avatar-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.34, 1.35, 0.64, 1);
}

.profile-studio__avatar-btn:hover {
  transform: scale(1.02);
}

.profile-studio__avatar-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.profile-studio__avatar-badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid color-mix(in srgb, var(--primary) 35%, var(--surface));
  color: var(--primary);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transition: transform 0.2s var(--ease-spring, ease), background 0.2s;
}

.profile-studio__avatar-btn:hover .profile-studio__avatar-badge {
  transform: scale(1.06);
  background: var(--primary-light);
}

.profile-studio__avatar-hint {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.profile-studio__avatar-reset {
  margin: 2px 0 0;
  padding: 6px 12px;
  border: none;
  background: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-full, 999px);
  transition: color 0.15s, background 0.15s;
}

.profile-studio__avatar-reset:hover {
  color: var(--danger, #c0392b);
  background: color-mix(in srgb, var(--danger, #c0392b) 8%, transparent);
}

.profile-studio__avatar-reset[hidden] {
  display: none !important;
}

.profile-studio__meter-core .user-avatar--photo.user-avatar--profile-lg {
  font-size: 0;
  padding: 0 !important;
  background: var(--bg);
}

/* 头像操作 · 微信风格底部菜单 */
.avatar-action-open {
  overflow: hidden;
}

.avatar-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 1190;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 12px max(12px, env(safe-area-inset-bottom, 0px));
}

.avatar-action-sheet[hidden] {
  display: none !important;
}

.avatar-action-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, #0a0c10 38%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: avatarCropFadeIn 0.22s ease-out both;
}

.avatar-action-sheet__panel {
  position: relative;
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: avatarCropSlideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.avatar-action-sheet__group {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px -12px rgba(0, 0, 0, 0.2);
}

.avatar-action-sheet__item {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s;
}

.avatar-action-sheet__item:last-child {
  border-bottom: none;
}

.avatar-action-sheet__item:hover {
  background: var(--bg);
}

.avatar-action-sheet__item--danger {
  color: var(--danger, #c0392b);
}

.avatar-action-sheet__cancel {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--surface);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 20px -10px rgba(0, 0, 0, 0.15);
  transition: background 0.15s;
}

.avatar-action-sheet__cancel:hover {
  background: var(--bg);
}
