/* Evening palette normalized */
html.avatar-editor-open,
body.avatar-editor-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.avatar-crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow: auto;
  background: var(--ui-solid);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.avatar-crop-dialog {
  width: min(500px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--ui-line);
  border-radius: 28px;
  color: var(--ui-text);
  background: var(--ui-solid);
  box-shadow: 0 28px 90px rgba(15, 8, 35, .35);
}

.avatar-crop-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.avatar-crop-header span {
  color: var(--ui-tint-text);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.avatar-crop-header h2 {
  margin: 5px 0 0;
  color: var(--ui-text);
  font-size: clamp(21px, 5vw, 28px);
  line-height: 1.08;
}

.avatar-crop-close {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  color: var(--ui-muted);
  background: var(--ui-solid);
  cursor: pointer;
  font: 400 27px/1 sans-serif;
}

.avatar-crop-intro {
  margin: 14px 0 18px;
  color: var(--ui-muted);
  font-size: 14px;
  line-height: 1.5;
}

.avatar-crop-stage {
  position: relative;
  width: min(330px, calc(100vw - 80px));
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ui-solid);
  box-shadow: 0 0 0 8px #f0ebf8, 0 16px 35px rgba(62, 37, 113, .2);
  touch-action: none;
  user-select: none;
}

.avatar-crop-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: grab;
  outline: none;
  touch-action: none;
}

.avatar-crop-canvas.is-dragging {
  cursor: grabbing;
}

.avatar-crop-canvas:focus-visible {
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .85);
}

.avatar-crop-ring {
  position: absolute;
  inset: 3px;
  pointer-events: none;
  border: 2px solid var(--ui-line);
  border-radius: 50%;
  box-shadow: inset 0 0 35px rgba(24, 13, 52, .2);
}

.avatar-crop-drag-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--ui-text);
  background: var(--ui-solid);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .03em;
}

.avatar-crop-zoom {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  color: var(--ui-muted);
  font-size: 14px;
  font-weight: 650;
}

.avatar-crop-zoom input {
  width: 100%;
  accent-color: #8058db;
  cursor: pointer;
}

.avatar-crop-zoom output {
  text-align: right;
  color: var(--ui-tint-text);
  font-variant-numeric: tabular-nums;
}

.avatar-crop-quality {
  margin: 12px 0 0;
  color: var(--ui-muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.avatar-crop-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 9px;
  margin-top: 20px;
}

.avatar-crop-actions button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--ui-line);
  border-radius: 13px;
  color: var(--ui-muted);
  background: var(--ui-solid);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.avatar-crop-actions .avatar-crop-save {
  border-color: var(--ui-line);
  color: var(--ui-text);
  background: var(--ui-solid);
}

.avatar-crop-actions .avatar-crop-reset {
  color: var(--ui-tint-text);
  background: var(--ui-solid);
}

.avatar-crop-actions button:disabled {
  opacity: .6;
  cursor: wait;
}

@media (max-width: 520px) {
  .avatar-crop-overlay {
    place-items: end center;
    padding: 0;
  }

  .avatar-crop-dialog {
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top));
    padding: 20px 18px max(20px, env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
  }

  .avatar-crop-stage {
    width: min(310px, calc(100vw - 68px));
  }

  .avatar-crop-actions {
    grid-template-columns: 1fr 1fr;
  }

  .avatar-crop-actions span {
    display: none;
  }

  .avatar-crop-actions .avatar-crop-reset,
  .avatar-crop-actions .avatar-crop-cancel {
    grid-row: 1;
  }

  .avatar-crop-actions .avatar-crop-save {
    grid-column: 1 / -1;
  }
}

@media (max-height: 700px) {
  .avatar-crop-dialog {
    padding-top: 16px;
  }

  .avatar-crop-intro {
    margin: 9px 0 13px;
  }

  .avatar-crop-stage {
    width: min(250px, calc(100vw - 76px));
  }

  .avatar-crop-zoom {
    margin-top: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-crop-overlay,
  .avatar-crop-dialog {
    scroll-behavior: auto;
  }
}
