.image-choose-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(0.75rem + env(safe-area-inset-top, 0px))
    1rem
    calc(0.75rem + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.image-choose-modal.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.image-choose-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.image-choose-modal__sheet {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 22.5rem);
  min-height: min(88dvh, 42rem);
  max-height: min(94dvh, 50rem);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.15rem;
  background:
    radial-gradient(circle at 12% -8%, rgba(255, 176, 196, 0.14), transparent 10rem),
    linear-gradient(180deg, #17171a 0%, #0d0d0f 100%);
  box-shadow:
    0 1rem 2.4rem rgba(0, 0, 0, 0.55),
    inset 0 1px rgba(255, 255, 255, 0.08);
  transform: translateY(0.34rem) scale(0.97);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease;
}

.image-choose-modal.is-open .image-choose-modal__sheet {
  transform: translateY(0) scale(1);
  opacity: 1;
}

body.image-choose-open {
  overflow: hidden;
}

.image-choose-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  flex-shrink: 0;
  padding: 1.15rem 1.15rem 0.55rem;
}

.image-choose-modal__title {
  margin: 0;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.image-choose-modal__subtitle {
  margin: 0.3rem 0 0;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}

.image-choose-modal__header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.image-choose-modal__coins {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.5rem;
  margin: 0;
  padding: 0 0.48rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: default;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.image-choose-modal__coins--low {
  cursor: pointer;
  border-color: rgba(255, 107, 138, 0.42);
  background: rgba(255, 107, 138, 0.16);
  box-shadow: 0 0 0.65rem rgba(255, 107, 138, 0.14);
}

.image-choose-modal__coins--low:hover {
  background: rgba(255, 107, 138, 0.24);
  transform: scale(1.03);
}

.image-choose-modal__coins--low:active {
  transform: scale(0.98);
}

body:not(.user-logged-in) .image-choose-modal__coins {
  display: none !important;
}

.image-choose-modal__close {
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  transition: background 0.16s ease, transform 0.16s ease;
}

.image-choose-modal__close:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.14);
}

.image-choose-modal__body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 0.65rem;
  overflow: hidden;
  padding: 0 1.15rem 0.65rem;
}

.image-choose-modal__picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  flex: 1.05 1 0;
  min-height: 0;
}

.image-choose-modal__slot {
  position: relative;
  height: 100%;
  min-height: clamp(10rem, 30dvh, 13.5rem);
  max-height: clamp(11.5rem, 34dvh, 15rem);
  overflow: hidden;
  border-radius: 0.78rem;
  background: #121014;
}

.image-choose-modal__slot--upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0.65rem;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 0.78rem;
  background: #0b0b0d;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.image-choose-modal__slot--upload:not(.has-photo) .image-choose-modal__upload-placeholder {
  cursor: pointer;
}

.image-choose-modal__slot--upload:not(.has-photo) .image-choose-modal__upload-placeholder:hover {
  opacity: 0.92;
}

.image-choose-modal__slot--upload.has-photo {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.14);
  padding: 0;
  background: #121014;
  box-shadow: none;
}

.image-choose-modal__slot--upload:not(.has-photo):hover {
  border-color: rgba(255, 143, 168, 0.42);
  background: #0e0e10;
  box-shadow: inset 0 0 0 1px rgba(255, 107, 138, 0.08);
}

.image-choose-modal__upload-placeholder {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.45rem 0.35rem;
  text-align: center;
}

.image-choose-modal__upload-icon {
  position: relative;
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  flex-shrink: 0;
  place-items: center;
  border-radius: 0.85rem;
  background: linear-gradient(145deg, #ff8fa8 0%, #e85d75 100%);
  color: #fff;
  box-shadow:
    0 0 0 1px rgba(255, 210, 110, 0.28),
    0 0.45rem 1.1rem rgba(255, 107, 138, 0.42),
    0 0 1.65rem rgba(255, 107, 138, 0.32);
}

.image-choose-modal__upload-icon .material-symbols-outlined {
  font-size: 1.65rem;
  line-height: 1;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
}

.image-choose-modal__upload-title {
  margin: 0;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.image-choose-modal__upload-hint {
  margin: -0.12rem 0 0;
  color: rgba(255, 255, 255, 0.44);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.25;
}

.image-choose-modal__user-preview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-choose-modal__slot--upload.has-photo .image-choose-modal__upload-placeholder {
  display: none;
}

.image-choose-modal__slot--upload.has-photo .image-choose-modal__user-preview {
  display: block;
}

.image-choose-modal__change-photo {
  position: absolute;
  left: 50%;
  bottom: 0.55rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  min-height: 1.85rem;
  padding: 0.32rem 0.72rem;
  border: 0;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 0.35rem 0.85rem rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: translateX(-50%);
  transition: transform 0.16s ease, background 0.16s ease;
}

.image-choose-modal__change-photo:active {
  transform: translateX(-50%) scale(0.97);
  background: rgba(18, 18, 20, 0.92);
}

.image-choose-modal__change-photo .material-symbols-outlined {
  font-size: 0.95rem;
  line-height: 1;
}

.image-choose-modal__change-photo[hidden] {
  display: none !important;
}

.image-choose-modal__arrow {
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  flex-shrink: 0;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6b8a, #e85d75);
  color: #1c1028;
  box-shadow: 0 0.3rem 0.7rem rgba(232, 93, 117, 0.28);
}

.image-choose-modal__arrow .material-symbols-outlined {
  font-size: 1.05rem;
  line-height: 1;
}

.image-choose-modal__template-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-choose-modal__badge {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.92);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2;
}

.image-choose-modal__favorite {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 2;
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.image-choose-modal__favorite .material-symbols-outlined {
  font-size: 1.05rem;
  line-height: 1;
}

.image-choose-modal__favorite.is-favorited {
  background: rgba(255, 143, 168, 0.28);
  color: #ffc0d0;
}

.image-choose-modal__tips {
  display: flex;
  min-height: 0;
  flex: 1 1 0;
  flex-direction: column;
  gap: 0.45rem;
}

.image-choose-modal__tips-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
}

.image-choose-modal__tips-heading .material-symbols-outlined {
  flex-shrink: 0;
  margin-top: 0.02rem;
  color: #ffc0d0;
  font-size: 1rem;
  line-height: 1;
}

.image-choose-modal__tips-heading p {
  margin: 0;
}

.image-choose-modal__tips-grid {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 0.5rem;
  align-items: stretch;
}

.image-choose-modal__tip-card {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.04);
}

