/* IMGIFY design-first — 이미지·PDF 작업 화면 (시안 v3 Main / Mobile / MobileResult / PdfTool)
   패널(#convert #photoEdit #pdf)의 id·내부 훅은 기존 JS가 쓰므로 유지하고, 배치는 시안 구조로 새로 짭니다. */

.panel { display: none; }
.panel.active { display: block; }

/* ===== 작업 카드: 1 사진 선택 | 2·3 설정 ===== */
.ig-workspace { display: flex; flex-wrap: wrap; gap: var(--ig-space-5); }
.ig-col { min-width: 0; display: flex; flex-direction: column; gap: var(--ig-space-3); }
.ig-col--main { flex: 999 1 520px; }
.ig-col--side { flex: 1 1 360px; gap: 22px; padding-left: var(--ig-space-5); border-left: 1px solid var(--ig-color-line); }
.ig-col--side .options { display: flex; flex-direction: column; gap: 22px; }
.ig-run { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--ig-color-line); }
.ig-run .actions { display: flex; flex-direction: column; gap: 10px; }
.ig-run .ig-run__hint { text-align: center; }
.ig-run .actions #clearBtn { display: none; }

/* ===== 결과 카드 ===== */
.ig-results { margin-top: var(--ig-space-4); padding: 28px var(--ig-space-5); display: flex; flex-direction: column; gap: 18px; }
.ig-results[hidden] { display: none; }
.ig-results__head { display: flex; align-items: center; justify-content: space-between; gap: var(--ig-space-3); flex-wrap: wrap; }
.ig-results__title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ig-results__title h2 { font-size: var(--ig-text-section); font-weight: var(--ig-weight-heavy); }
.ig-results__tools { display: flex; gap: 10px; flex-wrap: wrap; }
.ig-results #downloadAll, .ig-results #pdfDownloadAll { width: auto; min-height: var(--ig-control-height); padding: 12px 20px; font-size: 15px; font-weight: var(--ig-weight-bold); margin: 0; }
.ig-results #retryFailed, .ig-results #resumeBatch { min-height: var(--ig-control-height); font-size: 15px; }
.ig-results .results .item .meta { white-space: normal; }

/* 다른 도구 카드 */
.ig-related { margin-top: 56px; }
.ig-related h2 { margin-bottom: var(--ig-space-3); font-size: var(--ig-text-section); font-weight: var(--ig-weight-heavy); }
.ig-related__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ig-related__card { display: flex; flex-direction: column; gap: 8px; padding: 20px; border: 1px solid var(--ig-color-line); border-radius: var(--ig-radius-card); background: var(--ig-color-surface); color: var(--ig-color-ink); text-decoration: none; transition: border-color var(--ig-duration); }
.ig-related__card:hover { border-color: var(--ig-color-primary); color: var(--ig-color-ink); }
.ig-related__card svg { width: 24px; height: 24px; color: var(--ig-color-primary); }
.ig-related__card strong { font-size: 16px; font-weight: var(--ig-weight-heavy); }
.ig-related__card span { font-size: 14px; color: var(--ig-color-muted); }

/* 작업 소개 문구(기존 image-workflows.js가 .card 앞에 넣는 .image-task-intro) */
.image-task-intro { display: none; }

