/* AI 배경 합성 체험 — 휴대폰 세로(4:6)·노트북 가로(6:4) 모두 */
body { overflow-x: hidden; }
.try-home { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 14px; font-weight: 700; color: var(--soft); }
.try-home svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.try-home:hover { color: var(--ink); }

.app { min-height: 100svh; padding: calc(var(--nav-h) + 16px) var(--gutter) 24px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: center; }
.stage-wrap { display: grid; place-items: center; min-height: 0; }
.stage { --ar: 1.5; position: relative; width: min(100%, calc((100svh - var(--nav-h) - 48px) * var(--ar))); aspect-ratio: var(--ar); border-radius: 26px; overflow: hidden;
  background: #05051a url("/try/bg/yonggungsa-stars.jpg?v=5d2ab787") center / cover; box-shadow: 0 30px 80px rgba(0,0,40,.5); isolation: isolate; }
.stage video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; }
body:not([data-state="live"]) #view { visibility: hidden; }
.hud b { position: absolute; width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.85); z-index: 3; pointer-events: none; transition: opacity .3s; }
.hud b:nth-child(1) { left: 16px; top: 16px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; } .hud b:nth-child(2) { right: 16px; top: 16px; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.hud b:nth-child(3) { left: 16px; bottom: 16px; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; } .hud b:nth-child(4) { right: 16px; bottom: 16px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
body:not([data-state="live"]) .hud b { opacity: 0; }
.count { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; font-size: clamp(90px, 18vw, 200px); font-weight: 900; text-shadow: 0 6px 30px rgba(0,0,0,.5); pointer-events: none; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; z-index: 5; pointer-events: none; }
.flash.on { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }

/* 겹쳐 뜨는 안내 화면 */
.ov { position: absolute; inset: 0; z-index: 6; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 28px;
  background: linear-gradient(180deg, rgba(0,0,10,.25), rgba(0,0,10,.82)); }
body[data-state="intro"] .ov-intro, body[data-state="loading"] .ov-loading, body[data-state="result"] .ov-result,
body[data-state="nocam"] .ov-nocam, body[data-state="denied"] .ov-denied, body[data-state="error"] .ov-error { display: flex; }
.ov h1 { font-weight: 800; font-size: clamp(30px, 4.4vw, 52px); letter-spacing: -0.035em; line-height: 1.22; }
.ov h2 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; }
.ov p { max-width: 26em; color: var(--soft); font-size: 15px; }
.ov .kicker { margin: 0; }
.ov .btn { margin-top: 6px; }
.privacy { display: inline-flex; align-items: center; gap: 8px; font-size: 13px !important; color: var(--soft); }
.privacy svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--scan); stroke-width: 2; }
.privacy.small { font-size: 12px !important; color: var(--dim); margin-top: 18px; }
.ov-t { font-size: 18px !important; font-weight: 800; color: var(--ink) !important; }
.ov-n { font-size: 13px !important; }
.bar { width: min(70%, 260px); height: 6px; border-radius: 6px; background: rgba(255,255,255,.15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 4%; border-radius: 6px; background: linear-gradient(90deg, var(--scan), var(--accent2)); transition: width .2s; box-shadow: 0 0 12px var(--scan); }
.ov-result { padding: 0; background: #000; }
.ov-result img { width: 100%; height: 100%; object-fit: contain; }
.ios-hint { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0 auto; padding: 10px 14px; border-radius: 14px; background: rgba(0,0,0,.7); font-size: 13px !important; }
.qr { width: 168px; height: 168px; padding: 10px; border-radius: 16px; background: #fff; }
.qr svg { width: 100%; height: 100%; }
.qr-url { font-weight: 800; color: var(--ink) !important; letter-spacing: .02em; }

/* 오른쪽(휴대폰은 아래) 조작판 */
.panel { align-self: center; }
.live-ctl, .result-ctl { display: none; }
body[data-state="live"] .live-ctl { display: block; }
body[data-state="result"] .result-ctl { display: block; }
.panel-k { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-bottom: 12px; }
.bgs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bg-opt { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 2px solid transparent; background: #111 center / cover; transition: border-color .15s, transform .15s; }
.bg-opt span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 11px; font-weight: 700; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.bg-opt:hover { transform: translateY(-2px); }
.bg-opt[aria-checked="true"] { border-color: var(--scan); box-shadow: 0 0 0 3px rgba(127,230,255,.25); }
.shoot-row { margin-top: 22px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.timer { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--soft); cursor: pointer; }
.timer input { width: 18px; height: 18px; accent-color: var(--scan); }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; transition: transform .12s; }
.shutter i { width: 56px; height: 56px; border-radius: 50%; background: #fff; transition: background .15s; }
.shutter:hover i { background: var(--scan); } .shutter:active { transform: scale(.94); }
.shoot-k { justify-self: end; font-size: 11px; font-weight: 700; color: var(--dim); padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; }
.result-ctl .cta-row { flex-direction: column; }
.result-ctl .btn { width: 100%; }
.real-link { display: inline-block; margin-top: 16px; font-size: 14px; font-weight: 700; color: var(--scan); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; padding: 12px 18px; border-radius: 999px; background: #fff; color: #000; font-weight: 800; font-size: 14px; }

/* 휴대폰·세로 화면 */
@media (max-width: 860px), (orientation: portrait) {
  .app { grid-template-columns: 1fr; align-items: start; gap: 16px; padding-top: calc(var(--nav-h) + 10px); }
  .stage { width: min(100%, calc((100svh - var(--nav-h) - 230px) * var(--ar))); border-radius: 22px; }
  .bgs { display: flex; overflow-x: auto; gap: 8px; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter) 4px; scroll-snap-type: x mandatory; }
  .bgs::-webkit-scrollbar { display: none; }
  .bg-opt { flex: 0 0 104px; scroll-snap-align: start; }
  .panel-k { display: none; }
  .shoot-row { margin-top: 14px; }
  .shoot-k { visibility: hidden; }
  .result-ctl .cta-row { flex-direction: row; } .result-ctl .btn { width: auto; flex: 1; padding: 0 14px; }
  .privacy.small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .flash.on { animation: none; } }

/* ── 조작판 정리(2026-11-24): 제목 · 개인정보 안내 · 배경 · 테스트 안내 · 타이머/Space ── */
body[data-state="busy"] .ov-busy { display: flex; }
.err-code { margin-top: 4px; font-size: 11px; color: var(--dim); font-family: ui-monospace, Consolas, monospace; }
.panel { display: flex; flex-direction: column; gap: 14px; }
.panel-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.live-only { display: none; }
body[data-state="live"] .live-only { display: block; }
.privacy-box { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--ink);
  background: linear-gradient(120deg, rgba(127,230,255,.16), rgba(185,166,255,.12)); border: 1px solid rgba(127,230,255,.4); box-shadow: 0 0 30px rgba(127,230,255,.12); }
.privacy-box svg { width: 26px; height: 26px; flex: none; fill: none; stroke: var(--scan); stroke-width: 2; filter: drop-shadow(0 0 6px rgba(127,230,255,.7)); }
.live-ctl { display: none; flex-direction: column; gap: 14px; }
body[data-state="live"] .live-ctl { display: flex; }
.beta-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 13px; line-height: 1.55; color: #ffe6b3;
  background: rgba(255, 196, 90, .1); border: 1px solid rgba(255, 196, 90, .35); }
.beta-note svg { width: 20px; height: 20px; flex: none; margin-top: 1px; fill: none; stroke: #ffc65a; stroke-width: 2; stroke-linecap: round; }
.shoot-row { margin-top: 6px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.timer { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255,255,255,.05); font-size: 14px; color: var(--ink); cursor: pointer; transition: border-color .2s, background .2s; justify-self: start; }
.timer:hover { border-color: rgba(127,230,255,.5); }
.timer input { position: absolute; opacity: 0; pointer-events: none; }
.timer .sw { position: relative; width: 36px; height: 20px; flex: none; border-radius: 999px; background: rgba(255,255,255,.2); transition: background .2s; }
.timer .sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.timer input:checked + .sw { background: var(--scan); }
.timer input:checked + .sw::after { transform: translateX(16px); }
.timer:has(input:checked) { border-color: var(--scan); background: rgba(127,230,255,.1); }
.timer:has(input:focus-visible) { outline: 2px solid var(--scan); outline-offset: 3px; }
.space-hint { justify-self: end; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--soft); }
.space-hint kbd { padding: 6px 12px; border-radius: 8px; font: 800 13px var(--sans); color: #031; background: var(--scan); box-shadow: 0 3px 0 #3aa9c6, 0 0 18px rgba(127,230,255,.45); }
.shutter { box-shadow: 0 0 0 6px rgba(127,230,255,.15), 0 0 30px rgba(127,230,255,.3); }
@media (max-width: 860px), (orientation: portrait) {
  .panel { gap: 10px; }
  .panel-title { font-size: 18px; }
  .privacy-box { padding: 10px 12px; font-size: 13px; }
  .space-hint { display: none; }
  .shoot-row { grid-template-columns: 1fr auto 1fr; }
  .beta-note { font-size: 12px; padding: 10px 12px; }
}
@media (pointer: coarse) { .space-hint { display: none; } }
/* 촬영 줄: 셔터는 가운데 한 줄, 아래에 타이머 · Space 안내 */
@media (min-width: 861px) and (orientation: landscape) { .app { grid-template-columns: minmax(0, 1fr) 340px; } }
.shoot-row { grid-template-columns: 1fr 1fr; grid-template-areas: "shut shut" "timer space"; row-gap: 14px; }
.shutter { grid-area: shut; justify-self: center; }
.timer { grid-area: timer; white-space: nowrap; }
.space-hint { grid-area: space; white-space: nowrap; }
@media (max-width: 860px), (orientation: portrait) {
  .shoot-row { grid-template-columns: 1fr auto 1fr; grid-template-areas: "timer shut ."; }
}
/* 휴대폰: 배경 목록(가로 스크롤)이 칸을 넓히지 않게 */
.app > * { min-width: 0; }
@media (max-width: 860px), (orientation: portrait) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .stage-wrap { width: 100%; }
}

/* 배경 영상을 받는 동안 안내 */
.bgwait { position: absolute; left: 50%; top: 50%; z-index: 4; display: none; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 40px); padding: 14px 20px; border-radius: 18px; line-height: 1.45; transform: translate(-50%, -50%);
  background: rgba(3,6,23,.72); border: 1px solid rgba(127,230,255,.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 14px; font-weight: 700; color: #fff; text-align: left; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
body[data-state="live"] .stage.bg-wait .bgwait { display: flex; animation: bgw .3s ease-out; }
.bgwait .spin { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(127,230,255,.25); border-top-color: var(--scan); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bgw { from { opacity: 0; transform: translate(-50%, -40%); } }
.bg-opt.loading::after { content: ""; position: absolute; right: 8px; top: 8px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
.mob-note { margin-top: 6px; color: #ffd27a !important; }
@media (prefers-reduced-motion: reduce) { .bgwait .spin, .bg-opt.loading::after { animation-duration: 2s; } }

/* 휴대폰: 셔터·타이머를 합성 화면 안 아래쪽에(try.js가 .shoot-row를 화면 안으로 옮김) */
.shoot-row.in-stage { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; margin: 0; padding: 40px 14px 14px; display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "timer shut ."; align-items: center; gap: 10px;
  background: linear-gradient(to top, rgba(3,6,23,.6), rgba(3,6,23,0)); pointer-events: none; }
.shoot-row.in-stage > * { pointer-events: auto; }
body:not([data-state="live"]) .shoot-row.in-stage { display: none; }
.shoot-row.in-stage .shutter { width: 66px; height: 66px; border-width: 3px; }
.shoot-row.in-stage .shutter i { width: 50px; height: 50px; }
.shoot-row.in-stage .timer { justify-self: start; padding: 8px 12px; gap: 8px; font-size: 13px; background: rgba(3,6,23,.55); border-color: rgba(255,255,255,.3); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.shoot-row.in-stage .timer .sw { width: 30px; height: 17px; }
.shoot-row.in-stage .timer .sw::after { width: 11px; height: 11px; }
.shoot-row.in-stage .timer input:checked + .sw::after { transform: translateX(13px); }
.shoot-row.in-stage .space-hint { display: none; }
@media (max-width: 860px), (orientation: portrait) {
  /* 조작 버튼이 화면 안으로 들어갔으니 합성 화면을 조금 더 크게 */
  .stage { width: min(100%, calc((100svh - var(--nav-h) - 190px) * var(--ar))); }
}

/* AI 엔진 로딩: 체험 화면이 열린 뒤 첫 합성 화면이 나올 때까지(스캔 빛 + 궤도 점 + 안내) */
.aiwait { position: absolute; inset: 0; z-index: 6; display: none; place-items: center; overflow: hidden; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(3,6,23,.35), rgba(3,6,23,.7)); }
body[data-state="live"] .stage.ai-wait .aiwait { display: grid; animation: bgw .3s ease-out; }
body[data-state="live"] .stage.ai-wait .bgwait { display: none; }
.ai-scan { position: absolute; left: 0; right: 0; top: 0; height: 30%; background: linear-gradient(to bottom, transparent, rgba(127,230,255,.18) 80%, rgba(127,230,255,.65)); border-bottom: 2px solid var(--scan); box-shadow: 0 6px 24px rgba(127,230,255,.45); animation: aiscan 2.2s ease-in-out infinite; }
@keyframes aiscan { 0% { transform: translateY(-100%); } 100% { transform: translateY(440%); } }
.ai-box { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px 26px; max-width: calc(100% - 40px); border-radius: 20px; text-align: center;
  background: rgba(3,6,23,.72); border: 1px solid rgba(127,230,255,.4); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 12px 44px rgba(0,0,0,.5), 0 0 30px rgba(127,230,255,.15);
  font-size: 15px; font-weight: 800; line-height: 1.5; color: #fff; }
.ai-orb { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(127,230,255,.25); animation: aispin 1.4s linear infinite; }
.ai-orb i { position: absolute; left: 50%; top: -5px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--scan); box-shadow: 0 0 12px var(--scan); transform-origin: 4.5px 28px; }
.ai-orb i:nth-child(2) { transform: rotate(120deg); background: #a58bff; box-shadow: 0 0 12px #a58bff; }
.ai-orb i:nth-child(3) { transform: rotate(240deg); background: #fff; box-shadow: 0 0 12px #fff; }
@keyframes aispin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ai-scan { animation: none; opacity: .4; } .ai-orb { animation-duration: 3s; } }
