/*
  사진 보정 위젯 — 독립형 CSS
  다른 사이트의 디자인 시스템에 의존하지 않도록 모든 색상·폰트를 --pe-* 변수로 내렸습니다.
  브랜드 컬러에 맞추려면 .pe-widget 블록의 변수 값만 바꾸면 됩니다.
*/

.pe-widget{
  --pe-ink-900: #201D19;
  --pe-ink-700: #4A453D;
  --pe-stone-500: #948A7A;
  --pe-paper: #F7F5F1;
  --pe-paper-2: #E4DFD5;
  --pe-line: rgba(32,29,25,0.13);
  --pe-line-strong: rgba(32,29,25,0.22);
  --pe-brass-700: #7C5F27;
  --pe-brass-600: #9C7A34;
  --pe-brass-500: #B6903F;
  --pe-brass-300: #D8BD84;
  --pe-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Pretendard, Roboto, sans-serif;
  --pe-font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --pe-ease: cubic-bezier(0.4, 0, 0.2, 1);

  font-family: var(--pe-font);
  color: var(--pe-ink-900);
}

.pe-dropzone[hidden], .pe-canvas-wrap[hidden], .pe-selection[hidden],
.pe-lasso-overlay[hidden], .pe-tool-row[hidden],
.pe-hint[hidden], .pe-controls[hidden]{ display: none; }

.pe-layout{
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px;
  align-items: stretch;
}
@media (max-width: 860px){
  .pe-layout{ grid-template-columns: 1fr; }
}

