/* ============================================================
   image.css — TimeSave Image 서비스 스타일
   ------------------------------------------------------------
   공통 디자인 토큰은 pdf/link 와 동일 계열을 따르되,
   image 서비스 액센트만 lime(#65A30D)로 교체한다.
   레이아웃은 image.md 확정 설계:
     · 데스크톱: 좌(이미지 전/후 위아래) | 우(아코디언 + 이력)
     · 모바일:   카드 → 이미지(전/후 좌우) → 아코디언 세로 스택
   처리 모델: 적용 기반 파이프라인(원본 + 적용 작업 목록) + 되돌리기.
   ============================================================ */

:root {
  --bg-base:        #f8f9fb;
  --bg-surface:     #ffffff;
  --accent:         #65A30D;            /* lime green — image 서비스 액센트 */
  --accent-dim:     rgba(101,163,13,0.08);
  --accent-strong:  #4d7c0f;
  --green:          #22C55E;
  --green-dim:      rgba(34,197,94,0.08);
  --text-primary:   #111218;
  --text-secondary: #55556a;
  --text-muted:     #9898b0;
  --border:         rgba(0,0,0,0.08);
  --border-hover:   rgba(0,0,0,0.15);
  --radius:         10px;
  --radius-lg:      16px;
  --font-body:      'DM Sans', system-ui, sans-serif;
  --font-mono:      'Space Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   공통 레이아웃
═══════════════════════════════════════════ */
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }

.section        { padding: 56px 0; }
.section-label  {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 4px; padding: 3px 10px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 30px; font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.2;
  margin-bottom: 12px;
}
.section-desc {
  font-size: 16px; color: var(--text-secondary);
  max-width: 620px; line-height: 1.7;
  margin-bottom: 36px;
}