/* ===== 편집기(사진 편집) ===== */
.ig-edit { display: flex; flex-direction: column; gap: var(--ig-space-3); }
.editor { display: flex; flex-direction: column; gap: var(--ig-space-3); padding: var(--ig-space-3); border: 1px solid var(--ig-color-line); border-radius: var(--ig-radius-card); background: var(--ig-color-surface); }
.editor:not(.open) { display: none; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--ig-text-section); }
.editor canvas { display: block; width: 100%; height: auto; border-radius: var(--ig-radius-control); background: var(--ig-color-segment); touch-action: none; }
.editor .options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ig-space-3); }
.editor-rotation, .crop-ratios, .editor-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.crop-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.crop-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: var(--ig-weight-bold); }
.crop-ratios button { min-height: var(--ig-touch-min); padding: 0 16px; border: 1px solid var(--ig-color-line-chip); border-radius: var(--ig-radius-pill); background: var(--ig-color-surface); color: var(--ig-color-text); font-size: 14px; font-weight: var(--ig-weight-medium); }
.crop-ratios button[aria-pressed="true"], .crop-ratios button.active { background: var(--ig-color-primary); border-color: var(--ig-color-primary); color: #fff; }
.crop-zoom { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.image-photo-output { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: var(--ig-space-3); border: 1px solid var(--ig-color-line); border-radius: var(--ig-radius-card); }
.image-photo-output img { max-width: 100%; height: auto; border-radius: var(--ig-radius-control); }

/* ===== PDF 도구 (시안 PdfTool: 모드 탭 + 3단계) ===== */
.pdf-tool-menu { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--ig-space-4); }
.pdf-tool-card { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 48px; padding: 8px 18px; border: 1px solid var(--ig-color-line-chip); border-radius: var(--ig-radius-pill); background: var(--ig-color-surface); color: var(--ig-color-text); text-align: left; text-decoration: none; transition: border-color var(--ig-duration), background var(--ig-duration); }
.pdf-tool-card strong { font-size: 15px; font-weight: var(--ig-weight-medium); color: inherit; }
.pdf-tool-card span { display: none; }
.pdf-tool-card:hover { border-color: var(--ig-color-primary); color: var(--ig-color-primary); }
.pdf-tool-card.active, .pdf-tool-card[aria-pressed="true"] { border-color: var(--ig-color-primary); background: var(--ig-color-primary); color: #fff; }
.pdf-tool-card.active strong, .pdf-tool-card[aria-pressed="true"] strong { font-weight: var(--ig-weight-heavy); }
.help-box { margin-top: var(--ig-space-2); }

/* ===== 사용 방법 패널(#guide) ===== */
.guide-block + .guide-block { margin-top: var(--ig-space-3); }
.guide-block h2 { font-size: var(--ig-text-section); font-weight: var(--ig-weight-heavy); margin-bottom: 4px; }
.guide-block p, .stamp-guide p { margin-top: 6px; font-size: 15px; color: var(--ig-color-text); }

/* ===== 모바일 ===== */
@media (max-width: 899px) {
  .ig-col--side { flex-basis: 100%; padding-left: 0; border-left: 0; padding-top: var(--ig-space-4); border-top: 1px solid var(--ig-color-line); }
  .ig-related__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .ig-card { border-radius: 18px; }
  .ig-tool-card { margin-top: var(--ig-space-3); }
  .ig-workspace { gap: var(--ig-space-3); }
  .drop { padding: var(--ig-space-3); gap: 12px; }
  .drop .ig-drop__icon, .drop > strong { display: none; }
  .drop .choose { width: 100%; }
  .ig-col--main .ig-step { margin-bottom: 0; }
  /* 하단 고정 실행 막대 (시안 Mobile) */
  .ig-run { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--ig-z-sticky); gap: 6px; padding: 12px var(--ig-space-3) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ig-color-line); background: var(--ig-color-surface); }
  .ig-run .ig-step, .ig-run .ig-run__desc { display: none; }
  .ig-run .ig-run__hint { font-size: 13px; }
  .ig-results { padding: var(--ig-space-3); }
  .ig-results__tools { width: 100%; }
  .ig-results #downloadAll, .ig-results #pdfDownloadAll { width: 100%; }
  .ig-summary__total { font-size: 24px; }
  .ig-related { margin-top: var(--ig-space-5); }
  .results .item-actions { width: 100%; margin-left: 0; }
  .crop-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor .options { grid-template-columns: minmax(0, 1fr); }
  .pdf-tool-menu { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--ig-space-3) * -1); padding-inline: var(--ig-space-3); }
  .pdf-tool-menu::-webkit-scrollbar { display: none; }
  .pdf-tool-card { flex: none; }
}
.steps { display: none; }
.ig-run .ig-tool-note { text-align: center; }
.ig-run__hint { text-align: center; }
@media (max-width: 700px) { .ig-run .ig-tool-note { display: none; } }
#compressionSummary, .batch-summary { display: none; }

