:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #2a2f3a;
  --text: #eef0f4;
  --mute: #9aa1ae;
  --acc: #e9c46a;
  --acc2: #3fa9ff;
  --on: #e9c46a;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); height: 100%; }
body { font-family: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; font-size: 15px; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
button.primary { background: var(--acc); color: #1a1405; border-color: var(--acc); font-weight: 700; }
button.ghost { background: none; border: none; color: var(--mute); padding: 8px 6px; }
button.mini { padding: 4px 10px; font-size: 13px; }
#app { max-width: 720px; margin: 0 auto; min-height: 100%; }
.screen { display: none; padding: env(safe-area-inset-top) 0 calc(16px + env(safe-area-inset-bottom)); min-height: 100vh; }
.screen.active { display: block; }

/* 시작 */
#scr-start { padding: calc(40px + env(safe-area-inset-top)) 20px 30px; }
.hero { text-align: center; margin-bottom: 28px; }
.logo { width: 76px; height: 76px; border-radius: 20px; }
.hero h1 { margin: 14px 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.sub { color: var(--mute); margin: 0; }
.start-actions { display: grid; gap: 12px; }
.big { padding: 18px; font-size: 17px; border-radius: 16px; }
.tips { margin-top: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; }
.tips h3 { margin: 0 0 6px; font-size: 15px; }
.tips ul { margin: 0; padding-left: 18px; color: var(--mute); line-height: 1.7; }
.disclaimer { color: var(--mute); font-size: 12px; line-height: 1.6; margin-top: 22px; }
.maker { text-align: center; color: #5c6270; font-size: 12px; }

/* 카메라 */
#scr-camera { background: #000; padding: 0; }
.cam-wrap { position: relative; width: 100%; height: calc(100vh - 110px); overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.guide-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.cam-hint { position: absolute; left: 0; right: 0; bottom: 14px; line-height: 1.4; text-align: center; font-size: 13px; color: #fff; text-shadow: 0 1px 3px #000; }
.cam-bar { height: 110px; display: flex; align-items: center; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); }
.shutter { width: 72px; height: 72px; border-radius: 50%; background: #fff; border: 5px solid #555; padding: 0; }

/* 공통 막대 */
.bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.bar h2 { margin: 0; font-size: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 12px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 7px 12px; border-radius: 999px; font-size: 13.5px; }
.chips button.on { background: var(--on); color: #1a1405; border-color: var(--on); font-weight: 700; }

.stage { position: relative; margin: 0 12px; border-radius: 14px; overflow: hidden; background: #000; touch-action: none; }
.stage canvas { display: block; width: 100%; }
.loupe { position: absolute; width: 120px !important; height: 120px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.6); display: none; pointer-events: none; }
.toast { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: rgba(0,0,0,.7); padding: 6px 12px; border-radius: 999px; font-size: 13px; display: none; white-space: nowrap; }
.legend { display: grid; gap: 4px; padding: 10px 16px; font-size: 13px; color: var(--mute); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 2px solid #fff; }
.legend b { color: var(--text); margin-right: 4px; }
.actions { display: flex; gap: 10px; padding: 8px 12px; }
.actions button { flex: 1; padding: 14px; }

/* 디자인 */
.split-handle { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; display: none; transform: translateX(-1px); }
.split-handle span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: #111; font-size: 11px; padding: 6px 7px; border-radius: 999px; white-space: nowrap; }
.corner { position: absolute; top: 8px; font-size: 12px; background: rgba(0,0,0,.55); padding: 3px 9px; border-radius: 999px; display: none; }
.corner.l { left: 8px; } .corner.r { right: 8px; }
.split .split-handle, .split .corner { display: block; }
.summary { padding: 8px 16px 0; font-size: 13px; color: var(--mute); line-height: 1.5; }
.summary b { color: var(--text); }
.quick { display: flex; gap: 8px; padding: 8px 12px; }
.quick button { flex: 1; font-size: 13px; padding: 8px; }
.toggle.on { border-color: var(--acc); color: var(--acc); }
.tabs { display: flex; margin: 4px 12px 0; border-bottom: 1px solid var(--line); position: sticky; top: 46px; background: var(--bg); z-index: 4; }
.tabs button { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--mute); padding: 12px 4px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--acc); font-weight: 700; }
.panel { display: none; padding: 10px 12px 30px; }
.panel.on { display: block; }
.panel h4 { margin: 6px 4px; font-size: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.tile { background: var(--card); border: 2px solid var(--line); border-radius: 12px; overflow: hidden; padding: 0; text-align: left; position: relative; }
.tile.on { border-color: var(--acc); }
.tile canvas { display: block; width: 100%; background: #000; }
.tile .cap { padding: 6px 8px 7px; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.tile .cap small { font-weight: 400; color: var(--mute); font-size: 11px; }
.tile .desc { padding: 0 8px 8px; font-size: 11.5px; color: var(--mute); line-height: 1.4; }
.tile .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,.3); flex: none; }
.badge { position: absolute; top: 6px; left: 6px; background: #ff4d6d; color: #fff; font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: none; background: none; border-radius: 9px; padding: 10px; }
.seg button.on { background: var(--acc); color: #1a1405; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.row label { flex: none; font-size: 14px; color: var(--mute); }
.row input[type=range] { flex: 1; accent-color: var(--acc); }
.row .val { width: 62px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.row.checks { gap: 18px; flex-wrap: wrap; }
.row.checks label { color: var(--text); }
.stats { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; line-height: 1.75; }
.stats .muted, .note { color: var(--mute); font-size: 12px; line-height: 1.6; }

/* 비교 */
.sheet-wrap { padding: 4px 12px; }
#sheet-img { width: 100%; border-radius: 12px; display: block; }

.auto-note { display: none; align-items: center; justify-content: space-between; gap: 8px; margin: 0 12px 8px; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.auto-note.ok { background: rgba(80,200,120,.12); color: #8be0a8; }
.auto-note.warn { background: rgba(255,180,60,.13); color: #ffc874; }

/* 스타일 비교(참고 사진처럼 이름을 사진 아래쪽에) */
#grid-shape { gap: 6px; }
.tile.style .pic { position: relative; }
.tile.style .over { display: block; padding: 5px 6px 1px; text-align: center; color: #fff; font-weight: 700; font-size: 13.5px; line-height: 1.2; background: #000; }
.tile.style .over small { font-weight: 500; font-size: 11.5px; color: #c9ced8; margin-left: 5px; }
.tile.style .desc { padding: 6px 8px 8px; }

/* 보내기 */
.send-box { margin: 4px 12px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.send-box h4 { margin: 0 0 8px; font-size: 15px; }
.send-box label { display: block; font-size: 12.5px; color: var(--mute); margin-bottom: 8px; }
.send-box input, .send-box textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 15px; color: var(--text); background: #0f1115; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.send-box details { margin: 2px 0 10px; }
.send-box summary { font-size: 13.5px; color: var(--acc); cursor: pointer; padding: 4px 0 8px; }
.send-box summary span { color: var(--mute); font-size: 12px; margin-left: 4px; }
button.wide { width: 100%; padding: 14px; }

/* 앨범 사진 맞추기 */
.frame-stage { aspect-ratio: 4 / 3; }
.frame-stage canvas { width: 100%; height: 100%; touch-action: none; }
.frame-hint { text-align: center; color: var(--mute); font-size: 13.5px; line-height: 1.6; margin: 12px 16px 4px; }
.frame-hint b { color: var(--text); }
.zoom-row { padding: 4px 18px; }
button.mini.primary { background: var(--acc); color: #1a1405; border-color: var(--acc); }
.auto-note span { flex: none; display: flex; gap: 6px; }

/* 분석 중 */
.busy { position: fixed; inset: 0; background: rgba(8,9,12,.72); display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
.busy.on { display: flex; }
.busy-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; text-align: center; display: grid; gap: 8px; max-width: 320px; }
.busy-card small { color: var(--mute); line-height: 1.5; }
.spinner { width: 34px; height: 34px; margin: 0 auto 4px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--acc); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* 인식 실패 */
.fail-box { margin: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.fail-lead { margin: 0 0 10px; line-height: 1.6; }
#fail-list { margin: 0 0 12px; padding-left: 0; list-style: none; display: grid; gap: 8px; }
#fail-list li { padding: 9px 12px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
#fail-list li.fail { background: rgba(255,90,90,.13); color: #ff9c9c; }
#fail-list li.warn { background: rgba(255,180,60,.13); color: #ffc874; }
.fail-tips { font-size: 13px; color: var(--mute); line-height: 1.6; display: grid; gap: 2px; }
.fail-tips b { color: var(--text); }
.actions.col { flex-direction: column; }
/* 카메라 실시간 안내 */
.cam-live { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; font-size: 13px; background: rgba(0,0,0,.6); color: #fff; display: none; white-space: nowrap; }
.cam-live.ok { display: block; color: #8be0a8; }
.cam-live.warn { display: block; color: #ffc874; }
.auto-note { flex-wrap: wrap; }
.auto-note .warns { flex-basis: 100%; font-size: 12.5px; opacity: .95; }
