.photo-crop-editor{
  position: fixed;
  z-index: 2147483600;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(8,7,10,.82);
  color: #21141b;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.photo-crop-editor__card{
  width: min(760px, 100%);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.4);
}

.photo-crop-editor__title{
  margin: 0;
  color: #4b2435;
  font-size: 20px;
}

.photo-crop-editor__hint,
.photo-crop-editor__size,
.photo-crop-editor__message{
  margin: 7px 0 0;
  font-size: 13px;
}

.photo-crop-editor__hint,
.photo-crop-editor__size{
  color: #65525b;
}

.photo-crop-editor__message{
  min-height: 18px;
  color: #b42345;
  font-weight: 750;
}

.photo-crop-editor__stage{
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  overflow: hidden;
  border-radius: 12px;
  background: #171217;
  line-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.photo-crop-editor__canvas{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(56dvh, 560px);
  display: block;
}

.photo-crop-editor__crop-box{
  position: absolute;
  border: 2px solid #ff416c;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.58);
}

.photo-crop-editor__crop-box::before,
.photo-crop-editor__crop-box::after{
  content: "";
  position: absolute;
  pointer-events: none;
}

.photo-crop-editor__crop-box::before{
  inset: 33.333% 0;
  border-top: 1px solid rgba(255,255,255,.55);
  border-bottom: 1px solid rgba(255,255,255,.55);
}

.photo-crop-editor__crop-box::after{
  inset: 0 33.333%;
  border-right: 1px solid rgba(255,255,255,.55);
  border-left: 1px solid rgba(255,255,255,.55);
}

.photo-crop-editor__handle{
  position: absolute;
  z-index: 2;
  display: block;
  touch-action: none;
  outline: none;
}

.photo-crop-editor__handle::after{
  content: "";
  position: absolute;
  background: #ff416c;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.42);
}

.photo-crop-editor__handle:focus-visible::after{
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.photo-crop-editor__handle--n,
.photo-crop-editor__handle--s{
  right: 44px;
  left: 44px;
  height: 44px;
  cursor: ns-resize;
}

.photo-crop-editor__handle--n{ top: 0; }
.photo-crop-editor__handle--s{ bottom: 0; }

.photo-crop-editor__handle--n::after,
.photo-crop-editor__handle--s::after{
  left: 50%;
  width: 42px;
  height: 7px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.photo-crop-editor__handle--n::after{ top: 4px; }
.photo-crop-editor__handle--s::after{ bottom: 4px; }

.photo-crop-editor__handle--e,
.photo-crop-editor__handle--w{
  top: 44px;
  bottom: 44px;
  width: 44px;
  cursor: ew-resize;
}

.photo-crop-editor__handle--e{ right: 0; }
.photo-crop-editor__handle--w{ left: 0; }

.photo-crop-editor__handle--e::after,
.photo-crop-editor__handle--w::after{
  top: 50%;
  width: 7px;
  height: 42px;
  border-radius: 999px;
  transform: translateY(-50%);
}

.photo-crop-editor__handle--e::after{ right: 4px; }
.photo-crop-editor__handle--w::after{ left: 4px; }

.photo-crop-editor__handle--nw,
.photo-crop-editor__handle--ne,
.photo-crop-editor__handle--se,
.photo-crop-editor__handle--sw{
  width: 44px;
  height: 44px;
}

.photo-crop-editor__handle--nw{ top: 0; left: 0; cursor: nwse-resize; }
.photo-crop-editor__handle--ne{ top: 0; right: 0; cursor: nesw-resize; }
.photo-crop-editor__handle--se{ right: 0; bottom: 0; cursor: nwse-resize; }
.photo-crop-editor__handle--sw{ bottom: 0; left: 0; cursor: nesw-resize; }

.photo-crop-editor__handle--nw::after,
.photo-crop-editor__handle--ne::after,
.photo-crop-editor__handle--se::after,
.photo-crop-editor__handle--sw::after{
  width: 17px;
  height: 17px;
  border-radius: 5px;
  transform: none;
}

.photo-crop-editor__handle--nw::after{ top: 5px; left: 5px; }
.photo-crop-editor__handle--ne::after{ top: 5px; right: 5px; }
.photo-crop-editor__handle--se::after{ right: 5px; bottom: 5px; }
.photo-crop-editor__handle--sw::after{ bottom: 5px; left: 5px; }

.photo-crop-editor__actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.photo-crop-editor__button{
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.photo-crop-editor__button--secondary{
  border: 1px solid rgba(75,36,53,.2);
  background: #fff;
  color: #4b2435;
}

.photo-crop-editor__button--primary{
  border: 1px solid #b32649;
  background: #b32649;
  color: #fff;
}

.photo-crop-editor__button:disabled{
  opacity: .55;
  cursor: default;
}

@media (max-width: 520px){
  .photo-crop-editor{
    align-items: end;
    padding: 0;
  }

  .photo-crop-editor__card{
    width: 100%;
    max-height: 94dvh;
    padding: 16px 12px max(12px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }

  .photo-crop-editor__canvas{
    max-height: 52dvh;
  }

  .photo-crop-editor__actions{
    position: sticky;
    bottom: 0;
    padding-top: 8px;
    background: #fff;
  }

  .photo-crop-editor__button{
    flex: 1;
  }
}
