/* 사진 편집기 — P0 MVP UI (2026-05-17 v167)
   설계: ~/.claude/plans/zesty-snacking-clarke.md §25 */

.pe-sheet {
  position: fixed; inset: 0; z-index: 10000;
  background: #111;
  display: none;
  flex-direction: column;
}

.pe-root {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  max-width: 720px; margin: 0 auto;
  background: #0c0c10; color: #f7f7f9;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.pe-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top, 8px));
  background: transparent;
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  flex-shrink: 0;
}
.pe-topbar-spacer { flex: 1; }
.pe-topbar-chip {
  background: rgba(255,255,255,0.12);
  color: #fff; border: none; border-radius: 16px;
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; backdrop-filter: blur(8px);
}
.pe-back-btn {
  display: flex; align-items: center;
  background: rgba(0,0,0,0.3);
  color: #fff; border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  touch-action: manipulation;
}
.pe-back-btn:active { transform: scale(.93); }
.pe-iconbtn {
  background: rgba(0,0,0,0.3);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(8px);
}
.pe-iconbtn:active { transform: scale(.93); }
.pe-btn-primary {
  background: linear-gradient(135deg, #D58A95, #c66a80);
  color: #fff; border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.pe-btn-primary:active { transform: scale(.96); opacity: 0.9; }

.pe-stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0a0a0f;
  padding: 0;
  overflow: hidden;
  position: relative;
}
/* [v203 2026-05-19] 핀치 줌·패닝 — wrap 에 transform 적용 (자식 canvas/mask/cursor 모두 같이) */
.pe-canvas-wrap {
  position: relative;
  max-width: 100%; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.05s linear;
  will-change: transform;
  touch-action: none;  /* 브라우저 기본 핀치 줌 차단 — 직접 처리 */
}
.pe-canvas {
  display: block;
  max-width: 100%; max-height: 100%;
  border-radius: 6px;
  background: #222;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.pe-canvas-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px;
  text-align: center;
}

.pe-tabs {
  display: flex; gap: 2px;
  overflow: auto hidden;
  background: rgba(20,20,26,0.97);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 6px 6px env(safe-area-inset-bottom, 0);
  scrollbar-width: none;
  flex-shrink: 0;
}
.pe-tabs::-webkit-scrollbar { display: none; }
.pe-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent;
  color: #8a8a96;
  border: none;
  padding: 6px 10px 4px;
  border-radius: 10px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 52px;
  transition: color 0.15s, background 0.15s;
}
.pe-tab-icon {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.pe-tab.on {
  background: rgba(213,138,149,0.12);
  color: #D58A95;
}
.pe-tab.on .pe-tab-icon { stroke-width: 2.2; }

.pe-panel {
  background: linear-gradient(180deg, #18181f 0%, #111117 100%);
  padding: 14px 14px 22px;
  max-height: 38vh;
  overflow-y: auto;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.05);
  scrollbar-width: none;
}
.pe-panel::-webkit-scrollbar { display: none; }
.pe-panel-row { margin-bottom: 10px; }
.pe-panel-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pe-panel-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.pe-action-btn {
  width: 100%;
  padding: 12px;
  background: rgba(213,138,149,0.15);
  color: #D58A95; border: 1px solid rgba(213,138,149,0.25);
  border-radius: 14px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.pe-action-btn:active { background: rgba(213,138,149,0.25); transform: scale(.98); }

.pe-chip-btn {
  background: rgba(255,255,255,0.06);
  color: #d0d0d8;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 9px 14px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pe-chip-btn.on {
  background: rgba(213,138,149,0.2);
  color: #fff;
  border-color: rgba(213,138,149,0.5);
}
.pe-chip-btn:active { transform: scale(.97); }

.pe-slider {
  display: block;
  margin-bottom: 12px;
}
.pe-slider-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #a0a0ac;
  margin-bottom: 5px;
}
.pe-slider-val {
  color: #fff; font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.08);
  padding: 2px 8px; border-radius: 8px;
  font-size: 11px;
}
.pe-slider input[type="range"] {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  touch-action: manipulation;
}
.pe-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(213,138,149,0.5);
  cursor: pointer;
}
.pe-slider input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(213,138,149,0.5);
  cursor: pointer;
}

