/* ========================================
   1. CSS 변수 및 초기화
   ======================================== */
:root {
  --nt-bg: #fafaf9;
  --nt-card-bg: #ffffff;
  --nt-text: #37352f;
  --nt-sub: #6b6b6b;
  --nt-border: #e9e9e7;
  --nt-blue: #2383e2;
  --nt-hover: rgba(55, 53, 47, 0.08);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-popup: 0 8px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  background: #ffffff;
  color: var(--nt-text);
  font-family: "GmarketSans", sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ========================================
   2. 네비게이션 및 컨트롤러
   ======================================== */
.top-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 20px;
  z-index: 2000;
  margin: auto;
}

.scale-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: bold;
  color: var(--nt-sub);
}

.scale-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--nt-border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.scale-btn:hover {
  background: var(--nt-hover);
}

.export-btn {
  background: var(--nt-text);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

/* ========================================
   3. 메인 작업 영역 (간격 축소 반영)
   ======================================== */
.canvas-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 80vh;
}

#capture-area {
  padding: 10px 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s ease-out;
  transform-origin: top center;
}

.pair-title-container {
  margin-bottom: 10px;
}

.pair-title {
  font-size: 3.5rem;
  font-weight: 800;
  outline: none;
  text-align: center;
}

.main-wrapper {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: stretch;
}

/* ========================================
   4. 카드 및 이미지 박스 스타일
   ======================================== */
.nt-card {
  border: 1px solid var(--nt-border);
  padding: 24px;
  background: var(--nt-card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}
.outfit-card {
  width: 320px;
}
.char-card {
  width: 360px;
}

.label {
  font-size: 13px;
  font-weight: 700;
  color: var(--nt-sub);
  margin-bottom: 12px;
  text-transform: uppercase;
  text-align: center;
}

.img-box {
  position: relative;
  background: #f7f7f5;
  border: 1px solid #ededeb;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.plus-icon,
.small-box-label {
  position: absolute;
  color: #acaba9;
}

.del-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  border: none;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.img-box:hover .del-btn {
  display: flex;
}

.outfit-img-box {
  height: 460px;
  margin-bottom: 12px;
}
.char-img-box {
  height: 350px;
  margin-bottom: 15px;
}
.small-box-container {
  display: flex;
  gap: 10px;
}
.small-img-box {
  flex: 1;
  aspect-ratio: 1/1;
}

/* ========================================
   5. 텍스트 입력 및 리스트
   ======================================== */
.name-input {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  margin-bottom: 10px;
}
.char-basic-info {
  text-align: center;
  margin-bottom: 15px;
}
.keywords-input {
  font-size: 14px;
  color: var(--nt-sub);
  outline: none;
}
.body-info-input {
  font-size: 13px;
  color: var(--nt-sub);
  outline: none;
}

.info-list {
  flex-grow: 1;
  margin-bottom: 15px;
  min-height: 90px;
}
.info-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
}
.info-item:hover {
  background: var(--nt-hover);
}
.info-item::before {
  content: "•";
  margin-right: 8px;
  color: #ccc;
}
.info-text {
  flex-grow: 1;
  outline: none;
  font-size: 15px;
}

.btn-group {
  display: flex;
  opacity: 0;
  gap: 4px;
  margin-left: 10px;
}
.info-item:hover .btn-group {
  opacity: 1;
}
.list-btn {
  background: #f4f4f2;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 8px;
}

/* ========================================
   6. 팝업 및 모달 (정리된 최종본)
   ======================================== */
/* 컬러 피커 팝업 */
.palette {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #fbfbfa;
  border-radius: 8px;
  justify-content: center;
  margin-top: auto;
  border: 1px solid var(--nt-border);
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: 0.2s;
}

#color-popup {
  display: none;
  position: absolute;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-popup);
  z-index: 2500;
  width: 200px;
  animation: popup-fade 0.2s ease-out;
}

.popup-header {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #91918e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.popup-header::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--nt-blue);
  border-radius: 2px;
}

#hidden-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.color-grid div {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.1s;
}
.color-grid div:hover {
  transform: scale(1.1);
}

.sys-picker-btn {
  width: 100%;
  padding: 8px;
  background: #f7f7f5;
  border: 1px solid var(--nt-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.sys-picker-btn:hover {
  background: var(--nt-hover);
}

/* 이미지 편집 모달 */
#crop-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.8);
  backdrop-filter: blur(5px);
  z-index: 3000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 15px;
  color: var(--nt-text);
}

.crop-area {
  height: 400px;
  background: #f7f7f5;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--nt-border);
}

.modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.m-btn {
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: 0.2s;
  border: 1px solid var(--nt-border);
  background: #fff;
  color: var(--nt-sub);
}
.m-btn.save {
  background: var(--nt-text);
  color: #fff;
  border: none;
}
.m-btn:not(.save):hover {
  background: #f1f1ef;
  color: var(--nt-text);
}
.m-btn.save:hover {
  background: #000;
  transform: translateY(-1px);
}

/* ========================================
   7. 푸터 및 애니메이션
   ======================================== */
.copyright-container {
  text-align: center;
  margin: 10px auto 0 auto;
  width: 100%;
}

.copyright-text {
  display: inline-block;
  font-size: 13px;
  color: #ccc;
  letter-spacing: 1px;
  outline: none;
  text-transform: uppercase;
  cursor: text;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}
.copyright-text:hover {
  background: var(--nt-hover);
  color: var(--nt-text);
}

@keyframes popup-fade {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#color-popup {
  display: none;
  position: absolute;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-popup);
  z-index: 2500;
  width: 180px; /* 라이브러리 크기에 맞춰 조정 */
}

#color-popup {
  display: none;
  position: absolute;
  background: #ffffff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-popup);
  z-index: 2500;
  width: 280px;
  animation: popup-fade 0.2s ease-out;
  border: 1px solid var(--nt-border);
}

/* 2) 팝업 헤더 */
.popup-header {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #91918e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 2px;
}
.popup-header::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--nt-blue);
  border-radius: 2px;
}

/* 3) 라이브러리 내부 요소 커스텀 (Vanilla-Picker) */
.picker_wrapper {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}

/* 색상 선택판 */
.picker_sl {
  border-radius: 8px !important;
  margin-bottom: 12px !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* 슬라이더 바 (채도/밝기) */
.picker_slider {
  height: 12px !important;
  border-radius: 6px !important;
  margin-bottom: 8px !important;
}

/* 4) 하단 버튼 영역 */
.popup-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #f1f1ef;
}

.p-btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  border: 1px solid var(--nt-border);
  background: #fff;
  color: var(--nt-sub);
}

.p-btn.apply {
  background: var(--nt-text);
  color: #fff;
  border: none;
}

.p-btn:hover {
  background: var(--nt-hover);
}

.p-btn.apply:hover {
  background: #000;
}

/* 불필요한 라이브러리 기본 요소 숨기기 */
.picker_editor,
.picker_done,
.picker_sample {
  display: none !important;
}
