:root {
  --bg: #f7f8f7;
  --fg: #16201e;
  --muted: #5f6b68;
  --line: #dde3e1;
  --card: #ffffff;
  --accent: #0f766e;
  --accent-fg: #ffffff;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --rec: #e11d48;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1413; --fg: #e8eeec; --muted: #9aa6a3; --line: #2a3331; --card: #171e1d;
    --accent: #2dd4bf; --accent-fg: #062b27; --warn: #fbbf24; --warn-bg: #2a2110;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1413; --fg: #e8eeec; --muted: #9aa6a3; --line: #2a3331; --card: #171e1d;
  --accent: #2dd4bf; --accent-fg: #062b27; --warn: #fbbf24; --warn-bg: #2a2110;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
h1 { font-size: 26px; margin: 8px 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 4px 0 10px; letter-spacing: -0.01em; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
[hidden] { display: none !important; }

.screen.pad { max-width: 520px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }

.tips { padding-left: 20px; margin: 16px 0 20px; line-height: 1.6; }
.tips li { margin-bottom: 6px; }

.field { display: block; margin: 16px 0; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 16px; font-weight: 600; padding: 13px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; flex: 1;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; margin-top: 8px; }
.btn:disabled { opacity: .45; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; padding: 12px; display: block; margin: 4px auto 0; cursor: pointer; }
.file-btn { width: 100%; margin: 14px 0 6px; }
.row { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- 카메라 화면 ---------- */
.screen.camera {
  position: fixed; inset: 0; background: #000; color: #fff;
  display: flex; flex-direction: column;
}
.cam-top { padding: max(12px, env(safe-area-inset-top)) 16px 10px; background: linear-gradient(#000d, #0000); z-index: 2; }
.cam-top h2 { margin: 6px 0 4px; font-size: 18px; }
.cam-top p { margin: 0; font-size: 14px; color: #dfe7e5; line-height: 1.45; }
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: #ffffff33; }
.steps span.done { background: #2dd4bf; }
.steps span.cur { background: #fff; }

/* 위: 확대 화면 */
.cam-zoom { position: relative; flex: 1.35; min-height: 0; overflow: hidden; background: #000; touch-action: none; }
#zoom-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.guide { position: absolute; inset: 10% 8%; width: 84%; height: 80%; pointer-events: none; }
.pane-label {
  position: absolute; left: 8px; bottom: 8px; font-size: 11px; color: #e5ecea;
  background: #0009; padding: 3px 8px; border-radius: 999px; pointer-events: none;
}
.zoom-ctl {
  position: absolute; right: 8px; bottom: 6px; display: flex; align-items: center; gap: 4px;
  background: #0009; border-radius: 999px; padding: 2px 4px;
}
.zoom-ctl button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #ffffff26; color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.zoom-ctl input { width: 90px; accent-color: #2dd4bf; }

/* 아래: 전체 화면 */
.cam-full {
  position: relative; flex: 1; min-height: 0; background: #0b0f0e; border-top: 2px solid #2dd4bf55;
  display: grid; place-items: center; overflow: hidden; touch-action: none;
}
.full-wrap { position: relative; overflow: hidden; border-radius: 6px; }
.full-wrap.mirror { transform: scaleX(-1); }
.full-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.crop-box {
  position: absolute; border: 2px solid #2dd4bf; border-radius: 4px;
  box-shadow: 0 0 0 9999px #0000008c; pointer-events: none;
}
.badge {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: #000a; color: #fde68a; padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.rec-timer {
  position: absolute; right: 12px; top: 12px; background: #000a; padding: 6px 10px; border-radius: 999px;
  font-size: 14px; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums;
}
.rec-timer .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.cam-bottom {
  display: flex; align-items: center; justify-content: space-around;
  padding: 16px 24px 4px; background: #000;
}
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: #ffffff1f; color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.ghost { background: transparent; }
.icon-btn.on { background: #fde68a; color: #000; }
.icon-btn:disabled { opacity: .3; }
.rec-btn {
  width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.rec-btn span { width: 58px; height: 58px; border-radius: 50%; background: var(--rec); transition: all .2s; }
.rec-btn.recording span { width: 28px; height: 28px; border-radius: 6px; }
.screen.camera .link-btn { color: #c9d3d1; margin: 0 auto; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: #000; width: 100%; }

/* ---------- 확인 ---------- */
#review-video { width: 100%; max-height: 46dvh; background: #000; border-radius: var(--radius); }
.frames { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.frames img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: #000; }

/* ---------- 요약 ---------- */
.summary { display: grid; gap: 8px; }
.sum-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.sum-row img, .sum-row .ph { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; background: #0002; display: grid; place-items: center; font-size: 12px; color: var(--muted); flex: none; }
.extra-list { display: grid; gap: 6px; }
.extra { display: flex; align-items: center; gap: 8px; font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; overflow: hidden; }
.extra .x { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; }

/* ---------- 업로드 ---------- */
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 16px; }
#prog-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-list { list-style: none; padding: 0; margin: 14px 0; font-size: 13px; display: grid; gap: 4px; }
.upload-list li { display: flex; justify-content: space-between; color: var(--muted); padding: 4px 0; border-bottom: 1px dashed var(--line); }
.upload-list li.active { color: var(--fg); font-weight: 600; }
.upload-list li.ok { color: var(--accent); }
.upload-list li.ok::before { content: "✓ "; }

.done-mark { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-size: 38px; display: grid; place-items: center; margin: 40px 0 10px; }