/* ═══════════════════════════════════════════
   HERO (간단 — 도구 페이지라 컴팩트)
═══════════════════════════════════════════ */
.img-hero {
  text-align: center;
  padding: 48px 28px 24px;
}
.img-hero h1 {
  font-size: 34px; font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.2;
  margin-bottom: 12px;
}
.img-hero h1 .grad {
  background: linear-gradient(135deg, #65A30D 10%, #22C55E 90%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.img-hero p {
  font-size: 17px; color: var(--text-secondary);
  max-width: 560px; margin: 0 auto; line-height: 1.6;
}

/* ═══════════════════════════════════════════
   기능 카드 (모바일 빠른 진입 / 데스크톱 숨김)
   image.md: 데스크톱은 아코디언 헤더가 곧 기능선택 → 카드 중복 → CSS로 숨김.
═══════════════════════════════════════════ */
.tool-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.tool-card-btn {
  flex: 1 1 100px;
  max-width: 140px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.tool-card-btn:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 18px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}
.tool-card-btn.active {
  border-color: var(--accent);
  background: rgba(101, 163, 13, 0.06);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 4px 20px rgba(101, 163, 13, 0.1);
  transform: translateY(-2px);
}
.tool-card-btn.active .tool-card-name {
  color: var(--accent);
}
.tool-card-ico {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.tool-card-name { font-size: 12px; font-weight: 700; text-align: center; }
.tool-card-sub  { display: none; }

/* ═══════════════════════════════════════════
   메인 작업 영역 — 좌우 분할 (데스크톱) / 세로 (모바일)
═══════════════════════════════════════════ */
.workspace {
  display: grid;
  grid-template-columns: var(--panel-cols, minmax(360px, 1fr) 340px);
  gap: 28px;
  align-items: start;
}

/* 패널 크기 조절 중에는 작업 영역만 뷰포트 폭까지 확장 (page-wrap 1180px 제한 돌파) */
.workspace.expanded {
  width: var(--ws-expanded-w, 100%);
  max-width: var(--ws-expanded-w, none);
  margin-left: var(--ws-expanded-ml, 0);
  margin-right: var(--ws-expanded-mr, 0);
}

/* ── 왼쪽: 이미지 영역 ─────────────────────────── */
.img-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 20px 20px;
  position: sticky; top: 16px;
  min-width: 0;
  max-width: 100%;
  --preview-box-min: 180px;
  --preview-box-max: 360px;
  --preview-image-width: 100%;
}

/* 드롭존 (이미지 미등록 상태) */
.dropzone {
  position: relative;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone.drag-over { border-color: var(--accent); background: var(--accent-dim); }
/* 모바일 호환: input이 dropzone 전체를 커버, 직접 탭으로 파일 선택 */
.dropzone input[type="file"] {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0; /* inset 대신 명시적 스타일 (iOS 호환) */
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
  font-size: 16px; /* iOS Safari 자동 줄 확대 방지 */
  margin: 0; padding: 0; border: 0;
}
/* 드롭존 안 자식 요소들은 터치 이벤트를 input에게 양보 */
.dropzone > *:not(input[type="file"]) { pointer-events: none; }
.drop-icon { color: var(--accent); margin-bottom: 14px; }
.drop-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.drop-hint  { font-size: 13px; color: var(--text-muted); }
.btn-pick {
  margin-top: 18px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  padding: 11px 22px; border-radius: var(--radius);
  border: none; cursor: pointer;
  transition: filter 0.15s;
}
.btn-pick:hover { filter: brightness(1.07); }

/* 전/후 미리보기 — 데스크톱: 위아래 / 모바일: 좌우 (미디어쿼리에서 전환) */
#editArea { min-width: 0; max-width: 100%; }
#editArea > *:first-child { margin-top: 0; }
.preview-item { min-width: 0; max-width: 100%; }
.preview-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; max-width: 100%; margin-top: 0; }
.preview-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  min-width: 0;
  height: var(--preview-box-max);
  overflow: auto;
  position: relative;
}
/* 이미지가 커서 스크롤이 생길 때, flex 중앙정렬로 잘려 못 보는 부분 방지 — 내부에 wrap 두지 않으므로 flex 기본 동작로 충분 */
.preview-box img {
  /* 100% = 고 · 그 표시영역 = 요소 크기여서 크롭 오버레이가 정확히 맞음.
     폭·높이를 둘 다 캔버스×배율로 제한 → 브라우저가 비율 유지하며 작은 쪽에 맞춤(contain).
     100%면 전체가 보이고(스크롤 없음), 초과하면 캔버스를 넘어 스크롤 생김. */
  max-width: calc(100% * var(--preview-image-scale, 1));
  max-height: calc(100% * var(--preview-image-scale, 1));
  width: auto;
  height: auto;
  display: block;
  flex: 0 0 auto;
  /* flex 중앙정렬(align/justify center)은 자식이 컨테이너보다 클 때
     위·왼쪽 넘침분을 스크롤로 닿지 못하는 알려진 버그가 있다.
     margin:auto 로 정렬하면 작을 때는 가운데, 클 때는 양방향 스크롤이 정상 확보된다. */
  margin: auto;
}
/* fit 모드: 체크된 축을 캔버스에 맞춤 (슬라이더 배율 무시) */
.preview-box.fit-w.fit-h img {   /* 둘 다: contain — 전체가 다 보임 */
  max-width: 100%;
  max-height: 100%;
}
.preview-box.fit-w:not(.fit-h) img {   /* 너비만 맞춤 — 높으면 세로 스크롤 */
  max-width: 100%;
  max-height: none;
  width: 100%;
}
.preview-box.fit-h:not(.fit-w) img {   /* 높이만 맞춤 — 넓으면 가로 스크롤 */
  max-width: none;
  max-height: 100%;
  height: 100%;
}
.preview-tag {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 3px 8px; border-radius: 4px;
}
.preview-tag.after { background: var(--accent); }

/* 패널 크기 조절 핸들 (좌상단·좌하단 모서리) — 대각선: width+height, 수평: width만 */
.img-panel { position: sticky; }
.panel-resize-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  opacity: 0.85;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s;
  touch-action: none;
}
.img-panel.has-resize .panel-resize-handle { display: flex; }
.panel-resize-handle:hover {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
}
.panel-resize-handle svg { pointer-events: none; }
.panel-resize-handle.tl { top: -11px;    left: -11px;    cursor: nwse-resize; }
.panel-resize-handle.bl { bottom: -11px; left: -11px;    cursor: nesw-resize; }

