Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

60.1 KB
Raw Blame
/* SPDX-License-Identifier: Apache-2.0 */
/* 깨끗한 라이트(화이트 베이스) 테마 — 중립 그레이 + 블루 액센트 1개 (2026-07-02) */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #e4e7ec;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dim: #dbe5fb;
  --reject: #eceef2;
  --danger: #dc2626;
  --checker-a: #e9ebef;
  --checker-b: #f4f5f7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.title { font-size: 15px; }
.muted { color: var(--muted); margin-left: 8px; font-weight: normal; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
.status { color: var(--muted); font-size: 12px; min-width: 80px; text-align: right; }
.status.ok { color: #16a34a; }
.status.err { color: var(--danger); }
/* 고칠 수 없지만 알려야 하는 것 — 오류(빨강)도 성공(초록)도 아니다 */
.status.warn { color: #b45309; }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  /* 좁은 카드에서 "빼기" 같은 한글 라벨이 글자 단위로 부러지지 않게 */
  white-space: nowrap;
  flex: none;
}
button:hover { background: var(--panel-2); border-color: #d3d8e0; }
button.ghost { background: transparent; padding: 3px 8px; font-size: 12px; box-shadow: none; }
button.ghost:hover { background: var(--panel-2); }
/* flip 버튼은 도구형(누를 때마다 반전) — 활성 강조 폐기 (maintainer 2026-07-19, 구 maintainer 2026-05-28 토글 강조 제거) */

/* 공통 커스텀 툴팁 (data-tip). 네이티브 title 대체 — 위임형 단일 팝오버. */
#sg-tip {
  position: fixed;
  z-index: 4000;
  max-width: 360px;
  padding: 6px 9px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text);
  background: var(--panel, #fff);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.16);
  pointer-events: none; /* 기본 툴팁은 통과 (호버 방해 없음) */
  opacity: 0;
  visibility: hidden;
  word-break: break-word;
  white-space: pre-line;
}
#sg-tip.open { opacity: 1; visibility: visible; }
/* 복사 가능 툴팁: 마우스를 팝오버 안으로 옮겨 텍스트를 드래그·복사 (에이전트 협업) */
#sg-tip.copyable { pointer-events: auto; }
#sg-tip.copyable .sg-tip-text { user-select: text; cursor: text; font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 11px; }

/* 좌측 파일트리 사이드바 + 본문 2단 레이아웃 (쿠마피커 도크 스타일) */
#layout { display: flex; align-items: flex-start; min-width: 0; }
#sidebar {
  position: sticky;
  top: var(--topbar-h, 49px); /* 실측값은 boot 가 --topbar-h 로 주입 */
  flex: 0 0 320px;
  width: 320px;
  /* 내용 길이와 무관하게 좌측을 전체 높이로 가른다 (쫙 갈라진 스플릿) */
  height: calc(100vh - var(--topbar-h, 49px));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 10px 24px 12px;
}
#sidebar:empty { display: none; }
main { flex: 1; min-width: 0; padding: 18px; display: flex; flex-direction: column; gap: 26px; }

/* 사이드바 접기/펴기 — 폭·패딩·투명도 트랜지션, 토글 탭은 경계선에 붙는다 */
#sidebar { transition: flex-basis 0.28s ease, width 0.28s ease, padding 0.28s ease, opacity 0.2s ease; }
body.sidebar-collapsed #sidebar {
  flex-basis: 0;
  width: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  overflow: hidden;
  border-right: none;
}
#sidebar-toggle {
  position: sticky;
  top: calc(var(--topbar-h, 49px) + 12px);
  z-index: 5;
  flex: none;
  align-self: flex-start;
  width: 17px;
  height: 46px;
  margin-left: -1px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: var(--panel);
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}
#sidebar-toggle svg { transition: transform 0.28s ease; color: var(--muted); }
body.sidebar-collapsed #sidebar-toggle svg { transform: rotate(180deg); }
#sidebar-toggle:hover svg { color: var(--accent, #0ea5e9); }

