:root {
  --bg: #f4f1ec; --panel: #fffdfa; --ink: #1c1a18; --sub: #6b645d; --line: #e6e0d8;
  --brown: #8e6842; --brown-2: #a98058; --dark: #22201e; --ok: #4d7c4d; --err: #b5473a;
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: #f0ebe4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 22px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--sub); }
.brand img { height: 26px; }
.topbar nav { display: flex; gap: 6px; }
.tab, .ghost { border: 0; background: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--sub); font-weight: 500; }
.tab.active { background: var(--dark); color: #fff; }
.ghost:hover, .tab:not(.active):hover { background: #f1ece6; }

#view-make { display: grid; grid-template-columns: 380px 1fr; gap: 18px; padding: 18px; align-items: start; }
.panel { display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 90px); overflow: auto; padding-right: 4px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.step h3 { margin: 0 0 2px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--brown); color: #fff; font-size: 12px; display: grid; place-items: center; }
.hint { margin: 0; color: var(--sub); font-size: 12px; line-height: 1.55; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #cfc6bb; }
.btn.primary { background: var(--brown); border-color: var(--brown); color: #fff; }
.btn.primary:hover { background: #7d5a37; }
.btn.subtle { background: #faf7f3; color: var(--sub); font-size: 13px; }
.btn.wide { width: 100%; }
.btn.big { padding: 13px; font-size: 15px; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: wait; }
.mini { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 3px 9px; font-size: 12px; cursor: pointer; color: var(--sub); }
.mini:hover { color: var(--ink); border-color: #cfc6bb; }

.seg { display: inline-flex; background: #ece7e0; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--sub); font-weight: 500; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg.small button { padding: 4px 10px; font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 8px; }
.lbl { font-size: 12px; color: var(--sub); }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--sub); }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline input { flex: 1; }
.field input:not([type=range]):not([type=file]), .field select, textarea, .captions input, .tp-label { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); font-size: 13px; width: 100%; }
textarea { font-size: 11.5px; line-height: 1.5; resize: vertical; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
input[type=range] { accent-color: var(--brown); }
input[type=checkbox], input[type=radio] { accent-color: var(--brown); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; cursor: pointer; font-size: 12.5px; color: var(--sub); }
.chip.on { background: var(--dark); border-color: var(--dark); color: #fff; }

/* 시점 목록 */
.tp { border: 1px solid var(--line); border-radius: 10px; padding: 9px; display: flex; flex-direction: column; gap: 7px; background: #fff; }
.tp.off { opacity: .55; }
.tp-h { display: flex; align-items: center; gap: 7px; }
.tp-kind { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; color: #fff; background: var(--dark); flex: none; }
.tp-kind.after { background: var(--brown); }
.tp-date { font-size: 11px; color: var(--sub); flex: none; }
.tp-label { padding: 4px 8px !important; font-size: 12.5px !important; }
.thumbs { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
.thumb { position: relative; flex: none; width: 54px; height: 70px; border-radius: 6px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: #eee; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.sel { border-color: var(--brown); }
.thumb .tag { position: absolute; left: 2px; bottom: 2px; font-size: 9px; background: rgba(0,0,0,.6); color: #fff; border-radius: 3px; padding: 0 3px; }
.thumb .tag.corr { left: auto; right: 2px; background: var(--ok); }
#timepoints { display: flex; flex-direction: column; gap: 8px; }

.pick { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: #fff; }
.pick-h { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pick-h small { font-weight: 400; color: var(--sub); }
.drop { border: 1.5px dashed #d6cdc2; border-radius: 9px; min-height: 74px; display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; color: var(--sub); font-size: 12.5px; padding: 6px; }
.drop.hover { border-color: var(--brown); background: #faf5ef; }
.drop img { height: 62px; border-radius: 5px; }
.quick { display: flex; flex-wrap: wrap; gap: 4px; }
.quick button { font-size: 11px; padding: 2px 7px; }

/* 진행 */
.progress { position: relative; height: 26px; background: #eee7df; border-radius: 8px; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #c9a882, var(--brown)); transition: width .3s; }
.progress span { position: relative; z-index: 1; font-size: 12px; line-height: 26px; padding-left: 10px; color: var(--ink); }

/* 스테이지 */
.stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stage-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stage-top select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.canvas-wrap { background: #e9e4dd; border-radius: 16px; min-height: 560px; height: calc(100vh - 330px); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.canvas-wrap canvas { max-width: 96%; max-height: 96%; box-shadow: 0 12px 40px rgba(60,40,20,.18); border-radius: 6px; touch-action: none; }
.empty { text-align: center; color: var(--sub); }
.empty .emoji { font-size: 40px; }
.stage-bottom { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.adjust { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 12px; color: var(--sub); }
.adjust label { display: flex; align-items: center; gap: 6px; }
.adjust input[type=range] { width: 110px; }
.adjust select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; }
.captions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1 1 100%; }
.captions input { padding: 6px 9px; }
.exports { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* 갤러리 */
#view-gallery { padding: 22px; }
.gal-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.gal-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s; position: relative; }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(60,40,20,.12); }
.card img { width: 100%; aspect-ratio: 5/8; object-fit: cover; display: block; background: #f1ede7; }
.card .meta { padding: 10px 12px; font-size: 12.5px; }
.card .meta b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.card .meta span { color: var(--sub); }
.card .ops { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.card:hover .ops { opacity: 1; }
.card .ops button { border: 0; background: rgba(255,255,255,.92); border-radius: 7px; padding: 4px 8px; font-size: 12px; cursor: pointer; }
.gal-empty { color: var(--sub); padding: 60px; text-align: center; grid-column: 1/-1; }

/* 고객용 보기 */
#present { position: fixed; inset: 0; background: #12110f; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 34px 0 72px; }
#present canvas { max-width: 100vw; max-height: 100%; touch-action: none; }
.p-ctrl { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; background: rgba(255,255,255,.1); backdrop-filter: blur(8px); padding: 5px; border-radius: 12px; }
.p-ctrl button, .p-ctrl select { border: 0; background: none; color: #ddd; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.p-ctrl select { background: rgba(255,255,255,.1); }
.p-ctrl select option { color: #000; }
.p-ctrl button.on { background: #fff; color: #111; }
.p-note { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.45); font-size: 12px; }

dialog { border: 0; border-radius: 16px; padding: 22px; width: min(460px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,16,12,.45); }
dialog h3 { margin-top: 0; }
dialog form { display: flex; flex-direction: column; gap: 10px; }
#dlgMosaic { width: min(760px, 96vw); }
#mzCanvas { width: 100%; border-radius: 8px; background: #222; cursor: grab; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(30px); background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: all .25s; z-index: 100; pointer-events: none; max-width: 80vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--err); }