/* PDF 패널 (시안 PdfTool): 가로형 업로드, 2단 배치 */
.drop--compact { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon title btn" "icon meta btn" "trust trust trust"; align-items: center; justify-items: start; gap: 2px 16px; padding: 20px 24px; text-align: left; }
.drop--compact .ig-drop__icon { grid-area: icon; width: 48px; height: 48px; }
.drop--compact > strong { grid-area: title; font-size: 16px; align-self: end; }
.drop--compact .ig-drop__meta { grid-area: meta; align-self: start; }
.drop--compact .choose { grid-area: btn; min-height: 48px; padding: 12px 22px; }
.drop--compact .ig-drop__trust { grid-area: trust; margin-top: 10px; }
.ig-field-mode { display: none; }
.ig-pdf .queued .queue-actions .small-button { border-color: var(--ig-color-line-strong); color: var(--ig-color-text); }
@media (max-width: 700px) {
  .drop--compact { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "meta" "btn" "trust"; justify-items: center; text-align: center; }
  .drop--compact .ig-drop__icon { display: none; }
  .drop--compact > strong { display: block; }
}

/* PDF 분할 범위 입력 */
.range-box { display: flex; flex-direction: column; gap: 8px; }
.range-box label { font-size: 15px; font-weight: var(--ig-weight-bold); }
.range-box .range-combine { display: inline-flex; align-items: center; gap: 10px; min-height: var(--ig-touch-min); font-weight: var(--ig-weight-medium); font-size: 14px; }

/* 변환 랜딩 안내 문단 (design-first: 도구 아래 카드) */
.ig-doc-card { margin-top: var(--ig-space-5); padding: var(--ig-space-4); border: 1px solid var(--ig-color-line); border-radius: var(--ig-radius-card); background: var(--ig-color-surface); }
.ig-doc-card h2 { margin: var(--ig-space-3) 0 6px; font-size: 18px; font-weight: var(--ig-weight-heavy); }
.ig-doc-card h2:first-child { margin-top: 0; }
.ig-doc-card p { font-size: 15px; line-height: 1.7; color: var(--ig-color-text); }

/* 메인 안에 상주하는 도구(iframe: 크기·규격 변경, 배경 제거, 일반 도장) */
.workspace-frame { display: block; width: 100%; min-height: 480px; border: 0; background: transparent; }

/* 변환·용량 줄이기: 사진을 고르기 전에는 드롭 영역이 왼쪽 열을 채워 빈 공간을 줄임 */
@media (min-width: 701px) {
  #convert .ig-col--main > .drop:not(.drop--compact) { flex: 1 1 auto; min-height: 320px; }
  #convert .ig-col--main:has(#selectionList > *, #results > *) > .drop:not(.drop--compact) { flex: 0 0 auto; min-height: 0; }
}

/* 사진 편집 중에는 선택 카드를 접어 작업면에 집중합니다. */
#photoEdit:has(> .editor.open) > .ig-edit { display: none; }

/* ===== 사진 편집 실제 작업 화면 · 결과 (2026-11-27) ===== */
.editor-head__tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.editor canvas { width: auto; max-width: 100%; max-height: min(52vh, 440px); margin: 0 auto; }
.editor-howto summary { min-height: var(--ig-touch-min); display: flex; align-items: center; font-size: 14px; font-weight: var(--ig-weight-bold); cursor: pointer; }
.editor .editor-help { margin: 0; font-size: 13px; line-height: 1.6; }
.editor .editor-tone { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.editor .editor-tone .field { display: grid; grid-template-columns: auto minmax(0, 1fr) 4ch; align-items: center; gap: 8px; margin: 0; }
.editor .editor-tone input[type="range"] { width: 100%; min-height: var(--ig-touch-min); margin: 0; }
.editor .editor-tone .hint { margin: 0; text-align: right; white-space: nowrap; }
.crop-zoom input { flex: 1; min-width: 0; min-height: var(--ig-touch-min); }
.editor input[type="range"] { touch-action: pan-y; }
.editor-actions { position: sticky; bottom: 0; z-index: 2; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--ig-color-surface); border-top: 1px solid var(--ig-color-line); }
.editor-actions button { min-height: 48px; }
.editor-actions #saveEdit { flex: 1 1 160px; }
.image-photo-output { gap: 8px; margin-bottom: var(--ig-space-3); scroll-margin-top: 12px; }
.image-photo-output h3, .image-photo-output p { margin: 0; }
.image-photo-output img { width: auto; max-height: min(48vh, 420px); }
.image-photo-output .button { width: 100%; max-width: 360px; text-align: center; }
@media (max-width: 700px) {
  .editor { gap: 8px; padding: 10px; }
  .crop-ratios { flex-wrap: nowrap; gap: 4px; }
  .crop-ratios button { flex: 1 1 0; min-width: 0; padding: 0 4px; }
  .editor .editor-tone { grid-template-columns: minmax(0, 1fr); }
  .editor-rotation button { flex: 1 1 0; }
}
/* 목록 위의 "전체 선택 취소"와 중복되지 않게 실행 막대에서는 숨김 */
.ig-run .actions #pdfClearBtn { display: none; }

/* 결과가 생기면 원본 전달 칸은 숨기고 결과물 이어서 작업(.ig-continue)을 사용 */
#convert.ig-has-results .resize-transfer { display: none; }
