/* 사진 편집기 — 템플릿 문구 편집 하단 시트 (PR-S2 2026-06-06)
   라이트 톤 · 보라 포커스. 스코프: .pe-tpl-edit */

.pe-tpl-edit {
  position: absolute;
  inset: 0;
  z-index: 10020;
  display: flex;
  align-items: flex-end;
  -webkit-tap-highlight-color: transparent;
}
.pe-tpl-edit-scrim {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
}
.pe-tpl-edit-sheet {
  position: relative;
  width: 100%;
  max-height: min(74dvh, 640px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -18px 44px rgba(15, 23, 42, 0.16);
  border-top: 1px solid #e8eaf0;
  overflow: hidden;
  animation: peTplEditUp .2s ease;
}
@keyframes peTplEditUp { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }

.pe-tpl-edit-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f1f2f5;
}
.pe-tpl-edit-handle {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: #d8dbe2;
}
.pe-tpl-edit-head strong { font-size: 15px; font-weight: 800; color: #111827; letter-spacing: -0.02em; }
.pe-tpl-edit-x {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pe-tpl-edit-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  flex: 1;
}

.pe-tpl-edit-field { display: grid; gap: 6px; margin-bottom: 13px; }
.pe-tpl-edit-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 750;
  color: #374151;
  letter-spacing: -0.02em;
}
.pe-tpl-edit-count { font-size: 11px; font-weight: 600; color: #9ca3af; }
.pe-tpl-edit-field input,
.pe-tpl-edit-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e8eaf0;
  border-radius: 14px;
  background: #f9fafb;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 11px 12px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.pe-tpl-edit-field textarea { resize: none; line-height: 1.45; }
.pe-tpl-edit-field input:focus,
.pe-tpl-edit-field textarea:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14);
  background: #fff;
}

/* services 행 */
.pe-tpl-edit-services > label { margin-bottom: 2px; }
.pe-tpl-edit-svc-actions { display: inline-flex; align-items: center; gap: 12px; }
.pe-tpl-edit-addrow {
  border: 0;
  background: transparent;
  color: #7c3aed;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.pe-tpl-edit-pastebtn {
  border: 1px solid #d6d3e6;
  background: #faf9ff;
  color: #6d28d9;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
}

/* 붙여넣기 자동 배치 영역 (S5a) */
.pe-tpl-edit-paste {
  display: grid;
  gap: 8px;
  margin: 2px 0 8px;
  padding: 10px;
  border: 1px solid #e2def0;
  border-radius: 14px;
  background: #faf9ff;
}
.pe-tpl-edit-paste[hidden] { display: none; }
.pe-tpl-edit-paste textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e8eaf0;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.5;
  padding: 10px 11px;
  resize: none;
  outline: none;
}
.pe-tpl-edit-paste textarea:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14);
}
.pe-tpl-edit-paste-foot { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.pe-tpl-edit-paste-cancel {
  height: 38px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.pe-tpl-edit-paste-apply {
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* 되돌리기 토스트 (시트 하단, 5초) */
.pe-tpl-edit-undo {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  background: #1f2430;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.24);
  animation: peTplEditUp .18s ease;
}
.pe-tpl-edit-undo button {
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  border-radius: 9px;
  padding: 5px 11px;
  cursor: pointer;
}
.pe-tpl-edit-svc-row {
  display: grid;
  grid-template-columns: 22px 1fr 28px;
  align-items: start;
  gap: 8px;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid #eef0f4;
  border-radius: 14px;
  background: #fcfcfd;
}
.pe-tpl-edit-svc-no {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ede9fe;
  color: #7c3aed;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin-top: 4px;
}
.pe-tpl-edit-svc-fields { display: grid; gap: 6px; min-width: 0; }
.pe-tpl-edit-svc-line { display: grid; grid-template-columns: 1fr 0.78fr; gap: 6px; }
.pe-tpl-edit-svc-del {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 2px;
}

.pe-tpl-edit-imgnote {
  border: 1px dashed #d6d3e6;
  border-radius: 14px;
  background: #faf9ff;
  color: #8b80a6;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  padding: 13px 14px;
}

/* before 사진 교체 슬롯 (S3a) */
.pe-tpl-edit-imgrow { display: flex; align-items: center; gap: 12px; }
.pe-tpl-edit-imgthumb {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 1px solid #e8eaf0;
  background: #f3f4f6;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.pe-tpl-edit-imgthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pe-tpl-edit-imgthumb.is-empty {
  border-style: dashed;
  border-color: #d6d3e6;
  background: #faf9ff;
}
.pe-tpl-edit-imgplus { color: #b3a9cf; font-size: 26px; font-weight: 400; line-height: 1; }
.pe-tpl-edit-imgbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-tpl-edit-imgpick {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 14px;
  cursor: pointer;
}
.pe-tpl-edit-imgclear {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: #6b7280;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 13px;
  cursor: pointer;
  max-width: 188px;
  white-space: normal;
  line-height: 1.25;
}
.pe-tpl-edit-imghint { margin: 8px 0 0; font-size: 11.5px; font-weight: 600; color: #9ca3af; line-height: 1.5; }

.pe-tpl-edit-foot {
  display: grid;
  gap: 8px;
  padding: 11px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #f1f2f5;
  background: #fff;
}
.pe-tpl-edit-savehint {
  color: #6b7280;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.02em;
}
.pe-tpl-edit-actions {
  display: grid;
  grid-template-columns: .8fr 1.15fr 1.25fr;
  gap: 8px;
}
.pe-tpl-edit-cancel {
  height: 48px;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.pe-tpl-edit-save {
  height: 48px;
  border: 1px solid #d6d3e6;
  border-radius: 14px;
  background: #faf9ff;
  color: #6d28d9;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}
.pe-tpl-edit-apply {
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

/* 갤러리 문구 편집 버튼 */
.pe-tplg-edit {
  width: 100%;
  height: 46px;
  margin-top: 10px;
  border: 1px solid #d6d3e6;
  border-radius: 14px;
  background: #faf9ff;
  color: #6d28d9;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}

@media (width <= 430px) {
  .pe-tpl-edit-svc-line { grid-template-columns: 1fr 0.72fr; }
  .pe-tpl-edit-actions { grid-template-columns: 1fr; }
}
