:root {
  --ink: #202020; --sub: #5d6157; --panel: #f1f3ec; --surface: #fff; --line: #dbdfd2;
  --accent: #3f6b00; --on-accent: #fff; --op: #e2f3c0; --op-ink: #345900; --fn: #e4e7de;
  --tag: #abe52e; --stage: #202020; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #f2f4ec; --sub: #a9ada1; --panel: #1b1b1b; --surface: #292a27; --line: #3a3c36; --accent: #abe52e; --on-accent: #202020; --op: #35451a; --op-ink: #c9f06f; --fn: #33352f; --stage: #121212; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden; background: var(--panel); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans KR", "Malgun Gothic", "Noto Sans JP", "Noto Sans SC", "Noto Sans Thai", sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, .tok:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 머리줄 */
.bar { display: flex; align-items: center; gap: 4px; padding: max(6px, env(safe-area-inset-top)) 8px 6px 16px; background: var(--stage); color: #fff; }
.rate { flex: 1; min-width: 0; text-align: left; line-height: 1.25; min-height: 44px; }
.rate span { display: block; font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate small { font-size: 12px; color: #b4b8ac; white-space: nowrap; }
.rate small.warn { color: var(--tag); }
.ibtn { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 44px; height: 44px; padding: 0 8px; border-radius: 10px; font-size: 13px; font-weight: 600; }

/* 사진 영역 */
.stage { position: relative; flex: 1; min-height: 160px; overflow: hidden; background: var(--stage); color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.canvas img { display: block; width: 100%; height: 100%; -webkit-user-drag: none; -webkit-touch-callout: none; }
#marks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; stroke: none; }
.tok { cursor: pointer; }
.tok .box { vector-effect: non-scaling-stroke; stroke: rgba(255, 255, 255, .55); stroke-width: 1; fill: rgba(16, 24, 26, .05); }
.tok.price .box { stroke: #6fb000; stroke-width: 2; fill: rgba(171, 229, 46, .24); }
.tok .tag { fill: var(--tag); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45)); }
.tok text { fill: #202020; font-weight: 700; font-family: inherit; text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; }
.tok.doubt .box { stroke-dasharray: 5 4; stroke: #ff8a3d; }
.name { cursor: pointer; }
.name rect { fill: rgba(255, 255, 255, .94); stroke: #3f6b00; stroke-width: 1; vector-effect: non-scaling-stroke; }
.name text { fill: #2f5000; font-weight: 650; font-family: inherit; dominant-baseline: central; }
.name.near text { font-weight: 500; fill: #4a5a56; }
.intro { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: safe center; align-items: center; text-align: center; gap: 8px; padding: 8px 24px; overflow: auto; touch-action: auto; }
.intro h1 { margin: 0; font-size: clamp(18px, 5vw, 26px); line-height: 1.25; text-wrap: balance; max-width: 18em; }
.logo { width: min(260px, 68vw); height: auto; margin-bottom: 6px; }
.intro p { margin: 0; color: #cfd2c8; text-wrap: balance; max-width: 26em; font-size: 15px; }
.intro .fine { font-size: 12px; color: #a0a497; }
.cta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 650; }
.stage .primary { background: var(--tag); color: #202020; }
.ghost { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1.5px solid currentColor; font-weight: 600; }
.link { min-height: 32px; padding: 0 10px; text-decoration: underline; text-underline-offset: 4px; color: #dfe8e5; font-size: 14px; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 22px; background: rgba(10, 16, 17, .72); color: #fff; font-size: 14px; font-weight: 600; }
.aim { position: absolute; left: 50%; top: 36%; translate: -50% -50%; width: min(84%, 460px); aspect-ratio: 2.4; border-radius: 14px; border: 3px solid var(--tag); box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5); pointer-events: none; }
.aim p { position: absolute; left: 0; right: 0; top: calc(100% + 10px); margin: 0; text-align: center; font-size: 14px; font-weight: 600; text-shadow: 0 1px 3px #000; }
.modes { position: absolute; left: 50%; bottom: 98px; translate: -50% 0; display: flex; padding: 3px; border-radius: 22px; background: rgba(10, 10, 10, .72); z-index: 1; }
.modes button { min-height: 40px; padding: 0 16px; border-radius: 20px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.modes button[aria-pressed=true] { background: var(--tag); color: #202020; }
.cam-on .keys { display: none; }
.dcc { background: var(--op); color: var(--op-ink); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 4px; }
.shutter-row { position: absolute; left: 0; right: 0; bottom: 14px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; padding: 0 12px; }
.shutter { width: 68px; height: 68px; border-radius: 50%; background: #fff; border: 5px solid rgba(255, 255, 255, .35); background-clip: padding-box; box-shadow: 0 0 0 3px #fff; }
.trans { position: absolute; left: 10px; bottom: 10px; }
.trans[aria-pressed=true] { background: #abe52e; color: #202020; }
.cam-on .trans { display: none; }
.retake { position: absolute; right: 10px; bottom: 10px; }
.status { position: absolute; left: 10px; right: 10px; top: 10px; margin: auto; width: fit-content; max-width: calc(100% - 20px); padding: 8px 14px; border-radius: 12px; background: rgba(10, 16, 17, .8); font-size: 14px; overflow: hidden; pointer-events: none; text-align: center; }
.status i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--tag); transition: width .2s; }
.notice { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 8px 8px 8px 14px; border-radius: 12px; background: #fff; color: #202020; font-size: 14px; }
.notice button { min-height: 40px; padding: 0 14px; border-radius: 9px; background: #202020; color: #fff; font-weight: 600; flex: none; }

/* 변환 · 계산 */
.panel { flex: none; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.conv { position: relative; background: var(--surface); border-radius: 14px; }
.row { display: flex; align-items: center; min-height: 58px; padding: 4px 14px 4px 6px; gap: 10px; }
.row.from { border-bottom: 1px solid var(--line); }
.cur { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px; border-radius: 9px; font-size: 17px; flex: none; }
.cur svg { width: 16px; height: 16px; color: var(--sub); }
.amt { flex: 1; min-width: 0; text-align: right; }
.expr { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow-x: auto; scrollbar-width: none; line-height: 1.25; }
.expr::-webkit-scrollbar { display: none; }
.sum { font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; line-height: 1.2; }
.sum:empty { display: none; }
.result { flex: 1; min-width: 0; text-align: right; font-size: 30px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; overflow: hidden; line-height: 1.2; }
.swap { position: absolute; left: 92px; top: 50%; translate: 0 -50%; width: 40px; height: 40px; border-radius: 50%; background: var(--op); color: var(--op-ink); display: grid; place-items: center; border: 3px solid var(--surface); }
.extra { display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; font-size: 14px; padding: 0 4px; }
.split { display: flex; align-items: center; gap: 6px; color: var(--sub); }
.split b { color: var(--ink); min-width: 1.2em; text-align: center; font-variant-numeric: tabular-nums; }
.split em { font-style: normal; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.split button { width: 36px; height: 36px; border-radius: 50%; background: var(--fn); font-size: 18px; line-height: 1; }
.fees { text-align: right; min-height: 36px; color: var(--sub); font-variant-numeric: tabular-nums; }
.fees b { color: var(--ink); }
.fees.empty { text-decoration: underline; text-underline-offset: 3px; }
.tools { display: none; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.tools button { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 10px; background: var(--fn); font-weight: 600; }
#selInfo { color: var(--sub); flex: 1; text-align: center; }
.has-photo .tools { display: flex; }
.has-photo.kb-closed .keys { display: none; }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.keys button { height: clamp(36px, 5.5dvh, 54px); border-radius: 10px; background: var(--surface); font-size: 20px; font-weight: 550; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.keys button:active { filter: brightness(.92); }
.keys .fn { background: var(--fn); }
.keys .op { background: var(--op); color: var(--op-ink); font-size: 23px; }
.keys .eq { background: var(--tag); color: #202020; font-size: 23px; }

/* 시트 */
dialog { border: 0; padding: 0 16px max(16px, env(safe-area-inset-bottom)); margin: auto auto 0; width: 100%; max-width: 520px; max-height: 84dvh; border-radius: 18px 18px 0 0; background: var(--panel); color: var(--ink); overflow: auto; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dh { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; background: var(--panel); }
.dh h2 { margin: 0; font-size: 18px; }
.x { min-height: 40px; padding: 0 12px; border-radius: 10px; background: var(--fn); font-size: 14px; font-weight: 600; flex: none; }
#curQ { width: 100%; height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--surface); }
.list h3 { font-size: 13px; color: var(--sub); margin: 16px 4px 6px; font-weight: 600; }
.list button { display: flex; width: 100%; align-items: center; gap: 14px; min-height: 48px; padding: 4px 12px; border-radius: 10px; text-align: left; }
.list button b { width: 3em; flex: none; }
.list button span { color: var(--sub); }
.list button[aria-current=true] { background: var(--op); color: var(--op-ink); }
.list button[aria-current=true] span { color: inherit; }
dialog p { color: var(--sub); margin: 0 0 12px; }
dialog p b { color: var(--ink); }
.fld { display: flex; align-items: center; justify-content: space-between; min-height: 56px; border-top: 1px solid var(--line); }
.fld input { width: 84px; height: 44px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0 10px; text-align: right; }
.src { border-top: 1px solid var(--line); margin: 0; padding: 14px 0; font-size: 14px; }
.src dt { font-weight: 600; } .src dd { margin: 4px 0 0; color: var(--sub); }
.wide { width: 100%; }
.warnline { background: #fff1c2; color: #5b4300; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.warnline:empty, #mDesc:empty { display: none; }
.staff { background: var(--surface); border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.staff small, .staff span { color: var(--sub); font-size: 13px; }
.staff b { font-size: 32px; line-height: 1.25; }
.mprices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.mprices div { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.mprices b { font-size: 20px; color: var(--accent); }
.mprices .primary { min-height: 44px; }
.editrow { display: flex; align-items: center; gap: 12px; }
.editrow input { flex: 1; min-width: 0; height: 56px; font-size: 24px; font-weight: 650; text-align: right; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0 14px; }
.btns { display: flex; gap: 8px; margin-top: 14px; } .btns > * { flex: 1; }

/* 태블릿·PC·가로 화면 */
@media (min-width: 820px), (orientation: landscape) and (max-height: 560px) {
  body { display: grid; grid-template: auto 1fr / 1fr min(400px, 46vw); }
  .bar { grid-column: 1 / -1; }
  .panel { overflow: auto; justify-content: flex-end; }
  .has-photo.kb-closed .keys { display: grid; }
  #kbToggle { display: none; }
  .cam-on .keys { display: grid; }
  .keys { flex: 1; grid-auto-rows: minmax(36px, 1fr); }
  .keys button { height: auto; }
  dialog { margin: auto; border-radius: 18px; }
}
@media (max-height: 640px) and (max-width: 819px) and (orientation: portrait) {
  .bar { padding-top: 2px; padding-bottom: 2px; }
  .panel { gap: 5px; padding-top: 6px; padding-bottom: 6px; }
  .row { min-height: 46px; padding-top: 0; padding-bottom: 0; }
  .keys { gap: 4px; } .keys button { height: 33px; }
  .split button, .fees { height: 32px; min-height: 32px; }
  .intro { gap: 6px; padding: 6px 14px; } .intro h1 { font-size: 18px; } .intro p:not(.fine) { font-size: 13px; line-height: 1.3; } .intro .fine { display: none; } .logo { width: 150px; margin: 0; }
  .cta { flex-wrap: nowrap; margin: 0; } .cta button { padding: 0 10px; font-size: 13.5px; line-height: 1.2; min-height: 44px; } .cta svg { display: none; }
  .link { min-height: 30px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