.image-choose-modal__tip-img {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  object-fit: cover;
  background: #100f13;
}

.image-choose-modal__tip-label {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  flex-shrink: 0;
  min-height: 1.55rem;
  padding: 0.28rem 0.42rem;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.2;
}

.image-choose-modal__tip-label .material-symbols-outlined {
  font-size: 0.88rem;
  line-height: 1;
}

.image-choose-modal__tip-card--good .image-choose-modal__tip-label {
  color: #4ade80;
}

.image-choose-modal__tip-card--bad .image-choose-modal__tip-label {
  color: #f472b6;
}

.image-choose-modal__submit {
  display: flex;
  width: calc(100% - 2.3rem);
  margin: 0 1.15rem 1.1rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 3rem;
  flex-shrink: 0;
  border: 0;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #ff6b8a, #e85d75);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  box-shadow:
    0 0.55rem 1.15rem rgba(232, 93, 117, 0.32),
    inset 0 1px rgba(255, 255, 255, 0.2);
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.image-choose-modal__submit:active {
  transform: scale(0.98);
  opacity: 0.94;
}

.image-choose-modal__submit--generate {
  background: linear-gradient(135deg, #ffc0d0, #e85d75);
  box-shadow:
    0 0.55rem 1.15rem rgba(232, 93, 117, 0.38),
    inset 0 1px rgba(255, 255, 255, 0.24);
}

.image-choose-modal__submit .material-symbols-outlined {
  font-size: 1.15rem;
  line-height: 1;
}

.image-choose-modal__picker-row--template-only {
  justify-content: center;
}

.image-choose-modal__picker-row--template-only .image-choose-modal__slot--template {
  width: min(100%, 14rem);
}

/* Depois de enviar a foto: layout equilibrado com dicas + qualidade + Gerar */
.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) {
  min-height: 0;
  max-height: calc(
    100dvh - 1.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
  );
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__header {
  padding: 0.9rem 1.15rem 0.4rem;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__subtitle {
  display: none;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__body {
  flex: 1 1 auto;
  gap: 0.55rem;
  padding-bottom: 0.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__picker-row {
  flex: 0 0 auto;
  align-items: center;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__slot {
  min-height: clamp(7.75rem, 22dvh, 10.25rem);
  max-height: clamp(8.25rem, 24dvh, 10.75rem);
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__tips {
  flex: 0 0 auto;
  gap: 0.38rem;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__tips-heading {
  font-size: 0.66rem;
  line-height: 1.3;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__tips-grid {
  flex: 0 0 auto;
  grid-template-rows: auto;
  gap: 0.45rem;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__tip-img {
  flex: 0 0 auto;
  aspect-ratio: 4 / 3;
  max-height: 4.35rem;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__tip-label {
  min-height: 1.35rem;
  padding: 0.22rem 0.38rem;
  font-size: 0.6rem;
  line-height: 1.15;
}

.image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__submit {
  min-height: 2.85rem;
  margin-bottom: 0.9rem;
  font-size: 0.93rem;
}

@media (max-height: 700px) {
  .image-choose-modal__slot {
    min-height: clamp(8.5rem, 26dvh, 11rem);
    max-height: clamp(9.5rem, 28dvh, 12rem);
  }

  .image-choose-modal__header {
    padding-top: 0.9rem;
    padding-bottom: 0.4rem;
  }

  .image-choose-modal__submit {
    min-height: 2.75rem;
    margin-bottom: 0.85rem;
  }

  .image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__slot {
    min-height: clamp(6.75rem, 20dvh, 8.75rem);
    max-height: clamp(7.25rem, 21dvh, 9.25rem);
  }

  .image-choose-modal__sheet:has(.image-choose-modal__slot--upload.has-photo) .image-choose-modal__tip-img {
    max-height: 3.75rem;
  }
}