/* 전/후 미리보기 헤더 (태그 + key·value 칩 메타) */
.preview-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin: 0 0 10px;
}
.ph-before-toggle-inline {
  margin-left: auto;         /* Current 정보 오른쪽 끝에 붙음 */
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.ph-before-toggle-inline:hover { color: var(--text-secondary); }
.ph-before-toggle-inline input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px; height: 13px;
  margin: 0;
  cursor: pointer;
}
.ph-tag {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 5px 13px; border-radius: 999px;
  flex-shrink: 0;
}
.preview-header.after .ph-tag {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
/* key·value 칩 메타 마디 (가로 컴팩트) */
.ph-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}
.meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
  padding: 4px 11px;
  border-radius: 7px;
  background: var(--bg-base);
  border: 1px solid var(--border);
}
.meta-chip .mc-k {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted);
}
.meta-chip .mc-v {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
/* 용량 증감 배지 (현재 헤더 끝) */
.preview-header .meta-delta {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 7px;
  flex-shrink: 0;
}
.meta-delta.up   { color: #dc2626; background: rgba(220,38,38,0.08); }
.meta-delta.down { color: #16a34a; background: rgba(22,163,74,0.08); }

/* 썸네일 줄 (다중 이미지) — editArea 최상단에 위치 */
.thumb-strip {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 16px;
}
.thumb-mode-label {
  flex-shrink: 0;
  width: 108px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.4;
  display: flex;
  align-items: center;
}
.thumb-mode-label.locked {
  color: var(--accent-strong);
}
.thumb-strip .thumb-row {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.thumb-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.thumb-row::-webkit-scrollbar {
  height: 8px;
}
.thumb-row::-webkit-scrollbar-track {
  background: var(--bg-base);
  border-radius: 999px;
}
.thumb-row::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.28);
  border-radius: 999px;
}
.thumb-row::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.42);
}
.thumb-wrapper {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  cursor: grab;
}
.thumb-wrapper:active { cursor: grabbing; }
.thumb-wrapper.dragging { opacity: 0.35; }
.thumb-wrapper.drag-over { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.thumb-drop-placeholder {
  width: 3px;
  min-width: 3px;
  height: 52px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
  pointer-events: none;
  align-self: center;
}
.thumb {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 2px solid transparent;
  object-fit: cover;
  cursor: pointer;
  background: #f0f0f0;
}
.thumb.active { border-color: var(--accent); }
.thumb-remove {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.12s, background 0.12s;
  padding: 0;
}
.thumb-remove:hover {
  transform: scale(1.15);
  background: #dc2626;
}

/* 다운로드 버튼 */
.img-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn-download {
  flex: 1; min-width: 160px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff;
  font-family: var(--font-body); font-size: 15px; font-weight: 700;
  padding: 13px 20px; border-radius: var(--radius);
  border: none; cursor: pointer;
  transition: filter 0.15s;
}
.btn-download:hover { filter: brightness(1.07); }
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; color: var(--text-secondary);
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 13px 18px; border-radius: var(--radius);
  border: 1px solid var(--border-hover); cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 오른쪽: 아코디언 + 이력 ───────────────────── */
.acc-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* Preview·Info 공통 접기/펼치기 (기본 열림) */
.pc-accordion { gap: 0 !important; }
.pc-acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
  user-select: none;
}
.pc-acc-chev {
  color: var(--text-muted);
  display: flex;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.pc-accordion.open .pc-acc-chev { transform: rotate(180deg); }
.pc-acc-body {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.pc-accordion.open .pc-acc-body { display: flex; }

/* 우측 고정 미리보기 컨트롤 — 좌측 패널과 겹치지 않게 sticky */
.preview-controls-card {
  position: sticky;
  top: 16px;
  z-index: 5;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(17,18,24,0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.preview-controls-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
.preview-scale-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  min-width: 42px;
  text-align: right;
}
.preview-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label label"
    "slider value";
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  min-width: 0;
}
.preview-control-label {
  grid-area: label;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}
.preview-control-row input[type="range"] {
  grid-area: slider;
  width: 100%;
  min-width: 80px;
  accent-color: var(--accent);
}
.preview-scale-value { grid-area: value; }
.preview-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.preview-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
/* fit 체크 두 개 가로 배치 */
.preview-fit-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.preview-fit-row .preview-toggle-row { gap: 7px; }
/* fit 활성 시 사이즈 슬라이더 행 흐림처림(비활성) */
.preview-controls-card.fit-active .preview-control-row {
  opacity: 0.4;
  pointer-events: none;
}

/* 정보 카드 (원본 메타 + EXIF) — Preview 카드 바로 아래 */
.info-card {
  position: sticky;
  top: 16px;
  z-index: 4;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(17,18,24,0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.info-card-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.info-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.info-row .info-k {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.info-row .info-v {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}
.info-row.info-gps .info-v {
  color: #d97706;
}
.info-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding-top: 2px;
}
.info-note.info-strip {
  color: var(--accent-strong);
  background: var(--accent-dim);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 2px;
}

.accordion {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-top: 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.03);
}
.accordion.open {
  display: block;
}
.accordion.highlight { animation: none; }

.acc-header {
  display: none;
}
.acc-body {
  padding: 0;
}
.acc-disabled-note {
  font-size: 13px; color: var(--text-muted);
  background: var(--bg-base); border-radius: var(--radius);
  padding: 12px 14px;
}

/* 폼 컨트롤 (아코디언 내부) */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label {
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.form-input, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: var(--font-body); font-size: 14px;
  color: var(--text-primary); background: var(--bg-base);
  outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 비율 프리셋 버튼 (crop / resize) */
.ratio-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ratio-btn {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text-secondary); cursor: pointer;
  transition: all 0.12s;
}
.ratio-btn:hover  { border-color: var(--accent); color: var(--accent); }
.ratio-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 슬라이더 (압축 품질) */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.slider-val { font-family: var(--font-mono); font-size: 13px; font-weight: 700; min-width: 44px; text-align: right; }

/* 적용 버튼 */
.btn-apply {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff;
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  padding: 12px 18px; border-radius: var(--radius);
  border: none; cursor: pointer; margin-top: 4px;
  transition: filter 0.15s, background 0.15s;
}
.btn-apply:hover { filter: brightness(1.07); }
.btn-apply:disabled { opacity: 0.38; cursor: not-allowed; filter: none; }
.apply-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.apply-btn-group .btn-apply { margin-top: 0; }
.btn-apply-single {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border) !important;
}
.btn-apply-single:hover { background: var(--bg-base); filter: none; }

/* 회전/반전 버튼 그리드 (Rotate & Flip) — 5개 버튼 3열 2줄 */
.rotate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.btn-rotate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 6px;
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s, box-shadow .12s;
}
.btn-rotate svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.btn-rotate:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 2px 10px rgba(101,163,13,0.12);
}
.btn-rotate:active { transform: translateY(1px); }