.pe-field {
  display: block;
  margin-bottom: 12px;
}
.pe-field > span,
.pe-field-label {
  display: block;
  font-size: 11px; color: #7a7a88;
  margin-bottom: 6px; letter-spacing: 0.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.pe-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  color: #f0f0f5;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.pe-input:focus { border-color: rgba(213,138,149,0.5); outline: none; }
.pe-input::placeholder { color: #55555f; }

.pe-coming {
  background: rgba(213,138,149,0.10);
  color: #f9c4ce;
  border: 1px dashed rgba(213,138,149,0.35);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 12px; line-height: 1.5;
  text-align: center;
}

.pe-hint {
  font-size: 11px; color: #6b6b76;
  line-height: 1.5;
  margin-top: 8px;
}
.pe-group-label {
  font-size: 11px; font-weight: 700; color: #9090a0;
  letter-spacing: 0.3px;
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* 저장 후 다음 단계 모달 */
.pe-modal {
  position: fixed; inset: 0; z-index: 10010;
  display: flex; align-items: flex-end; justify-content: center;
}
.pe-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55);
}
.pe-modal-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px;
  background: #fff; color: #222;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -12px 40px rgba(0,0,0,0.3);
  animation: pe-modal-up 220ms ease-out;
}
@keyframes pe-modal-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.pe-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.pe-modal-head strong { font-size: 14px; font-weight: 800; color: #222; }
.pe-modal-head .pe-iconbtn { background: #f3f3f6; color: #444; }
.pe-modal-thumb {
  display: flex; justify-content: center;
  margin-bottom: 14px;
}
.pe-modal-thumb img {
  max-width: 180px; max-height: 180px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.pe-modal-actions {
  display: flex; flex-direction: column; gap: 8px;
}
.pe-modal-actions .pe-action-btn { width: 100%; padding: 13px; font-size: 14px; }

/* AI 잇비 카테고리별 예시 칩 */
.pe-nl-examples { display: flex; flex-direction: column; gap: 10px; }
.pe-nl-group { display: flex; flex-direction: column; gap: 4px; }
.pe-nl-group-label { font-size: 11px; font-weight: 700; color: #8a8a96; letter-spacing: 0.02em; padding-left: 2px; }
.pe-nl-group-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pe-nl-group-chips .pe-chip-btn { font-size: 12px; padding: 5px 10px; border-radius: 16px; white-space: nowrap; }

/* ──────────────────────────────────────────────────────────────
   [PR-C1] 작업실 C-lite containment — 부위보정을 슬롯 팝업(#slotPopup) 안에
   absolute 로 담아 슬라이드업. 전체화면 fixed(.pe-sheet) 를 .pe-inline 일 때만 덮음.
   범위 전부 `.pe-inline` 스코프 → 일반/챗봇/타 메뉴 열기 영향 0.
   롤백: window.PE_CLITE=false (클래스 미부여 → 이 블록 비활성).
   ────────────────────────────────────────────────────────────── */
.pe-sheet.pe-inline {
  position: absolute;       /* #slotPopup(fixed) 내부에 갇힘 */
  inset: 0;
  z-index: 5;              /* 슬롯 팝업 헤더/툴바 위, 전역 오버레이엔 영향 없음 */
  animation: pe-inline-up 240ms ease-out;
}
@keyframes pe-inline-up {
  from { transform: translateY(100%); opacity: 0.5; }
  to   { transform: translateY(0); opacity: 1; }
}

/* [PR-C1] C-lite 썸네일 스트립 — 작업실 사진들과 연결감(번호/active 링). inline 일 때만 노출. */
.pe-thumb-strip {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 12px 6px; flex-shrink: 0;
  scrollbar-width: none; background: transparent;
}
.pe-thumb-strip::-webkit-scrollbar { display: none; }
/* 상단 topbar 가 position:absolute 라 inline 스트립을 그 높이만큼 내려 겹침 방지 */
.pe-sheet.pe-inline .pe-thumb-strip {
  margin-top: calc(52px + env(safe-area-inset-top, 0px));
}
.pe-thumb {
  position: relative; flex: 0 0 auto;
  width: 52px; height: 52px; border-radius: 12px;
  overflow: hidden; padding: 0; cursor: pointer;
  border: 2px solid transparent; background: #eceef1;
  -webkit-tap-highlight-color: transparent;
}
.pe-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pe-thumb.on { border-color: #6b5cff; box-shadow: 0 0 0 2px rgba(107,92,255,0.22); }
.pe-thumb-num {
  position: absolute; top: 2px; left: 2px;
  min-width: 15px; height: 15px; padding: 0 3px;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 9px; font-weight: 800; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
}

/* ══ [C-lite 디자인 매칭] inline 편집기 라이트 정밀화 (CSS only, 로직/수치 불변) ══ */
#photoEditorSheet.pe-inline { --pe-c-accent: #5b7cfa; --pe-c-border: #e8eaf0; }
/* 캔버스 영역을 밝은 카드처럼 */
#photoEditorSheet.pe-inline .pe-canvas-wrap {
  background: #f1f3f7; border-radius: 18px; border: 1px solid var(--pe-c-border);
  box-shadow: 0 10px 28px rgba(15,23,42,0.08); overflow: hidden;
}
#photoEditorSheet.pe-inline .pe-panel { border-radius: 22px 22px 0 0; box-shadow: 0 -12px 28px rgba(15,23,42,0.07); }
/* 부위 칩 — accent active */
#photoEditorSheet.pe-inline .pe-beauty-focus { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
#photoEditorSheet.pe-inline .pe-beauty-focus::-webkit-scrollbar { display: none; }
#photoEditorSheet.pe-inline .pe-beauty-focus button {
  flex: 0 0 auto; min-height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid transparent; background: #f2f4f7; color: #374151;
  font-size: 13px; font-weight: 750; cursor: pointer;
}
#photoEditorSheet.pe-inline .pe-beauty-focus button.on {
  color: var(--pe-c-accent); background: rgba(91,124,250,0.12); border-color: rgba(91,124,250,0.2);
}
/* 슬라이더 — 트랙 얇은 회색 + 블루 thumb (studio 핑크 오버라이드) */
#photoEditorSheet.pe-inline .pe-slider-head { color: #374151; }
#photoEditorSheet.pe-inline .pe-slider-val { color: var(--pe-c-accent); font-weight: 800; }
/* 기존 슬라이더는 input 의 background 자체를 트랙(rainbow/pink)으로 씀 → input bg 를 회색으로 덮고 thumb 만 블루. 효과 수치/이벤트 불변. */
#photoEditorSheet.pe-inline .pe-slider input[type="range"] { background: #e5e7eb !important; height: 4px; border-radius: 999px; accent-color: var(--pe-c-accent); }
#photoEditorSheet.pe-inline .pe-slider input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: transparent; }
#photoEditorSheet.pe-inline .pe-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; margin-top: -6.5px; border-radius: 999px;
  background: #fff !important; border: 2px solid var(--pe-c-accent) !important; box-shadow: 0 3px 10px rgba(91,124,250,0.28) !important;
}
#photoEditorSheet.pe-inline .pe-slider input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: #e5e7eb; }
#photoEditorSheet.pe-inline .pe-slider input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; border-radius: 999px; background: #fff; border: 2px solid var(--pe-c-accent); box-shadow: 0 3px 10px rgba(91,124,250,0.28); }
/* nav-v7 active accent 블루 통일 */
#photoEditorSheet.pe-inline .pe-nav-v7 { background: rgba(255,255,255,0.97); border-top: 1px solid var(--pe-c-border); }
#photoEditorSheet.pe-inline .pe-nav-v7-cat.on, #photoEditorSheet.pe-inline .pe-nav-v7-chip.on { color: var(--pe-c-accent); }
#photoEditorSheet.pe-inline .pe-nav-v7-chip.on::after { background: linear-gradient(135deg, #5b7cfa, #6c63ff); }
