* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* 헤더 */
.header {
  text-align: center;
  margin-bottom: 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 28px;
  margin-bottom: 10px;
}

.header p {
  font-size: 14px;
  opacity: 0.9;
}

/* 사이즈/용지 콤보박스 */
#size-paper-row {
  display: flex;
  gap: 15px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

#size-paper-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}

#size-select,
#paper-select {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}

#size-select option,
#paper-select option {
  background: #667eea;
  color: white;
}

#paper-info-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  margin: 0 0 0 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

#paper-info-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 에러 배너 */
.error-banner {
  background: #fee;
  color: #c33;
  padding: 15px;
  border-left: 4px solid #c33;
  margin-bottom: 20px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.error-banner.hidden {
  display: none;
}

/* 섹션 */
.section {
  background: white;
  padding: 25px;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.section h3 {
  margin-bottom: 20px;
  font-size: 18px;
  color: #667eea;
}

.hidden {
  display: none !important;
}

/* 파일 입력 */
.file-input-wrapper {
  position: relative;
  margin-bottom: 20px;
}

#file-input {
  display: none;
}

.file-label {
  display: block;
  padding: 40px 20px;
  border: 2px dashed #667eea;
  border-radius: 8px;
  text-align: center;
  background: #f9f9f9;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 16px;
}

.file-label:hover {
  border-color: #764ba2;
  background: #f0f0f0;
}

.helper-text {
  font-size: 12px;
  color: #999;
  margin-top: 10px;
}

/* 미리보기 섹션 */
.preview-section {
  display: none;
}

.preview-section.show {
  display: block;
}

.preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f0f0;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
}

.preview-item-remove:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* 진행률 바 */
.progress-container {
  margin-bottom: 25px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
}