/* 처리 이력 / 파이프라인 */
.history-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.history-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.btn-undo {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border-hover); background: var(--bg-surface);
  color: var(--text-secondary); cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-undo:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn-undo:disabled { opacity: 0.4; cursor: not-allowed; }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-secondary);
  padding: 8px 10px; border-radius: 8px; background: var(--bg-base);
}
.history-item .hist-num {
  width: 20px; height: 20px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  border-radius: 50%; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.history-empty { font-size: 13px; color: var(--text-muted); }

/* ═══════════════════════════════════════════
   SEO 콘텐츠 블록 (기능별 고유 텍스트 — 중복 콘텐츠 회피)
═══════════════════════════════════════════ */
.seo-block { padding: 8px 0 16px; }
.seo-block h2 { font-size: 22px; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.01em; }
.seo-block h3 { font-size: 16px; font-weight: 700; margin: 20px 0 8px; }
.seo-block p  { font-size: 15px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 12px; }
.faq-item { border-top: 1px solid var(--border); padding: 16px 0; }
.faq-item:last-child { border-bottom: 1px solid var(--border); }
.faq-q { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.faq-a { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary); color: #fff;
  font-size: 16px; font-weight: 600;
  padding: 15px 30px; border-radius: 12px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 28px rgba(17,18,24,0.28);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════════════════════
   CONFIRM DIALOG
═══════════════════════════════════════════ */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(17,18,24,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s;
}
.confirm-overlay.show { opacity: 1; pointer-events: all; }
.confirm-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 28px 28px 20px;
  max-width: 360px; width: calc(100vw - 48px);
  box-shadow: 0 12px 40px rgba(17,18,24,0.22);
  transform: translateY(10px);
  transition: transform 0.18s;
}
.confirm-overlay.show .confirm-box { transform: translateY(0); }
.confirm-msg {
  font-size: 15px; line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 20px;
}
.confirm-btns {
  display: flex; gap: 10px; justify-content: flex-end;
}
.confirm-btns button {
  padding: 9px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background 0.15s, color 0.15s;
}
.confirm-cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border) !important;
}
.confirm-cancel:hover { background: var(--bg-base); }
.confirm-ok {
  background: var(--accent); color: #fff;
}
.confirm-ok:hover { background: var(--accent-strong); }

