.profile-avatar-upload__row {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.profile-avatar-upload__pick {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  padding: 0;
  overflow: hidden;
  border: 1px dashed var(--border-hover);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 28px;
  cursor: pointer;
}

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

/* Draw the plus around its geometric center, independent of the font baseline. */
.profile-avatar-upload__pick > span {
  position: relative;
  width: 24px;
  height: 24px;
  font-size: 0;
}

.profile-avatar-upload__pick > span::before,
.profile-avatar-upload__pick > span::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 1px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.profile-avatar-upload__pick > span::before {
  width: 18px;
  height: 1.8px;
}

.profile-avatar-upload__pick > span::after {
  width: 1.8px;
  height: 18px;
}

.profile-avatar-upload__pick:focus-visible,
.profile-avatar-upload__action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.profile-avatar-upload__pick:disabled,
.profile-avatar-upload__action:disabled {
  cursor: default;
  opacity: 0.6;
}

.profile-avatar-upload__text {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.profile-avatar-upload__text .form-hint {
  margin: 0;
}

.profile-avatar-upload__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0 16px;
}

.profile-avatar-upload__action {
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.profile-avatar-upload__error {
  color: var(--danger);
  text-align: left;
}

.profile-avatar-revision {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-avatar-crop {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 20px;
  overflow-y: auto;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text-primary);
}

.profile-avatar-crop::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.profile-avatar-crop__title {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.3;
}

.profile-avatar-crop__canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  margin: 16px 0;
  border-radius: var(--radius-badge);
  background: var(--bg);
  cursor: grab;
  touch-action: none;
}

.profile-avatar-crop__canvas:active {
  cursor: grabbing;
}

.profile-avatar-crop__controls {
  display: grid;
  gap: 8px;
}

.profile-avatar-crop__controls label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-avatar-crop__controls input {
  width: 100%;
  min-height: 32px;
  margin: 0;
  accent-color: var(--accent);
}

.profile-avatar-crop__actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.profile-avatar-crop__actions .btn {
  min-width: 0;
  flex: 1;
  padding-inline: 10px;
}

/* Only profile editors use these gallery rules; listing editors are unchanged. */
.profile-gallery {
  min-width: 0;
}

.profile-gallery .photo-previews,
.profile-gallery.account-card-photos {
  display: flex;
  flex-flow: row nowrap;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.profile-gallery .photo-preview,
.profile-gallery .account-card-photo {
  flex: 0 0 80px;
  width: 80px;
  min-width: 0;
  scroll-snap-align: start;
}

.profile-gallery .photo-preview {
  height: 100px;
  aspect-ratio: 4 / 5;
}

.profile-gallery #photo-previews .photo-preview {
  flex-basis: 80px !important;
  width: 80px !important;
  height: 100px !important;
}

.profile-gallery .account-card-photo .admin-card-photos__item {
  width: 80px;
  height: 100px;
  aspect-ratio: 4 / 5;
}

.profile-gallery .account-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 480px) {
  .profile-avatar-crop {
    padding: 16px;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  }
}
