/* 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; }

/* ---- pidu academy ---- */
.brand { display: flex; align-items: center; gap: 8px; color: #fff; }
.brand img { height: 26px; display: block; }
.home-title { margin: 8px 4px 14px; }
.feature-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.feature-card {
  display: flex; flex-direction: column; gap: 6px; padding: 22px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.feature-card b { font-size: 19px; color: var(--navy); }
.feature-card span { color: var(--muted); font-size: 14px; }
.feature-card:active { transform: scale(.99); }
.guide-list { padding-left: 20px; margin: 6px 0 12px; }
.field-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.field-row label.inline input { width: 190px; }

/* 체형분석 촬영: 전체 화면 */
#pcScreen { position: fixed; inset: 0; background: #000; z-index: 50; }
#pcVideo, #pcOverlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#pcScreen.mirror #pcVideo, #pcScreen.mirror #pcOverlay { transform: scaleX(-1); }
.pc-step {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px;
  background: rgba(0, 0, 0, .6); color: #fff; border-radius: 16px; padding: 5px 12px; font-weight: 700;
}
.pc-count {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: 110px; font-weight: 800; color: #fff; text-shadow: 0 2px 16px rgba(0, 0, 0, .6); pointer-events: none;
}
.pc-count.rec { color: #FCA5A5; font-size: 72px; }

/* 결과 */
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.score-big { text-align: right; }
.score-big b { font-size: 48px; color: var(--navy); line-height: 1; }
.score-big span { font-size: 18px; margin-left: 2px; }
.score-big small { display: block; color: var(--muted); }
.region-row { display: grid; grid-template-columns: 70px 1fr 36px; align-items: center; gap: 10px; margin: 6px 0; }
.region-row .bar { height: 10px; background: var(--surface-alt); border-radius: 5px; overflow: hidden; }
.region-row .bar i { display: block; height: 100%; background: var(--navy); border-radius: 5px; }
.region-row b { text-align: right; }
.view-head { display: flex; justify-content: space-between; align-items: center; }
.view-body { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 14px; align-items: start; margin-top: 8px; }
@media (max-width: 640px) { .view-body { grid-template-columns: 1fr; } }
.shot { width: 100%; border-radius: 8px; background: #000; }
.lv, .q { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.lv.keep { background: #DCF0E3; color: #1B6B3A; }
.lv.watch { background: #FBEFD3; color: #8A6100; }
.lv.risk { background: #F9DEDE; color: #9B2C2C; }
.q.good { background: #DCF0E3; color: #1B6B3A; }
.q.fair { background: #FBEFD3; color: #8A6100; }
.q.poor, .q.invalid { background: #F9DEDE; color: #9B2C2C; }
.issues { margin: 10px 0 0; padding-left: 18px; font-size: 14px; }
table.items td:last-child { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.gauge { position: relative; width: 90px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #86EFAC 0 33.3%, #FDE68A 33.3% 66.6%, #FCA5A5 66.6%); }
.gauge i { position: absolute; top: -3px; width: 3px; height: 14px; margin-left: -1px; background: #1A2230; border-radius: 1px; }
.notice-card { background: #FFFBEB; border-color: #FDE68A; }
@media (max-width: 480px) {
  table.items .gauge { display: none; }
  table.items th, table.items td { padding: 6px 6px; }
}
.feature-card, .feature-card:visited { text-decoration: none; color: inherit; }

/* 관리 */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 2px 12px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; }
.admin-card { border: 1px dashed var(--navy); background: #F7F9FC; }
.org-top { display: flex; gap: 12px; align-items: center; }
.org-main { flex: 1; min-width: 0; }
.swatch { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; overflow: hidden; flex: none; }
.swatch img { max-width: 40px; max-height: 40px; }
.small { font-size: 13px; }
.bad { color: #9B2C2C; font-weight: 700; }
.link-row { display: flex; gap: 6px; margin-top: 10px; }
.link-row input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; background: var(--surface-alt); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.grid2 input[type=color] { height: 42px; padding: 2px; }
.check-line { display: flex; align-items: center; gap: 6px; }
.feat-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 8px 0; }
.feat-row > span { font-weight: 600; }
.person { display: grid; grid-template-columns: 1fr minmax(0, 360px); gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
@media (max-width: 640px) { .person { grid-template-columns: 1fr; } }
.person.pending { background: #FFFBEB; margin: 0 -16px; padding: 12px 16px; }
.person-ctl select { margin: 0 6px 6px 0; }
.st.pending { color: #8A6100; font-weight: 700; }
.st.approved { color: #1B6B3A; font-weight: 700; }
.st.suspended { color: #9B2C2C; font-weight: 700; }
.exp { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: #DCF0E3; color: #1B6B3A; margin-left: 4px; }
.exp.soon { background: #FBEFD3; color: #8A6100; }
.exp.over { background: #F9DEDE; color: #9B2C2C; }
.exp.none { background: var(--surface-alt); color: var(--muted); }
.date-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.date-row input { flex: 1; margin: 0 !important; }
.acct-box { margin-top: 10px; padding: 12px; background: var(--surface-alt); border-radius: 8px; }
.acct-result { width: min(440px, 92vw) !important; text-align: left !important; }
.acct-result dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 10px 0; }
.acct-result dt { color: var(--muted); }
.acct-result dd { margin: 0; word-break: break-all; }
.acct-result .pw { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: 1px; }
.manual-link { color: var(--navy); font-weight: 700; }
.save-card h2 { margin-bottom: 4px; }
.save-form select, .save-form input { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.ok-msg { color: #1B6B3A; font-weight: 700; }
.search { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; min-width: 180px; }
.subject-row, .rec-open { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 4px; font: inherit; cursor: pointer; color: inherit; flex-wrap: wrap; }
.subject-row:first-child { border-top: 0; }
.rec-row { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.rec-row .rec-open { border-top: 0; flex: 1; }
.rec-score { font-weight: 800; color: var(--navy); }
.trend { width: 100%; height: auto; }
.trend .grid { stroke: var(--line); }
.trend .line { fill: none; stroke: var(--navy); stroke-width: 2.5; }
.trend circle { fill: var(--navy); }
.trend text { font-size: 11px; fill: var(--muted); }
.trend text.v { fill: var(--navy); font-weight: 700; font-size: 12px; }
.brand img.org-logo { background: #fff; padding: 3px 8px; border-radius: 6px; height: 34px; max-width: 170px; object-fit: contain; }
.logo-row { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.logo-row input[type=file] { flex: 1; min-width: 0; font-size: 13px; }
.logo-preview { width: 120px; height: 48px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: grid; place-items: center; flex: none; overflow: hidden; }
.logo-preview img { max-width: 110px; max-height: 42px; object-fit: contain; }
.notice-text { width: 100%; height: 300px; font: 13px/1.5 inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.trial-card { border: 2px solid var(--navy); }

/* 근육 지도·소견 */
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; margin: 6px 0 10px; }
.map-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.map-legend i.dash { border: 2px dashed #888; background: none; }
.map-wrap { position: relative; }
.map-wrap canvas { width: 100%; height: auto; display: block; }
.map-labels { display: flex; justify-content: space-around; font-weight: 700; color: var(--muted); margin-top: 2px; }
.pin { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid; background: #fff; font-size: 13px; }
.pin.tight, .todo.tight, .dose.tight, .lab.tight { color: #D93A3A; border-color: #D93A3A; }
.pin.weak, .todo.weak, .dose.weak, .lab.weak { color: #2F6FDB; border-color: #2F6FDB; }
.todo { font-weight: 800; font-size: 13px; }
.muscle-table td { text-align: left; vertical-align: top; white-space: normal; }
.finding { border-left: 4px solid #CBD2DB; background: #F7F8F9; border-radius: 6px; padding: 12px; margin: 10px 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; }
.finding.watch { border-left-color: #E0A21A; }
.finding.risk { border-left-color: #D93A3A; }
@media (max-width: 700px) { .finding { grid-template-columns: 1fr; } }
.finding-title { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.gauge.wide { width: 180px; margin: 8px 0; }
.why { font-size: 14px; margin: 6px 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 4px 0; }
.lab { font-size: 12px; font-weight: 800; margin-right: 4px; border: 0 !important; }
.chip-m { font-size: 12px; font-weight: 700; border: 1.5px solid; border-radius: 12px; padding: 1px 8px; background: #fff; }
.chip-m.tight { color: #D93A3A; border-color: #D93A3A; }
.chip-m.weak { color: #2F6FDB; border-color: #2F6FDB; }
.ex-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ex { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; }
.ex-img { display: flex; align-items: center; gap: 2px; height: 96px; }
.ex-img img { flex: 1; min-width: 0; height: 100%; object-fit: contain; }
.ex-img span { color: var(--muted); }
.dose { font-weight: 800; margin: 2px 0; }
.print-head { display: none; }

/* A4 보고서 인쇄 */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .no-print, .save-card, [data-retake], #busy { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; page-break-inside: avoid; }
  .page-break { break-before: page; page-break-before: always; }
  .finding { break-inside: avoid; page-break-inside: avoid; }
  .print-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; color: #444; }
  .print-head img { height: 28px; }
  .view-body { grid-template-columns: 220px 1fr; }
  .notice-card { background: #fff; }
  #postureResult { display: block !important; }
}
.finding > * { min-width: 0; }
.ex-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.todo { white-space: nowrap; }
.muscle-table th { text-align: left; }
.muscle-table td:nth-child(3) { white-space: nowrap; }
.finding-title b { overflow-wrap: anywhere; }
.finding { grid-template-columns: 1fr; }
/* 세 방향을 넓은 화면·인쇄에서 나란히 */
@media (min-width: 1000px) {
  #postureResult.wrap { max-width: 1200px; }
  .views { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .views .view-body { grid-template-columns: 1fr; }
  .views .card { margin: 0; }
}
@media print {
  .views { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; break-inside: avoid; page-break-inside: avoid; margin-bottom: 8px; }
  .views .card { margin: 0; padding: 8px; }
  .views .view-body { grid-template-columns: 1fr !important; gap: 6px; }
  .views .shot { max-height: 330px; object-fit: contain; }
  .views table { font-size: 10px; }
  .views th, .views td { padding: 3px 4px; }
  .views h2 { font-size: 13px; }
  .views .issues { font-size: 10px; }
  .result-head, .region-row { break-inside: avoid; }
  .result-head h1 { font-size: 18px; }
  .score-big b { font-size: 36px; }
}
@media print { .views .lv, .views .q { font-size: 9px; padding: 0 5px; } .views .table-wrap { overflow: visible; } }