.state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 18px;
  /* 클릭 스크롤 도착 시 sticky 상단바가 타이틀을 가리지 않게 */
  scroll-margin-top: calc(var(--topbar-h, 49px) + 14px);
}
.state-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.state-head .name { font-size: 16px; font-weight: 600; }
.state-head .meta { color: var(--muted); font-size: 12px; }
.state-head .action { color: var(--muted); font-size: 12px; font-style: italic; }
.state-warn { color: var(--danger); font-size: 12px; }
/* 여백 침범 정보 알림 — 경고가 아니라 순한 안내 톤 (리롤 대상 아님) */
.state-note { color: var(--muted); font-size: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; }
/* 방향 앵커 배지 — 이 줄이 해당 방향의 identity 원천임을 표시 */
.anchor-badge { color: var(--accent, #0ea5e9); font-size: 12px; font-weight: 600; border: 1px solid var(--accent-dim, rgba(14,165,233,0.35)); border-radius: 5px; padding: 1px 7px; white-space: nowrap; flex: none; }
/* 방향 그룹 구분 헤더 (directions 계약 런) */
.dir-head { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); margin: 6px 2px -16px; text-transform: uppercase; }
.dir-head.dir-mirror { font-weight: 500; font-style: italic; margin-bottom: -14px; }

/* 생성 구조 트리 — base → idle 행 → 앵커 → rows 파이프라인 개요 */
.pipeline-tree .tree { padding: 4px 2px 2px; }
.pipeline-tree .tree ul { list-style: none; margin: 2px 0 0; padding-left: 26px; }
.pipeline-tree .tree > ul { margin-left: 13px; }
.pipeline-tree .tree li { position: relative; padding: 5px 0 3px 14px; }
/* 커넥터 기하:
   - 트렁크(li::before) = 계속 아래로 내려가는 직선. 마지막 자식은 트렁크 없음.
   - 가지(li::after)   = 트렁크에서 노드로 꺾여 들어가는 └ 모양, 모서리는 라운드.
   모든 가지가 부드러운 곡선으로 노드에 붙고, 마지막 가지는 곡선만 남아 끝난다. */
.pipeline-tree .tree li::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.pipeline-tree .tree li:last-child::before { display: none; }
.pipeline-tree .tree li::after {
  content: "";
  position: absolute;
  left: -13px;
  top: 0;
  width: 27px;
  height: 19px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-bottom-left-radius: 9px;
  pointer-events: none;
}
.tree-node {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  font-size: 12.5px;
  vertical-align: middle;
}
.tree-node img {
  height: 30px;
  width: 30px;
  object-fit: contain;
  background: repeating-conic-gradient(#ececec 0% 25%, #f8f8f8 0% 50%) 0 0 / 8px 8px;
  border-radius: 4px;
}
.tree-node .thumb-missing { height: 30px; width: 30px; border: 1px dashed var(--line); border-radius: 4px; }
.tree-node.pending { border-style: dashed; color: var(--muted); }
.tree-node .tn-label { font-weight: 600; }
.tree-node .tn-note { color: var(--muted); font-size: 11.5px; }
.tree-node.clickable { cursor: pointer; }
.tree-node.clickable:hover { border-color: var(--accent, #0ea5e9); }
.tree-node.anchor { border-color: var(--accent-dim, rgba(14,165,233,0.4)); }
.tree-node.anchor .tn-label { color: var(--accent, #0ea5e9); }
.tree-node.mirror { border-style: dashed; font-style: italic; color: var(--muted); }
.tree-node.tree-root { background: var(--panel); font-size: 13px; }
/* 폴더 노드 — 파일트리 뼈대. 박스 없이 아이콘+경로 라벨만. 클릭 = 접기/펴기 */
.tree-node.folder { border: none; background: transparent; padding: 2px 2px; }
.tree-node.folder svg { color: var(--muted); flex: none; }
.tree-node.folder .caret { transition: transform 0.2s ease; transform: rotate(90deg); }
.folder-collapsed > .tree-node.folder .caret { transform: rotate(0deg); }
.folder-collapsed > ul { display: none; }
.tree-node.folder.clickable:hover { border: none; background: var(--panel-2); border-radius: 6px; }
/* 파이프라인 / 파일 — 사이드바 상위 블록 */
.tree-block { margin-bottom: 10px; }
.tree-block > .tree-node.folder { font-weight: 700; }
.tree-block > .tree-node.folder .tn-label { font-family: inherit; font-size: 12.5px; letter-spacing: 0.02em; text-transform: uppercase; }
.tree-block > ul { margin-top: 2px; }

/* 파이프라인 블록 — 트렁크에 대시가 아래로 흐른다 (파이프에 물 흐르듯, 느긋하게).
   가지 곡선은 액센트 정적, 가지 끝(노드 왼쪽 모서리)에 화살촉이 정확히 붙는다. */
.tree-block.pipeline li::before {
  background:
    repeating-linear-gradient(to bottom,
      rgba(37, 99, 235, 0) 0 11px,
      rgba(37, 99, 235, 0.75) 11px 16px),
    linear-gradient(rgba(37, 99, 235, 0.28), rgba(37, 99, 235, 0.28));
  background-size: 1px 27px, 1px 100%;
  background-repeat: repeat-y, no-repeat;
  animation: pipe-flow 2.3s linear infinite;
}
@keyframes pipe-flow {
  to { background-position: 0 27px, 0 0; }
}
/* 파이프라인 가지는 CSS 곡선 대신 SVG(.branch)가 그린다 — 대시가 곡선을 타고 흐름 */
.tree-block.pipeline li::after { display: none; }
.tree-block.pipeline svg.branch {
  position: absolute;
  left: -7px;
  top: 0;
  pointer-events: none;
  overflow: visible;
}
.tree-block.pipeline svg.branch path { fill: none; stroke-linecap: round; }
.tree-block.pipeline svg.branch .rail { stroke: rgba(37, 99, 235, 0.28); stroke-width: 1; }
.tree-block.pipeline svg.branch .dash {
  stroke: rgba(37, 99, 235, 0.75);
  stroke-width: 1;
  stroke-dasharray: 5 12;
  animation: branch-flow 1.45s linear infinite;
}
@keyframes branch-flow {
  to { stroke-dashoffset: -17; }
}
/* 화살촉: 가지 밑변(y=19px 라인) 연장선상에서 노드 모서리에 밀착 (li 좌표 기준) */
.tree-block.pipeline li > .tree-node:first-of-type::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 10px;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  border-left: 5px solid rgba(37, 99, 235, 0.6);
}
@media (prefers-reduced-motion: reduce) {
  .tree-block.pipeline li::before { animation: none; }
  .tree-block.pipeline svg.branch .dash { animation: none; }
}

/* 트리에서 이동해 온 대상 패널 하이라이트 — 도착 후 따닥! 두 번 깜빡이고 즉시 끝 */
@keyframes target-flash {
  0% { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0); }
  25% { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.9); }
  50% { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5); }
  75% { box-shadow: 0 0 0 2px rgba(37, 99, 235, 1); }
  100% { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0); }
}
.state.flash-target { animation: target-flash 0.22s ease 1; }
.tree-node.folder .tn-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
/* 런 경로: 한 줄 + 앞쪽 말줄임 — 뒤(폴더명)가 중요하므로 끝을 보여주고 앞을 …로.
   direction:rtl 트릭; 전체 경로는 hover 툴팁(title). */
.pipeline-tree .tree-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
  cursor: default;
}

/* 사이드바 안에서는 카드 껍데기를 벗고 세로 밀도 위주로 */
#sidebar .pipeline-tree { background: transparent; border: none; border-radius: 0; padding: 2px 2px 8px; }
#sidebar .pipeline-tree .state-head { flex-direction: column; align-items: flex-start; gap: 3px; margin-bottom: 8px; }
#sidebar .pipeline-tree .state-head .name { font-size: 13px; }
#sidebar .pipeline-tree .tree ul { padding-left: 14px; }
#sidebar .pipeline-tree .tree li { padding-left: 8px; }
#sidebar .pipeline-tree .tree li::before { left: -7px; }
#sidebar .pipeline-tree .tree li::after { left: -7px; width: 15px; border-bottom-left-radius: 7px; }
#sidebar .tree-rows { flex-direction: column; gap: 2px; }
#sidebar .tree-node { font-size: 12px; padding: 2px 7px; max-width: 100%; }
#sidebar .tree-node .tn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sidebar .tree-node .tn-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar .tree-node img { height: 22px; width: 22px; }
#sidebar .tree-node.raw-only img { width: 40px; }
#sidebar .tree-node.tree-root img { height: 28px; width: 28px; }
.tree-rows { display: flex; flex-wrap: wrap; gap: 0 4px; }
.tree-rows li { padding-right: 0; }
/* raw 는 생성됐고 추출 전 — 중간 진행 상태 (raw 스트립 썸네일) */
.tree-node.raw-only { border-style: dotted; }
.tree-node.raw-only img { width: 52px; object-fit: cover; }

/* 런 세대 변경 배너 — 폴링이 프레임 재생성을 감지하면 표시 */
#reload-banner {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 3000;
  background: var(--accent, #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

/* 큐레이션 무효화 알림 — 프레임 재생성으로 드롭된 행 + 백업 파일 안내 (조용한 소실 금지) */
#curation-dropped-note {
  position: sticky;
  top: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 12.5px;
  background: rgba(234, 179, 8, 0.12);
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}
#curation-dropped-note button { margin-left: auto; }

