.popup_container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 9999;
  justify-content: center;
  align-items: flex-start;
}

/* ===== 데스크톱/태블릿 기본: 가변폭 + 상한 ===== */
.popup_list {
  width: 100%;
  max-width: 500px;
  position: absolute;
  display: flex;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
}

.popup_close_container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(calc(-50% + 405px), calc(-50% - 403px));
}

.popup_left-panel {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* 데스크톱/태블릿: 컨테이너 가변폭 + 상한, 비율 고정은 하지 않음(자연 비율) */
.popup_image-container {
  width: min(85vw, 500px);
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}

/* 슬라이드 트랙(가로 긴 띠) */
.popup_image-slide {
  display: flex;
  width: 100%;
  /* 높이는 컨테이너 내용(height:auto 이미지)에 의해 결정 */
  cursor: pointer;
  transition: transform 0.5s ease-in-out;
  will-change: transform;
  touch-action: pan-y;
}

.popup_image-slide > img {
  cursor: pointer;
}

/* 각 슬라이드(직계 자식)를 100% 너비로 */
.popup_image-slide > * {
  flex: 0 0 100%;
  position: relative;
}

/* 데스크톱/태블릿: 이미지가 컨테이너 폭에 맞춰 유동, 세로는 자동(비율 유지) */
.popup_image-container img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain; /* 잘림 없이 비율 유지 */
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
}

.popup_footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(85vw, 500px);
  height: 38px;
  background: #000;
  box-sizing: border-box;
  color: #fff;
  padding: 0 0 0 10px;
  margin: 0 auto;
}

.popup_footer-text {
  font-family: Pretendard;
  font-size: 14px;
  cursor: pointer;
  font-weight: 400;
}

.popup_close-btn {
  font-family: Pretendard;
  width: 80px;
  padding: 10px 10px;
  justify-content: center;
  align-items: center;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  background: #393939;
}

.popup_close-btn > img {
  width: 100%;
  height: 100%;
}

.popup_right-panel {
  width: 100%;
  background-color: #fff;
}

.popup_image-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
}

.popup_image-item {
  flex: 1 1 calc(33.333% - 10px);
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Pretendard;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  color: #888;
  font-size: 12px;
  box-sizing: border-box;
  border: 1px solid #F1F1F1;
}

.popup_image-item.active {
  color: #562461;
  font-weight: 700;
}

.popup_image-dots { display: none; }

.popup_mo_panel {
  width: 100%;
  display: none;
  background-color: #562461;
}

.popup_mo_list {
  display: flex;
  width: 100%;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.popup_mo_image_item {
  width: 33%;
  height: 60px;
  font-size: 14px;
}

.popup_image-slide img.clone {
  pointer-events: none;
  user-select: none;
}

/* ===== 1300px 이하: 픽셀 고정폭 제거, 컨테이너/푸터는 상한만 축소 ===== */
@media (max-width: 1300px) {
  .popup_list { max-width: 438px; }

  .popup_left-panel { max-width: 438px; }

  .popup_image-container {
    width: 100%;
    max-width: 438px;   /* ← 고정폭(438px) 대신 상한 설정 */
  }

  /* 이미지에 픽셀 고정폭(439px) 주던 것 제거! */
  .popup_image-container img {
    width: 100%;
    height: auto;       /* 비율 유지 */
    object-fit: contain;
  }

  .popup_footer {
    width: 100%;
    max-width: 438px;
  }

  .popup_image-item { height: 50px; }

  .popup_close-btn { width: 70px; }

  .popup_close_container {
    transform: translate(calc(-50% + 279px), calc(-50% - 299px));
  }
}

/* ===== 768px 이하(모바일): A4 비율 뷰포트 + 트랙 높이 100% ===== */
@media (max-width: 768px) {
  .popup_list { max-width: 320px; }

  /* 모바일 뷰포트(액자)는 A4 비율 고정 */
  .popup_image-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 210 / 297;  /* A4 */
    overflow: hidden;
    margin: 0 auto;
  }

  /* 트랙은 액자를 꽉 채우고, 높이 100% (이미지 cover 가능) */
  .popup_image-slide {
    position: absolute;
    inset: 0;
    display: flex;
    height: 100%;
  }

  .popup_image-slide > * { height: 100%; }

  .popup_image-container img {
    width: 100%;
    height: 100%;        /* 액자 꽉 채우기 */
    object-fit: cover;   /* 넘치면 가림, 늘어짐 방지 */
  }

  .popup_right-panel { display: none; }
  .popup_left-panel { width: 100%; max-width: 320px; }
  .popup_mo_panel { display: block; }

  .popup_footer { width: 100%; max-width: 320px; }

  .popup_image-dots {
    display: flex;
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    justify-content: center;
    z-index: 2;
    pointer-events: auto;
  }

  .popup_dot {
    width: 8px; height: 8px;
    margin: 0 5px;
    border-radius: 50%;
    background-color: #fff;
    opacity: 1;
    cursor: pointer;
    transition: background-color 0.3s ease, transform .2s ease;
  }

  .popup_dot.active {
    opacity: 1;
    width: 10px; height: 10px;
    margin-bottom: 2px;
    background-color: #3e004b;
    transform: translateY(-1px);
  }

  .popup_footer-text { font-size: 14px; }

  .popup_close_container {
    transform: translate(calc(-50% + 147px), calc(-50% - 220px));
  }
}

@media (max-width: 650px) {
  .popup_list { max-width: 320px; }
  .popup_close_container {
    transform: translate(calc(-50% + 146px), calc(-50% - 220px));
  }
}

@media (max-width: 530px) {
  .popup_list { max-width: 320px; }
  .popup_close_container {
    transform: translate(calc(-50% + 149px), calc(-50% - 218px));
  }
}

@media (max-width: 500px) {
  .popup_close-btn {
    font-family: Pretendard;
    width: 55px;
    height: 35px;
  }
}
