/* ============ Swipera design tokens ============ */
:root {
  --bg: #F6F5F2;        /* warm paper */
  --panel: #FFFFFF;
  --canvas: #ECEAE4;
  --fg: #141414;        /* ink */
  --ink: #141414;
  --muted: #5E5A53;
  --line: #E4E1DA;
  --hover: #EFEDE7;
  --brand: #FF5A1F;     /* Swipera orange */
  --brand-soft: rgba(255, 90, 31, .10);
  --lime: #C6F432;      /* secondary accent */
  --lime-soft: rgba(198, 244, 50, .28);
  --font-ui: 'Pretendard Variable', 'Pretendard', 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Pretendard Variable', 'Pretendard', sans-serif;
}
html.dark {
  --bg: #141414;
  --panel: #1C1B19;
  --canvas: #0F0F0E;
  --fg: #F6F5F2;
  --ink: #141414;
  --muted: #A8A39A;
  --line: #2C2A26;
  --hover: #262421;
  --brand-soft: rgba(255, 90, 31, .18);
}
html, body { height: 100%; }
body { font-family: var(--font-ui); overflow: hidden; font-feature-settings: 'ss01'; }
.app-name, .font-display { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

/* ============ Primitives ============ */
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; color: var(--muted); font-size: 13px; transition: all .15s;
}
.tb-btn { white-space: nowrap; flex-shrink: 0; }
.tb-btn:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.tb-btn:disabled { opacity: .35; cursor: not-allowed; }

.rail-btn {
  width: 52px; height: 52px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 15px; transition: all .15s;
}
.rail-btn span { font-size: 9.5px; font-weight: 600; letter-spacing: .02em; }
.rail-btn:hover { background: var(--hover); color: var(--fg); }
.rail-btn.active { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.panel-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.panel-sub { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.lbl { display: block; font-size: 12px; }
.lbl > span:first-child { display: block; color: var(--muted); font-weight: 600; margin-bottom: 4px; font-size: 11px; }
.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; transition: border .15s, box-shadow .15s;
}
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.btn-sm {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); font-size: 12px; font-weight: 600; color: var(--fg); transition: all .15s;
}
.btn-sm:hover:not(:disabled) { background: var(--hover); }
.btn-sm:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--ink); border-color: var(--brand); }
.btn-primary:hover:not(:disabled) { background: #FF6B36; border-color: #FF6B36; }
.bg-\[var\(--brand\)\] { color: var(--ink); }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex-shrink: 0; }
.toggle input::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--brand); }
.toggle input:checked::after { transform: translateX(16px); }

.chip { font-size: 11px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 600; transition: all .15s; }
.chip:hover { background: var(--hover); color: var(--fg); }
.chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.step { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; gap: 8px; align-items: flex-start; }
.step b { width: 20px; height: 20px; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 11px; flex-shrink: 0; }

