/* 사진대지 조판 — 화면 미리보기와 인쇄(PDF) 가 같은 DOM 을 쓴다. 치수는 mm 고정. */
.sheet-app { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.sheet-panel { position: sticky; top: 64px; }
.sheet-stage { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; overflow: auto; min-height: 60vh; }
.sheet-scale { transform-origin: top left; }
.page { width: 210mm; height: 297mm; overflow: hidden; background: #fff; color: #111; margin: 0 auto 14px; padding: 14mm 14mm 12mm; box-shadow: 0 8px 30px -14px rgba(0,0,0,.35); display: flex; flex-direction: column; font-family: var(--font); font-size: 10.5pt; page-break-after: always; break-after: page; position: relative; }
.page:last-child { page-break-after: auto; break-after: auto; }
.page .ph { display: grid; grid-template-columns: 1fr auto; align-items: end; border-bottom: 2px solid #111; padding-bottom: 4mm; margin-bottom: 5mm; }
.page .ph h1 { font-size: 17pt; margin: 0; letter-spacing: -.01em; font-weight: 800; color: #111; }
.page .ph .sub { font-size: 9.5pt; color: #444; margin-top: 1mm; }
.page .meta { display: grid; grid-template-columns: repeat(2, auto); gap: 1mm 6mm; font-size: 9pt; color: #333; text-align: right; }
.page .meta b { color: #111; font-weight: 700; }
.page .grid { display: grid; gap: 4mm; flex: 1; min-height: 0; }
.page .grid.l-2x3 { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); }
.page .grid.l-2x2 { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); }
.page .grid.l-1x2 { grid-template-columns: 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); }
.page .grid.l-1x3 { grid-template-columns: 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); }
.cell { min-height: 0; min-width: 0; border: 1px solid #222; display: flex; flex-direction: column; overflow: hidden; break-inside: avoid; }
.cell .img { flex: 1; min-height: 0; background: #f3f3f3; display: grid; place-items: center; border-bottom: 1px solid #222; }
/* 사진 비율(세로 사진 포함)이 칸 높이를 밀어내지 않도록 칸 안에 고정 */
.cell .img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.cell .cap { display: grid; grid-template-columns: 22mm 1fr; font-size: 8.5pt; }
.cell .cap > div { padding: 1.3mm 2mm; border-right: 1px solid #222; min-height: 6mm; }
.cell .cap > div:last-child { border-right: 0; }
.cell .cap .k { background: #eef0f4; font-weight: 700; color: #222; }
.cell .cap .desc { grid-column: 1 / -1; border-top: 1px solid #222; min-height: 9mm; max-height: 18mm; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.cell .cap .desc:empty::before { content: attr(data-ph); color: #9aa; }
.grid.l-1x2 .cell, .grid.l-1x3 .cell { flex-direction: row; }
.grid.l-1x2 .cell .img, .grid.l-1x3 .cell .img { flex: 0 0 62%; border-bottom: 0; border-right: 1px solid #222; }
.grid.l-1x2 .cell .cap, .grid.l-1x3 .cell .cap { flex: 1; grid-template-columns: 24mm 1fr; align-content: start; }
.grid.l-1x2 .cell .cap .desc, .grid.l-1x3 .cell .cap .desc { min-height: 30mm; max-height: 60mm; }
.page .pf { display: flex; justify-content: space-between; font-size: 8.5pt; color: #555; border-top: 1px solid #999; padding-top: 2mm; margin-top: 4mm; }
[contenteditable] { outline: none; cursor: text; }
[contenteditable]:focus { background: #fffbe6; box-shadow: inset 0 0 0 1.5px #f2c94c; }
.empty-stage { display: grid; place-items: center; height: 60vh; color: var(--muted); text-align: center; }
@media (max-width: 900px) { .sheet-app { grid-template-columns: 1fr; } .sheet-panel { position: static; } }
@page { size: A4 portrait; margin: 0; }
@media print {
  body { background: #fff !important; }
  .no-print, header.top, footer.foot { display: none !important; }
  .wrap, .wrap.wide { max-width: none; padding: 0; margin: 0; }
  .sheet-app { display: block; }
  .sheet-stage { background: none; border: 0; padding: 0; min-height: 0; height: auto !important; overflow: visible; border-radius: 0; }
  .sheet-scale { transform: none !important; width: auto !important; }
  .page { margin: 0; box-shadow: none; }
  [contenteditable]:focus { background: none; box-shadow: none; }
  .cell .cap .desc:empty::before { content: ''; }
}

/* v0.3 — 칸 도구(순서·회전·빼기), 끌어다 놓기 */
.cell .img { position: relative; }
.cell .tools { position: absolute; top: 1.5mm; right: 1.5mm; display: flex; gap: 3px; opacity: 0; transition: opacity .12s; }
.cell:hover .tools, .cell:focus-within .tools { opacity: 1; }
.cell .tools button { width: 30px; height: 30px; border: 0; border-radius: 7px; background: rgba(0,0,0,.68); color: #fff; font-size: 14px; cursor: pointer; }
.cell .tools button:disabled { opacity: .35; cursor: default; }
.sheet-stage.over { outline: 3px dashed var(--brand); outline-offset: -6px; }
@media (hover: none) { .cell .tools { opacity: 1; } }