/* 복제 인스턴스 배지 — 원본 프레임 번호를 항상 노출 */
.clone-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  opacity: 0.85;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 5px;
  padding: 0 5px;
}

.state-body { display: flex; gap: 18px; align-items: flex-start; min-width: 0; }
.frames {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  flex: 1;
  /* (maintainer 2026-05-28) flex child 가 content (3000px+) 만큼 늘어나면 overflow-x:auto
     가 발화 안 함 — 가로 18 frame 다 못 봄. min-width:0 으로 flex 의 default
     min-content 동작을 끄고 부모 폭에 fit + 가로 scrollbar 가 발화하도록. */
  min-width: 0;
}

.card {
  flex: 0 0 auto;
  width: 168px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  user-select: none;
}
.card.selected { border-color: var(--accent); }
.card.missing { border-style: dashed; }
/* 방향 앵커 프레임 = 이 방향의 identity 한 장 (생성에 붙는 그 프레임). 선택
   테두리와 구분되게 은은한 틴트 + 얇은 균일 테두리로만 표시한다 (액센트 바 금지). */
.card.is-anchor { border-color: #b45309; background: rgba(180, 83, 9, 0.05); }
.card-top .anchor-frame-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #b45309;
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-radius: 4px;
  padding: 0 4px;
  white-space: nowrap;
}
.card-controls .anchor-btn.on { color: #b45309; background: rgba(180, 83, 9, 0.1); }
.card-top .anchor-frame-badge.pinned { background: rgba(180, 83, 9, 0.12); }
/* 증명되지 않는 핀 = 경고색 (지금 이대로 생성하면 fail-loud 한다) */
.card-top .anchor-frame-badge.stale { color: #b91c1c; border-color: rgba(185, 28, 28, 0.4); background: rgba(185, 28, 28, 0.08); }
.card.is-anchor:has(.anchor-frame-badge.stale) { border-color: #b91c1c; background: rgba(185, 28, 28, 0.04); }
.card-controls .anchor-btn.stale { color: #b91c1c; background: rgba(185, 28, 28, 0.1); }

/* two rows per state: sequence (top) + candidate pool (bottom) */
.zones { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.zone { border-radius: 8px; padding: 6px 8px 4px; }
.zone-seq { background: rgba(37, 99, 235, 0.04); border: 1px solid var(--accent-dim); }
.zone-pool { background: rgba(17, 24, 39, 0.02); border: 1px dashed var(--line); }
.zone-label {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 2px 6px;
  letter-spacing: 0.03em;
}
.zone .frames { flex: none; min-height: 64px; } /* droppable even when empty */

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  /* 헤더(타이틀 줄) 전체가 드래그 핸들 — 타이틀을 잡고 임계값을 넘으면 순서변경/
     시퀀스↔풀 이동. 그냥 클릭은 아무 것도 안 한다 (maintainer 2026-07-15). 우측 아이콘
     버튼은 pointerdown 전파를 끊어 드래그를 시작하지 않는다. */
  cursor: grab;
  padding: 1px 1px 1px 2px;
  touch-action: none; /* claim the pointer so the scroll row doesn't steal the drag */
}
.card-top:active { cursor: grabbing; }
.card.dragging .card-top { cursor: grabbing; }
.card-top .ct-left {
  display: flex;
  align-items: center; /* 좌측 복제 버튼(svg)과 타이틀 수직 정렬 */
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.card-top .idx {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
} /* long imported labels truncate instead of breaking the card-top layout */
/* 실콘텐츠 픽셀 크기 — 타이틀 옆 인라인 (한 줄 정보). 사이즈 통일 검수용. */
.card-top .psize {
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}
.card.dragging {
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  opacity: 0.97;
  cursor: grabbing;
  transition: none; /* fixed-positioned card must track the cursor 1:1 */
}
/* the gap the lifted card will drop into */
.card-placeholder {
  flex: 0 0 auto;
  border-radius: 8px;
  border: 2px dashed var(--accent-dim);
  background: rgba(37, 99, 235, 0.05);
}

.stage {
  position: relative;
  width: 152px;
  aspect-ratio: var(--cell-aspect, 1);
  border-radius: 5px;
  overflow: hidden;
  /* 스프라이트 드래그 = 이동(move) 커서 — 손(grab)은 뷰 팬 전용 어휘 (maintainer 2026-07-20:
     캐릭터 이동이 손 모양이라 직관적이지 않다). 팬 상태(pan-space/pan-tool)가 grab 으로 덮는다. */
  cursor: move;
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.stage:active { cursor: grabbing; }
.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  pointer-events: none;
  z-index: 1;
}
/* 원본 픽셀보다 확대 표시될 때만 붙는 클래스 — 픽셀아트 계단을 그대로 보여준다.
   부여 주체는 display.js `applyPixelScaling` 하나뿐이다 (표시 기하로 판정·재평가). */
.px-upscale { image-rendering: pixelated; }
/* 변형 편집 중 실시간 격자 스냅 프리뷰 캔버스 (픽셀 언페이크 줄 전용, applyCardTransform 소유) */
.stage .snap-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: none;
  pointer-events: none;
  /* nearest 여부는 여기서 정하지 않는다 — 이 캔버스도 버퍼≠표시 해상도라
     display.js `applyPixelScaling` 이 판정하고 `.px-upscale` 로만 부여된다.
     (무조건 규칙이 남아 소스 해상도 버퍼를 축소 표시에서 데시메이션했다 — validator R1) */
}
.grid-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: none;
  pointer-events: none;
}
body.show-grid .grid-overlay { display: block; }
body.show-grid .stage { background-image: none; background-color: #eef0f3; }
.rotate-handle {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 2;
}
.stage:hover .rotate-handle { opacity: 0.9; }
.shear-handle {
  position: absolute;
  left: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #ffb450;
  border: 2px solid #fff;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 2;
}
.stage:hover .shear-handle { opacity: 0.9; }
.missing-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  font-size: 12px;
}

/* 푸터 2층: (1) 정보 줄 — 크기·변형값 (봐야 하는 정보) / (2) 버튼 줄 */
.card-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
  min-height: 14px;
}
.card-info .psize { font-size: 10.5px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.card-info .tvals { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
/* 버튼이 카드 폭(168px)을 넘으면 잘리지 말고 2줄로 접힌다 — 로케일마다 라벨 폭이
   달라(빼기 / remove) 한 줄 고정은 언제든 다시 넘친다 (maintainer 2026-07-26 실측 오버플로). */
.card-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.tvals { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

.preview {
  flex: 0 0 auto;
  width: 180px;
  text-align: center;
}
.preview h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.preview canvas {
  width: 160px;
  border-radius: 6px;
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.preview .count { font-size: 11px; color: var(--muted); margin-top: 4px; }
.pv-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}
.pv-controls button.ghost {
  padding: 3px 8px;
  font-size: 13px;
  line-height: 1;
}
.pv-controls .pv-play { min-width: 32px; }
.pv-controls button:disabled { opacity: 0.4; cursor: default; }
.pv-controls button:disabled:hover { background: transparent; }
.pv-speed {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 4px;
  font-size: 11px;
  cursor: pointer;
}
.pv-pos {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.fatal {
  margin: 40px auto;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 18px;
  color: var(--danger);
  white-space: pre-wrap;
}

/* pixel unfake apply checkbox (top-right) + view toggle */
.unfake-apply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  /* --fg 는 어디에도 정의돼 있지 않아 폴백이 항상 이겼다 — 라이트 배경 위 #ddd 는
     반투명처럼 보임 (maintainer 지적 2026-07-17). 버튼(.gif-btn)과 같은 잉크색으로 통일. */
  color: var(--fg-dim, #64748b);
  border: 1px solid var(--line, #3a3a3a);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.unfake-apply input {
  margin: 0;
  cursor: pointer;
}

/* top base reference row */
.base-row .base-stage {
  padding: 12px;
  display: flex;
  justify-content: flex-start;
}
.base-row .base-stage img {
  max-width: 100%;
  max-height: 240px;
  border: 1px solid var(--line, #3a3a3a);
  border-radius: 8px;
  background:
    repeating-conic-gradient(#e8e8e8 0% 25%, #f7f7f7 0% 50%) 0 0 / 16px 16px;
}

/* nearest 샘플링 여부는 CSS 가 무조건 정하지 않는다 — 표시 기하로 판정하는
   display.js `applyPixelScaling` 이 단일 소유자이고 `.px-upscale` 로만 부여된다.
   (여기 있던 무조건 `.stage img` 규칙이 그 판정을 덮어써 고해상 원본 트윈을
   축소 표시에서 nearest 데시메이션시켰다 — maintainer 2026-07-24) */

/* 픽셀 그리드 오버레이 (줄별 체크박스 / 상단 전체 토글) — display 는 sizePxGrids 가 소유 */
.stage .pxgrid {
  position: absolute;
  inset: 0;
  z-index: 2; /* snap-canvas(z1) 위 — 픽셀 언페이크 뷰에서도 격자가 보여야 한다 */
  pointer-events: none;
  display: none;
  background-image:
    linear-gradient(to right, rgba(220, 40, 40, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(40, 110, 220, 0.28) 1px, transparent 1px);
}

/* 상태별 생성 ref 칩 (어떤 재료로 이 줄을 생성했는가) + 우측 줄별 표시/굽기 컨트롤 */
.state-refs { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; flex-wrap: wrap; }
.state-refs .refs-label { font-size: 12px; opacity: 0.6; }
.state-refs .row-controls { margin-left: auto; display: inline-flex; gap: 8px;
  /* 컨트롤이 많아도 카드 밖으로 안 나가게 — 오른쪽 정렬 유지한 채 줄바꿈 (maintainer 2026-07-18) */
  flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; min-width: 0; }
.row-toggle { padding: 3px 8px; background: var(--panel, transparent); }

/* 하단 힌트바 — 힌트 span 이 구분자 없이 붙지 않게 (회귀 2026-07-14 픽) */
.hintbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  padding: 10px 16px 14px;
  font-size: 12px;
  color: var(--muted);
}
.hintbar span { position: relative; }
.hintbar span + span::before {
  content: "·";
  position: absolute;
  left: -11px;
  color: var(--line);
}

/* 검출된 입력 격자 오버레이 (원본 표시 줄 전용) — 추출이 실제로 자른 절단선, 초록 */
.stage .ingrid {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
  z-index: 2;
}

/* 보관함 — 후보 풀에서도 제외한 프레임. 접힌 칩 + 쇽 팝오버 + 드래그 복구 */
.archive-wrap { position: relative; margin-top: 6px; display: flex; }
.archive-wrap.empty { opacity: 0.45; }
.archive-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 2px 9px;
}
.archive-chip:hover { border-color: var(--accent, #0ea5e9); color: var(--accent, #0ea5e9); }
.archive-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 50;
  min-width: 180px;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.14);
  transform: translateY(6px) scale(0.92);
  transform-origin: left bottom;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.16s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.14s ease;
}
.archive-pop.open { transform: none; opacity: 1; pointer-events: auto; }
.archive-pop .ap-hint { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.ap-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-card {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  background: var(--panel-2);
  cursor: grab;
  user-select: none;
}
.ap-card img { height: 26px; width: 26px; object-fit: contain; }
.ap-ghost { position: fixed; z-index: 3000; pointer-events: none; opacity: 0.85; }
/* 확대 스크러버 — 스테이지 내부 우하단, 호버 시 표시. [−][돋보기⁺ 드래그][+] */
.stage .scale-scrub {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 1px 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.stage:hover .scale-scrub { opacity: 1; }
.scale-scrub .ss-step { padding: 2px 3px; }
.scale-scrub .ss-grab { cursor: ew-resize; padding: 2px 3px; display: inline-flex; touch-action: none; }
.scale-scrub .ss-grab:hover, .scale-scrub .ss-step:hover { color: var(--accent, #0ea5e9); }

/* 버튼 줄: [반전][초기화][앵커] ... [넣기/빼기][보관] (오른쪽 그룹).
   아이콘 전용 버튼은 헤더 우측(ct-right)과 같은 컴팩트 규격으로 통일한다 —
   button.ghost 기본 padding(3px 8px)을 그대로 쓰면 글자 없는 버튼이 30px 을 먹는다. */
.card-controls .flip-btn, .card-controls .reset-btn { flex: none; }
.card-controls .flip-btn,
.card-controls .reset-btn,
.card-controls .anchor-btn,
.card-controls .arch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border-radius: 5px;
  color: var(--muted);
  line-height: 0;
}
.card-controls .flip-btn:hover,
.card-controls .reset-btn:hover {
  color: var(--accent, #0ea5e9);
  background: rgba(37, 99, 235, 0.08);
}
/* 넣기·빼기 + 보관을 한 묶음으로 오른쪽 정렬 (성격이 비슷한 멤버십 액션) */
.card-controls .ctrl-group { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; flex: none; }

/* 헤더 우측 아이콘 버튼 (복제·확대) — 균일한 라인 아이콘 버튼 */
.card-top .ct-right { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.card-top .ct-right .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border-radius: 5px;
  color: var(--muted);
  line-height: 0;
}
.card-top .ct-right .ghost:hover { color: var(--accent, #0ea5e9); background: rgba(37, 99, 235, 0.08); }
.card-top .zoom-btn { cursor: zoom-in; }

/* 넣기/빼기 = 시퀀스⇄풀 토글 버튼. 색상 강조 없이 방향 아이콘(위/아래)+라벨로만 구분. */
.sel-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 2px 7px 2px 5px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
}
.sel-btn svg { display: block; }
.sel-btn:hover { border-color: var(--accent, #0ea5e9); color: var(--accent, #0ea5e9); }
/* 보관 버튼 규격은 위 아이콘 버튼 공통 규칙이 소유한다 (여기 재선언 금지) */
.card-controls .arch-btn:hover { color: var(--accent, #0ea5e9); background: rgba(37, 99, 235, 0.08); }

/* 픽셀 편집 툴바 (확대 모달) */
.edit-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edit-toolbar .ghost { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 6px; }
.edit-toolbar .ghost.active { background: var(--accent, #0ea5e9); color: #fff; border-color: transparent; }
.et-swatches { display: inline-flex; gap: 3px; }
.swatch { width: 18px; height: 18px; padding: 0; border: 1px solid rgba(0, 0, 0, 0.18); border-radius: 4px; cursor: pointer; box-shadow: none; }
.et-color { width: 26px; height: 22px; padding: 0 1px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); cursor: pointer; }
.et-note { font-size: 11px; }
.stage.pixel-editing { cursor: crosshair; }
/* 스포이드 모드 = 색 집기 커서 (copy) 로 구분 */
.stage.pixel-editing.picking { cursor: copy; }
.stage.pixel-editing .rotate-handle, .stage.pixel-editing .shear-handle, .stage.pixel-editing .scale-scrub { display: none; }

/* 보관함 풀 모달 — 일반 카드 크기 그리드 + 복구 버튼 */
#archive-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 24px; }
#archive-modal .zoom-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 24, 0.5); }
/* 카드가 많아도 화면 밖으로 넘치지 않게 — 모달 자체를 뷰포트에 가두고 내부 스크롤.
   #archive-modal 스코프로 .zoom-card.card 기본값을 확실히 덮는다 (특정성). */
#archive-modal .arch-modal-card {
  position: relative;
  z-index: 1;
  width: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(92vw, 900px);
  max-height: 86vh;
  overflow: hidden;
  padding: 14px 16px 12px;
  background: var(--panel, #fff);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  border-radius: 12px;
}
#archive-modal .arch-modal-card .zoom-head { flex: none; }
.arch-grid { display: flex; flex-wrap: wrap; gap: 12px; overflow: auto; padding: 2px; align-content: flex-start; }
.arch-card { width: 168px; } /* row 카드와 동일 규격 — 프레임 그리드 (maintainer 2026-07-18) */
.arch-card .stage { cursor: default; }
.arch-card .card-controls { justify-content: center; gap: 6px; }

/* 확대 편집 모달 — 한 프레임 크게, 격자/픽셀 언페이크 토글하며 조정 */
#zoom-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
#zoom-modal .zoom-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 24, 0.5); }
/* 3계층 계약 (maintainer 2026-07-20): 모달 = 최대 크기 고정, 그 안의 뷰포트가 화면
   배율·팬을 소유, 캐릭터(스테이지)는 뷰포트 안에서 자유 확대/이동. */
.zoom-card.card {
  position: relative;
  z-index: 1;
  width: 94vw;
  height: 94vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--panel, #fff);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  border-radius: 12px;
}
.zoom-head { display: flex; align-items: center; gap: 8px; }
/* 타이틀 = 복붙 대상 (maintainer 2026-07-20: 프레임 이름을 블록 지정해 복사) — .card 의
   user-select:none 상속을 풀어준다. 줌/비교/아카이브 모달 공통. */
.zoom-head .zoom-title { font-weight: 600; font-size: 15px; margin-right: 6px; user-select: text; cursor: text; }
.zoom-head .row-controls { margin-left: auto; display: inline-flex; gap: 8px; }
/* flex 컨테이너(column)가 높이를 눌러 aspect-ratio 를 깨지 않게 — 확대는 뷰포트
   스크롤로 수용. (회귀 2026-07-14: flex-shrink 가 스테이지 높이만 줄여
   스프라이트/격자가 가로로 찌그러졌다.) */
.zoom-card .stage { width: 480px; flex: 0 0 auto; }
/* 뷰포트 계층: stage-row 가 남은 높이를 전부 차지, 그 안의 뷰포트가 스크롤 소유.
   stage-pad 의 큰 사방 패딩 = 자유 팬 (어느 구석이든 화면 중앙으로 끌어올 수 있다). */
.zoom-card .stage-row { flex: 1 1 auto; min-height: 0; }
/* align-self:stretch — stage-row 는 align-items:flex-start (팔레트 도크 계약) 라
   명시로 늘려야 뷰포트가 높이 제약을 받아 스크롤/센터링이 산다 (회귀 2026-07-20:
   뷰포트가 콘텐츠 높이만큼 자라 세로 팬 불능 + 코너 위젯이 카드 밖으로 밀림). */
.stage-viewwrap { position: relative; flex: 1 1 auto; align-self: stretch; min-width: 0; min-height: 0; display: flex; }
.stage-viewport {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
  background: var(--panel-2, #f8fafc);
}
.stage-pad { width: max-content; padding: 46vh 46vw; }
.stage-viewport.pan-tool, body.pan-space .stage-viewport { cursor: grab; }
/* 돋보기 위젯 — 화면 배율 전용 (스프라이트 크기 = scale-scrub, 별도 어휘) */
.view-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 7px;
  padding: 1px 4px;
}
.view-nav .vn-label { font-size: 11px; min-width: 38px; text-align: center; user-select: none; }
.view-nav button { padding: 2px 4px; display: inline-flex; }
.view-nav button:hover { color: var(--accent, #0ea5e9); }
.view-nav.vn-corner {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.ref-chip { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: inherit;
  border: 1px solid rgba(128,128,128,0.3); border-radius: 6px; padding: 2px 8px 2px 2px; }
.ref-chip:hover { border-color: rgba(128,128,128,0.6); }
.ref-chip img { height: 40px; width: auto; border-radius: 4px; display: block; }
.ref-chip span { font-size: 11px; opacity: 0.8; }

/* 줄 단위 GIF 다운로드 버튼 — row-controls 안, 체크박스 토글과 같은 높이 */
.gif-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--fg-dim, #64748b);
  background: transparent;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  cursor: pointer;
}
.gif-btn:hover { color: var(--fg, #0f172a); border-color: var(--fg-dim, #94a3b8); }
.gif-btn:disabled { opacity: 0.5; cursor: default; }
.gif-btn svg { display: block; }

/* AI 중간 프레임(보간) 버튼의 파라미터 팝오버 */
.gen-wrap { position: relative; display: inline-flex; }
.gen-pop[hidden] { display: none !important; } /* display:flex 가 hidden 속성을 이기지 못하게 */
.tween-picking .card { cursor: crosshair; }
.tween-picking .card.selected { border-color: var(--line); } /* 픽 모드에선 기존 선택 파랑 억제 */
.tween-picking .card.tween-picked {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.gen-pop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}
.gen-pop label {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  font-size: 10px;
  color: var(--fg-dim, #64748b);
  white-space: nowrap;
}
.gen-pop input {
  width: 46px;
  padding: 2px 4px;
  font-size: 11px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 4px;
  background: transparent;
  color: inherit;
}

/* 최종 아틀라스 섹션 — 페이지 맨 아래: 시트(좌) | 런타임 manifest(우) */
.final-atlas .atlas-split {
  display: flex;
  gap: 14px;
  /* 기준은 아틀라스 시트 (maintainer 지시 2026-07-17): JSON 패널 높이는 JS
     (syncAtlasDocHeight)가 시트 실측 높이로 고정한다 — stretch 를 쓰면 JSON 이
     길 때 반대로 JSON 이 기준이 돼 버린다. */
  align-items: flex-start;
  margin-top: 10px;
}
.final-atlas .atlas-sheet {
  flex: 0 1 52%;
  min-width: 0;
  display: block;
  background:
    repeating-conic-gradient(rgba(148, 163, 184, 0.18) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 8px;
}
.final-atlas .atlas-sheet img {
  display: block;
  width: 100%;
  height: auto;
}
.final-atlas .atlas-doc {
  flex: 1 1 48%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
}
.final-atlas .atlas-doc-head {
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--fg-dim, #64748b);
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: var(--bg-soft, #f8fafc);
}
.final-atlas .atlas-doc-json {
  margin: 0;
  padding: 10px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}
.final-atlas .atlas-pending {
  margin-top: 10px;
  padding: 18px;
  border: 1px dashed var(--line, #cbd5e1);
  border-radius: 8px;
  color: var(--fg-dim, #64748b);
  font-size: 12.5px;
}

.gen-pop select {
  padding: 2px 4px;
  font-size: 11px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 4px;
  background: transparent;
  color: inherit;
}

/* 저장 실패 배너 — 상태줄과 달리 무시할 수 없게 상단 고정 (죽은 탭 편집 유실 방지) */
.save-lost-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5000;
  padding: 10px 18px;
  background: #fef2f2;
  color: var(--danger, #dc2626);
  border-bottom: 1px solid #fecaca;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* 보간 생성 중 스피너 — Generate 버튼 안에서 돈다 */
.gen-spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  border: 2px solid var(--accent-dim, #dbe5fb);
  border-top-color: var(--accent, #2563eb);
  border-radius: 50%;
  animation: sg-spin 0.8s linear infinite;
}
@keyframes sg-spin { to { transform: rotate(360deg); } }


/* 마키(영역 선택) — 점선 박스, 개미행렬 애니메이션 */
.marquee {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  border: 1px dashed var(--accent, #2563eb);
  background: rgba(37, 99, 235, 0.07);
  animation: sg-ants 0.6s linear infinite;
}
@keyframes sg-ants { to { border-color: rgba(37, 99, 235, 0.35); } }
.stage.selecting { cursor: crosshair; }
/* 변형 툴 — 기본 모드. 선택이 있으면 그 영역만, 없으면 셀 전체를 옮긴다. */
.stage.transforming { cursor: move; }
.stage.lassoing { cursor: crosshair; }
/* 올가미 — 그리는 중 윤곽(위)과 확정 마스크(아래). 둘 다 포인터 통과. */
.lasso-path, .lasso-mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.lasso-path { z-index: 5; }
.lasso-mask { z-index: 4; }
/* 영역 변형 실시간 미리보기 — 스테이지 위에 겹치는 결과 레이어 (포인터는 통과). */
.region-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}


/* 팔레트 도크 — Aseprite 식 세로 팔레트 (maintainer 지시 2026-07-17):
   위 = 현재 쓰인 색 전부(같은 색 1개, 빈도순), 아래 = 자유 색상 피커 */
.stage-row { display: flex; align-items: flex-start; gap: 8px; }
.stage-row .stage { flex: 1 1 auto; }
.palette-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line, #e4e7ec);
  border-radius: 8px;
  background: var(--panel-2, #f1f3f6);
  max-height: 72vh;
}
.palette-swatches {
  display: grid;
  grid-template-columns: repeat(2, 18px); /* 두 줄(2열) — maintainer 지시 2026-07-17 */
  gap: 3px;
  overflow-y: auto;
  min-height: 0;
  padding: 1px;
}
.palette-swatches .swatch { flex: none; }
.palette-swatches .swatch.current { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
.palette-dock .et-color { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: transparent; flex: none; }

/* 호흡 모드 — 드래그 가슴선 + 컨트롤 바 */
.breathe-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed rgba(220, 40, 40, 0.75);
  cursor: ns-resize;
  z-index: 5;
}
.breathe-line::after { /* 잡기 쉬운 히트 영역 */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -6px;
  height: 12px;
}
.breathe-line-v { /* 세로선 (몸통 축·반폭, 영역 조정 UI 2026-07-30) */
  top: 0;
  bottom: 0;
  left: auto;
  right: auto;
  height: auto;
  width: 0;
  border-top: none;
  border-left: 2px dashed rgba(40, 110, 220, 0.7);
  cursor: ew-resize;
}
.breathe-line-v::after {
  left: -6px;
  right: auto;
  top: 0;
  width: 12px;
  height: 100%;
}
.breathe-axis { border-left-style: solid; border-left-color: rgba(40, 110, 220, 0.45); }
.breathe-recalc { /* 해부 재계산 중 배지 (zoom-editor setRecalcBadge) */
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-size: 11px;
  color: #333;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 6;
  pointer-events: none;
}
.breathe-recalc-spin {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(40, 110, 220, 0.25);
  border-top-color: rgba(40, 110, 220, 0.9);
  border-radius: 50%;
  animation: breathe-recalc-rot 0.7s linear infinite;
}
@keyframes breathe-recalc-rot { to { transform: rotate(360deg); } }
.breathe-bar { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.breathe-auto { padding: 2px 7px; font-size: 11px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }
.breathe-auto:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.breathe-count { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.breathe-count input { width: 44px; padding: 2px 4px; font-size: 11px; border: 1px solid var(--line); border-radius: 4px; text-align: center; }
.breathe-count button { padding: 2px 7px; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; background: transparent; cursor: pointer; }
.breathe-count button:hover { border-color: var(--accent); color: var(--accent); }
.breathe-range { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.breathe-range > span { display: inline-flex; align-items: center; gap: 3px; }
.breathe-range input { width: 50px; padding: 2px 4px; font-size: 11px; border: 1px solid var(--line); border-radius: 4px; text-align: center; }
.breathe-fit-badge { color: #b45309; font-size: 11px; font-weight: 600; margin-left: 2px; }
/* 줄 fps 스텝퍼 — 전체 재생 속도 (프레임별 시간은 복제가 담당) */
.fps-stepper { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--fg-dim, #64748b); }
.fps-stepper .fps-value { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.fps-stepper button { padding: 2px 7px; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; background: transparent; cursor: pointer; color: inherit; }
.fps-stepper button:hover { border-color: var(--accent); color: var(--accent); }
.fps-stepper button:disabled { opacity: 0.5; cursor: default; }
/* 최종 굽기 필름스트립 — 시퀀스×호흡주기 LCM 전개를 그대로 나열 */
.breathe-strip { margin-top: 8px; }
.breathe-strip .bs-caption { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.breathe-strip .bs-frames { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.breathe-strip .bs-cell { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.breathe-strip .bs-cell canvas { width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 4px; background: repeating-conic-gradient(#ececec 0% 25%, #f8f8f8 0% 50%) 0 0 / 8px 8px; }
.breathe-strip .bs-cap { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
/* 파이프라인 진행 바 — 상단 고정 얇은 바 (표시 전용) */
#op-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 5000; background: transparent; pointer-events: none; }
#op-progress[hidden] { display: none; }
.op-progress-fill { height: 100%; width: 0; background: var(--accent, #2563eb); transition: width 0.4s ease; }
.op-progress-fill.indeterminate { animation: op-indet 1.2s linear infinite; width: 40% !important; }
@keyframes op-indet { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
/* 줄 헤더 호흡 토글: 체크박스 = 시퀀스 투입 on/off, 라벨 클릭 = 에디터 열기 */
.breathe-toggle { display: inline-flex; align-items: center; gap: 4px; }
.breathe-toggle .breathe-open { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.breathe-toggle .breathe-open:hover { color: var(--accent); }

/* 호흡 포커스 모드 — 가슴선·진폭·생성만 남기고 편집 크롬 전부 숨김 */
.zoom-card.breathe-focus .edit-toolbar > :not(.breathe-bar) { display: none; }
.zoom-card.breathe-focus .breathe-bar { margin-left: 0; }
/* 포커스 모드: 스테이지는 제 크기 유지 (스트립이 카드 폭을 키워도 안 따라 늘어남),
   스트립은 스테이지 폭 언저리에서 가로 스크롤 */
.zoom-card.breathe-focus .stage { flex: 0 0 auto; }
.zoom-card.breathe-focus .breathe-strip { max-width: 560px; }
.zoom-card.breathe-focus .palette-dock,
.zoom-card.breathe-focus .row-controls,
.zoom-card.breathe-focus .card-controls,
.zoom-card.breathe-focus .rotate-handle,
.zoom-card.breathe-focus .shear-handle,
.zoom-card.breathe-focus .zoom-prev,
.zoom-card.breathe-focus .zoom-next,
.zoom-card.breathe-focus .scale-scrub { display: none !important; }

/* 앵커 비교 캔버스 — 나란히/겹침 + 공유 바닥선 + 드래그 가이드 */
#compare-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 24px; }
#compare-modal .zoom-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 24, 0.5); }
/* 3계층 계약 (maintainer 2026-07-20): 카드 = 최대 크기 고정, 뷰포트(.cmp-scroll)가 배율·팬 소유 */
#compare-modal .cmp-card { position: relative; z-index: 1; width: 94vw; height: 92vh; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px; background: var(--panel, #fff); box-shadow: 0 18px 60px rgba(0,0,0,0.35); border-radius: 12px; }
#compare-modal .cmp-controls { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
#compare-modal .cmp-zoom { padding: 2px 4px; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; }
#compare-modal .cmp-hint { font-size: 11.5px; color: var(--muted); }
#compare-modal .cmp-stage { position: relative; flex: none; background-color: var(--checker-a); background-image: linear-gradient(45deg, var(--checker-b) 25%, transparent 25%), linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--checker-b) 75%), linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; border-radius: 6px; }
#compare-modal .cmp-canvas { display: block; image-rendering: pixelated; cursor: crosshair; }
#compare-modal .cmp-guides { position: absolute; inset: 0; pointer-events: none; }
#compare-modal .cmp-body { display: flex; gap: 10px; flex: 1 1 auto; min-height: 0; }
#compare-modal .cmp-list { flex: 0 0 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
#compare-modal .cmp-viewwrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
#compare-modal .cmp-item { display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 3px 5px; border-radius: 6px; cursor: pointer; }
#compare-modal .cmp-item:hover { background: var(--panel-2); }
#compare-modal .cmp-item img { width: 26px; height: 26px; object-fit: contain; }
/* 뷰포트: stage-pad 의 사방 패딩으로 자유 팬 — 중앙 정렬은 오픈 시 스크롤로 놓는다
   (compare.js render 의 1회 centerView). */
#compare-modal .cmp-scroll { overflow: auto; flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2, #f8fafc); }
/* 가이드: 0px 선은 못 잡는다 — 9px 히트영역 안에 선을 그린다 (maintainer "안 움직여") */
#compare-modal .cmp-guide { position: absolute; pointer-events: auto; }
#compare-modal .cmp-guide.gh { left: 0; right: 0; height: 9px; margin-top: -4px; cursor: ns-resize; }
#compare-modal .cmp-guide.gh::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; border-top: 2px dashed rgba(220, 38, 38, 0.85); }
#compare-modal .cmp-guide.gv { top: 0; bottom: 0; width: 9px; margin-left: -4px; cursor: ew-resize; }
#compare-modal .cmp-guide.gv::before { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; border-left: 2px dashed rgba(220, 38, 38, 0.85); }
#compare-modal .cmp-guide.focused.gh::before { border-top-style: solid; border-top-width: 3px; }
#compare-modal .cmp-guide.focused.gv::before { border-left-style: solid; border-left-width: 3px; }
#compare-modal .cmp-guide.gh span { position: absolute; right: 4px; top: -14px; font-size: 10.5px; color: #dc2626; background: rgba(255,255,255,0.85); padding: 0 4px; border-radius: 3px; }
#compare-modal .cmp-guide.gv span { position: absolute; left: 8px; top: 4px; font-size: 10.5px; color: #dc2626; background: rgba(255,255,255,0.85); padding: 0 4px; border-radius: 3px; }
#compare-modal .cmp-zoom-label { font-size: 12px; color: var(--muted); min-width: 30px; }
#compare-modal .cmp-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
#compare-modal .cmp-key .cmp-name { font-weight: 600; color: var(--text); }

/* 손(팬) 툴 — Space 홀드(임시) / 버튼 토글: 잡기 커서로 팬 가능 상태를 알린다.
   팬 소유자 = 뷰포트 (.stage-viewport / .cmp-scroll) — 3계층 계약. */
body.pan-space #zoom-modal .stage,
body.pan-space #zoom-modal .stage-viewport,
body.pan-space #compare-modal .cmp-scroll,
body.pan-space #compare-modal .cmp-stage,
body.pan-space #compare-modal .cmp-canvas,
#zoom-modal .stage-viewport.pan-tool,
#zoom-modal .stage-viewport.pan-tool .stage,
#compare-modal .cmp-scroll.pan-tool,
#compare-modal .cmp-scroll.pan-tool .cmp-canvas { cursor: grab; }
.et-hand.active, .cmp-hand.active { background: #e8ecf4; color: #2563eb; border-color: #2563eb; }

/* 줄 저장 팝오버 — 공용 .dl-wrap/.dl-menu 재사용, 줄 헤더 안 인라인 배치.
   .dl-wrap 의 inline-block(뒤쪽 규칙)을 이기도록 2클래스 지정 — 버튼이 형제 컨트롤
   높이(stretch)에 맞는다 (maintainer 2026-07-19 "저장버튼 높이가 안 맞네"). */
.dl-wrap.row-dl-wrap { display: inline-flex; align-items: stretch; }
.row-dl-wrap .dl-menu { right: 0; left: auto; } /* 맨 우측 배치라 메뉴는 오른끝 정렬 */

/* 확대뷰 호흡 토글 — 끄면 조정 컨트롤이 쉰다 (무호흡 재생 확인용) */
.breathe-enable { margin-right: 2px; }
.breathe-bar select:disabled, .breathe-bar input:disabled, .breathe-bar button:disabled { opacity: 0.45; cursor: default; }

/* 복제 링크 상태 버튼 — 배지 옆 (하단 컨트롤 줄 과밀로 잘리던 문제 해소, maintainer 2026-07-18) */
.link-state-btn { padding: 1px 4px; flex: none; }
.link-state-btn svg { display: block; }

/* 아틀라스 스테일 배지 — 편집 이후 아직 굽지 않음 (관측 가능한 스테일 상태) */
.atlas-bake-btn.stale {
  border-color: #c9862a;
  color: #c9862a;
}

/* 저장 팝오버 (비교/상단 공용) */
.cmp-dl-wrap, .dl-wrap { position: relative; display: inline-block; }
.cmp-dl-menu[hidden], .dl-menu[hidden] { display: none; } /* hidden 이 display:flex 를 이겨야 한다 */
.cmp-dl-menu, .dl-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 132px;
  padding: 4px;
  background: #fff;
  border: 1px solid #d7d7dc;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(20, 22, 30, 0.12);
}
.cmp-dl-menu button, .dl-menu button {
  border: 0;
  background: none;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.cmp-dl-menu button:hover, .dl-menu button:hover { background: #f0f1f5; }

/* 장기 heal/추출 첫 로드 로딩 패널 (plan long-op-loading-ux) */
.op-loading {
  max-width: 460px;
  margin: 18vh auto 0;
  padding: 28px 32px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.op-loading-title { font-size: 15px; font-weight: 600; }
.op-loading-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line, #e2e8f0);
  overflow: hidden;
}
.op-loading-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent, #3b82f6);
  transition: width 0.4s ease;
}
.op-loading-fill.indeterminate { animation: op-loading-slide 1.4s ease-in-out infinite; }
@keyframes op-loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.op-loading-live { font-size: 13px; color: var(--fg-dim, #64748b); min-height: 1.2em; }
.op-loading-note { font-size: 12px; color: var(--fg-dim, #94a3b8); }

/* ── 컬러웨이(recolor variant) 비교·픽 ─────────────────────────────────────
   스테이지는 시트를 겹쳐 쌓고 active 하나만 보인다: 목록 위를 지나가면 같은 자리에서
   즉시 갈아끼워져(전부 선로드) 한 칸짜리 색차가 깜빡임으로 드러난다. 나란히 비교는
   오른쪽 썸네일 목록이 겸한다. */
.recolor-variants .rc-split {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 10px;
}
.recolor-variants .rc-stage {
  position: relative;
  flex: 1 1 58%;
  min-width: 0;
  background:
    repeating-conic-gradient(rgba(148, 163, 184, 0.18) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 8px;
}
.recolor-variants .rc-stage img {
  display: block;
  width: 100%;
  height: auto;
}
/* 첫 장만 흐름에 남겨 스테이지 높이를 정하고, 나머지는 그 위에 겹친다 — 교체할 때
   레이아웃이 흔들리면 "같은 자리 비교" 가 깨진다. */
.recolor-variants .rc-stage img:not(:first-of-type) {
  position: absolute;
  left: 8px;
  top: 8px;
  width: calc(100% - 16px);
}
.recolor-variants .rc-stage img { visibility: hidden; }
.recolor-variants .rc-stage img.active { visibility: visible; }
.recolor-variants .rc-stage-label {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 11.5px;
  color: var(--fg-dim, #64748b);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 4px;
  padding: 1px 6px;
}
.recolor-variants .rc-list {
  flex: 1 1 42%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}
.recolor-variants .rc-thumb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
}
.recolor-variants .rc-thumb.previewing { border-color: var(--accent, #3b82f6); }
.recolor-variants .rc-thumb.picked { background: var(--bg-soft, #f8fafc); }
.recolor-variants .rc-thumb.missing { border-style: dashed; }
/* 썸네일 = 프레임 한 칸 창문. `cropped` 면 안의 <img> 가 상자 크기로 확대돼 밀려
   들어가 있고(recolorSwatchStyle), 창문이 나머지를 잘라낸다. 상자를 못 받은 런은
   창문이 시트 전체를 담는다 — 그때만 이미지가 창문 폭에 맞춰 줄어든다. */
.recolor-variants .rc-swatch {
  display: block;
  flex: none;
  width: 64px;
  height: 64px;
  overflow: hidden;
  background:
    repeating-conic-gradient(rgba(148, 163, 184, 0.18) 0% 25%, transparent 0% 50%) 0 0 / 8px 8px;
}
.recolor-variants .rc-swatch img {
  display: block;
  max-width: 100%;
  height: auto;
}
.recolor-variants .rc-swatch.cropped img { max-width: none; }
.recolor-variants .rc-thumb-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.recolor-variants .rc-name { font-size: 12.5px; font-weight: 600; }
.recolor-variants .rc-note,
.recolor-variants .rc-manifest,
.recolor-variants .rc-missing { font-size: 11.5px; color: var(--fg-dim, #64748b); }
.recolor-variants .rc-warn { font-size: 11.5px; color: var(--warn, #b45309); }
.recolor-variants .rc-pick { flex: none; }
.recolor-variants .rc-thumb.picked .rc-pick { color: var(--accent, #3b82f6); }
.recolor-variants .rc-unknown {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--warn, #b45309);
  border-radius: 8px;
  font-size: 12px;
  color: var(--warn, #b45309);
}