:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --line: #e1e4e9;
  --text: #12151a;
  --text-2: #5d6673;
  --accent: #c8f53c;       /* 라임: 버튼·카운트 */
  --accent-ink: #11140a;   /* 라임 위 글자 */
  --accent-text: #4a7a00;  /* 밝은 배경 위 강조 글자 */
  --warn: #d97706;
  --danger: #d6454a;
  --chart: #2f9ee8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  /* 안드로이드 앱에선 Capacitor 가 --safe-area-inset-* 를 넣어준다(구형 WebView 대비), 브라우저는 env() */
  --safe-b: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-t: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f2530;
    --line: #2a313d;
    --text: #f2f4f7;
    --text-2: #9aa3af;
    --accent-text: #c8f53c;
    --warn: #ffb020;
    --danger: #ff6b6f;
    --chart: #4cc9f0;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f2530;
  --line: #2a313d;
  --text: #f2f4f7;
  --text-2: #9aa3af;
  --accent-text: #c8f53c;
  --warn: #ffb020;
  --danger: #ff6b6f;
  --chart: #4cc9f0;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
b { font-weight: 700; }

/* 화면 */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(8px + var(--safe-t)) 16px calc(96px + var(--safe-b));
  min-height: 100%;
}
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 52px;
  margin-bottom: 4px;
}
.topbar .brand { grid-column: 1 / 4; }
.topbar-title { text-align: center; font-weight: 700; font-size: 17px; }
.topbar-title.left { grid-column: 1 / 4; text-align: left; font-size: 24px; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px; background: var(--accent);
  box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--accent) 60%, #000 40%);
}
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px;
  font-size: 26px; line-height: 1; display: grid; place-items: center;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.danger { font-size: 18px; }

.today-label { margin: 4px 0 8px; color: var(--text-2); font-size: 14px; }
.section-title { font-size: 18px; margin: 28px 0 10px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 16px;
}
.today-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat .num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .lbl { font-size: 12px; color: var(--text-2); }

/* 버튼 */
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; border: 0; border-radius: var(--radius); padding: 14px 16px;
  font-weight: 700; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-xl { min-height: 96px; margin-bottom: 10px; }
