/* ===========================================================================
   CAPEYO 셀프디자인툴 — 커스텀 스타일
   카페24 iframe 임베드를 고려해 라이트 테마 / 시스템 폰트 / 중립 팔레트.
   색·폰트는 :root 변수만 바꾸면 카페24 사이트 톤에 맞출 수 있다.
   =========================================================================== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d3d7dd;
  --text: #1d2026;
  --text-soft: #6b7280;
  --text-faint: #9aa1ab;
  --brand: #111317;
  --accent: #2f6df6;
  --accent-soft: #eaf1ff;
  --danger: #e5484d;
  --warn-bg: #fff6e6;
  --warn-text: #9a6700;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,20,28,.04), 0 6px 20px rgba(16,20,28,.06);
  --font: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont,
          "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  /* 선택 표시용 체크 (둥근 스트로크) — mask 로 색 입힘 */
  --check-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cpath%20d='M5%2012.5L10%2017.5L19%207'%20fill='none'%20stroke='%23000'%20stroke-width='3'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
/* display 가 지정된 요소(.slider-row 등)에서도 hidden 속성이 확실히 먹도록 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 헤더 / 스텝바 ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-weight: 800;
  letter-spacing: .14em;
  font-size: 20px;
  color: var(--brand);
}
.brand-sub { font-size: 13px; color: var(--text-soft); }

.stepbar {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.stepbar li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--text-faint);
  background: transparent;
  counter-increment: step;
}
.stepbar li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--line);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}
.stepbar { counter-reset: step; }
.stepbar li.active { color: var(--brand); background: var(--surface); box-shadow: var(--shadow); }
.stepbar li.active::before { background: var(--brand); color: #fff; }
.stepbar li.done::before {
  content: "";
  background-color: var(--accent);
  -webkit-mask: var(--check-mask) center / 15px 15px no-repeat;
  mask: var(--check-mask) center / 15px 15px no-repeat;
}

/* ---------- 레이아웃 ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  padding: 0 20px 24px;
  align-items: start;
}

/* ---------- 스테이지 (시안) ---------- */
.stage {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stage-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(120% 120% at 50% 18%, #ffffff 0%, #eef0f3 78%, #e7eaee 100%);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
#stage {
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#stage.grabbing { cursor: grabbing; }
.stage-hint {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  font-size: 12.5px;
  color: var(--text-soft);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(4px);
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
  transition: opacity .25s;
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.method-toggle { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.seg.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.price { font-size: 14px; font-weight: 700; color: var(--brand); }
.price small { font-weight: 500; color: var(--text-faint); }

/* ---------- 패널 / 카드 ---------- */
.panel { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.disabled { opacity: .5; pointer-events: none; filter: grayscale(.2); }
.card h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 13px;
  font-size: 15px;
  font-weight: 700;
}
.card h2 .num {
  display: grid; place-items: center;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
}
.field-label { font-size: 12px; color: var(--text-soft); margin: 14px 0 8px; font-weight: 600; }

/* ---------- 모자 종류 ---------- */
.hat-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hat-type {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 6px 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.hat-type:hover { border-color: var(--line-strong); }
.hat-type.active { border-color: var(--brand); background: #fafbfc; }
.hat-type svg { width: 100%; height: 42px; display: block; }
.hat-type span { font-size: 12.5px; font-weight: 600; color: var(--text); margin-top: 4px; display: block; }

/* ---------- 색상 스와치 ---------- */
.hat-colors { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px var(--line-strong);
  position: relative;
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px var(--brand); }
.swatch.active::after {
  content: "";
  position: absolute; inset: 0;
  background-color: var(--swatch-check, #fff);
  -webkit-mask: var(--check-mask) center / 14px 14px no-repeat;
  mask: var(--check-mask) center / 14px 14px no-repeat;
}

/* ---------- 탭 ---------- */
.tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 13px; }
.tab {
  flex: 1; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-soft); padding: 8px; border-radius: 8px; cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- 업로드 드롭존 ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.6px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 26px 16px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 22px; color: var(--accent); }
.dz-title { font-size: 14px; font-weight: 700; }
.dz-sub { font-size: 12px; color: var(--text-faint); }

.warn {
  margin: 10px 0 0; font-size: 12px;
  background: var(--warn-bg); color: var(--warn-text);
  padding: 8px 10px; border-radius: 8px;
}

/* ---------- 텍스트 입력 ---------- */
.text-input, .select {
  width: 100%; font: inherit; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; background: var(--surface); color: var(--text);
}
.text-input:focus, .select:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 9px; }
.row .select { flex: 1; }
.color { width: 44px; height: 42px; padding: 2px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }

/* ---------- 버튼 ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 700;
  border-radius: var(--radius-sm); padding: 11px 14px;
  border: 1.5px solid transparent; cursor: pointer;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; margin-top: 12px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); flex: 1; }
.btn-ghost:hover { border-color: var(--brand); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { border-color: var(--danger); }

/* ---------- 배경제거 에디터 ---------- */
.bg-editor {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; display: grid; place-items: center;
  background: #fff;
}
#bgCanvas { display: block; max-width: 100%; cursor: crosshair; }
.checker {
  background-image:
    linear-gradient(45deg, #e9ebee 25%, transparent 25%),
    linear-gradient(-45deg, #e9ebee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9ebee 75%),
    linear-gradient(-45deg, transparent 75%, #e9ebee 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tool {
  font: inherit; font-size: 12.5px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.tool:hover { border-color: var(--line-strong); }
.tool.active { border-color: var(--brand); background: var(--brand); color: #fff; }

.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 13px; }
.slider-row label { font-size: 12.5px; color: var(--text-soft); width: 48px; flex-shrink: 0; font-weight: 600; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--brand); }

.hint-sm { font-size: 12px; color: var(--text-faint); margin: 10px 0 0; line-height: 1.5; }

/* ---------- 수량 스테퍼 ---------- */
.qty-row { justify-content: space-between; }
.qty-row > label { font-size: 13px; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button { width: 36px; height: 38px; border: 0; background: var(--surface); font-size: 18px; cursor: pointer; color: var(--text); }
.stepper button:hover { background: var(--bg); }
.stepper input { width: 50px; height: 38px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font: inherit; font-size: 14px; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- 반응형 ---------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .stage { position: static; }
  .stepbar { align-self: stretch; }
  .stepbar li { flex: 1; justify-content: center; }
}