/* ═══════════════════════════════════════════
   NOTIFY OVERLAY (처리 중 / 완료)
═══════════════════════════════════════════ */
.notify-overlay {
  position: fixed; inset: 0;
  background: rgba(17,18,24,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s;
}
.notify-overlay.show { opacity: 1; pointer-events: all; }
.notify-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 32px 40px;
  max-width: 340px; width: calc(100vw - 48px);
  box-shadow: 0 12px 40px rgba(17,18,24,0.22);
  text-align: center;
  transform: translateY(10px);
  transition: transform 0.18s;
}
.notify-overlay.show .notify-box { transform: translateY(0); }
.notify-spinner {
  width: 28px; height: 28px; margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: notify-spin 0.7s linear infinite;
}
.notify-overlay.done .notify-spinner { display: none; }
.notify-done-icon {
  display: none;
  font-size: 28px; margin-bottom: 12px;
  color: var(--accent);
}
.notify-overlay.done .notify-done-icon { display: block; }
.notify-msg {
  font-size: 16px; font-weight: 600; line-height: 1.6;
  color: var(--text-primary);
}
.notify-overlay.done .notify-msg { color: var(--accent); }
@keyframes notify-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   DIVIDER
═══════════════════════════════════════════ */
.divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ═══════════════════════════════════════════
   RESPONSIVE
   image.md:
     · 데스크톱(>900px): 좌우 분할, 전/후 위아래, 카드 숨김
     · 모바일(≤900px): 세로 스택, 전/후 좌우, 카드 유지
═══════════════════════════════════════════ */


@media (max-width: 900px) {
  .thumb-strip { flex-direction: column; gap: 6px; }
  .thumb-mode-label { width: auto; padding: 6px 12px; font-size: 11px; }
  .workspace { grid-template-columns: 1fr; }
  .workspace.expanded {
    width: auto; max-width: none;
    margin-left: 0; margin-right: 0;
  }
  .img-panel { position: static; }
  .img-panel.has-resize .panel-resize-handle { display: none; }
  .preview-controls-card {
    position: static;
    grid-template-columns: auto minmax(0, 1fr);
  }
  /* 모바일: 전/후 좌우 나란히 */
  .preview-stack { flex-direction: row; }
  .preview-stack .preview-box { flex: 1; min-height: 140px; }
  .img-hero h1 { font-size: 28px; }
  .page-wrap { padding: 0 18px; }
}

