:root {
  --bg: #fff6f0; --ink: #4a3f55; --muted: #8a7f94; --primary: #f4877f; --primary-ink: #fff;
  --card: #ffffff; --line: #f0e4dc; --radius: 20px;
  --sans: "Pretendard Variable","Pretendard","Apple SD Gothic Neo","Noto Sans KR","Malgun Gothic",system-ui,sans-serif;
  font-family: var(--sans);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); overscroll-behavior-x: none; }
body { line-height: 1.5; letter-spacing: -0.01em; word-break: keep-all; -webkit-font-smoothing: antialiased; min-height: 100vh; padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 16px) env(safe-area-inset-left); }
button, select { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; max-width: 560px; margin: 0 auto; }
.logo { display: flex; flex-direction: column; line-height: 1.1; }
.logo-mark { font-family: var(--sans); font-size: 26px; font-weight: 800; letter-spacing: -0.05em; }
.logo-mark b { color: var(--primary); }
.logo-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
h2 { font-size: 18px; margin: 14px 2px 10px; }

.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.theme-card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 8px; text-align: left; cursor: pointer; transition: transform .1s; }
.theme-card:active { transform: scale(.97); }
.theme-card canvas { width: 100%; aspect-ratio: 4/3; border-radius: 14px; display: block; }
.theme-card .name { font-weight: 800; margin: 8px 4px 2px; font-size: 15px; }
.theme-card .icons { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 2px 2px; }
.theme-card .icons img { width: 26px; height: 22px; object-fit: contain; }