.pe-stage{
  background: var(--pe-paper-2);
  border: 1px solid var(--pe-line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  min-height: 360px;
  padding: 16px;
  box-sizing: border-box;
}
.pe-dropzone{
  width: 100%; height: 100%; min-height: 328px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 32px;
  border: 1px dashed var(--pe-line-strong);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.25s var(--pe-ease), background 0.25s var(--pe-ease);
}
.pe-dropzone:hover, .pe-dropzone:focus-visible, .pe-dropzone.is-dragover{
  border-color: var(--pe-brass-500); background: var(--pe-paper);
}
.pe-dropzone.is-busy{
  cursor: wait; opacity: 0.6; pointer-events: none;
}
.pe-dropzone-icon{ width: 32px; height: 32px; color: var(--pe-brass-600); }
.pe-dropzone-text{ font-size: 0.88rem; color: var(--pe-ink-700); line-height: 1.6; margin: 0; }
.pe-dropzone-text strong{ color: var(--pe-ink-900); font-size: 0.98rem; }

.pe-tool-row{ display: flex; gap: 8px; }
.pe-tool-btn{
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 8px 16px;
  background: transparent; color: var(--pe-ink-700);
  border: 1px solid var(--pe-line-strong);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s var(--pe-ease), color 0.2s var(--pe-ease), border-color 0.2s var(--pe-ease);
}
.pe-tool-btn:hover{ border-color: var(--pe-ink-900); }
.pe-tool-btn.is-active{ background: var(--pe-brass-500); border-color: var(--pe-brass-500); color: #201A0D; }

.pe-canvas-wrap{ position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.pe-canvas{ display: block; max-width: 100%; max-height: 520px; width: auto; height: auto; cursor: crosshair; touch-action: none; }
.pe-selection{
  position: absolute; left: 0; top: 0;
  border: 1.5px dashed var(--pe-brass-600);
  background: rgba(182,144,63,0.18);
  pointer-events: none;
}
.pe-lasso-overlay{
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.pe-lasso-poly{
  stroke: var(--pe-brass-600); stroke-width: 1.5; stroke-dasharray: 5 4;
  fill: rgba(182,144,63,0.18);
}
.pe-upload-overlay-btn{
  position: absolute; top: 12px; right: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  font-family: var(--pe-font); font-size: 0.82rem; font-weight: 600;
  border: 0; border-radius: 999px;
  background: rgba(32,29,25,0.72); color: var(--pe-paper);
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: background 0.2s var(--pe-ease), transform 0.2s var(--pe-ease);
}
.pe-upload-overlay-btn svg{ width: 15px; height: 15px; flex: none; }
.pe-upload-overlay-btn:hover{ background: var(--pe-brass-600); transform: translateY(-1px); }
.pe-zoom-overlay-btn{ left: 12px; right: auto; }
.pe-hint{ font-size: 0.78rem; color: var(--pe-stone-500); font-family: var(--pe-font-mono); text-align: center; margin: 0; }

/* ── 확대보기 ─────────────────────────────────────────────── */
.pe-zoom-lightbox{
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10,11,13,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(20px, 5vw, 60px);
}
.pe-zoom-lightbox[hidden]{ display: none; }
body.pe-zoom-open{ overflow: hidden; }
.pe-zoom-stage{
  flex: 1; width: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.pe-zoom-img{
  max-width: 100%; max-height: 100%;
  display: block;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  touch-action: none;
  user-select: none;
  transition: transform 0.08s linear;
}
.pe-zoom-bar{
  margin-top: 18px; flex: none;
  display: flex; align-items: center; gap: 10px;
  background: rgba(252,252,253,0.12); border-radius: 999px;
  padding: 7px 10px;
}
.pe-zoom-step, .pe-zoom-reset{
  border: 0; border-radius: 999px; cursor: pointer;
  font-family: var(--pe-font); color: var(--pe-paper);
  background: transparent;
  transition: background 0.15s ease;
}
.pe-zoom-step{ width: 30px; height: 30px; font-size: 1.1rem; line-height: 1; }
.pe-zoom-step:hover, .pe-zoom-reset:hover{ background: rgba(252,252,253,0.18); }
.pe-zoom-pct{
  min-width: 48px; text-align: center;
  font-family: var(--pe-font-mono); font-size: 0.8rem; color: var(--pe-paper);
}
.pe-zoom-reset{ font-size: 0.78rem; padding: 6px 14px; }
.pe-zoom-close{
  position: absolute; top: 18px; right: 18px; z-index: 1;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(252,252,253,0.12); color: var(--pe-paper);
  font-size: 1.3rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.pe-zoom-close:hover{ background: rgba(252,252,253,0.22); }

.pe-controls{
  background: var(--pe-paper);
  border: 1px solid var(--pe-line);
  padding: 36px;
  box-sizing: border-box;
  display: flex; flex-direction: column; gap: 22px;
}
.pe-target{
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 0.8rem; color: var(--pe-ink-700); font-family: var(--pe-font-mono);
  padding-bottom: 14px; border-bottom: 1px dashed var(--pe-line-strong);
}
.pe-target span{ color: var(--pe-ink-900); font-weight: 600; }

.pe-field{ display: flex; flex-direction: column; gap: 8px; }
.pe-field label{
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 0.86rem; font-weight: 500; color: var(--pe-ink-700);
}
.pe-field output{ font-family: var(--pe-font-mono); color: var(--pe-brass-700); font-weight: 700; }
.pe-field input[type="range"]{ width: 100%; accent-color: var(--pe-brass-500); }

.pe-presets{ display: flex; flex-direction: column; gap: 10px; }
.pe-presets-label{
  margin: 0; font-size: 0.78rem; font-family: var(--pe-font-mono); color: var(--pe-stone-500);
}
.pe-preset-grid{ display: flex; flex-wrap: wrap; gap: 8px; }
.pe-preset-item{
  display: inline-flex; align-items: stretch;
  width: 112px; height: 36px;
  background: var(--pe-paper-2);
  border: 1px solid transparent;
  border-radius: 999px;
  overflow: hidden;
  transition: border-color 0.2s var(--pe-ease);
}
.pe-preset-item:hover{ border-color: var(--pe-brass-500); }
.pe-chip{
  flex: 1 1 auto; min-width: 0;
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 0 4px;
  background: transparent; color: var(--pe-ink-900);
  border: 0;
  cursor: pointer;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.2s var(--pe-ease);
}
.pe-chip:hover{ background: var(--pe-brass-300); }
.pe-preset-step{
  width: 26px; flex: none;
  font-family: var(--pe-font-mono); font-size: 0.82rem; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--pe-stone-500);
  border: 0;
  cursor: pointer;
  transition: background 0.15s var(--pe-ease), color 0.15s var(--pe-ease);
}
.pe-preset-step:hover{ background: var(--pe-brass-500); color: #201A0D; }

.pe-actions{ display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

.pe-btn{
  flex: 1 1 auto; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px;
  font-family: inherit; font-size: 0.86rem; font-weight: 600;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.25s var(--pe-ease), background 0.25s var(--pe-ease),
    border-color 0.25s var(--pe-ease), color 0.25s var(--pe-ease);
  white-space: nowrap;
}
.pe-btn-primary{ background: var(--pe-brass-500); color: #201A0D; }
.pe-btn-primary:hover{ background: var(--pe-brass-300); transform: translateY(-2px); }
.pe-btn-outline{ background: transparent; border-color: var(--pe-line-strong); color: var(--pe-ink-900); }
.pe-btn-outline:hover{ border-color: var(--pe-ink-900); transform: translateY(-2px); }

.pe-link-btn{
  align-self: flex-start;
  font-family: var(--pe-font-mono); font-size: 0.78rem; color: var(--pe-stone-500);
  text-decoration: underline; text-underline-offset: 3px;
  background: none; border: 0; cursor: pointer; padding: 0;
}
.pe-link-btn:hover{ color: var(--pe-brass-600); }

.pe-note{ margin: 0; font-size: 0.78rem; color: var(--pe-stone-500); font-family: var(--pe-font-mono); line-height: 1.6; }

@media (max-width: 560px){
  .pe-controls{ padding: 24px; }
  .pe-btn{ flex: 1 1 100%; }
}
