/* PAL Design - 에디터 전용 스타일 (canva.css 위에 얹어 사용) */
html, body { height: 100%; overflow: hidden; }
body.pc-editor { background: #ece9f5; user-select: none; -webkit-user-select: none; }
.ed { height: 100vh; height: 100dvh; display: grid; grid-template-rows: 56px 1fr; }

/* ------------------------------------------------ 상단 */
.ed-top { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); z-index: 20; min-width: 0; }
.ed-top .brand-mark { width: 30px; height: 30px; font-size: 16px; border-radius: 10px; }
.ed-title { border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 7px 10px; font-size: 15px; font-weight: 700; color: var(--tx); width: clamp(120px, 22vw, 280px); font-family: inherit; outline: none; user-select: text; -webkit-user-select: text; }
.ed-title:hover { background: var(--p-soft); }
.ed-title:focus { background: #fff; border-color: var(--p2); }
.ed-top .spacer { flex: 1; }
.save-state { font-size: 12.5px; color: var(--tx3); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.save-state.saving { color: var(--p); }
.save-state.err { color: var(--danger); font-weight: 700; }
.zoom-box { display: flex; align-items: center; gap: 2px; background: var(--p-soft); border-radius: 10px; padding: 2px; }
.zoom-box .icon-btn { width: 30px; height: 30px; }
.zoom-box span { min-width: 46px; text-align: center; font-size: 13px; font-weight: 700; color: var(--p); cursor: pointer; }
.ed-top .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }

/* ------------------------------------------------ 본문 3단 */
.ed-body { display: grid; grid-template-columns: 76px 300px 1fr 300px; min-height: 0; }
.ed-body.no-panel { grid-template-columns: 76px 0 1fr 300px; }
.ed-rail { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; overflow-y: auto; }
.rail-btn { width: 64px; border: 0; background: transparent; border-radius: 12px; padding: 9px 2px 7px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--tx2); cursor: pointer; }
.rail-btn:hover { background: var(--p-soft); color: var(--p); }
.rail-btn.on { background: var(--p-soft); color: var(--p); }
.ed-panel { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; min-width: 0; user-select: none; }
.no-panel .ed-panel { display: none; }
.panel-inner { padding: 14px 14px 40px; }
.panel-inner h4 { margin: 4px 0 10px; font-size: 14px; }
.panel-inner h5 { margin: 18px 0 8px; font-size: 12.5px; color: var(--tx2); font-weight: 800; letter-spacing: 0.02em; }
.panel-hint { font-size: 12.5px; color: var(--tx3); margin: 6px 0 12px; }

.tpl-grid { columns: 2; column-gap: 10px; }
.tpl-item { break-inside: avoid; margin-bottom: 10px; cursor: pointer; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; position: relative; }
.tpl-item:hover { border-color: var(--p); box-shadow: var(--shadow-sm); }
.tpl-item .pc-preview { display: block; }
.tpl-item span { position: absolute; left: 6px; bottom: 6px; background: rgba(36, 31, 58, 0.72); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 6px; }