.stage { position: relative; border-radius: var(--radius); overflow: hidden; background: #2d2633; box-shadow: 0 6px 20px rgba(74, 63, 85, .15); }
.stage canvas { width: 100%; display: block; aspect-ratio: 4/3; touch-action: none; }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.slot { position: relative; border-radius: 10px; overflow: hidden; background: #efe6f3; border: 2px solid transparent; }
.slot canvas { width: 100%; aspect-ratio: 4/3; display: block; }
.slot span { position: absolute; left: 5px; top: 3px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.slot.active { border-color: var(--primary); }

.meter { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 0 2px 10px; }
.meter-track { position: relative; flex: 1; height: 8px; background: #efe6f3; border-radius: 4px; overflow: hidden; }
#meterBar { height: 100%; width: 0; background: #8fd3a8; border-radius: 4px; transition: width .06s linear; }
#meterLine { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); left: 50%; }

.big { display: block; width: 100%; border: 0; border-radius: 16px; padding: 16px; font-size: 19px; font-weight: 800; background: #fff; border: 2px solid var(--line); margin: 8px 0; cursor: pointer; }
.big.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); box-shadow: 0 4px 0 #d9675f; }
.big.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #d9675f; }
.big:disabled { opacity: .5; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border: 1.5px solid #e9dfd8; background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chip.ghost { background: transparent; }
.chip.wide { width: 100%; justify-content: center; margin-top: 8px; }
.chip.sel select { border: 0; background: transparent; font-weight: 800; color: var(--primary); padding: 0; -webkit-appearance: none; appearance: none; }
.chip:disabled, .chip.sel.disabled { opacity: .45; pointer-events: none; }

.strip-wrap { display: flex; justify-content: center; margin: 8px 0 6px; }
#stripImg { display: block; width: 100%; border-radius: 6px; box-shadow: 0 8px 24px rgba(74, 63, 85, .22); -webkit-touch-callout: default; }
.hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 2px 8px 6px; line-height: 1.45; }
.cut-rows { display: grid; gap: 8px; margin: 12px 0; }
.cut-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 6px 8px; }
.cut-row canvas { width: 72px; aspect-ratio: 4/3; border-radius: 8px; }
.cut-row b { flex: 1; font-size: 14px; }
.cut-row .chip { padding: 7px 11px; font-size: 13px; }

dialog { border: 0; border-radius: 22px; padding: 18px; width: min(92vw, 380px); color: var(--ink); text-align: center; }
dialog::backdrop { background: rgba(45, 38, 51, .5); }
dialog h3 { margin: 4px 0 10px; }
#qr { width: 220px; height: 220px; image-rendering: pixelated; }
.code { margin: 6px 0; font-size: 15px; }
.code b { letter-spacing: 3px; font-size: 20px; color: var(--primary); }
.status { font-weight: 800; font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px; max-width: 88vw; z-index: 10; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

#video { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: 0; top: 0; }

.theme-card .icons .dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line); margin: 3px 0; }
.colors { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 2px 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.colors span { margin-right: 2px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #e4d8d0; padding: 0; cursor: pointer; }
.swatch.on { outline: 3px solid var(--primary); outline-offset: 2px; }

main { overflow-x: hidden; }


/* ---- v1.3 깔끔한 버튼 ---- */
:root { --dark: #2b2730; --soft: #f5efea; }
.lang { display: inline-flex; background: #fff; border: 1.5px solid #ece2db; border-radius: 12px; padding: 3px; gap: 2px; }
.lang button { border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 6px 9px; border-radius: 9px; cursor: pointer; opacity: .35; filter: grayscale(.6); transition: all .15s; }
.lang button.on { opacity: 1; filter: none; background: var(--soft); }

.shutter { width: 100%; height: 62px; margin: 6px 0 12px; border: 0; border-radius: 18px; background: var(--dark); color: #fff;
  font-size: 18px; font-weight: 800; letter-spacing: -.2px; display: flex; align-items: center; justify-content: center; gap: 12px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(43, 39, 48, .22); transition: transform .08s; }
.shutter:active { transform: scale(.98); }
.shutter .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--dark), 0 0 0 5px #fff; transition: border-radius .15s; }
.shutter.stop { background: #3b3442; }
.shutter.stop .dot { border-radius: 5px; width: 18px; height: 18px; }

.panel { background: #fff; border: 1.5px solid #f0e6df; border-radius: 18px; padding: 2px 14px; transition: opacity .15s; }
.panel.disabled { opacity: .45; pointer-events: none; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; }
.opt + .opt { border-top: 1px solid #f4ede8; }
.opt > span { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.seg { display: inline-flex; background: var(--soft); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 7px 11px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(74, 63, 85, .14); }

.links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.link-btn { background: transparent; border: 1.5px solid #e9dfd8; border-radius: 14px; padding: 13px 8px; font-size: 14.5px; font-weight: 700; color: var(--ink); cursor: pointer; }
.link-btn:disabled { opacity: .4; }
.link-btn.wide { width: 100%; margin-top: 10px; }

.big { border-radius: 16px; font-size: 17px; padding: 16px; border: 1.5px solid #e2d7cf; box-shadow: none; }
.big.dark { background: var(--dark); color: #fff; border-color: var(--dark); box-shadow: 0 8px 20px rgba(43, 39, 48, .2); }
.big.dark:active { transform: scale(.98); }
.big.outline { background: transparent; }

.tools { display: flex; gap: 4px; background: var(--soft); border-radius: 13px; padding: 4px; margin: 12px 0; }
.tools button { flex: 1; border: 0; background: #fff; border-radius: 9px; padding: 10px 2px; font-size: 12.5px; font-weight: 700; color: var(--ink); cursor: pointer; white-space: nowrap; }
.tools button:active { background: #efe6f3; }


.big.waiting { opacity: .45; }
#home .link-btn.wide { margin: 16px 0 8px; }

/* 4×6 용지 위에 앉혀서 보기 */
.paper-stage { display: flex; justify-content: center; gap: 10px; background: linear-gradient(160deg, #3a3340, #2b2730); border-radius: 22px; padding: 18px 22px 26px 12px; margin: 10px 0 6px; }
.paper-col { display: flex; flex-direction: column; align-items: center; width: 66%; max-width: 320px; }
.paper { position: relative; width: 100%; background: #fff; box-shadow: 0 14px 34px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3); }
.paper canvas { display: block; width: 100%; cursor: pointer; }
.crop-guide { position: absolute; left: 1.48%; right: 1.48%; top: .98%; bottom: .98%; border: 1.5px dashed rgba(244, 135, 127, .9); pointer-events: none; }
.dim-w, .dim-h { color: #d8cfe0; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dim-w { width: 100%; margin-bottom: 8px; }
.dim-w::before, .dim-w::after { content: ''; flex: 1; height: 1px; background: rgba(216, 207, 224, .5); }
.dim-h { flex-direction: column; margin-top: 26px; }
.dim-h span { writing-mode: vertical-rl; transform: rotate(180deg); }
.dim-h::before, .dim-h::after { content: ''; flex: 1; width: 1px; background: rgba(216, 207, 224, .5); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 42px; height: 42px; border-radius: 11px; box-shadow: 0 3px 10px rgba(244, 135, 127, .35); }

/* 촬영 시작 버튼: 로고 'Pop' 색 */
.shutter { background: var(--primary); box-shadow: 0 8px 20px rgba(244, 135, 127, .45); }
.shutter .dot { background: #fff; box-shadow: 0 0 0 3px var(--primary), 0 0 0 5px #fff; }
.shutter.stop { background: #e46a6a; }
.shutter.stop .dot { box-shadow: 0 0 0 3px #e46a6a, 0 0 0 5px #fff; }

/* 여행모아와 같은 글씨 규칙: 제목·버튼은 800/700 굵기에 글자 간격을 조금 좁게 */
h2, h3, .theme-card .name, .opt > span { letter-spacing: -0.04em; }
.shutter, .big, .link-btn { letter-spacing: -0.03em; }

/* 상단 로고 고정 */
body { padding-top: 0; }
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding-top: calc(env(safe-area-inset-top) + 12px); padding-bottom: 8px;
  box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(0 -100vmax); }
/* 촬영 시작 버튼 그림자 없음 */
.shutter, .shutter.stop { box-shadow: none; }

/* 촬영 화면은 모든 글씨를 일반 굵기로 */
#camera, #camera * { font-weight: 400 !important; }

/* 결과 화면 컷 목록은 일반 굵기 */
.cut-row b, .cut-row .chip { font-weight: 400; }

/* 네컷 위에서 컷 누르기 */
.strip-box { position: relative; width: 66%; max-width: 320px; }
#cutHits { position: absolute; inset: 0; }
.cut-hit { position: absolute; border-radius: 4%; cursor: pointer; transition: box-shadow .15s, background .15s; }
.cut-hit.on { box-shadow: 0 0 0 3px var(--primary); background: rgba(43, 39, 48, .35); }
.cut-menu { position: absolute; inset: 0; display: none; flex-direction: row; align-items: center; justify-content: center; gap: 16px; }
.cut-hit.on .cut-menu { display: flex; }
.cut-menu button { border: 0; border-radius: 50%; width: 52px; height: 52px; padding: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); cursor: pointer; }
.cut-menu button:active { transform: scale(.94); }

/* 진한 버튼(완료, 사진 앨범에 저장, 4×6 저장) 그림자 없음 */
.big.dark { box-shadow: none; }
/* 소품 조정 메뉴 일반 굵기 */
#edit .tools button, #edit .big { font-weight: 400; }

/* 안내 말풍선: 엽기 얼굴 테마의 말풍선 스티커 모양 + 손글씨 */
.tip { position: absolute; left: 50%; top: 6%; transform: translateX(-50%); z-index: 2; pointer-events: none; white-space: pre; width: max-content; text-align: center;
  font-family: 'Nanum Pen Script', 'Gaegu', var(--sans); font-size: 24px; line-height: 1.05; color: #e46a6a;
  background: rgba(255, 255, 255, .82); border: 3px solid rgba(74, 63, 85, .85); border-radius: 50%; padding: 18px 34px 20px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, .6), 0 6px 16px rgba(0, 0, 0, .2); animation: tipBob 1.6s ease-in-out infinite; }
.tip::before { content: ''; position: absolute; left: 28%; bottom: -17px; border-style: solid; border-width: 18px 16px 0 6px; border-color: rgba(74, 63, 85, .85) transparent transparent transparent; }
.tip::after { content: ''; position: absolute; left: calc(28% + 4.5px); bottom: -11px; border-style: solid; border-width: 13px 10px 0 4px; border-color: rgba(255, 255, 255, .82) transparent transparent transparent; }
@keyframes tipBob { 0%, 100% { transform: translate(-50%, 0) rotate(-2deg); } 50% { transform: translate(-50%, -5px) rotate(-2deg); } }

/* 소품 조정 도구: 아이콘 한 줄, 맨 끝 코랄 체크가 '완료' */
.tools button { display: grid; place-items: center; height: 48px; padding: 0; color: var(--ink); }
.tools button.done { background: var(--primary); color: #fff; }

/* 테마 목록 위 여백 */
#home .themes { margin-top: 8px; }