@media (max-width: 520px) {
  /* 아주 좁은 화면: 전/후 다시 위아래로 (좌우는 너무 좁음) */
  .preview-stack { flex-direction: column; }
  .field-2col { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   CROP OVERLAY SYSTEM
═══════════════════════════════════════════ */
.crop-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
  display: none;
}
/* crop 오버레이는 가이드일 뿐 스크롤 대상이 아니다.
   crop 이 열린 동안은 미리보기 박스의 세로 스크롤(핵들·점선 테두리의
   미세 넘침 때문에 생기는 스크롤)를 숨긴다. 이미지 확대(>100%)는
   crop 이 아닌 상태에서만 쓰이므로 스크롤 손실 없음. */
.preview-box.crop-active {
  overflow: hidden;
}
.crop-overlay.show {
  display: block;
}
.crop-dim {
  position: absolute;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px dashed var(--accent);
  box-sizing: border-box;
  cursor: move;
  pointer-events: auto;
}
/* 격자 가이드선 (삼분할 법칙) */
.crop-grid-h, .crop-grid-v {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.crop-grid-h::before, .crop-grid-h::after {
  content: "";
  position: absolute;
  left: 0; width: 100%;
  border-top: 1px dashed rgba(255, 255, 255, 0.4);
}
.crop-grid-h::before { top: 33.33%; }
.crop-grid-h::after { top: 66.66%; }

.crop-grid-v::before, .crop-grid-v::after {
  content: "";
  position: absolute;
  top: 0; height: 100%;
  border-left: 1px dashed rgba(255, 255, 255, 0.4);
}
.crop-grid-v::before { left: 33.33%; }
.crop-grid-v::after { left: 66.66%; }

/* 드래그 조절 핸들 */
.crop-handle {
  position: absolute;
  width: 12px; height: 12px;
  background: var(--accent);
  border: 2px solid #ffffff;
  border-radius: 50%;
  z-index: 12;
}
/* 클릭 감지 영역 확장 */
.crop-handle::after {
  content: "";
  position: absolute;
  top: -10px; left: -10px; right: -10px; bottom: -10px;
}
.crop-handle.tl { top: -1px; left: -1px; cursor: nwse-resize; }
.crop-handle.tr { top: -1px; right: -1px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -1px; left: -1px; cursor: nesw-resize; }
.crop-handle.br { bottom: -1px; right: -1px; cursor: nwse-resize; }

/* ═══════════════════════════════════════
   ORIENTATION CARD (회전/뒤집기 방향 카드)
   · 바깥 wrapper(.orient-card) = 미리보기 박스 정중앙 고정(회전과 분리).
   · 안쪽 inner(.orient-card-inner) = 회전·뒤집 transform 전담.
   · 90° 회전에도 안 잘리도록 정사각 내접 크기(≤200px, ≤46%)로 제한.
═══════════════════════════════════════ */
.orient-card {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(46%, 200px);
  aspect-ratio: 3 / 4;
  pointer-events: none;   /* 미리보기 조작 방해 안 함 */
  display: none;
  z-index: 14;            /* 크롭 오버레이(10/12)보다 위 */
}
.orient-card.show { display: block; }

/* 방향 카드가 떠 있는 동안 뒤편 미리보기 사진을 흐리게 — 카드 내용에 집중 */
.preview-box:has(.orient-card.show) #previewAfter {
  filter: blur(6px) brightness(0.92);
  transition: filter .2s ease;
}

.orient-card-inner {
  width: 100%; height: 100%;
  transform-origin: center;
  transition: transform .25s ease;   /* 회전/뒤집 부드럽게 */
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.35));
}
.orient-card-svg {
  width: 100%; height: 100%;
  display: block;
  overflow: visible;
}
.orient-card-svg .oc-corner {
  font-family: var(--font-mono, 'Space Mono', monospace);
  font-size: 15px;
  font-weight: 700;
  fill: var(--accent, #22C55E);
  /* 사진 위에 떠므로 외곽선 그림자로 가독성 확보 */
  paint-order: stroke;
  stroke: rgba(0,0,0,0.55);
  stroke-width: 3px;
  stroke-linejoin: round;
}

/* ── HEIC 등록 진행바 (드롭존/이미지 패널 오버레이) ─────────── */
.heic-progress {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
  z-index: 30;
  border-radius: inherit;
}
.heic-progress.show { display: flex; }
.heic-progress-inner {
  width: min(280px, 78%);
  text-align: center;
}
.heic-progress-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin-bottom: 12px;
}
.heic-progress-sub {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 12px;
  margin-top: -6px;
  line-height: 1.4;
}
.heic-progress-track {
  height: 8px;
  background: var(--border, #e5e7eb);
  border-radius: 99px;
  overflow: hidden;
}
.heic-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #65A30D, #22C55E);
  border-radius: 99px;
  transition: width 0.25s ease;
}
.heic-progress-count {
  margin-top: 9px;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  color: var(--text-secondary, #6b7280);
}
/* 드롭존은 position:relative 가 아닐 수 있으므로 오버레이 기준 보장 */
.dropzone { position: relative; }

/* ===== 워터마크 (155-watermark.js) ===== */
/* 미리보기 오버레이 레이어 — #previewAfter 위에 겹쳐 그린다(crop 오버레이 패턴) */
.wm-layer {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 11;
  display: none;
}
.wm-layer.show { display: block; }

/* ===== 스티치 (160-stitch.js) ===== */
/* 미리보기 오버레이 레이어 — 메인 영역의 부모 박스를 기준 삼아 중앙에 띄운다 */
.stitch-layer {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  display: none;
}
.stitch-layer.show { display: block; }

/* 세그먼트 토글 (텍스트/로고, 타일/단일) */
.seg-group { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 8px 16px; border: none; background: var(--bg-surface);
  color: var(--text-secondary); cursor: pointer; transition: all 0.12s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { color: var(--accent); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* 색상 선택 입력 */
.form-color {
  width: 100%; height: 40px; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-surface); cursor: pointer;
}

/* ── 크기 모드 + 배경색 한 줄 레이아웃 ── */
.stitch-size-bg-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;   /* 라벨 기준 상단 정렬 */
  gap: 12px;
  margin-bottom: 16px;
}
.stitch-size-bg-row > .stitch-size-col,
.stitch-size-bg-row > .stitch-bg-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stitch-size-select { width: 100%; }

/* 컬러피커 래퍼 — select와 동일 높이(44px), 무지개 바로 기능 인지 */
.stitch-color-btn {
  position: relative;
  width: 52px;
  height: 44px;           /* form-select 와 높이 일치 */
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.stitch-color-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
/* color input — 전체 영역 투명 오버레이 (클릭 전달용) */
.stitch-color-btn input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  z-index: 2;
}
/* 색상 스와치 배경 (JS가 --swatch-color 변수로 동기화) */
.stitch-color-btn::before {
  content: '';
  position: absolute;
  inset: 0 0 8px 0;       /* 무지개 바 높이만큼 여백 */
  background: var(--swatch-color, #ffffff);
  pointer-events: none;
  z-index: 0;
  transition: inset 0.15s ease;
}
/* 무지개 바 — 컬러피커임을 직관적으로 인지 */
.stitch-color-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 8px;
  background: linear-gradient(
    to right,
    #ff0000, #ff7700, #ffff00,
    #00cc00, #0088ff, #8800ff, #ff0088
  );
  pointer-events: none;
  z-index: 1;
  transition: height 0.15s ease;
}
.stitch-color-btn:hover::before {
  inset: 0 0 10px 0;
}
.stitch-color-btn:hover::after {
  height: 10px;
}


/* 로고 선택 */
.wm-logo-pick { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.wm-logo-btn { display: inline-flex; padding: 9px 16px; font-size: 13px; }
.wm-logo-thumb {
  width: 40px; height: 40px; object-fit: contain;
  border: 1px solid var(--border); border-radius: 8px;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%) 0 0/12px 12px,
    linear-gradient(45deg, #e5e7eb 25%, #fff 25%, #fff 75%, #e5e7eb 75%) 6px 6px/12px 12px;
}

/* 워터마크 레이아웃 고도화 */
.seg-group-fill {
  display: flex !important;
  width: 100%;
}
.seg-group-fill .seg-btn {
  flex: 1;
  text-align: center;
}
.wm-dynamic-fields-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface-dim, #f8fafc);
  padding: 12px;
  margin-bottom: 14px;
  height: 80px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.wm-text-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.wm-text-row .flex-fill {
  flex: 1;
}
.wm-color-picker-group {
  flex-shrink: 0;
  width: 54px;
}
.wm-color-picker-btn {
  position: relative;
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wm-color-picker-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(to right, #ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6);
  z-index: 2;
}
.wm-color-picker-btn input[type="color"] {
  position: absolute;
  top: -5px;
  left: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  z-index: 1;
}
.wm-color-picker-ico {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f1f5f9;
  mix-blend-mode: difference;
}

#wmText {
  background-color: #ffffff !important;
}
