* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: #e8e8e8;
  font: 14px/1.4 -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

#app { display: flex; flex-direction: column; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* 상단 LCD */
#lcd { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; overflow-x: auto; white-space: nowrap;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: #cfe7c2;
  background: linear-gradient(#0d120c, #050805); border-bottom: 1px solid #1b2618; }
.lcd-big { font-size: 20px; font-weight: 700; color: #fff; }
.lcd-dim { color: #7d8c77; }

/* 뷰파인더 */
#finder { position: relative; flex: 1; overflow: hidden; background: #000; touch-action: none; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.overlay { position: absolute; pointer-events: none; }
#grid { inset: 0; width: 100%; height: 100%; }
#mask { position: absolute; pointer-events: none; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); outline: 1px solid rgba(255,255,255,.35); }
#histo { position: absolute; right: 10px; top: 10px; width: 128px; height: 56px; background: rgba(0,0,0,.45); border-radius: 4px; pointer-events: none; }
#level { left: 50%; top: 50%; width: 46%; height: 0; transform: translate(-50%, -50%); }
#level-bar { height: 2px; background: #ff5a4f; transition: transform .08s linear; }
#level-bar.ok { background: #48e06b; }
#af { position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border: 2px solid #ffd23f; pointer-events: none; animation: af .6s ease-out; }
@keyframes af { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 120px; font-weight: 200; color: #fff; text-shadow: 0 0 20px #000; pointer-events: none; }
#blink { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
#blink.on { animation: blink .18s ease-out; }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0; } }
#busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); }
.busy-box { width: 72%; max-width: 360px; padding: 16px; background: #111; border: 1px solid #333; border-radius: 10px; text-align: center; }
.bar { height: 6px; margin: 10px 0 6px; background: #2a2a2a; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: #f2c200; transition: width .15s; }
.center-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }
.small { font-size: 12px; color: #8a8a8a; }

/* 칩 */
#chips { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; background: #070707; min-height: 46px; }
.chip { flex: none; padding: 6px 11px; border-radius: 16px; border: 1px solid #333; background: #141414; font-size: 13px; }
.chip.on { border-color: #f2c200; color: #f2c200; }
.chip.manual { background: #2b2300; }
#slider-panel { padding: 6px 14px 10px; background: #070707; }
.slider-head { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.slider-head #slider-val { flex: 1; color: #f2c200; font-family: ui-monospace, Menlo, monospace; }
#slider { width: 100%; accent-color: #f2c200; }

/* 하단 조작부 */
#controls { display: flex; align-items: center; justify-content: space-between; padding: 14px 26px 18px; background: #000; }
#btn-shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #ddd; background: transparent; padding: 5px; }
#btn-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #f2f2f2; transition: transform .1s; }
#btn-shutter:active span { transform: scale(.9); }
#btn-shutter:disabled { opacity: .4; }
.thumb { width: 54px; height: 54px; border-radius: 8px; border: 1px solid #444; background: #111; padding: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img:not([src]) { visibility: hidden; }
.side { display: flex; flex-direction: column; gap: 8px; }
.round { width: 42px; height: 42px; border-radius: 50%; border: 1px solid #444; background: #141414; font-size: 19px; }

.pill { padding: 9px 16px; border-radius: 20px; border: 1px solid #555; background: #1b1b1b; }
.pill.danger { border-color: #7a2a2a; color: #ff8a80; }
.mini { padding: 3px 9px; border-radius: 10px; border: 1px solid #555; background: #1b1b1b; font-size: 12px; }

/* 대화상자 */
dialog { background: #111; color: #e8e8e8; border: 1px solid #333; border-radius: 14px; width: min(94vw, 440px); max-height: 90dvh; padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 10px; font-size: 17px; }
dialog label { display: block; margin: 10px 0; font-size: 14px; }
dialog label small { color: #888; }
dialog label.row { display: flex; gap: 8px; align-items: center; }
dialog select { display: block; width: 100%; margin-top: 4px; padding: 8px; background: #1c1c1c; color: #eee; border: 1px solid #3a3a3a; border-radius: 8px; font: inherit; }
dialog menu { display: flex; justify-content: flex-end; padding: 0; margin: 14px 0 0; }
dialog.full { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.g-head h2 { margin: 0; flex: 1; }
#g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 3px; padding: 3px; overflow-y: auto; max-height: calc(100dvh - 70px); }
#g-grid button { position: relative; padding: 0; border: 0; background: #222; aspect-ratio: 1; }
#g-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
#g-grid button span { position: absolute; left: 4px; bottom: 3px; font-size: 10px; background: rgba(0,0,0,.6); padding: 1px 4px; border-radius: 3px; }
#dlg-view[open] { display: flex; flex-direction: column; }
.v-wrap { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; background: #000; touch-action: pinch-zoom; }
.v-wrap img { max-width: 100%; max-height: 100%; }
.v-wrap.zoom { display: block; }
.v-wrap.zoom img { max-width: none; max-height: none; }
#v-info { padding: 8px 14px; font: 12px/1.5 ui-monospace, Menlo, monospace; color: #bbb; white-space: pre-wrap; }
.v-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px 14px; }
.empty { padding: 20px; grid-column: 1 / -1; }
