/* pidu(Dr.Won) 색을 따른다. 디자인은 나중에 이 파일만 고치면 바뀐다. */

:root {
  --navy: #243447;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-alt: #EDF0F4;
  --line: #E3E7EC;
  --text: #1A2230;
  --muted: #6B7684;
  --a: #2563EB;
  --b: #F97316;
  --guide: #FACC15;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(36, 52, 71, .06), 0 1px 8px rgba(36, 52, 71, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Pretendard", "Malgun Gothic", -apple-system, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body.no-scroll { overflow: hidden; }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 6px; }
.sub, .hint, .muted { color: var(--muted); }
.sub { margin: 0 0 14px; }
.hint { font-size: 13px; margin: 6px 0 0; }
.center { text-align: center; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: 17px; }
.brand small { font-weight: 400; opacity: .7; margin-left: 6px; }
.who { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.btn-link { background: none; border: 0; color: #fff; text-decoration: underline; font: inherit; cursor: pointer; }

.wrap { max-width: 900px; margin: 0 auto; padding: 14px; }
.wrap.narrow { max-width: 440px; }
.wrap.wide { max-width: 1400px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-alt); color: var(--text);
  border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.line { background: var(--surface); }
.btn.sm { padding: 5px 10px; font-size: 14px; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

label { display: block; font-weight: 600; margin: 10px 0; }
label small { font-weight: 400; color: var(--muted); margin-left: 6px; }
label input:not([type=checkbox]):not([type=range]) {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
label.inline { display: flex; align-items: center; gap: 8px; }
label.inline input { display: inline-block; width: 120px; margin: 0; }
label.inline.full input { flex: 1; width: auto; }
label.check { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 500; }
select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

.msg { color: #9B2C2C; min-height: 1.2em; margin: 6px 0; }
.notice { background: var(--surface-alt); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.auth-actions { margin-top: 10px; }

.tabs { display: inline-flex; background: var(--surface-alt); border-radius: 8px; padding: 3px; gap: 2px; }
.tabs button {
  border: 0; background: none; padding: 6px 12px; border-radius: 6px; font: inherit; cursor: pointer; color: var(--muted);
}
.tabs button.on { background: #fff; color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
#authTabs { display: flex; margin-bottom: 6px; }
#authTabs button { flex: 1; }

.guide summary { font-weight: 700; cursor: pointer; }
.guide ol { margin: 8px 0 0; padding-left: 20px; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .slots { grid-template-columns: 1fr; } }
.slot { margin: 0; }
.slot-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.slot-head .name { margin-left: auto; width: 120px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.chip { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 14px; }
.chip.a { background: var(--a); }
.chip.b { background: var(--b); }
.slot-empty { display: flex; gap: 8px; flex-wrap: wrap; padding: 24px 0; justify-content: center; }
.slot-ready canvas { width: 100%; border-radius: 6px; background: #000; display: block; }
.slot-info { margin: 8px 0; font-weight: 600; }
.row { display: flex; gap: 6px; flex-wrap: wrap; }

.actions { display: flex; gap: 10px; justify-content: center; margin: 14px 0 4px; flex-wrap: wrap; }

.stage { position: relative; width: 100%; background: #000; border-radius: 8px; overflow: hidden; touch-action: none; }
.stage video { width: 100%; height: 100%; display: block; }
.mat-line {
  position: absolute; top: 0; bottom: 0; width: 44px; margin-left: -22px; cursor: ew-resize; touch-action: none;
}
.mat-line::before {
  content: ""; position: absolute; left: 20px; top: 0; bottom: 0; width: 4px;
  background: repeating-linear-gradient(var(--guide) 0 12px, transparent 12px 20px);
}
.mat-line span {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--guide); color: #000; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
}

/* 비교 */
.cmp-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.legend { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; font-weight: 600; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; }
.legend i.a { background: var(--a); }
.legend i.b { background: var(--b); margin-left: 8px; }
#cmpCanvas { width: 100%; max-height: 72vh; object-fit: contain; background: #000; border-radius: 8px; display: block; }

.timeline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 12px; }
.seek-wrap { position: relative; padding-bottom: 10px; }
#seek { width: 100%; margin: 0; }
#ticks { position: absolute; left: 8px; right: 8px; bottom: 0; height: 8px; pointer-events: none; }
#ticks i { position: absolute; width: 3px; height: 8px; margin-left: -1px; border-radius: 1px; }
#ticks i.a { background: var(--a); }
#ticks i.b { background: var(--b); top: 0; opacity: .85; }
.controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th.a { color: var(--a); }
th.b { color: var(--b); }
tr.grp td { background: var(--surface-alt); font-weight: 700; text-align: left; }

/* 촬영 화면: 전체 화면 */
#camera { position: fixed; inset: 0; background: #000; z-index: 50; }
#camVideo, #camOverlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-msg {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 15px; white-space: nowrap;
}
.cam-msg.ok { background: rgba(34, 197, 94, .9); color: #fff; }
.cam-msg.warn { background: rgba(0, 0, 0, .7); color: var(--guide); }
.cam-msg.rec { background: rgba(220, 38, 38, .9); color: #fff; }
.cam-close {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px;
  background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 18px; padding: 6px 14px; font: inherit;
}
.cam-rec {
  position: absolute; right: max(18px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%);
  width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff; background: #DC2626; cursor: pointer;
}
.cam-rec:disabled { background: #666; opacity: .7; }
.cam-rec.recording { border-radius: 18px; background: #DC2626; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: grid; place-items: center; z-index: 60; }
.overlay .box { background: #fff; border-radius: 12px; padding: 20px 24px; width: min(360px, 90vw); text-align: center; }
.overlay progress { width: 100%; }

/* 캔버스에 그릴 원본 영상을 두는 자리. 안드로이드 크롬은 화면 밖이나 1px 짜리 영상은
   장면을 새로 그리지 않아(배터리 절약), 비교 화면에 첫 장면만 멈춰 보였다(2026-09-30).
   그래서 화면 안에 제 크기로 두고 거의 투명하게만 한다. */
#videoPool {
  position: fixed; left: 0; top: 0; z-index: -1;
  opacity: .01; pointer-events: none;
}
#videoPool video { width: 160px; height: 90px; display: block; }