.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shape-btn { aspect-ratio: 1; border: 1px solid var(--line); background: #faf8ff; border-radius: 12px; display: grid; place-items: center; cursor: pointer; padding: 10px; }
.shape-btn:hover { border-color: var(--p); background: var(--p-soft); }
.shape-btn svg { width: 100%; height: 100%; }
.emoji-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.emoji-tabs button { border: 0; background: var(--p-soft); color: var(--p); border-radius: 99px; padding: 5px 11px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.emoji-tabs button.on { background: var(--p); color: #fff; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.emoji-grid button { border: 0; background: transparent; border-radius: 10px; font-size: 26px; padding: 4px 0; cursor: pointer; line-height: 1.2; }
.emoji-grid button:hover { background: var(--p-soft); }
.text-btn { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; color: var(--tx); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.text-btn:hover { border-color: var(--p); background: var(--p-soft); }
.drop { border: 2px dashed var(--p-soft2); border-radius: 16px; padding: 22px 12px; text-align: center; color: var(--tx2); background: #faf8ff; font-size: 13.5px; }
.drop.over { border-color: var(--p); background: var(--p-soft); }
.drop .btn { margin-top: 10px; }
.up-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.up-grid button { border: 1px solid var(--line); background: repeating-conic-gradient(#f1eef8 0% 25%, #fff 0% 50%) 50% / 14px 14px; border-radius: 10px; aspect-ratio: 1; padding: 4px; cursor: pointer; display: grid; place-items: center; }
.up-grid button:hover { border-color: var(--p); }
.up-grid img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch:hover { box-shadow: 0 0 0 2px var(--p); }
.swatch.on { box-shadow: 0 0 0 2px var(--p); }
.grad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grad-grid button { aspect-ratio: 1.3; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.grad-grid button:hover { box-shadow: 0 0 0 2px var(--p); }
.size-list .opt { width: 100%; margin-bottom: 8px; }
.layer-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-size: 13.5px; }
.layer-item:hover { background: var(--p-soft); }
.layer-item.on { background: var(--p-soft); border-color: var(--p-soft2); color: var(--p); font-weight: 700; }
.layer-item.drag-over { border-color: var(--p); background: var(--p-soft2); }
.layer-item .lname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-item .ticon { width: 26px; height: 26px; border-radius: 7px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--tx2); flex: none; }
.layer-item .icon-btn { width: 26px; height: 26px; }

/* ------------------------------------------------ 캔버스 영역 */
.ed-canvas { overflow: auto; position: relative; background: #ece9f5; min-width: 0; touch-action: pan-x pan-y; }
.pages { padding: 28px 40px 160px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: min-content; }
.pc-pagebox { display: flex; flex-direction: column; align-items: stretch; }
.pc-pagehead { display: flex; align-items: center; gap: 2px; padding: 0 2px 6px; color: var(--tx2); font-size: 12.5px; font-weight: 700; }
.pc-pagehead .pn { flex: 1; }
.pc-pagehead .icon-btn { width: 28px; height: 28px; }
.pc-pagebox.active .pc-pagehead .pn { color: var(--p); }
.pc-wrap { position: relative; box-shadow: 0 6px 24px rgba(36, 31, 58, 0.16); background: #fff; }
.pc-pagebox.active .pc-wrap { box-shadow: 0 0 0 2px var(--p2), 0 6px 24px rgba(36, 31, 58, 0.16); }
.pc-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.pc-layer { position: absolute; inset: 0; }
.pc-overlay { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.add-page { margin: 18px 0 0; align-self: center; }

/* ------------------------------------------------ 요소 (에디터/공유 공용) */
.pc-el { position: absolute; transform-origin: 50% 50%; touch-action: none; cursor: move; }
.pc-el.is-locked { cursor: default; }
.pc-inner { width: 100%; height: 100%; }
.pc-text { width: 100%; white-space: pre-wrap; word-break: keep-all; overflow-wrap: break-word; outline: none; margin: 0; }
.pc-text[contenteditable] { cursor: text; user-select: text; -webkit-user-select: text; min-height: 1em; }
.pc-imgwrap { width: 100%; height: 100%; overflow: hidden; }
.pc-imgwrap img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pc-imgmissing { background: #eee; }
.pc-preview { position: relative; overflow: hidden; }
.pc-preview .pc-page { position: absolute; }

/* 선택 표시 */
.pc-overlay { --iz: 1; }
.pc-frame { position: absolute; outline: calc(1.5px * var(--iz)) solid var(--p); pointer-events: none; transform-origin: 50% 50%; }
.pc-frame.multi { outline-style: dashed; outline-width: calc(1px * var(--iz)); }
.pc-handle {
  position: absolute; width: calc(12px * var(--iz)); height: calc(12px * var(--iz)); margin: calc(-6px * var(--iz)) 0 0 calc(-6px * var(--iz));
  background: #fff; border: calc(1.5px * var(--iz)) solid var(--p); border-radius: 50%; pointer-events: auto; touch-action: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.pc-handle.edge { border-radius: calc(4px * var(--iz)); }
.pc-handle[data-h='n'], .pc-handle[data-h='s'] { width: calc(22px * var(--iz)); margin-left: calc(-11px * var(--iz)); height: calc(10px * var(--iz)); margin-top: calc(-5px * var(--iz)); }
.pc-handle[data-h='e'], .pc-handle[data-h='w'] { height: calc(22px * var(--iz)); margin-top: calc(-11px * var(--iz)); width: calc(10px * var(--iz)); margin-left: calc(-5px * var(--iz)); }
.pc-handle[data-h='nw'], .pc-handle[data-h='se'] { cursor: nwse-resize; }
.pc-handle[data-h='ne'], .pc-handle[data-h='sw'] { cursor: nesw-resize; }
.pc-handle[data-h='n'], .pc-handle[data-h='s'] { cursor: ns-resize; }
.pc-handle[data-h='e'], .pc-handle[data-h='w'] { cursor: ew-resize; }
.pc-handle.rot { cursor: grab; background: var(--p); border-color: #fff; }
.pc-rotline { position: absolute; width: calc(1.5px * var(--iz)); background: var(--p); pointer-events: none; }
.pc-lockbadge { position: absolute; background: var(--p); color: #fff; border-radius: 50%; width: calc(24px * var(--iz)); height: calc(24px * var(--iz)); display: grid; place-items: center; transform-origin: 50% 50%; }
.pc-lockbadge svg { width: 60%; height: 60%; }
.pc-guide { position: absolute; background: #ff4d8d; pointer-events: none; }
.pc-guide.v { width: calc(1px * var(--iz)); top: 0; bottom: 0; }
.pc-guide.hz { height: calc(1px * var(--iz)); left: 0; right: 0; }
.pc-marquee { position: absolute; border: calc(1px * var(--iz)) solid var(--p); background: rgba(123, 92, 240, 0.1); pointer-events: none; }
.pc-sizebadge { position: absolute; background: var(--tx); color: #fff; font-size: calc(12px * var(--iz)); padding: calc(2px * var(--iz)) calc(8px * var(--iz)); border-radius: calc(6px * var(--iz)); white-space: nowrap; pointer-events: none; transform: translateX(-50%); }

/* ------------------------------------------------ 속성 패널 */
.ed-inspector { background: #fff; border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; min-width: 0; user-select: none; }
.ins { padding: 14px 16px 60px; }
.ins h4 { margin: 2px 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ins h6 { margin: 18px 0 8px; font-size: 12px; color: var(--tx2); font-weight: 800; letter-spacing: 0.02em; }
.ins .row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ins .row > label { flex: none; width: 58px; font-size: 12.5px; color: var(--tx2); font-weight: 700; }
.ins .row .grow { flex: 1; min-width: 0; }
.ins input[type='number'], .ins select, .ins input[type='text'], .ins textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 8px; font-size: 13px; font-family: inherit; color: var(--tx); outline: none; min-width: 0; user-select: text; -webkit-user-select: text;
}
.ins textarea { resize: vertical; min-height: 64px; }
.ins input:focus, .ins select:focus, .ins textarea:focus { border-color: var(--p2); box-shadow: 0 0 0 3px rgba(123, 92, 240, 0.12); }
.ins input[type='range'] { width: 100%; accent-color: var(--p); margin: 0; }
.ins input[type='color'] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; flex: none; }
.ins .val { width: 38px; text-align: right; font-size: 12px; color: var(--tx2); flex: none; }
.ins .pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ins .pos-grid label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx2); font-weight: 700; }
.ins .pos-grid label span { width: 14px; }
.btn-row { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tbtn { border: 1px solid var(--line); background: #fff; border-radius: 9px; height: 32px; min-width: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer; color: var(--tx2); font-size: 12.5px; font-weight: 700; font-family: inherit; }
.tbtn:hover { background: var(--p-soft); color: var(--p); border-color: var(--p-soft2); }
.tbtn.on { background: var(--p-soft); color: var(--p); border-color: var(--p2); }
.tbtn.danger:hover { background: #ffe9ee; color: var(--danger); border-color: #ffc9d5; }
.tbtn:disabled { opacity: 0.4; cursor: default; }
.mini-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.mini-swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.mini-swatches button:hover { box-shadow: 0 0 0 2px var(--p); }
.ins .empty-note { color: var(--tx3); font-size: 13px; margin: 8px 0; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--tx2); cursor: pointer; margin: 6px 0 10px; }
.chk input { accent-color: var(--p); width: 16px; height: 16px; }

.ed-drop-hint { position: absolute; inset: 10px; border: 3px dashed var(--p); border-radius: 18px; background: rgba(123, 92, 240, 0.08); display: none; place-items: center; color: var(--p); font-size: 20px; font-weight: 800; pointer-events: none; z-index: 5; }
.ed-canvas.dragging .ed-drop-hint { display: grid; }

/* ------------------------------------------------ 반응형 */
@media (max-width: 1100px) {
  .ed-body { grid-template-columns: 64px 240px 1fr 240px; }
  .ed-body.no-panel { grid-template-columns: 64px 0 1fr 240px; }
  .rail-btn { width: 54px; font-size: 10.5px; }
}
@media (max-width: 820px) {
  .ed-body, .ed-body.no-panel { grid-template-columns: 56px 1fr; grid-template-rows: 1fr auto; }
  .ed-rail { grid-row: 1 / span 2; padding: 6px 2px; }
  .rail-btn { width: 50px; }
  .ed-panel { position: fixed; left: 56px; top: 56px; bottom: 0; width: min(300px, calc(100vw - 56px)); z-index: 25; box-shadow: var(--shadow); }
  .no-panel .ed-panel { display: none; }
  .ed-inspector { grid-column: 2; max-height: 38vh; border-left: 0; border-top: 1px solid var(--line); }
  .ed-title { width: 110px; }
  .hide-sm { display: none !important; }
  .pages { padding: 16px 12px 120px; }
}

/* 미디어(오디오·비디오) 요소 */
.pc-media { position: relative; width: 100%; height: 100%; overflow: hidden; background: #1f1b2e; }
.pc-media img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pc-media-audio { background: linear-gradient(135deg, #7b5cf0, #ff6b8b); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
.pc-media-note { line-height: 1; font-weight: 700; opacity: .95; }
.pc-media-name { max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.pc-media-ctl { position: absolute; left: 6%; right: 6%; bottom: 6%; width: 88%; height: 32px; pointer-events: auto; }
.pc-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(31, 27, 46, .62); color: #fff; display: grid; place-items: center; padding-left: 4%; pointer-events: none; }
.pc-static .pc-play.live { pointer-events: auto; cursor: pointer; }
.pc-media video { width: 100%; height: 100%; display: block; background: #000; }
.pc-static .pc-media video { pointer-events: auto; }