.btn-lg { min-height: 60px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-title { font-size: 20px; letter-spacing: -0.01em; }
.btn-lg .btn-title { font-size: 17px; }
.btn-sub { font-size: 13px; font-weight: 500; opacity: .75; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.howto { margin-top: 14px; }
.howto-title { font-weight: 700; margin-bottom: 4px; }
.howto ol { margin: 0 0 6px; padding-left: 20px; }
.howto li { margin: 2px 0; }

/* 세션 목록 */
.session-list { display: flex; flex-direction: column; gap: 8px; }
.session-item {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  box-shadow: var(--shadow);
}
.session-date { min-width: 52px; text-align: center; }
.session-date .d { font-size: 20px; font-weight: 800; line-height: 1.1; }
.session-date .m { font-size: 12px; color: var(--text-2); }
.session-main { flex: 1; min-width: 0; }
.session-main .t { font-weight: 700; }
.session-main .s { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--text-2); font-size: 22px; }
.empty { padding: 24px 16px; text-align: center; color: var(--text-2); background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; }

/* 탭바 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 12px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; max-width: 160px; border: 0; background: transparent; border-radius: 12px;
  padding: 6px 0 4px; font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tabbar button.active { color: var(--text); font-weight: 700; }
.tab-ico { font-size: 20px; line-height: 1.2; }
body.in-workout .tabbar { display: none; }

/* 운동 고르기 */
.pick-group { margin: 18px 0 6px; font-weight: 700; color: var(--text-2); font-size: 14px; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick-item {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px;
  padding: 12px; min-height: 64px; box-shadow: var(--shadow); position: relative;
}
.pick-item .n { font-weight: 700; }
.pick-item .h { font-size: 12px; color: var(--text-2); line-height: 1.35; margin-top: 2px; }
.beta {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; vertical-align: 2px;
  background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn);
}
.pick-item[aria-pressed="true"] { border-color: var(--accent-text); box-shadow: 0 0 0 2px var(--accent) inset; }
.pick-item[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; display: grid; place-items: center;
}
.weight-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.weight-row input { width: 76px; }
.sticky-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.sticky-bottom .btn { max-width: 528px; margin: 0 auto; }
body.has-sticky .tabbar { display: none; }

input[type="number"], input[type="text"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; min-height: 40px;
}

/* 운동 화면 */
.workout {
  position: fixed; inset: 0; background: #000; color: #fff; overflow: hidden; z-index: 30;
  --wo-accent: #c8f53c;
}
/* 화면은 캔버스 하나에 '영상 프레임 + 뼈대'를 같이 그린다(분석한 바로 그 프레임에 뼈대가 정확히 겹침).
   비디오 요소는 캔버스 아래에 두고 재생만 담당한다. */
.workout > video, .workout > canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.workout > canvas { pointer-events: none; }
.workout.mirror > video, .workout.mirror > canvas { transform: scaleX(-1); }
.wo-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 14px 26px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .65), transparent);
}
.wo-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }
.wo-status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wo-camera { position: absolute; top: calc(54px + var(--safe-t)); left: 14px; z-index: 2; font-size: 12px; color: #ddd; text-shadow: 0 1px 4px #000; }
.wo-framing {
  position: absolute; top: calc(80px + var(--safe-t)); left: 14px; right: 14px; z-index: 2;
  padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .8); color: #ffcf75;
  border: 1px solid rgba(255, 176, 32, .55); font-size: 14px; line-height: 1.45;
}
.workout:has(.wo-plan:not([hidden])) .wo-framing { top: calc(146px + var(--safe-t)); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #888; flex: none; }
.dot.ok { background: var(--wo-accent); box-shadow: 0 0 10px var(--wo-accent); }
.dot.warn { background: #ffb020; }
.wo-clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }
.wo-actions { display: flex; gap: 8px; }
.wo-btn {
  border: 0; border-radius: 12px; min-width: 44px; height: 40px; padding: 0 12px;
  background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700; backdrop-filter: blur(8px);
}
.wo-end { background: rgba(255, 90, 95, .9); }
.wo-center {
  position: absolute; left: 0; right: 0; bottom: max(18%, calc(var(--wo-lift, 0px) + 8px)); z-index: 2; text-align: center; pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .55);
  padding: 0 16px;
}
.wo-exercise { font-size: clamp(22px, 6.4vw, 44px); font-weight: 800; letter-spacing: -0.01em; }
.wo-count {
  font-size: clamp(120px, 42vw, 300px); line-height: .95; font-weight: 900; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; color: var(--wo-accent);
}
.wo-count.bump { animation: bump .28s ease-out; }
@keyframes bump { 0% { transform: scale(1.14); } 100% { transform: scale(1); } }
.wo-count.rest { color: #fff; font-size: clamp(88px, 30vw, 220px); }
.wo-count.tentative { color: rgba(255, 255, 255, .5); }
.wo-message { font-size: clamp(18px, 5vw, 30px); font-weight: 700; margin-top: 6px; }
.wo-cue {
  display: inline-block; margin-top: 12px; padding: 10px 18px; border-radius: 999px;
  background: #ffb020; color: #1a1200; font-weight: 800; font-size: clamp(20px, 5.6vw, 34px); text-shadow: none;
}
.wo-rest-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; pointer-events: auto; text-shadow: none; }
.wo-rest-actions[hidden] { display: none; }
.wo-rest-actions .wo-btn { height: 46px; padding: 0 18px; font-size: 16px; }
.wo-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 26px 14px calc(14px + var(--safe-b));
  background: linear-gradient(to top, rgba(0, 0, 0, .7), transparent);
}
/* 템포: 힘주기(라임)·돌아오기(파랑) 시간과 속도. 2~3m 밖에서도 읽히게 글자를 크게 */
.wo-tempo {
  margin-bottom: 10px; padding: 8px 12px 10px; border-radius: 14px;
  background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px);
}
.wo-tempo-text {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px;
  font-size: clamp(15px, 4.3vw, 26px); font-weight: 800; font-variant-numeric: tabular-nums;
}
.wo-tempo-text .con { color: var(--wo-accent); }
.wo-tempo-text .ecc { color: #5ab8ff; }
.wo-tempo-text .spd { color: #fff; }
.wo-tempo-text .loss { color: #ffb020; }
.wo-tempo-text .lbl { color: rgba(255, 255, 255, .7); font-size: .8em; font-weight: 700; }
.wo-tempo canvas { display: block; width: 100%; height: clamp(44px, 7vh, 76px); margin-top: 6px; }
.wo-sets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.wo-sets::-webkit-scrollbar { display: none; }
.wo-set-chip {
  flex: none; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .14);
  font-size: 13px; font-weight: 600; backdrop-filter: blur(6px);
}
.wo-set-chip b { color: var(--wo-accent); }
.wo-loading {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: rgba(0, 0, 0, .82); font-weight: 600; text-align: center; padding: 24px;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .2);
  border-top-color: var(--wo-accent); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.wo-debug {
  position: absolute; left: 10px; top: calc(60px + var(--safe-t)); z-index: 3; max-width: min(92vw, 420px);
  font: 11px/1.45 ui-monospace, Menlo, monospace; background: rgba(0, 0, 0, .6); padding: 8px 10px; border-radius: 8px;
  white-space: pre-wrap; pointer-events: none;
}
/* 가로로 세운 폰: 영상(4:3)은 가운데, 안내·템포·다음 운동은 오른쪽 기둥으로 — 큰 숫자가 가려지지 않게 */
@media (orientation: landscape) {
  .wo-framing { left: auto; width: min(36vw, 350px); }
  .workout:has(.wo-plan:not([hidden])) .wo-framing { top: calc(80px + var(--safe-t)); }
  .wo-bottom {
    left: auto; right: 0; top: calc(66px + var(--safe-t)); bottom: 0; width: min(40vw, 380px);
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 0 12px calc(10px + var(--safe-b)); background: none;
  }
  .wo-center { left: 0; right: min(40vw, 380px); bottom: 10%; }
  .wo-plan { right: auto; width: min(56vw, 480px); }
  .wo-count { font-size: clamp(90px, 32vh, 220px); }
  .wo-target { font-size: clamp(30px, 12vh, 80px); }
  .wo-exercise { font-size: clamp(20px, 7vh, 40px); }
  .wo-tempo canvas { height: 52px; }
  .wo-next-text, .wo-tempo-text { font-size: 16px; }
}

/* 요약·기록 */
.hero { text-align: center; padding: 8px 0 14px; }
.hero .big { font-size: 40px; font-weight: 900; letter-spacing: -0.03em; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.ex-block { margin-bottom: 12px; }
.ex-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.ex-head .n { font-weight: 800; font-size: 17px; }
.ex-head .s { color: var(--text-2); font-size: 13px; }
.set-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.set-row:first-of-type { border-top: 0; }
.set-no { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.set-main .v { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.set-main .q { font-size: 12px; color: var(--text-2); }
.set-main .q.warn { color: var(--warn); }
/* 템포: 반복별 힘주기 속도 막대 + 평균 */
.tempo-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.tempo-bars { height: 30px; flex: none; }
.tempo-bars rect.con, .tempo-legend .sw.con { fill: var(--accent-text); background: var(--accent-text); }
.tempo-bars rect.slow, .tempo-legend .sw.slow { fill: var(--warn); background: var(--warn); }
.tempo-bars rect.none { fill: var(--line); }
.tempo-txt { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tempo-legend { margin: 2px 4px 0; }
.tempo-legend .sw { display: inline-block; width: 8px; height: 10px; border-radius: 2px; margin: 0 4px 0 2px; vertical-align: -1px; }
.diag-card { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
textarea { width: 100%; resize: vertical; min-height: 72px; line-height: 1.4; }
.set-edit { display: flex; gap: 6px; }
.mini-btn {
  min-width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 700; padding: 0 10px;
}
.feedback { margin-top: 6px; }
.feedback li { margin: 4px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 10px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px;
}
.setting.stacked .seg { flex-wrap: wrap; max-width: 100%; }
.rest-ctl, .cam-ctl { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-top: 6px; }
.rest-ctl { align-items: stretch; }
.rest-ctl .stepper { justify-content: flex-start; }
.setting.stacked .seg button { white-space: nowrap; padding: 6px 4px; }
.rest-ctl .stepper { gap: 10px; }
.rest-val { min-width: 76px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.cam-ctl .chips { margin: 0; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 11px; color: var(--text-2); text-align: center; }
.cal-day {
  aspect-ratio: 1; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center;
  font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.cal-day.l1 { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); color: var(--text); }
.cal-day.l2 { background: color-mix(in srgb, var(--accent) 65%, var(--surface-2)); color: var(--accent-ink); font-weight: 700; }
.cal-day.l3 { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.cal-day.today { outline: 2px solid var(--text); outline-offset: -2px; }
.cal-day.blank { background: transparent; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--chart); }
.chart .bar.cur { fill: var(--accent-text); }
.chart text { fill: var(--text-2); font-size: 11px; font-family: var(--font); }
.chart .val { fill: var(--text); font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* 설정 */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting .l { font-weight: 600; }
.setting.stacked { flex-direction: column; align-items: stretch; }
.setting.stacked .seg { display: flex; }
.setting.stacked .seg button { flex: 1; }
.setting .d { font-size: 12px; color: var(--text-2); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .2s; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::before { transform: translateX(20px); }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
/* 운동 중엔 큰 숫자·안내와 겹치지 않게 위쪽에 */
body.in-workout .toast { bottom: auto; top: calc(70px + var(--safe-t)); z-index: 70; }
dialog {
  border: 0; border-radius: 18px; padding: 18px; width: min(92vw, 420px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h3 { margin: 0 0 10px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field label { font-size: 13px; color: var(--text-2); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 90px; text-align: center; font-size: 20px; font-weight: 800; }

/* 오늘의 루틴 (PT 모드) */
.btn-routine .btn-title { display: inline-flex; align-items: center; gap: 8px; }
.pt-badge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.routine-make { display: flex; flex-direction: column; gap: 10px; }
.rm-title { font-weight: 800; }
.rm-row { display: flex; flex-direction: column; gap: 6px; }
.rm-row > span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.rm-row .seg { display: flex; flex-wrap: wrap; }
.rm-row .seg button { flex: 1; white-space: nowrap; padding: 7px 4px; }
.routine-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 6px; }
.routine-reason { margin: 0 2px 8px; }
.routine-list { padding-top: 4px; padding-bottom: 8px; }
.r-item, .r-saved { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.r-item:first-child, .r-saved:first-child { border-top: 0; }
.r-no { width: 26px; height: 26px; flex: none; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.r-main { flex: 1; min-width: 0; }
.r-name { font-weight: 700; }
.r-sub { font-size: 13px; color: var(--text-2); }
.r-ctl { display: flex; gap: 4px; flex: none; }
.r-ctl .mini-btn { min-width: 34px; padding: 0 8px; }
.r-saved { justify-content: space-between; }
.routine-list .btn-ghost { width: 100%; margin-top: 6px; }

/* 운동 화면 · PT 진행 */
.wo-plan {
  position: absolute; left: 14px; right: 14px; top: calc(80px + var(--safe-t)); z-index: 2;
  padding: 8px 12px; border-radius: 12px; background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px);
}
.wo-plan-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 700; }
.wo-plan-bar { height: 5px; margin-top: 6px; border-radius: 99px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.wo-plan-bar i { display: block; height: 100%; width: 0; background: var(--wo-accent); transition: width .4s; }
.wo-count-row { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.wo-target { font-size: clamp(34px, 11vw, 80px); font-weight: 900; color: rgba(255, 255, 255, .7); font-variant-numeric: tabular-nums; }
.wo-next { margin-bottom: 10px; padding: 8px 12px 10px; border-radius: 14px; background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); }
.wo-next-text { font-size: clamp(15px, 4.2vw, 22px); font-weight: 700; }
.wo-next-text b { color: var(--wo-accent); }
.wo-next-actions { display: flex; gap: 8px; margin-top: 8px; }
.wo-next-actions .wo-btn { flex: 1; height: 42px; }
.wo-count.done { color: #fff; }

.plan-card { margin-bottom: 12px; }
.plan-card-top { display: flex; justify-content: space-between; align-items: baseline; }
.plan-card-top span { font-weight: 900; font-size: 20px; color: var(--accent-text); }
.plan-bar { position: static; margin: 8px 0 6px; background: var(--surface-2); height: 8px; }
.plan-bar i { background: var(--accent); }
.plan-tgt { font-size: 14px; font-weight: 600; }

/* 자리 잡기: 화면 테두리 색 */
.wo-frame { position: absolute; inset: 0; z-index: 1; pointer-events: none; border: 8px solid transparent; transition: border-color .3s, box-shadow .3s; }
.wo-frame.bad { border-color: rgba(255, 176, 32, .85); }
.wo-frame.ok { border-color: rgba(200, 245, 60, .95); box-shadow: inset 0 0 40px rgba(200, 245, 60, .45); }

/* 홈: 시작 두 가지 */
.start-grid { display: grid; gap: 10px; }
.start-grid .btn-xl { min-height: 104px; }
.link-card {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 4px; padding: 14px 16px;
  border: 1px dashed var(--line); border-radius: var(--radius); background: transparent; color: var(--text); text-align: left; font: inherit;
}
.link-card > span:last-child { font-size: 22px; color: var(--text-2); }

/* 동작 시범(막대 인형) */
.wo-next-row { display: flex; align-items: center; gap: 10px; }
.wo-demo { width: 84px; height: 84px; flex: none; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.wo-next-text .sub { font-size: .8em; font-weight: 600; color: rgba(255, 255, 255, .75); }
.r-name { display: inline; border: 0; padding: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.demo-ico { font-size: 10px; color: var(--accent-text); vertical-align: 2px; }
.demo-big { display: block; width: 100%; height: 220px; border-radius: 12px; background: var(--surface-2); }
.r-why { font-size: 12px; color: var(--accent-text); font-weight: 600; }

/* 휴식 중 다음 세트 무게·목표 조정 */
.wo-adjust { display: flex; gap: 10px; justify-content: center; margin-top: 10px; pointer-events: auto; text-shadow: none; flex-wrap: wrap; }
.wo-adjust .adj { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); }
.wo-adjust .adj[hidden] { display: none; }
.wo-adjust .wo-btn { width: 46px; height: 46px; font-size: 24px; padding: 0; }
.wo-adjust span { min-width: 74px; text-align: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.r-timer .r-name { color: var(--text-2); }
.r-timer .r-no { background: transparent; }

/* 기록: 부위별 세트·최고 기록·새 기록 */
.grp-row { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; }
.grp-name { color: var(--text-2); font-weight: 600; }
.grp-bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.grp-bar i { display: block; height: 100%; background: var(--chart); border-radius: 99px; }
.grp-val { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 4.5em; text-align: right; }
.pr-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 0; font-size: 15px; }
.pr-row + .pr-row { border-top: 1px solid var(--line); }
.pr-val { text-align: right; flex-shrink: 0; }
.pr-val .muted { display: block; font-size: 12px; }
.pr-new { margin-bottom: 12px; border: 2px solid var(--accent); }
.num-input { display: inline-flex; align-items: center; gap: 6px; }
.num-input input { width: 84px; text-align: right; }
.hc-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }

/* 하루 목표: 홈 카드·목표 화면 */
#goal-card { margin-bottom: 12px; }
.goal-card { display: flex; flex-direction: column; gap: 6px; }
.goal-card.met { border: 2px solid var(--accent); }
.goal-empty { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.goal-streak { font-size: 14px; font-weight: 700; color: var(--warn); }
.goal-row { display: grid; grid-template-columns: minmax(64px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 15px; }
.goal-row .grp-bar { height: 12px; }
.goal-row.done .grp-bar i { background: var(--accent-text); }
.goal-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-val { font-variant-numeric: tabular-nums; font-size: 14px; min-width: 5.5em; text-align: right; }
.goal-actions { display: flex; gap: 8px; margin-top: 6px; }
.goal-actions .btn-primary { flex: 1; }
.goal-bump { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
.goal-edit-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.goal-edit-row select { min-width: 0; }
.goal-edit-row .stepper input { width: 64px; text-align: center; }
.goal-edit-row .unit { font-size: 13px; color: var(--text-2); }
.gi-del { font-size: 22px; }
.time-ctl { display: inline-flex; align-items: center; gap: 10px; }
.time-ctl input[type="time"] { font-size: 16px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.time-ctl input[type="time"]:disabled { opacity: .45; }
.link-inline { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
@media (max-width: 360px) { .goal-edit-row { grid-template-columns: 1fr auto; } .goal-edit-row .gi-del { grid-column: 2; grid-row: 1; } }

/* 카메라 고르기·폰 어디에 둘까요 */
.cam-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.cam-chip span { font-size: 12px; color: var(--text-2); font-weight: 400; }
.place-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0 10px; }
.place-table th { font-size: 12px; color: var(--text-2); font-weight: 600; text-align: right; padding: 4px 2px; vertical-align: bottom; }
.place-table th:first-child, .place-table td:first-child { text-align: left; }
.place-table th span, .place-table td span { display: block; font-size: 11px; font-weight: 400; color: var(--text-2); }
.place-table td { padding: 7px 2px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.place-table tr.worst td { color: var(--text-2); font-weight: 400; }
.place-help .feedback li { margin: 4px 0; }
.place-link { display: block; margin: 8px auto 4px; font-size: 14px; font-weight: 500; color: var(--text-2); text-align: center; }
.goal-week { display: grid; grid-template-columns: minmax(64px, 30%) 1fr auto; align-items: center; gap: 10px; }
.goal-dots { display: inline-flex; gap: 6px; }
.goal-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.goal-dots i.on { background: var(--accent-text); border-color: var(--accent-text); }
.goal-battery-warn { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin: 4px 0 8px; }
.goal-battery-warn .muted { margin-top: 2px; }
.voice-select { max-width: 62%; }
/* 내 운동 고르기 창·부위 고르기 */
.my-ex { max-height: 78vh; overflow-y: auto; }
.my-ex-group { margin: 12px 0; }
.my-ex-group .chips { margin: 6px 0 0; }
.routine-make .rm-row .chips { margin: 0; }
.routine-counts { margin: 4px 0 0; }
