.avatar-editor {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.avatar-editor-head {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.avatar-editor--compact {
  margin-bottom: 0.25rem;
}

.avatar-editor--compact .avatar-preview {
  width: 72px;
  height: 72px;
  font-size: 1.35rem;
}

.avatar-preview--modal {
  width: 112px;
  height: 112px;
  margin: 0 auto 0.1rem;
}

.avatar-preview {
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(99, 102, 241, 0.65);
  color: var(--text-primary);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Signup loads avatar.css without nav.css — keep preview images sized inside the
   circle. Presets use contain (same rationale as nav.css for pack line art). */
.avatar-preview .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.avatar-preview.avatar-preset-image .avatar-img {
  object-fit: contain;
}

.avatar-preview.avatar-preset-image,
.avatar-btn.avatar-preset-image,
.identity-avatar.avatar-preset-image {
  background: #f3f4f6;
}

.avatar-editor-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.avatar-editor-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}

.avatar-editor-note,
.avatar-status {
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.avatar-status--error { color: var(--error); }
.avatar-status--success { color: var(--success, #34d399); }

.avatar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.avatar-actions--center {
  justify-content: center;
}

.avatar-secondary-btn {
  min-height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.avatar-secondary-btn:hover:not(:disabled) {
  border-color: rgba(99, 102, 241, 0.55);
  color: var(--text-primary);
}

.avatar-secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.avatar-crop-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  padding: 0.75rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
}

.avatar-crop-controls[hidden] { display: none; }

.avatar-crop-controls label {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.avatar-crop-controls input[type="range"] {
  width: 100%;
}

.avatar-crop-img {
  position: absolute;
  max-width: none;
  max-height: none;
  user-select: none;
  pointer-events: none;
}

.avatar-pack-title {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.avatar-pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 0.65rem;
  max-height: 310px;
  overflow: auto;
  padding-right: 0.2rem;
}

.avatar-pack-option {
  width: 100%;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: #f3f4f6;
  overflow: hidden;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.avatar-pack-option img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.avatar-pack-option:hover,
.avatar-pack-option.selected {
  transform: translateY(-1px);
  border-color: var(--accent-base);
  box-shadow: 0 0 0 2px var(--accent-base-dim);
}

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

.avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.avatar-modal[hidden] {
  display: none;
}

.avatar-modal-card {
  width: min(100%, 480px);
  max-height: min(760px, calc(100dvh - 2rem));
  overflow: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--glass-border);
  background: var(--bg-surface-solid, #141417);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
}

.avatar-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
}

.avatar-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.avatar-modal-subtitle {
  margin-top: 0.25rem;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.avatar-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}

.avatar-modal-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.avatar-modal-footer {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  padding-top: 0.2rem;
}

.avatar-modal-footer .btn,
.avatar-modal-footer .btn-primary {
  margin-top: 0;
}

@media (max-width: 380px) {
  .avatar-editor-head {
    align-items: flex-start;
  }

  .avatar-preview {
    width: 82px;
    height: 82px;
  }

  .avatar-pack-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }

  .avatar-pack-option {
    height: 48px;
  }
}
