:root {
  --bg: #0d0e10;
  --panel: #17181b;
  --raise: #1c1d21;
  --sunk: #101114;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --fg: #ececed;
  --fg-dim: #9b9ca3;
  --fg-mute: #75767e;
  --accent: #FFD75B;
  --accent-ink: #1d1703;
  --mono: 'Space Grotesk', ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #ffe38f; }

button, input, textarea { font-family: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(140deg, #FFE082, #FFC93C);
}
.brand-name { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; font-weight: 500; }
.badge {
  font-family: var(--mono); font-size: 11px; color: #83848c;
  padding: 3px 7px; border-radius: 6px; background: #212328;
}
.divider { width: 1px; height: 20px; background: var(--line-strong); }
.filemeta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.filename {
  font-size: 13px; font-weight: 500; max-width: 260px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filesub { font-family: var(--mono); font-size: 11px; color: #83848c; }

.segment { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: #212328; }
.seg-btn {
  border: none; cursor: pointer; padding: 7px 14px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; background: transparent; color: var(--fg-dim);
}
.seg-btn:hover { color: var(--fg); }
.seg-btn.is-on { background: var(--panel); color: var(--fg); box-shadow: 0 1px 5px rgba(0,0,0,.35); }

.btn {
  cursor: pointer; border-radius: 9px; font-size: 12.5px; font-weight: 500;
  padding: 8px 14px; border: 1px solid transparent; background: transparent;
}
.btn.ghost { border-color: var(--line-strong); color: #d6d7db; }
.btn.ghost:hover { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.04); }
.btn.primary { background: linear-gradient(140deg, #FFE082, #FFC93C); color: var(--accent-ink); font-weight: 700; font-size: 13px; padding: 9px 18px; }
.btn.primary:hover { background: #f5849b; }
.btn.wide { width: 100%; padding: 11px 0; border-radius: 11px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- layout ---------- */
.workspace { height: calc(100vh - 58px); display: flex; min-height: 0; }

.toolrail {
  width: 68px; flex: none; padding: 14px 0;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.tool {
  width: 44px; height: 44px; border-radius: 12px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--fg-dim);
}
.tool:hover { background: #212328; color: var(--fg); }
.tool.is-on { background: var(--accent); color: var(--accent-ink); }
.tool.is-off { color: #55565d; }
.tool svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.rail-rule { width: 28px; height: 1px; background: var(--line-strong); margin: 6px 0; }
.rail-label { font-family: var(--mono); font-size: 9.5px; color: #5f6068; letter-spacing: .1em; }
.swatches, .sizes { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
}
.swatch.is-on { border-color: #fff; }
#penColor {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border: none; padding: 0; background: transparent; cursor: pointer;
}
#penColor::-webkit-color-swatch-wrapper { padding: 0; }
#penColor::-webkit-color-swatch { border: 2px solid rgba(255,255,255,.18); border-radius: 8px; }

.size-btn {
  width: 32px; height: 32px; border-radius: 10px; border: none; cursor: pointer;
  background: transparent; display: flex; align-items: center; justify-content: center;
}
.size-btn:hover { background: #212328; }
.size-btn.is-on { background: #2a2c32; }
.size-dot { display: block; border-radius: 50%; background: #d7d8dc; }

/* ---------- stage ---------- */
.stage {
  flex: 1; min-width: 0; position: relative; padding: 30px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 0%, #151619, var(--bg) 70%);
}
.dropzone {
  width: min(620px, 100%); padding: 56px 40px; text-align: center; cursor: pointer;
  border: 1.5px dashed rgba(255,255,255,.16); border-radius: 18px;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.022) 0 8px, transparent 8px 16px);
  transition: border-color .15s, background-color .15s;
}
.dropzone.is-over { border-color: var(--accent); background-color: rgba(255,215,91,.06); }
.drop-icon {
  width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 14px; background: #212328;
  display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.drop-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone h2 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.dropzone p { margin: 0; font-size: 13px; color: var(--fg-dim); line-height: 1.7; }
.drop-note { display: block; margin-top: 22px; font-family: var(--mono); font-size: 11px; color: #606169; letter-spacing: .06em; }

.canvas-wrap {
  position: relative; line-height: 0; border-radius: 4px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  /* 투명(누끼) 영역 표시용 체커보드 — 불투명 사진은 전부 덮으므로 평소엔 안 보임 (사장님 2026-08-05) */
  background: conic-gradient(#26272c 0 25%, #1b1c20 0 50%, #26272c 0 75%, #1b1c20 0) 0 0/22px 22px;
}
.canvas-wrap canvas { display: block; }
#baseCanvas { max-width: 100%; max-height: calc(100vh - 178px); }
#drawCanvas, #origCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#drawCanvas { touch-action: none; cursor: crosshair; }
/* 줌인 상태 = 손바닥 팬 (사장님 2026-08-04: 마우스 올리면 손모양으로 잡고 이동) */
.canvas-wrap.is-pan #drawCanvas { cursor: grab; }
.canvas-wrap.is-pan.is-grabbing #drawCanvas { cursor: grabbing; }
/* 숨김=마커만 visibility로 완전 은닉 (투명 버튼 hover/클릭 가로채기 방지, 사장님 2026-08-05).
 * ⚠️ #drawCanvas는 숨기면 안 됨 — 패치 올가미·텍스트 핸들이 이 캔버스에 그려지고 포인터 이벤트도 받음.
 * 펜 획 숨김은 renderStrokes()가 데이터 단계에서 스킵 (2026-08-05 격자 간헐 미표시 근본픽스) */
.canvas-wrap.is-hidden-marks .markers { opacity: 0; visibility: hidden; }
/* AILAB(메모) 탭 밖에선 번호 마커가 포인터를 가로채지 않게 — 마커 클릭(focusRegion)은 메모 탭에서만 의미 있음 */
.canvas-wrap:not(.is-tab-memo) .marker { pointer-events: none; }
.canvas-wrap.is-compare #drawCanvas, .canvas-wrap.is-compare .markers { display: none; }

.markers { position: absolute; inset: 0; pointer-events: none; }
.marker {
  position: absolute; transform: translate(-50%, -50%);
  border-radius: 50%; border: 2px solid rgba(255,255,255,.92); cursor: pointer;
  color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; animation: pop .18s ease-out;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.marker.is-on { box-shadow: 0 0 0 4px rgba(255,255,255,.22), 0 2px 10px rgba(0,0,0,.5); }
.marker.is-applied::after {
  content: ""; position: absolute; right: -3px; bottom: -3px;
  width: 9px; height: 9px; border-radius: 50%; background: #6ee7a8; border: 2px solid #14151a;
}

.compare { position: absolute; inset: 0; }
#origCanvas { clip-path: inset(0 50% 0 0); }
.handle {
  position: absolute; top: 0; bottom: 0; width: 28px; margin-left: -14px; left: 50%;
  cursor: ew-resize; touch-action: none;
  display: flex; align-items: center; justify-content: center;
}
.handle-line { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.9); }
.handle-knob {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #1a1b1e;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.handle-knob svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tag {
  position: absolute; top: 14px; padding: 5px 10px; border-radius: 7px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; line-height: 1;
}
.tag.left { left: 14px; background: rgba(13,14,16,.72); }
.tag.right { right: 14px; background: rgba(255,215,91,.92); color: var(--accent-ink); font-weight: 500; }

.working {
  position: absolute; inset: 0; z-index: 8; /* 스테이지 소속 — 줌 배율 무관 고정 크기 */
  display: flex; align-items: center; justify-content: center;
  background: rgba(13,14,16,.42); backdrop-filter: blur(1px);
}
.working-inner {
  display: flex; align-items: center; gap: 11px; padding: 12px 18px; border-radius: 12px;
  background: rgba(23,24,27,.94); border: 1px solid var(--line-strong);
  font-size: 13px; line-height: 1;
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.18); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}

.hint {
  position: absolute; left: 24px; bottom: 20px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 13px; border-radius: 10px;
  background: rgba(23,24,27,.86); border: 1px solid var(--line);
  font-size: 12px; color: #a9aab1;
}
.hint .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- panel ---------- */
.panel {
  width: 384px; flex: none; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
/* 탭 = 3열 그리드 2줄 (사장님 2026-08-05 "너무 타이트, 2줄로 딱딱 칸 맞춰서" — 탭 늘어나면 자동 줄바꿈) */
.panel-tabs {
  flex: none; display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 5px; padding: 12px 14px 0;
}
.ptab {
  border: 1px solid rgba(255,255,255,.06); cursor: pointer; padding: 9px 2px; border-radius: 9px;
  font-size: 12.5px; font-weight: 500; background: var(--sunk); color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .12s, border-color .12s, background .12s;
}
.ptab:hover { color: var(--fg); border-color: rgba(255,255,255,.16); }
.ptab.is-on { background: var(--raise); color: var(--fg); border-color: rgba(255,215,91,.5); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 14px; }

.empty {
  padding: 38px 20px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: 14px;
}
.empty strong { display: block; font-size: 14px; font-weight: 500; margin-bottom: 7px; }
.empty span { font-size: 12.5px; color: #8a8b93; line-height: 1.65; }

.memo-list { display: flex; flex-direction: column; gap: 10px; }
.memo {
  border-radius: 13px; padding: 12px 13px; background: var(--raise);
  border: 1px solid transparent; animation: fadeup .2s ease-out; cursor: pointer;
}
.memo.is-on { border-color: rgba(255,215,91,.45); background: #23202280; background-color: #221f23; }
.memo-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.memo-num {
  width: 22px; height: 22px; flex: none; border-radius: 50%; color: #fff;
  font-family: var(--mono); font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.memo-title { font-size: 12px; color: var(--fg-dim); }
.memo-del {
  border: none; background: transparent; color: var(--fg-mute); cursor: pointer;
  font-size: 11px; padding: 3px 5px; border-radius: 6px;
}
.memo-del:hover { color: #ffd75b; background: rgba(255,215,91,.1); }
.memo textarea {
  width: 100%; resize: vertical; min-height: 62px;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.09);
  background: var(--sunk); font-size: 13px; line-height: 1.6; padding: 9px 10px;
}
.memo textarea::placeholder { color: #6d6e75; }
.memo textarea:focus { outline: none; border-color: rgba(255,215,91,.55); }
.memo-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0; }
.qchip {
  border: 1px solid rgba(255,255,255,.1); background: #1e1f23; color: #b9bac1;
  cursor: pointer; font-size: 11.5px; padding: 5px 9px; border-radius: 20px;
}
.qchip:hover { border-color: rgba(255,255,255,.24); color: #fff; }
.qchip.is-on { background: rgba(255,215,91,.16); border-color: rgba(255,215,91,.5); color: #ffe9a8; }
.memo-foot { display: flex; align-items: center; gap: 8px; }
.memo-apply {
  flex: 1; border: none; cursor: pointer; border-radius: 9px; padding: 9px 0;
  font-size: 12.5px; font-weight: 700; background: var(--accent); color: var(--accent-ink);
}
.memo-apply:hover { background: #f5849b; }
.memo-apply.is-applied { background: #24352b; color: #8ce0af; }
.memo-strength { display: flex; align-items: center; gap: 7px; width: 128px; min-width: 0; }
.memo-strength input { flex: 1; min-width: 0; }

.card { border-radius: 14px; background: var(--raise); padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.card-head strong { font-size: 13.5px; }
.card-head .mono { font-size: 10.5px; color: var(--fg-mute); }
.card-sub { margin: 0 0 12px; font-size: 12px; color: #8a8b93; line-height: 1.6; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  cursor: pointer; font-size: 12.5px; font-weight: 500; padding: 8px 13px; border-radius: 22px;
  background: #22242a; color: #c3c4cb; border: 1px solid rgba(255,255,255,.08);
}
.chip:hover { border-color: rgba(255,255,255,.22); color: #fff; }
.chip.is-on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.tones { display: flex; gap: 10px; }
.tone { flex: 1; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.tone-swatch { width: 100%; height: 44px; border-radius: 10px; border: 2px solid transparent; }
.tone span { font-size: 11.5px; color: #8a8b93; }
.tone.is-on .tone-swatch { border-color: #fff; }
.tone.is-on span { color: var(--fg); }

.slider-stack { display: flex; flex-direction: column; gap: 10px; }
.slider-row { display: flex; align-items: center; gap: 11px; margin-top: 14px; }
.slider-stack .slider-row { margin-top: 0; }
/* 라벨 고정폭 42px에 kbd 뱃지가 넘쳐 슬라이더가 패널 밖으로 밀리던 문제 — 내용폭+줄바꿈 금지로 픽스 (사장님 2026-08-05) */
.slider-label { font-size: 12px; color: var(--fg-dim); min-width: 42px; flex: none; white-space: nowrap; }
.slider-row input[type="range"] { min-width: 0; }
.slider-val { font-size: 11.5px; color: #c8c9cf; width: 36px; text-align: right; flex: none; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 22px; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: #34363b; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%;
  background: #f2f2f4; border: none; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

.panel-foot {
  flex: none; padding: 13px 14px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px;
}
.foot-meta { display: flex; justify-content: space-between; font-size: 12px; color: #8a8b93; }
.foot-meta .mono { font-size: 11px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  padding: 12px 20px; border-radius: 12px; background: #f4f4f6; color: #16171a;
  font-size: 13px; font-weight: 500; box-shadow: 0 12px 34px rgba(0,0,0,.5);
  animation: fadeup .2s ease-out; z-index: 20;
}

/* ── 커스텀 스크롤바 (사장님 지시 2026-08-05: 기본 스크롤 노출 금지) ──
 * 주의: scrollbar-width/scrollbar-color가 걸린 요소는 크롬 121+에서
 * ::-webkit-scrollbar 커스텀이 통째로 무효화됨 → 이 파일에서 둘 다 쓰지 말 것 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #34363e; border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
  min-height: 32px;
}
::-webkit-scrollbar-thumb:hover { background: #4a4d58; background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: #ffd75b; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

/* 사진 스트립(하단 필름) — 얇은 필 형태, 트랙도 라운드로 살짝만 */
.photo-strip::-webkit-scrollbar { height: 8px; }
.photo-strip::-webkit-scrollbar-track {
  background: rgba(255,255,255,.05); border-radius: 999px; margin: 0 12px;
}
.photo-strip::-webkit-scrollbar-thumb {
  background: #43464f; border: 2px solid transparent; background-clip: padding-box;
  min-width: 36px;
}
.photo-strip::-webkit-scrollbar-thumb:hover { background: #5a5e6a; background-clip: padding-box; }
.photo-strip::-webkit-scrollbar-thumb:active { background: #ffd75b; background-clip: padding-box; }

@keyframes pop { from { transform: translate(-50%,-50%) scale(.4); opacity: 0 } to { transform: translate(-50%,-50%) scale(1); opacity: 1 } }
@keyframes fadeup { from { transform: translateY(6px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
@keyframes spin { to { transform: rotate(360deg) } }

/* ---- AI 전체 보정 탭 (실 API 연동, 2026-08-04) ---- */
.gtext {
  width: 100%; resize: vertical; min-height: 74px;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.09);
  background: var(--sunk); font-size: 13px; line-height: 1.6; padding: 9px 10px;
}
.gtext::placeholder { color: #6d6e75; }
.gtext:focus { outline: none; border-color: rgba(255,215,91,.55); }
.hist-label { font-size: 11.5px; color: #8a8b93; }
.hist-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.hist-row .btn { flex: 1; }

/* ── 업로드 사진 리스트 스트립 (2026-08-04) ── */
.photo-strip {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  max-width: calc(100% - 320px); z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(20,21,26,.92); border: 1px solid #2a2c33; border-radius: 12px;
  overflow-x: auto;
  box-shadow: 0 8px 22px rgba(0,0,0,.42);
}
.strip-add {
  flex: 0 0 auto; width: 44px; height: 56px; border-radius: 9px;
  background: transparent; border: 1.5px dashed #3a3c44; color: #8a8b93; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s, transform .15s;
}
.strip-add:hover { border-color: #ffd75b; color: #ffd75b; transform: translateY(-1px); }
.strip-add svg { width: 18px; height: 18px; }
.strip-list { display: flex; align-items: center; gap: 8px; }
.strip-item {
  position: relative; flex: 0 0 auto; width: 44px; height: 56px;
  padding: 0; border-radius: 9px; overflow: hidden; cursor: pointer;
  border: 2px solid #2e3038; background: #17181d;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.strip-item:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.4); }
.strip-item.is-on { border-color: #ffd75b; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-badge {
  position: absolute; left: 3px; bottom: 3px;
  padding: 1px 5px; border-radius: 6px; font-size: 9px; font-weight: 700; letter-spacing: .02em;
  background: rgba(10,10,12,.85); color: #fff;
}

/* ── 스페이스 원본 보기 뱃지 ── */
.orig-badge {
  /* 캔버스 밖(스테이지)에 두어 줌 배율 무관 고정 크기 (사장님 지적 2026-08-04) */
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 7;
  padding: 5px 12px; border-radius: 8px; font-size: 11.5px; font-weight: 700;
  background: rgba(10,10,12,.85); color: #fff; pointer-events: none;
}

/* ── 포토샵식 히스토리 패널 (2026-08-04) ── */
.hist-panel {
  flex: 0 0 auto; margin: 0 14px 8px; padding: 10px 10px 8px;
  background: rgba(20,21,26,.92); border: 1px solid #2a2c33; border-radius: 12px;
}
.hist-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: #c9cad1; margin-bottom: 7px;
}
.hist-head svg { width: 14px; height: 14px; color: #8a8b93; }
.hist-head .mono { margin-left: auto; font-size: 10.5px; color: #8a8b93; }
.hist-list { max-height: 168px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.hist-step {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: #b9bac1; font-size: 11.5px; text-align: left; cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.hist-step:hover { background: rgba(255,255,255,.05); transform: translateY(-1px); }
.hist-step.is-on { background: rgba(255,215,91,.10); border-color: rgba(255,215,91,.45); color: #fff; }
.hist-step.is-ahead { opacity: .38; } /* 현재보다 뒤 단계 = 흐리게 (포토샵처럼 다시 갈 수 있음) */
.hist-num {
  flex: 0 0 auto; min-width: 18px; height: 18px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(10,10,12,.7); color: #ffd75b; font-size: 10px; font-weight: 700;
}
.hist-lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- portrait / liquify 탭 (2026-08-04) ---------- */
.free-tag {
  font-size: 10px !important; color: #7fd8a0 !important;
  border: 1px solid rgba(127,216,160,.35); border-radius: 6px; padding: 2px 6px;
}
/* 프리셋 가격 뱃지 (서버 preset_cost>0일 때만 JS가 부착 — 유료화 스위치 대비, 2026-08-05) */
.cost-tag {
  font-size: 10px !important; color: #ffd75b !important;
  border: 1px solid rgba(255,215,91,.4); border-radius: 6px; padding: 2px 6px;
}
.check-row {
  display: flex; align-items: center; gap: 9px; margin-top: 14px;
  font-size: 12.5px; color: var(--fg-dim); cursor: pointer; user-select: none;
}
.check-row input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.check-row:hover span { color: var(--fg); }

.lq-modes { display: flex; gap: 7px; margin-bottom: 4px; }
.lq-mode {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 9px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--sunk); color: var(--fg-dim);
  font-size: 12px; font-weight: 500;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.lq-mode svg { width: 20px; height: 20px; }
.lq-mode:hover { color: var(--fg); border-color: rgba(255,255,255,.22); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.3); }
.lq-mode:active { transform: translateY(0); }
.lq-mode.is-on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- 단축키 뱃지 (사장님 2026-08-04 "전부 단축키 버튼 옆에 아주 작게") ---------- */
.kb {
  display: inline-block; font-family: var(--mono); font-size: 9px; line-height: 1;
  padding: 2.5px 4px; margin-left: 3px; border-radius: 4px; vertical-align: 1px;
  border: 1px solid var(--line-strong); color: var(--fg-mute); background: var(--sunk);
}
.btn .kb, .lq-mode .kb { opacity: .85; }
.kb-hint { margin: 12px 0 0 !important; font-family: var(--mono); font-size: 10.5px; color: var(--fg-mute); }
.tool { position: relative; }
.kb-corner {
  position: absolute; right: 3px; bottom: 2px; font-family: var(--mono);
  font-size: 8px; color: currentColor; opacity: .55; pointer-events: none;
}

/* ---------- 패치 탭 (포토샵 J키 패치 툴, 사장님 지시 2026-08-04) ---------- */
.pa-steps { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.pa-step {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: var(--sunk);
  font-size: 12.5px; color: var(--fg-dim);
}
.pa-step svg { width: 19px; height: 19px; flex: none; color: var(--fg-dim); }
.pa-num {
  flex: none; width: 19px; height: 19px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
}

/* ---------- 브러시 원 커서: GPU 합성 DOM 오버레이 (사장님 2026-08-04 "마우스 즉각 반응") ---------- */
.brush-cur {
  position: absolute; left: 0; top: 0; z-index: 30; pointer-events: none;
  border-radius: 50%; border: 1.6px solid rgba(255,255,255,.92);
  box-shadow: 0 0 0 1.4px rgba(0,0,0,.5), inset 0 0 0 1.4px rgba(0,0,0,.35);
  will-change: transform;
}
.brush-cur.is-erase { border-color: rgba(255,120,120,.95); }

/* ---------- 탭 명칭 개편: AILAB AI 아이콘 (사장님 2026-08-04) ---------- */
.ptab-ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; display: inline-block; }
.ptab { white-space: nowrap; }

/* ---------- AI 보정 프리셋 (2026-08-05, 픽셀 잠금 인페인트) ---------- */
.pr-preset-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 11px; margin-top: 8px;
  border: 1px solid var(--line-strong); background: var(--sunk);
}
.pr-preset-name { font-size: 13px; font-weight: 500; color: var(--fg); }
.pr-preset-name .free-tag, .pr-preset-name .ai-tag, .pr-preset-name .cost-tag { margin-left: 6px; }
.ai-tag {
  display: inline-block; font-size: 9.5px; padding: 2.5px 6px; border-radius: 5px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.pr-lv { display: flex; gap: 5px; }
.pr-lv button {
  min-width: 34px; padding: 6px 0; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; color: var(--fg-dim);
  font-size: 12px; font-weight: 600;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
.pr-lv button:hover { color: var(--fg); border-color: rgba(255,255,255,.24); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.3); }
.pr-lv button:active { transform: translateY(0); background: var(--raise); }

/* 히스토리 취소 흔적 (필터 교체, 사장님 2026-08-05) */
.hist-step.is-ghost { opacity: .42; pointer-events: none; }
.hist-step.is-ghost .hist-lb { text-decoration: line-through; }

/* 토큰 지갑 칩 (2026-08-05, ai_intro 공유) */
.token-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--sunk); color: var(--fg);
}
.token-chip svg { width: 15px; height: 15px; color: var(--accent); }

/* 사진첩 (서버 보관) 스트립 아이템 (2026-08-05 DB화 2단계) */
.strip-item.strip-cloud { opacity: .88; }
.strip-badge-cloud { display: inline-flex; align-items: center; justify-content: center; }
.strip-badge-cloud svg { width: 11px; height: 11px; }

/* ---------- 토큰 사용내역 모달 (2026-08-05) ---------- */
.tk-modal {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(8,9,11,.62); backdrop-filter: blur(3px);
}
/* 추출 확인(과금 고지) 모달은 사진첩 모달 위에서 열림 — DOM 순서상 pgModal에 가려지는 문제 방지 */
#exModal { z-index: 210; }

/* 고배율 줌 = 픽셀 또렷하게 (사장님 2026-08-05 "픽셀 단위까지") */
.canvas-wrap.is-pixelzoom canvas { image-rendering: pixelated; }

/* 로그인 세션 풀림 안내 배너 (부트 API 403 재시도 소진 시) */
.sess-banner {
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 10px; font-size: 12.5px;
  background: #2a2118; border: 1px solid rgba(255,215,91,.45); color: #ffe9ad;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.sess-banner button {
  border: none; border-radius: 7px; padding: 5px 10px; cursor: pointer;
  background: linear-gradient(140deg, #FFE082, #FFC93C); color: var(--accent-ink); font-weight: 700; font-size: 12px;
}

/* 텍스트 프리뷰 더블클릭 인라인 편집 (사장님 2026-08-05) */
.tx-inline {
  position: fixed; z-index: 260; min-height: 40px; resize: none;
  padding: 8px 10px; border-radius: 10px; font-size: 14px; line-height: 1.4;
  background: rgba(20,21,25,.96); color: var(--fg);
  border: 1.5px solid var(--accent); outline: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

/* 이미지 좌표 뱃지 */
.coord-badge {
  position: absolute; right: 18px; bottom: 18px; z-index: 30;
  padding: 5px 9px; border-radius: 8px; font-size: 11px; color: #c8c9cf;
  background: rgba(23,24,27,.85); border: 1px solid var(--line);
  pointer-events: none;
}

/* 선택 영역 액션바 (크롭/투명 지우기) */
.sel-bar {
  position: absolute; bottom: 86px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; gap: 8px; padding: 8px 10px; border-radius: 12px;
  background: rgba(23,24,27,.94); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.sel-bar button {
  border: 1px solid var(--line-strong); border-radius: 9px; cursor: pointer;
  background: var(--raise); color: var(--fg); font-size: 12.5px; padding: 7px 12px;
}
.sel-bar button:hover { border-color: rgba(255,215,91,.55); }
.sel-bar #selCropBtn { background: linear-gradient(140deg, #FFE082, #FFC93C); color: var(--accent-ink); font-weight: 700; border: none; }

/* 텍스트 효과 프리셋 칩 */
.tx-fx { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.tx-fx button {
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--raise);
  color: var(--fg); font-size: 12px; padding: 8px 0; cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.tx-fx button:hover { transform: translateY(-1px); border-color: rgba(255,215,91,.55); }
.tx-fx button:active { transform: translateY(0); }
.tk-sheet {
  width: min(440px, calc(100vw - 32px)); max-height: 78vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 16px; padding: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.tk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tk-head strong { font-size: 15px; }
.tk-head .mono { margin-left: auto; color: var(--accent); font-weight: 600; }
.tk-close { border: none; background: transparent; color: var(--fg-dim); cursor: pointer; padding: 4px; }
.tk-close svg { width: 16px; height: 16px; }
.tk-close:hover { color: var(--fg); }
.tk-list { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.tk-row {
  border-radius: 10px; border: 1px solid var(--line); background: var(--sunk);
  animation: tkin .28s cubic-bezier(.2,.8,.3,1) backwards;
  transition: border-color .18s ease;
}
@keyframes tkin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.tk-row .tk-main {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tk-row .tk-chev { width: 14px; height: 14px; flex: none; color: var(--fg-mute); transition: transform .22s cubic-bezier(.2,.8,.3,1); }
.tk-row.open { border-color: rgba(255,215,91,.35); }
.tk-row.open .tk-chev { transform: rotate(90deg); }
.tk-detail { padding: 2px 11px 11px; animation: tkin .2s ease-out; }
.tk-detail dl { margin: 0; border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.tk-detail dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tk-detail dt { font-size: 11px; color: var(--fg-mute); flex: none; }
.tk-detail dd { margin: 0; font-size: 11.5px; text-align: right; word-break: break-all; }
.tk-detail dd.plus { color: #8affc1; }
.tk-detail dd.minus { color: #ff8f9f; }
.tk-more {
  margin-top: 4px; padding: 11px; border-radius: 10px; cursor: pointer;
  border: 1px dashed var(--line-strong); background: transparent;
  color: var(--accent); font-size: 12.5px; font-weight: 700;
  transition: transform .15s ease, border-color .18s ease;
}
.tk-more:hover { border-color: rgba(255,215,91,.5); }
.tk-more:active { transform: scale(.98); }
.tk-more:disabled { opacity: .5; cursor: default; }
.tk-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-label { font-size: 12.5px; font-weight: 500; }
.tk-src { font-size: 9.5px; color: var(--fg-mute); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 4px; margin-left: 4px; }
.tk-date { font-size: 10px; color: var(--fg-mute); }
.tk-amt { font-size: 13px; font-weight: 700; text-align: right; }
.tk-amt.plus { color: #8affc1; }
.tk-amt.minus { color: #ff8f9f; }
.tk-after { display: block; font-size: 10px; font-weight: 400; color: var(--fg-mute); }
.tk-empty { padding: 30px 0; text-align: center; color: var(--fg-mute); font-size: 12.5px; }

/* 토큰 차감 확인 모달 (2026-08-05) */
.tk-confirm-sheet { width: min(360px, calc(100vw - 32px)); }
.tkc-ic { width: 18px; height: 18px; color: var(--accent); }
.tkc-text { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; }
.tkc-text b { color: var(--accent); }
.tkc-sub { margin: 6px 0 0; font-size: 11px; color: var(--fg-mute); }
.tkc-skip { margin-top: 12px; font-size: 12px; color: var(--fg-dim); }

/* 내 사진첩 모달 (2026-08-05) */
.pg-sheet { width: min(560px, calc(100vw - 32px)); }
.pg-grid {
  flex: 1; min-height: 140px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px;
}
.pg-item {
  border: 1px solid var(--line-strong); border-radius: 11px; background: var(--sunk);
  padding: 0; cursor: pointer; overflow: hidden; display: flex; flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  animation: pgin .32s cubic-bezier(.2,.8,.3,1) backwards;   /* 스태거 등장 (JS가 delay 지정) */
}
@keyframes pgin { from { transform: translateY(10px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.pg-item:hover { transform: translateY(-1px); border-color: rgba(255,215,91,.5); box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.pg-item img { width: 100%; height: auto; aspect-ratio: 1/1; object-fit: cover; display: block; background: #17181b; }
.pg-name {
  font-size: 10.5px; color: var(--fg-dim); padding: 6px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
/* 여러 장 추출 (2026-08-05) */
.pg-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 10px; }
.pg-foot .btn { display: inline-flex; align-items: center; gap: 6px; }
.pg-foot .btn svg { width: 15px; height: 15px; }
.pg-foot .btn:disabled { opacity: .45; cursor: default; }
#pgMulti.on { border-color: rgba(255,215,91,.6); color: #FFD75B; }
.pg-item.sel {
  border-color: #FFD75B; box-shadow: 0 0 0 2px rgba(255,215,91,.55), 0 4px 14px rgba(0,0,0,.35);
  position: relative;
}
.pg-item.sel::after {
  content: ''; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
  border-radius: 50%; background: #FFD75B;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4 10-10'/%3E%3C/svg%3E");
  background-size: 12px; background-repeat: no-repeat; background-position: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ===== 텍스트 레이어 (포스터, 2026-08-05) ===== */
.btn.wide { display: inline-flex; align-items: center; justify-content: center; }
.tx-layers { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.tx-layer { display: flex; align-items: center; gap: 4px; padding: 7px 9px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--sunk); cursor: pointer; transition: border-color .12s; }
.tx-layer.on { border-color: #FFD75B; box-shadow: 0 0 0 1px rgba(255,215,91,.4); }
.tx-layer-nm { flex: 1; font-size: 12px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-lb { width: 22px; height: 22px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent;
  color: var(--fg-dim); font-size: 9px; cursor: pointer; padding: 0; }
.tx-lb:hover { color: #FFD75B; border-color: rgba(255,215,91,.5); }
.tx-props .card { margin-bottom: 10px; }
.tx-ta { width: 100%; resize: vertical; min-height: 40px; margin-bottom: 8px; padding: 8px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--sunk); color: var(--fg); font: inherit; font-size: 13px; }
.tx-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; font-size: 12px; color: var(--fg-dim); }
.tx-row > span:first-child { flex: 0 0 46px; }
.tx-row input[type=range] { flex: 1; }
.tx-row input[type=color] { width: 34px; height: 26px; border: 1px solid var(--line-strong); border-radius: 6px; background: none; padding: 1px; cursor: pointer; }
.tx-sel { flex: 1; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--sunk); color: var(--fg); font-size: 12px; }
.tx-num { flex: 0 0 40px; text-align: right; font-variant-numeric: tabular-nums; color: var(--fg); font-size: 11px; }
.tx-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.tx-seg button { padding: 5px 9px; background: transparent; border: none; border-right: 1px solid var(--line-strong);
  color: var(--fg-dim); cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; }
.tx-seg button:last-child { border-right: none; }
.tx-seg button svg { width: 15px; height: 15px; }
.tx-seg button.on { background: rgba(255,215,91,.16); color: #FFD75B; }
.tx-seg.tx-mini button { padding: 3px 8px; font-size: 10.5px; }
.tx-switch { margin-left: auto; position: relative; display: inline-block; width: 36px; height: 20px; }
.tx-switch input { opacity: 0; width: 0; height: 0; }
.tx-switch span { position: absolute; inset: 0; background: var(--sunk); border: 1px solid var(--line-strong); border-radius: 20px; transition: .15s; }
.tx-switch span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; border-radius: 50%; background: var(--fg-dim); transition: .15s; }
.tx-switch input:checked + span { background: rgba(255,215,91,.25); border-color: #FFD75B; }
.tx-switch input:checked + span::before { transform: translateX(16px); background: #FFD75B; }
.tx-actions { display: flex; gap: 8px; }
.tx-actions .btn { flex: 1; justify-content: center; }

/* ===== 단축키 가이드 모달 (2026-08-05) ===== */
.kbd-sheet { width: min(500px, calc(100vw - 32px)); }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kbd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--sunk); }
.kbd-keys { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px; min-width: 62px; }
.kbd-desc { font-size: 12px; color: var(--fg-dim); line-height: 1.35; }
kbd { display: inline-block; min-width: 20px; padding: 3px 6px; text-align: center;
  font-family: var(--mono); font-size: 11px; color: var(--fg);
  background: #23252b; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; }
.kbd-hold, .kbd-scroll { font-size: 10px; color: var(--accent); font-weight: 600; margin-left: 2px; }
.kbd-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.kbd-dontshow { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-dim); cursor: pointer; }
.kbd-dontshow input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
@media (max-width: 520px) { .kbd-grid { grid-template-columns: 1fr; } }

/* ── 통합 레이어 패널 (사장님 B안 2026-08-05) ── */
.layer-panel { flex: 0 0 auto; margin: 0 14px 8px; padding: 10px 10px 8px; background: rgba(20,21,26,.92); border: 1px solid #2a2c33; border-radius: 12px; }
.layer-list { max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.ly-row { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-size: 11.5px; color: #b9bac1; transition: background .12s, border-color .12s; }
.ly-row:hover { background: rgba(255,255,255,.04); }
.ly-row.on { border-color: rgba(255,215,91,.5); background: rgba(255,215,91,.05); color: #fff; }
.ly-th { width: 24px; height: 24px; border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.ly-th.txt { background: #101116; color: #ffd75b; }
.ly-th.img { background: linear-gradient(135deg, #4a6a8a, #c9a888); }
.ly-nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ly-sub { font-size: 9.5px; color: #8a8b93; }
.ly-row.is-hid .ly-nm { color: #5d5e66; text-decoration: line-through; }
.ly-act { display: flex; gap: 3px; }
.ly-act button { width: 22px; height: 22px; border: none; border-radius: 6px; background: transparent; color: #8a8b93; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.ly-act button:hover:not(:disabled) { background: #24262d; color: #fff; }
.ly-act button:disabled { cursor: default; color: #4a4c55; }
.ly-act button.off { color: #4a4c55; }
.ly-act svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── 좌측 레일 커스텀 툴팁 (B안: 기본 title 대신 사이트 톤, 2026-08-05) ── */
.tool[data-tip] { position: relative; }
.tool[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #0c0d10; border: 1px solid #3a3c44; color: #fff; font-size: 11.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 40;
  box-shadow: 0 6px 16px rgba(0,0,0,.5); pointer-events: none;
}
.tool[data-tip]:hover::before {
  content: ''; position: absolute; left: calc(100% + 6px); top: 50%;
  transform: translateY(-50%) rotate(45deg); width: 8px; height: 8px;
  background: #0c0d10; border-left: 1px solid #3a3c44; border-bottom: 1px solid #3a3c44;
  z-index: 41; pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   모바일 셸 (사장님 시안 v1 승인 2026-08-05) — body.is-mobile 스코프.
   mobile.js가 coarse pointer+좁은 화면에서만 클래스를 달아줌 → PC 무영향 ═══ */
body.is-mobile { overflow: hidden; }
body.is-mobile .topbar, body.is-mobile .toolrail { display: none; }
body.is-mobile .workspace { height: 100dvh; display: block; }
body.is-mobile .stage {
  position: fixed; inset: 0; z-index: 1;
  padding: calc(64px + env(safe-area-inset-top)) 8px calc(186px + env(safe-area-inset-bottom));
}
body.is-mobile #baseCanvas { max-height: calc(100dvh - 258px); }
body.is-mobile .stage, body.is-mobile #drawCanvas { touch-action: none; }
body.is-mobile .dropzone { width: min(480px, 92vw); padding: 38px 20px; }
body.is-mobile .hint, body.is-mobile #coordBadge, body.is-mobile #kbdModal { display: none !important; }

/* ── 상단 오버레이 바 ── */
.mtop {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(13,14,16,.94), rgba(13,14,16,.55) 72%, transparent);
}
.mtop .mtbtn {
  width: 34px; height: 34px; flex: none; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.13); background: rgba(23,24,27,.78);
  backdrop-filter: blur(6px); color: var(--fg);
  display: flex; align-items: center; justify-content: center;
}
.mtop .mtbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mtop .mtbtn:active { transform: scale(.94); }
.mtop .mspacer { flex: 1; }
.mtop .msave {
  height: 34px; padding: 0 13px; border-radius: 12px; border: 0; cursor: pointer;
  background: linear-gradient(140deg, #FFE082, #FFC93C); color: #1d1703;
  font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 5px;
}
.mtop .msave svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mtop .msave:active { transform: scale(.96); }
body.is-mobile .token-chip { height: 31px; font-size: 12px; border-radius: 12px; background: rgba(23,24,27,.78); backdrop-filter: blur(6px); }

/* ── 하단 독: 기존 우측 패널을 통째로 재배치 (ctx 위 · 탭바 아래) ── */
body.is-mobile .panel {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; z-index: 70;
  border-left: 0; max-height: 64dvh;
  background: linear-gradient(0deg, rgba(16,17,20,.98) 72%, rgba(16,17,20,.88) 88%, rgba(16,17,20,.35));
  padding-bottom: env(safe-area-inset-bottom);
}
body.is-mobile .panel-body { order: 1; flex: none; max-height: 25dvh; padding: 8px 11px 3px; }
body.is-mobile .panel-tabs {
  order: 2; grid-template-columns: repeat(6, 1fr); gap: 3px;
  padding: 5px 6px 6px; border-top: 1px solid rgba(255,255,255,.07);
}
body.is-mobile .ptab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 5px 1px 4px; font-size: 9.5px; font-weight: 600; letter-spacing: -.01em;
  background: transparent; border-color: transparent; border-radius: 12px;
}
body.is-mobile .ptab .ptab-ic { width: 18px; height: 18px; margin: 0; }
body.is-mobile .ptab.is-on { background: rgba(255,215,91,.09); border-color: rgba(255,215,91,.25); color: var(--accent); }
body.is-mobile .layer-panel, body.is-mobile .hist-panel, body.is-mobile .panel-foot { display: none; }

/* 독 카드 압축: 설명문·단축키 숨김 (상태 라벨 .mono는 유지) */
body.is-mobile .card { padding: 8px 10px; margin-bottom: 6px; border-radius: 11px; }
body.is-mobile .card-head { margin-bottom: 2px; }
body.is-mobile .card-head strong { font-size: 12.5px; }
body.is-mobile .panel .btn { padding: 8px 10px; font-size: 12.5px; border-radius: 10px; }
body.is-mobile .lq-mode { padding: 6px 3px; font-size: 10.5px; gap: 3px; border-radius: 10px; }
body.is-mobile .lq-mode svg { width: 15px; height: 15px; }
body.is-mobile .slider-row { margin: 5px 0; gap: 8px; }
body.is-mobile .slider-label { font-size: 11.5px; }
body.is-mobile .pr-lv button { padding: 5px 10px; font-size: 11.5px; }
body.is-mobile .check-row { font-size: 11.5px; }
body.is-mobile .hist-row { gap: 6px; }
body.is-mobile .memo { padding: 9px 10px; border-radius: 11px; }
body.is-mobile .chips .chip { padding: 6px 10px; font-size: 11.5px; }
body.is-mobile .card-sub { display: none; }
body.is-mobile .card-sub.mono { display: block; }
body.is-mobile .kb, body.is-mobile .kb-hint { display: none !important; }
body.is-mobile .empty { padding: 11px 10px; }
body.is-mobile .empty strong { font-size: 12.5px; margin-bottom: 4px; }
body.is-mobile .empty span { font-size: 11px; }
/* 배경·색감 탭: 모바일은 필터 우선 배치 (누끼·AI는 아래로) */
body.is-mobile #tabAdjust { display: flex; flex-direction: column; }
body.is-mobile #tabAdjust .card:nth-of-type(1) { order: 2; }
body.is-mobile #tabAdjust .card:nth-of-type(2) { order: 1; }
body.is-mobile #tabAdjust .card:nth-of-type(3) { order: 3; }
body.is-mobile #tabAdjust .card:nth-of-type(4) { order: 4; }

/* 사진 스트립: 상단바 아래로 */
body.is-mobile .photo-strip {
  top: calc(54px + env(safe-area-inset-top)); bottom: auto; padding: 5px 7px;
  max-width: calc(100% - 20px); z-index: 60;
}
/* 선택 액션바: 독 위로 */
body.is-mobile .sel-bar { position: fixed; bottom: calc(38dvh + 12px); top: auto; z-index: 75; }
/* 원본 뱃지: 상단바 아래 */
body.is-mobile .orig-badge { top: calc(58px + env(safe-area-inset-top)); z-index: 66; }
body.is-mobile .working { z-index: 90; }
body.is-mobile .toast { bottom: auto; top: calc(148px + env(safe-area-inset-top)); z-index: 95; max-width: 88vw; text-align: center; }
body.is-mobile .sess-banner { top: calc(60px + env(safe-area-inset-top)); }

/* ── 좌측 세로 브러시 크기 슬라이더 (피부·몸매 탭) ── */
.mvs {
  position: fixed; left: 8px; top: 42%; transform: translateY(-50%); z-index: 65;
  width: 33px; height: 172px; border-radius: 13px;
  background: rgba(23,24,27,.75); border: 1px solid rgba(255,255,255,.13);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.mvs .mvs-track { width: 4px; height: 134px; border-radius: 4px; background: #2a2b31; position: relative; }
.mvs .mvs-fill { position: absolute; bottom: 0; left: 0; width: 100%; border-radius: 4px; background: linear-gradient(0deg, #FFE082, #FFC93C); }
.mvs .mvs-knob {
  position: absolute; left: 50%; transform: translate(-50%, 50%);
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}

/* ── GPU 경로 뱃지 (몸매 탭) — 폴백 시 CPU 표시 ── */
.mgl {
  position: fixed; right: 10px; top: calc(58px + env(safe-area-inset-top)); z-index: 65;
  display: flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 9px;
  background: rgba(23,24,27,.8); border: 1px solid rgba(255,255,255,.13);
  font-family: var(--mono); font-size: 10.5px; color: #8fd18f;
}
.mgl i { width: 6px; height: 6px; border-radius: 50%; background: #8fd18f; }
.mgl.is-cpu { color: #d9b45b; }
.mgl.is-cpu i { background: #d9b45b; }

/* ── 필터 썸네일 스트립 (스노우식 — 내 사진 미리보기) ── */
.mfthumbs { display: none; }
body.is-mobile #filterChips { display: none; }
body.is-mobile .mfthumbs {
  display: flex; gap: 9px; overflow-x: auto; padding: 2px 0 8px;
  -webkit-overflow-scrolling: touch;
}
.mfthumbs .mft { flex: 0 0 auto; width: 56px; background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 5px; align-items: center; }
.mfthumbs .mft .im { width: 56px; height: 56px; border-radius: 12px; border: 2px solid transparent; overflow: hidden; background: #17181b; }
.mfthumbs .mft .im img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mfthumbs .mft span { font-size: 10.5px; color: var(--fg-mute); font-weight: 600; white-space: nowrap; }
.mfthumbs .mft.is-on .im { border-color: var(--accent); }
.mfthumbs .mft.is-on span { color: var(--accent); }

/* ── 모달 전부 바텀시트화 ── */
body.is-mobile .tk-modal { align-items: flex-end; }
body.is-mobile .tk-sheet {
  width: 100%; max-width: none; margin: 0; border-radius: 22px 22px 0 0;
  border-left: 0; border-right: 0; border-bottom: 0;
  max-height: 82dvh; padding-bottom: calc(18px + env(safe-area-inset-bottom));
  animation: msheetup .22s ease-out;
}
@keyframes msheetup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ── 제스처 힌트 필 ── */
.mhint {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(108px + env(safe-area-inset-top)); z-index: 66;
  display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  background: rgba(13,14,16,.85); border: 1px solid rgba(255,255,255,.13);
  backdrop-filter: blur(6px); font-size: 12px; color: var(--fg-dim);
  white-space: nowrap; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.mhint.is-show { opacity: 1; }
.mhint b { color: var(--fg); }

/* ── 사진 스트립 [+N] 사진첩 타일 (사장님 2026-08-06 "기본 10개, 나머지 사진첩으로") ── */
.strip-more {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: #1d1f25; border: 1.5px dashed #3a3c44; cursor: pointer;
}
.strip-more:hover { border-color: #ffd75b; }
.strip-more .strip-more-n { font-family: var(--mono); font-size: 12px; font-weight: 700; color: #ffd75b; }
.strip-more .strip-more-t { font-size: 9px; color: #8a8b93; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════
   세션 만료/미로그인 풀스크린 안내 (app.js _loginGate, 2026-08-06)
   — 사장님 폰 사진첩 먹통: 오류 무음이라 원인 몰랐던 것 방지 ═══ */
#loginGate {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,11,13,.82); backdrop-filter: blur(8px);
  animation: lgfade .25s ease-out;
}
@keyframes lgfade { from { opacity: 0; } to { opacity: 1; } }
#loginGate .lg-card {
  width: min(340px, 86vw); padding: 30px 26px 24px; border-radius: 20px;
  background: #17181c; border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 18px 50px rgba(0,0,0,.55); text-align: center;
  animation: lgup .3s cubic-bezier(.2,.9,.3,1.15);
}
@keyframes lgup { from { transform: translateY(26px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
#loginGate .lg-ico {
  width: 40px; height: 40px; color: #ffd75b; margin-bottom: 12px;
  stroke-linecap: round; stroke-linejoin: round;
}
#loginGate .lg-title { font-size: 17px; font-weight: 800; margin-bottom: 8px; }
#loginGate .lg-desc { font-size: 12.5px; line-height: 1.65; color: #9a9ba3; margin-bottom: 18px; }
#loginGate .lg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; width: 100%; border-radius: 13px; text-decoration: none;
  background: linear-gradient(140deg, #FFE082, #FFC93C); color: #1d1703;
  font-weight: 800; font-size: 14px;
  transition: transform .15s ease, box-shadow .2s ease;
}
#loginGate .lg-btn:active { transform: scale(.97); }

/* ═══════════════════════════════════════════════════════════════════
   모바일 인터랙션 부드러움 (사장님 2026-08-06 "존나 뻣뻣해") — is-mobile 스코프.
   원칙: transform/opacity만(GPU 합성, 캔버스·제스처 무간섭), 캔버스/스테이지엔 트랜지션 금지 ═══ */
body.is-mobile { -webkit-tap-highlight-color: transparent; }

/* 1) 누르는 것 전부 — 눌림 스프링 피드백 */
body.is-mobile .mtop .mtbtn, body.is-mobile .mtop .msave,
body.is-mobile .ptab, body.is-mobile .panel .btn,
body.is-mobile .chips .chip, body.is-mobile .lq-mode,
body.is-mobile .pr-lv button, body.is-mobile .mfthumbs .mft,
body.is-mobile .strip-item, body.is-mobile .strip-add, body.is-mobile .strip-more,
body.is-mobile .pg-item, body.is-mobile .token-chip {
  transition: transform .16s cubic-bezier(.2,.9,.3,1.4), background .18s ease,
              border-color .18s ease, color .18s ease, opacity .18s ease;
}
body.is-mobile .ptab:active, body.is-mobile .panel .btn:active,
body.is-mobile .chips .chip:active, body.is-mobile .lq-mode:active,
body.is-mobile .pr-lv button:active { transform: scale(.95); }
body.is-mobile .mfthumbs .mft:active, body.is-mobile .pg-item:active,
body.is-mobile .strip-item:active, body.is-mobile .strip-add:active,
body.is-mobile .strip-more:active { transform: scale(.93); }
body.is-mobile .mtop .mtbtn:active { transform: scale(.9); }
body.is-mobile .mtop .msave:active { transform: scale(.95); }
body.is-mobile .mvs .mvs-knob { transition: transform .12s ease; }

/* 2) 탭 전환 — 새 패널이 아래에서 사르르 */
body.is-mobile .panel-body:not([hidden]) { animation: mtabin .22s cubic-bezier(.2,.8,.3,1); }
@keyframes mtabin { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
body.is-mobile .ptab.is-on .ptab-ic { animation: mtabpop .28s cubic-bezier(.2,.9,.3,1.5); }
@keyframes mtabpop { 45% { transform: scale(1.18); } }

/* 3) 모달·바텀시트 — 배경 페이드 + 시트 스프링 상승 (기존 msheetup 강화) */
body.is-mobile .tk-modal:not([hidden]) { animation: lgfade .22s ease-out; }
body.is-mobile .tk-sheet { animation: msheetup .3s cubic-bezier(.2,.9,.3,1.08); }

/* 4) 토스트·작업중 — 팝 등장 */
body.is-mobile .toast:not([hidden]) { animation: mtoast .28s cubic-bezier(.2,.9,.3,1.3); }
@keyframes mtoast { from { transform: translateY(-8px) scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }
body.is-mobile .working:not([hidden]) { animation: lgfade .2s ease-out; }
body.is-mobile .sel-bar:not([hidden]) { animation: mtoast .24s cubic-bezier(.2,.9,.3,1.2); }
body.is-mobile .photo-strip:not([hidden]) { animation: lgfade .25s ease-out; }
body.is-mobile .mgl { transition: opacity .25s ease; }
body.is-mobile .orig-badge:not([hidden]) { animation: lgfade .18s ease-out; }

/* 5) 접근성 — 시스템 "동작 줄이기" 켠 사용자는 전부 즉시 표시 */
@media (prefers-reduced-motion: reduce) {
  body.is-mobile * { animation-duration: .01s !important; transition-duration: .01s !important; }
}

/* 서버 썸네일 페이드인 (r69 — URL+lazy 로드) */
.thumb-fade { opacity: 0; transition: opacity .3s ease; }
.thumb-fade.ld { opacity: 1; }