.progress-bar {
  width: 100%;
  height: 30px;
  background: #e0e0e0;
  border-radius: 15px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  width: 0%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* 파일별 진행 목록 */
.file-progress-list {
  margin-top: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.file-progress-item {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
}

.file-progress-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-progress-bar {
  width: 100%;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.file-progress-fill {
  height: 100%;
  background: #667eea;
  width: 0%;
  transition: width 0.2s ease;
}

/* 버튼 */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

/* 사진 목록 헤더 */
.photo-list-header {
  margin-bottom: 12px;
}

.list-header-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.list-header-row1 h3 {
  margin: 0;
  font-size: 15px;
}

.list-header-row2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}


#size-filter {
  background: white;
  border: 1px solid #667eea;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  min-width: 0;
  max-width: 100px;
}

/* 수량 일괄지정 */
.bulk-qty-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}
.bulk-qty-label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}
.bulk-qty-btn {
  width: 24px;
  height: 24px;
  border: 1.5px solid #888;
  background: #fff;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bulk-qty-btn:hover { background: #f0f0f0; }
.bulk-qty-input {
  width: 44px;
  height: 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid #bbb;
  border-radius: 4px;
  padding: 0 2px;
  -moz-appearance: textfield;
}
.bulk-qty-input::-webkit-outer-spin-button,
.bulk-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.bulk-qty-input:focus { outline: none; border-color: #667eea; }

/* 액션 버튼 공통 */
.btn-action {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-action:hover { opacity: 0.85; }
.btn-apply { background: #e67e22; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger-outline { background: #fff; color: #e74c3c; border: 1.5px solid #e74c3c; }

#size-filter:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 사진 목록 */
/* 사진 목록 - 반응형 그리드 레이아웃 */
.photo-list {
  display: grid;
  /* minmax 200 — 휴지통까지 한 줄에 표시되는 카드 최소폭 (원래 버튼 크기 기준) */
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* 각 카드 */
.photo-item {
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  transition: all 0.2s ease;
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
}

.photo-item:hover {
  background: #f0f0f0;
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 맨 위: seq + 사이즈/용지 */
.photo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid #e0e0e0;
}

.photo-index {
  font-weight: bold;
  color: #667eea;
  font-size: 13px;
}

.photo-size {
  font-weight: 600;
  color: #333;
  font-size: 12px;
}

/* 썸네일 (전체폭) */
.thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #f0f0f0;
  overflow: hidden;
  margin: 6px 0;
}
.thumb-clickable { cursor: pointer; }
.thumb-wrap .photo-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.photo-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f0f0f0;
}
.crop-overlay {
  position: absolute;
  border: 2px solid red;
  box-sizing: border-box;
  cursor: move;
  pointer-events: auto;
  background: none; /* By Claude: 오버레이 배경 제거 - 사진 원색 유지 */
}
.thumb-dim {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  pointer-events: none;
}
/* By Claude: 크롭 영역 밖을 어둡게 — clip-path로 처리 */

/* 컨트롤 바 (수량 + 편집 + 삭제 가로 한 줄) */
.photo-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  gap: 4px;
  overflow: visible;
}

.ctrl-qty {
  display: flex;
  align-items: center;
  gap: 2px;
}

.qty-btn {
  background: #fff;
  border: 1.5px solid #ccc;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: #667eea;
  font-weight: bold;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:hover {
  background: #f0f0ff;
  border-color: #667eea;
}

.qty-display {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.ctrl-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ctrl-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.ctrl-btn:hover {
  background: #f0f0f0;
}

/* 이미지풀 토글 버튼 - 활성화 상태 */
.ctrl-full {
  filter: grayscale(0.5) opacity(0.6);
}
.ctrl-full.active {
  filter: none;
  background: #e8f5e9;
  border: 1.5px solid #4caf50;
}
.ctrl-full.active:hover {
  background: #c8e6c9;
}

/* 이미지풀 배지 (썸네일 위 우측 상단) */
.image-full-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(76, 175, 80, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
}

/* 이미지풀 모드 — 흰색 용지 배경 + 그림자 (실제 인화 미리보기) */
.thumb-wrap.imagefull-mode {
  background: #fff;
  /* 테두리/패딩 모두 제거 — 이미지풀은 "이미지가 종이를 꽉 채우고 남은 부분만 흰색".
     padding 이 있으면 항상 사방에 흰 띠 생겨서 "테두리 인화되나?" 오해 발생. (2026-05-27 재수정) */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-wrap.imagefull-mode .photo-thumbnail {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: transparent;
  display: block;
  margin: auto;
}

/* 맨 아래: 파일명 (센터) */
.photo-footer {
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
  text-align: center;
}

.photo-filename {
  font-size: 11px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.photo-delete {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
  padding: 4px;
}

.photo-delete:hover {
  color: #e74c3c;
}

/* 뒷배경합성 체크박스 */
.bg-composite-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #c0392b;
  font-weight: 600;
  white-space: nowrap;
}

.bg-composite-cb {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #c0392b;
}

/* 페이지네이션 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

.pagination.hidden {
  display: none;
}

.btn-pagination {
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.btn-pagination:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#page-info {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
}

/* 모달 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

.modal.hidden {
  display: none;
}

.modal-content {
  max-width: 90%;
  max-height: 90vh;
  overflow: auto;
}

#modal-image {
  width: 100%;
  height: auto;
  display: block;
}

/* 메시지로 돌아가기 / 결제하기 버튼 영역 */
.back-to-messenger {
  display: flex;
  gap: 12px;
  padding: 15px 0;
  margin-top: 10px;
}

.back-to-messenger .btn-action {
  flex: 1;
  padding: 14px 0;
  font-size: 16px;
  font-weight: 700;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.back-to-messenger .btn-messenger {
  background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
  box-shadow: 0 3px 10px rgba(0, 132, 255, 0.3);
}

.back-to-messenger .btn-checkout {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.back-to-messenger .btn-action:hover {
  transform: translateY(-2px);
}

.back-to-messenger .btn-action:active {
  transform: translateY(0);
}

.back-to-messenger .btn-action:disabled {
  background: #aaa;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 반응형 */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header {
    padding: 15px;
  }

  .header h1 {
    font-size: 20px;
  }

  .section {
    overflow: hidden;
  }

  .photo-list-header h3 {
    font-size: 14px;
  }

  .photo-list-controls {
    gap: 4px;
  }

  .bulk-qty-wrap {
    gap: 2px;
  }

  .bulk-qty-label { font-size: 11px; }
  .bulk-qty-btn { width: 22px; height: 22px; font-size: 13px; }
  .bulk-qty-input { width: 36px; height: 22px; font-size: 12px; }
  .btn-action { padding: 3px 7px; font-size: 11px; }
  #size-filter { padding: 3px 4px; font-size: 11px; max-width: 80px; }

  .photo-list {
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 8px;
  }

  .photo-item {
    padding: 8px;
  }

  .preview-list {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

/* 용지 안내 iframe 모달 */
#paper-guide-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

#paper-guide-modal.hidden {
  display: none;
}

#paper-guide-close {
  position: absolute;
  top: 24px;
  right: 16px; /* fallback for browsers without max()/calc */
  right: max(16px, calc(50% - 450px + 8px)); /* PC: 900px 패널 우상단에 붙임 */
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  cursor: pointer;
  font-size: 24px;
  line-height: 40px;
  text-align: center;
  border-radius: 50%;
  transition: background 0.2s;
  z-index: 2001;
}

#paper-guide-close:hover {
  background: rgba(0, 0, 0, 0.5);
}

#paper-guide-modal iframe {
  width: 100%;
  max-width: 900px; /* 사진 업로드 영역(.container)과 동일 폭 */
  border: none;
  border-radius: 12px;
  background: #fff;
}

/* 확인 모달 (confirm 대체) - 인앱브라우저 호환 */
#confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

#confirm-modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
}

#confirm-modal .modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 3001;
}

#confirm-message {
  font-size: 16px;
  margin-bottom: 25px;
  text-align: center;
  color: #333;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-buttons .btn {
  padding: 10px 25px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-buttons .btn-primary {
  background: #667eea;
  color: white;
}

.modal-buttons .btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.modal-buttons .btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.modal-buttons .btn-secondary:hover {
  background: #d0d0d0;
  transform: translateY(-2px);
}

/* Business Footer */
.biz-footer { max-width: 900px; margin: 0 auto; padding: 0 20px 24px; }
.biz-footer-inner { border-top: 1px solid #ddd; padding-top: 16px; text-align: center; }
.biz-footer-inner strong { font-size: 13px; color: #555; }
.biz-footer-inner p { font-size: 12px; color: #999; line-height: 1.7; margin: 0; }
.biz-footer-inner .copyright { margin-top: 8px; font-size: 11px; color: #bbb; }


/* 주문코드 확인하기 — 디자인 백서 v1.1 (옐로우 + 잉크블루) */
.back-to-messenger .btn-confirm-code {
  background: linear-gradient(135deg, #F8C31F 0%, #E5B015 100%);
  color: #1A3A52;
  box-shadow: 0 4px 14px rgba(248, 195, 31, 0.4);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
  height: 56px;
}
.back-to-messenger .btn-confirm-code:hover {
  background: linear-gradient(135deg, #E5B015 0%, #C99A0F 100%);
  box-shadow: 0 6px 20px rgba(248, 195, 31, 0.5);
}