.menu {
  position: absolute; top: 100%; left: 0; margin-top: 4px; min-width: 240px; z-index: 50;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.menu button:hover { background: var(--hover); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* ============ Template gallery ============ */
.tpl-card { border-radius: 12px; overflow: hidden; border: 2px solid var(--line); cursor: pointer; transition: all .15s; background: var(--bg); position: relative; }
.tpl-card:hover { border-color: var(--muted); transform: translateY(-1px); }
.tpl-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.tpl-card .thumb { width: 100%; aspect-ratio: 4/5; overflow: hidden; position: relative; background: #ddd; }
.tpl-card .thumb > div { transform-origin: top left; position: absolute; top: 0; left: 0; }
.tpl-card .meta { padding: 6px 8px; font-size: 11px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.tpl-card .meta small { font-weight: 500; color: var(--muted); font-size: 10px; }
.tpl-card.active .meta::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: var(--brand); font-size: 10px; }
.tpl-card .badge { position: absolute; top: 6px; left: 6px; font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 999px; background: var(--brand); color: #fff; z-index: 2; letter-spacing: .04em; }

.scheme-dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; position: relative; overflow: hidden; transition: all .15s; }
.scheme-dot:hover { transform: scale(1.08); }
.scheme-dot.active { border-color: var(--fg); box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--fg); }

/* ============ Filmstrip ============ */
.film-item { flex: 0 0 auto; position: relative; cursor: pointer; border-radius: 8px; transition: transform .15s; }
.film-item .film-thumb { border-radius: 6px; overflow: hidden; position: relative; border: 2px solid transparent; background: #ddd; transition: border .15s; }
.film-item .film-thumb > div { transform-origin: top left; position: absolute; top: 0; left: 0; }
.film-item.active .film-thumb { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.film-item:hover .film-thumb { border-color: var(--muted); }
.film-item .film-num { position: absolute; top: 4px; left: 4px; font-size: 10px; font-weight: 800; background: rgba(0,0,0,.6); color: #fff; padding: 1px 6px; border-radius: 6px; z-index: 2; }
.film-item .film-type { position: absolute; bottom: 4px; left: 4px; font-size: 9px; font-weight: 700; background: rgba(255,255,255,.85); color: #111; padding: 1px 5px; border-radius: 4px; z-index: 2; text-transform: uppercase; letter-spacing: .04em; }
.film-item.dragging { opacity: .4; }
.film-item.drop-before::before, .film-item.drop-after::after { content: ''; position: absolute; top: 0; bottom: 0; width: 3px; background: var(--brand); border-radius: 2px; }
.film-item.drop-before::before { left: -8px; }
.film-item.drop-after::after { right: -8px; }
.film-add { flex: 0 0 auto; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: 18px; transition: all .15s; }
.film-add:hover { border-color: var(--brand); color: var(--brand); }

/* ============ Focus canvas ============ */
#focus-frame { transition: width .2s, height .2s; }
#focus-frame > div { transform-origin: top left; position: absolute; top: 0; left: 0; }
#focus-frame .card [contenteditable] { cursor: text; transition: outline-color .15s; outline: 3px dashed transparent; outline-offset: 8px; border-radius: 8px; }
#focus-frame .card [contenteditable]:hover { outline-color: color-mix(in srgb, currentColor 35%, transparent); }
#focus-frame .card [contenteditable]:focus { outline-color: var(--brand); }
#export-stage { position: fixed; left: -30000px; top: 0; pointer-events: none; }

/* ============ Toast / modal ============ */
.toast { pointer-events: auto; background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: toastIn .25s ease; }
.toast.error { background: #dc2626; color: #fff; }
.toast.ok i { color: #34d399; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .15s ease; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 800; }
.modal-body { padding: 20px; }
.kbd { display: inline-block; font-family: ui-monospace, monospace; font-size: 11px; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }

.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899); transition: width .2s; }

/* phone preview */
.phone { width: 340px; height: 700px; border-radius: 44px; background: #0b0b0f; padding: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 0 0 2px #333; position: relative; }
.phone-screen { width: 100%; height: 100%; border-radius: 34px; overflow: hidden; background: #000; display: flex; flex-direction: column; }
.phone-notch { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 110px; height: 28px; background: #0b0b0f; border-radius: 0 0 18px 18px; z-index: 3; }
.phone-carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.phone-carousel::-webkit-scrollbar { display: none; }
.phone-carousel > div { flex: 0 0 100%; scroll-snap-align: start; position: relative; overflow: hidden; }
.phone-carousel > div > div { transform-origin: top left; position: absolute; top: 0; left: 0; }

/* generating overlay */
.skeleton { background: linear-gradient(90deg, var(--line) 25%, var(--hover) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* responsive */
@media (max-width: 1100px) { #inspector { display: none; } }
@media (max-width: 860px) {
  #left-panel { width: 300px; }
}

/* ============ Design panel ============ */
.dsec { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.dsec summary { list-style: none; cursor: pointer; padding: 10px 12px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--fg); }
.dsec summary::-webkit-details-marker { display: none; }
.dsec summary::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; margin-left: auto; font-size: 10px; color: var(--muted); transition: transform .2s; }
.dsec[open] summary::after { transform: rotate(180deg); }
.dsec summary i:first-child { color: var(--brand); width: 14px; }
.dsec-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.range { display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.range b { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg); font-weight: 600; }
.range input[type=range] { width: 100%; accent-color: var(--brand); height: 4px; }
.seg { display: flex; gap: 2px; background: var(--hover); border-radius: 9px; padding: 2px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; height: 28px; min-width: 40px; border-radius: 7px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 0 8px; }
.seg button:hover { color: var(--fg); }
.seg button.active { background: var(--panel); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cpick { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); cursor: pointer; }
.cpick input[type=color] { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); padding: 0; background: transparent; cursor: pointer; }
.cpick input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.cpick input[type=color]::-webkit-color-swatch { border-radius: 8px; border: none; }
.pat { aspect-ratio: 1; border-radius: 8px; border: 2px solid var(--line); background-color: var(--panel); color: var(--fg); font-size: 11px; display: grid; place-items: center; background-size: 10px 10px !important; }
.pat.pat-grid { background-size: 8px 8px !important; }
.pat.pat-lines { background-size: auto !important; background-image: repeating-linear-gradient(45deg, currentColor 0 1px, transparent 1px 6px); }
.pat.pat-cross { background-size: 14px 14px !important; }
.pat.pat-waves { background-image: repeating-radial-gradient(circle at 50% 120%, transparent 0 6px, currentColor 6px 7px); }
.pat.active { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); }
.pal { height: 28px; border-radius: 8px; display: flex; overflow: hidden; border: 2px solid var(--line); cursor: pointer; transition: transform .15s; }
.pal:hover { transform: scale(1.06); border-color: var(--muted); }
.pal i { flex: 1; display: block; }
.pal.saved { position: relative; width: 84px; }
.pal .pal-del { position: absolute; right: -4px; top: -6px; width: 16px; height: 16px; border-radius: 50%; background: #ef4444; color: #fff; font-size: 9px; display: none; place-items: center; }
.pal:hover .pal-del { display: grid; }
.contrast-pill { padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 10px; }
.contrast-pill.ok { background: #d1fae5; color: #065f46; } .contrast-pill.warn { background: #fef3c7; color: #92400e; } .contrast-pill.bad { background: #fee2e2; color: #991b1b; }
html.dark .contrast-pill.ok { background: #064e3b; color: #a7f3d0; } html.dark .contrast-pill.warn { background: #78350f; color: #fde68a; } html.dark .contrast-pill.bad { background: #7f1d1d; color: #fecaca; }
.variant-card { border: 2px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: all .15s; background: var(--bg); }
.variant-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.variant-card .vthumb { position: relative; overflow: hidden; aspect-ratio: 4/5; }
.variant-card .vthumb > div { position: absolute; top: 0; left: 0; transform-origin: top left; }
.variant-card .vmeta { padding: 8px 10px; font-size: 11px; }
.variant-card .vmeta b { display: block; font-size: 12px; margin-bottom: 2px; }

/* ---------- Smart image tools (inspector) ---------- */
#img-tools .dsec > div { padding: 4px 12px 12px; }
.imgl, .imgf, .imgo { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 2px 4px; border-radius: 9px; border: 2px solid var(--line); background: var(--panel); color: var(--muted); font-size: 9.5px; line-height: 1; cursor: pointer; transition: border-color .15s, color .15s; }
.imgl:hover, .imgf:hover, .imgo:hover { border-color: var(--muted); color: var(--fg); }
.imgl.active, .imgf.active, .imgo.active { border-color: var(--brand); color: var(--fg); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.imgl small, .imgf small, .imgo small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-weight: 600; }
/* layout mini diagrams: box = card, i = image area */
.imgl-ico { width: 30px; height: 30px; border-radius: 5px; background: var(--hover); position: relative; overflow: hidden; border: 1px solid var(--line); }
.imgl-ico i { position: absolute; background: currentColor; opacity: .55; border-radius: 2px; }
.imgl-ico::after { content: ''; position: absolute; left: 6px; right: 6px; bottom: 5px; height: 3px; background: currentColor; opacity: .35; border-radius: 2px; }
.imgl-auto i { inset: 4px; background: repeating-linear-gradient(45deg, currentColor 0 2px, transparent 2px 5px); opacity: .5; }
.imgl-full i { inset: 0; }
.imgl-full::after { background: #fff; opacity: .9; }
.imgl-top i { top: 0; left: 0; right: 0; height: 46%; }
.imgl-bottom i { bottom: 0; left: 0; right: 0; height: 46%; }
.imgl-bottom::after { bottom: auto; top: 6px; }
.imgl-left i { top: 0; bottom: 0; left: 0; width: 46%; }
.imgl-left::after { left: 17px; }
.imgl-right i { top: 0; bottom: 0; right: 0; width: 46%; }
.imgl-right::after { right: 17px; }
.imgl-card i { top: 4px; left: 4px; right: 4px; height: 44%; border-radius: 4px; }
.imgl-circle i { top: 3px; left: 8px; width: 14px; height: 14px; border-radius: 50%; }
.imgl-polaroid i { top: 3px; left: 5px; width: 15px; height: 17px; border: 2px solid #fff; border-bottom-width: 5px; transform: rotate(-6deg); box-sizing: border-box; }
.imgf img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.imgo span { display: block; width: 100%; aspect-ratio: 1.6; border-radius: 5px; border: 1px solid var(--line); background-color: var(--hover); }
#img-focus-dot { transition: left .05s, top .05s; }
#btn-img-flip.active { border-color: var(--brand); color: var(--brand); }
#tpl-filters .chip[data-filter="photo"] i { margin-right: 3px; }

/* ---------- Source image gallery ---------- */
.sg-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 2px solid var(--line); background: var(--hover); cursor: pointer; transition: border-color .15s, transform .15s; }
.sg-item:hover { border-color: var(--muted); transform: translateY(-1px); }
.sg-item.cover { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); }
.sg-item.used::after { content: attr(data-used); position: absolute; right: 3px; bottom: 3px; background: rgba(0,0,0,.7); color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 999px; }
.sg-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sg-item .sg-star { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.sg-item:hover .sg-star, .sg-item.cover .sg-star { opacity: 1; }
.sg-item.cover .sg-star { background: var(--brand); }
.sg-item.broken { display: none; }
.sg-item.loading::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, var(--hover) 25%, var(--line) 50%, var(--hover) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.sg-grid-lg .sg-item { border-radius: 12px; }
.sg-grid-lg .sg-item .sg-alt { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; font-size: 10px; padding: 14px 6px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Template Designer (v2.6) ---------------- */
.modal.dz-modal { max-height: 94vh; display: flex; flex-direction: column; }
.modal.dz-modal .modal-body { padding: 0; flex: 1; min-height: 0; display: flex; }
.dz-root { display: grid; grid-template-columns: 360px 1fr; width: 100%; min-height: 0; height: calc(94vh - 58px); }
.dz-left { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.dz-presets, .dz-ai { padding: 12px 14px 0; }
.dz-ai { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.dz-scroll { flex: 1; overflow: auto; padding: 8px 14px 14px; }
.dz-sec { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.dz-sec:last-child { border-bottom: 0; }
details.dz-sec > summary { cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
details.dz-sec > summary::-webkit-details-marker { display: none; }
details.dz-sec > summary::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 9px; margin-left: auto; color: var(--muted); transition: transform .15s; }
details.dz-sec[open] > summary::after { transform: rotate(180deg); }
details.dz-sec > summary i { color: var(--brand); width: 14px; text-align: center; }
details.dz-sec > summary small { font-weight: 600; color: var(--muted); font-size: 10px; }
.dz-scheme { display: grid; grid-template-columns: 1fr repeat(5, 30px) 24px; gap: 4px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.dz-scheme.active { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.dz-scheme .dz-sname { font-size: 11px; font-weight: 600; background: transparent; border: 0; min-width: 0; outline: none; color: var(--fg); }
.dz-scheme label { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.dz-scheme label input[type=color] { width: 26px; height: 22px; border: 1px solid var(--line); border-radius: 6px; padding: 0; background: transparent; cursor: pointer; }
.dz-scheme label small { font-size: 8px; color: var(--muted); }
.dz-right { display: flex; flex-direction: column; min-height: 0; background: var(--hover); }
.dz-topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.dz-topbar .seg { width: auto; }
.dz-topbar .seg button { min-width: 44px; }
.dz-preview { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; overflow: hidden; background: repeating-conic-gradient(color-mix(in srgb, var(--fg) 4%, transparent) 0 25%, transparent 0 50%) 0 0/24px 24px; }
.dz-card { box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; position: relative; }
.dz-card > div { transform-origin: top left; position: absolute; top: 0; left: 0; }
.dz-strip { display: flex; gap: 8px; padding: 8px 14px; overflow-x: auto; border-top: 1px solid var(--line); background: var(--panel); }
.dz-th { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 2px solid transparent; border-radius: 9px; padding: 3px; flex: 0 0 auto; }
.dz-th.active { border-color: var(--brand); }
.dz-th span { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.dz-actions { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.dz-deco-item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; cursor: pointer; }
.dz-deco-item.active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.dz-deco-item small { color: var(--muted); font-size: 10px; }
.dz-props { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--hover); }
.tpl-card .ct-actions { position: absolute; top: 4px; right: 4px; z-index: 3; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.tpl-card.is-custom:hover .ct-actions { opacity: 1; }
.tpl-card .ct-actions .tb-btn { width: 24px; height: 24px; background: rgba(0,0,0,.55); color: #fff; border-radius: 6px; font-size: 10px; }
.tpl-card .ct-actions .tb-btn:hover { background: rgba(0,0,0,.8); }
.tpl-card.tpl-new { border-style: dashed; background: transparent; text-align: center; }
.tpl-card.tpl-new .thumb { background: transparent; }
.tpl-card.tpl-new:hover { border-color: var(--brand); }
.tpl-card.tpl-new .meta { justify-content: center; }
@media (max-width: 900px) { .dz-root { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; } .dz-left { border-right: 0; border-bottom: 1px solid var(--line); } }

/* paste feedback */
.paste-flash { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 200; background: var(--fg); color: var(--bg); font-size: 12px; font-weight: 700; padding: 8px 16px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; gap: 8px; align-items: center; animation: fadeIn .15s ease; }

/* ---- v3.1 Smart text fit ---- */
.fit-count { font-size: 10px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.fit-count.warn { color: #d97706; }
.fit-count.over { color: #dc2626; }
.fit-meter { height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.fit-meter-bar { height: 100%; width: 0; border-radius: 999px; background: #7BB800; transition: width .25s ease, background .25s ease; }
.fit-meter.tight .fit-meter-bar { background: #f59e0b; }
.fit-meter.over .fit-meter-bar, .fit-meter.shrunk .fit-meter-bar { background: #ef4444; }
.fit-meter.shrunk .fit-meter-bar { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.fit-status { font-size: 10px; font-weight: 700; }
.fit-status.ok { color: #5C8A00; } .fit-status.tight { color: #d97706; } .fit-status.over, .fit-status.shrunk { color: #dc2626; }
.fit-all-count { font-size: 10px; font-weight: 800; background: #ef4444; color: #fff; border-radius: 999px; padding: 0 6px; margin-left: 4px; }
#ins-fit-wrap { padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel) 92%, var(--brand) 8%); }
.film-item .film-fitbadge { position: absolute; top: 4px; right: 4px; z-index: 2; width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; font-size: 9px; color: #fff; }
.film-item .film-fitbadge.over { background: #ef4444; }
.film-item .film-fitbadge.shrunk { background: #f59e0b; }
/* overflow outline on the focused card when auto-shrink is disabled */
#focus-frame .card.fit-over::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 50; box-shadow: inset 0 0 0 10px rgba(239,68,68,.75); }
.card .c-main { will-change: transform; }
.lbl > span:first-child.flex, #ins-fit-wrap > span:first-child { display: flex; }
.fit-count { margin-left: 8px; }
#ins-fit-wrap > span:first-child { align-items: center; margin-bottom: 6px; }
#ins-fit-wrap .fit-status { margin-left: auto; }
#ins-fit-wrap .btn-sm { padding: 0 6px; white-space: nowrap; font-size: 11px; }
#opt-density-wrap > span:first-child { display: flex; }
#opt-density-hint { margin-left: 8px; }

/* ---- Sprint 1: platform presets ---- */
.platform-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pf-chip { display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border-radius: 10px; border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); transition: all .15s; }
.pf-chip i { font-size: 13px; color: var(--pf); }
.pf-chip:hover { background: var(--hover); color: var(--fg); }
.pf-chip.active { border-color: var(--pf); color: var(--fg); background: color-mix(in srgb, var(--pf) 10%, var(--bg)); box-shadow: inset 0 0 0 1px var(--pf); }
.dark .pf-chip.active { background: color-mix(in srgb, var(--pf) 22%, var(--bg)); }
.pf-rules { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 11px; color: var(--muted); background: var(--hover); }
.pf-rules-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--fg); } .pf-rules-head b { font-size: 12px; } .pf-rules-head span { color: var(--muted); }
.pf-rules ul { margin: 0; padding-left: 14px; display: flex; flex-direction: column; gap: 2px; }
.pf-issues { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.pf-issue { display: flex; align-items: flex-start; gap: 6px; font-size: 11px; font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.pf-issue.warn { background: rgba(239,68,68,.1); color: #dc2626; } .pf-issue.info { background: rgba(245,158,11,.12); color: #b45309; }
.pf-issue i { margin-top: 2px; }
.ex-platform { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--hover); font-size: 12px; } .ex-platform span { color: var(--muted); font-size: 11px; }
.ex-rec { position: absolute; top: -7px; right: 6px; font-style: normal; font-size: 9px; font-weight: 800; letter-spacing: .04em; background: var(--ink); color: var(--lime); padding: 1px 6px; border-radius: 999px; }
#btn-safe-area.active { color: var(--brand); background: var(--brand-soft); }
/* canvas overlay (inside the scaled card wrapper, so it uses design-space px) */
.safe-area { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 60; }
.safe-area .sa-zone { position: absolute; background: repeating-linear-gradient(135deg, rgba(239,68,68,.22) 0 14px, rgba(239,68,68,.08) 14px 28px); outline: 3px dashed rgba(239,68,68,.75); outline-offset: -3px; display: flex; align-items: center; justify-content: center; }
.safe-area .sa-zone span { font: 800 30px/1 Inter, 'Noto Sans KR', sans-serif; color: #fff; background: rgba(220,38,38,.85); padding: 10px 18px; border-radius: 999px; letter-spacing: .02em; }
.safe-area .sa-tag { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); font: 700 28px/1 Inter, 'Noto Sans KR', sans-serif; color: #fff; background: rgba(17,17,17,.78); padding: 12px 22px; border-radius: 999px; display: flex; gap: 10px; align-items: center; }
.safe-area .sa-free { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 36px; }
.safe-area .sa-free span { font: 700 26px/1 Inter, 'Noto Sans KR', sans-serif; color: #fff; background: rgba(16,185,129,.85); padding: 12px 22px; border-radius: 999px; }

/* ---- Swipera motion ---- */
@media (prefers-reduced-motion: no-preference) {
  /* primary CTA + rail/chip buttons: tilt like a card being picked up */
  #btn-generate, #btn-export, .btn-primary, .pf-chip, .film-add, .tpl-card, .tpl-new { transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s, background .15s, color .15s; transform-origin: 50% 80%; }
  #btn-generate:hover:not(:disabled), #btn-export:hover:not(:disabled), .btn-primary:hover:not(:disabled), .pf-chip:hover, .film-add:hover, .tpl-card:hover, .tpl-new:hover { transform: rotate(-3deg) translateY(-1px); box-shadow: 0 8px 20px -10px rgba(20,20,20,.35); }
  #btn-generate:active:not(:disabled), #btn-export:active:not(:disabled), .btn-primary:active:not(:disabled) { transform: rotate(-3deg) scale(.98); }
  /* generation complete: thumbs fan out from a stack, then settle */
  @keyframes fan-in { 0% { opacity: 0; transform: translateX(calc(var(--fan-i, 0) * -72px)) rotate(var(--fan-rot, 0deg)) scale(.92); } 60% { opacity: 1; transform: translateX(0) rotate(calc(var(--fan-rot, 0deg) * .35)); } 100% { transform: none; } }
  .film-item.fan-in { animation: fan-in .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--fan-i, 0) * 45ms); transform-origin: 50% 120%; }
  @keyframes deal-in { 0% { opacity: 0; transform: translateY(24px) rotate(-4deg) scale(.96); } 100% { opacity: 1; transform: none; } }
  #focus-frame.deal-in { animation: deal-in .55s cubic-bezier(.2,.8,.2,1) both; }
}

/* ---- try-first export gate ---- */
.gate { display: flex; flex-direction: column; }
.gate-stack { position: relative; height: 84px; margin: 4px 0 14px; }
.gate-stack i { position: absolute; left: 50%; top: 10px; width: 56px; height: 70px; margin-left: -28px; border: 2px solid var(--ink); background: var(--brand); transform: rotate(calc((var(--i) - 1) * 10deg)) translateX(calc((var(--i) - 1) * 44px)); box-shadow: 3px 3px 0 var(--ink); }
.gate-stack i:nth-child(2) { background: var(--lime); } .gate-stack i:nth-child(3) { background: #fff; }
.gate-perks { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.gate-perks li::before { content: '■ '; color: var(--brand); }
