:root {
  --bg: #0f1412;
  --surface: #1b2320;
  --line: #2d3733;
  --text: #f1f5f3;
  --muted: #a4b0aa;
  --accent: #3ee28f;
  --on-accent: #06281a;
  --good: #3ee28f;
  --warn: #ffc53d;
  --bad: #ff5d5d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.screen { max-width: 520px; min-height: 100%; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 20px 96px; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; }
h2 { margin: 28px 0 10px; color: var(--muted); font-size: 14px; font-weight: 600; }
.brand p { margin: 8px 0 0; color: var(--muted); }
.brand-logo { display: block; margin-bottom: 14px; border-radius: 16px; }
.lead { margin: 16px 0; }
.privacy { margin: 20px 0 0; color: var(--muted); font-size: 14px; text-align: center; }
.error { margin: 12px 0 0; color: var(--bad); }

.exercises { margin: 0; padding: 0; list-style: none; }
.exercise { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 68px; margin-bottom: 10px; padding: 12px 18px; background: var(--surface); border-radius: 18px; text-align: left; }
.exercise strong { display: block; font-size: 17px; }
.exercise span { color: var(--muted); font-size: 14px; }
.exercise i { color: var(--muted); font-size: 24px; font-style: normal; }

.back { min-height: 44px; margin: -6px 0 6px -4px; color: var(--muted); }
.stage { position: relative; aspect-ratio: 1 / 1.08; overflow: hidden; background: radial-gradient(circle at 50% 38%, #b9bec4, #7d8389 48%, #4c5157); border-radius: 28px; }
#guide, #report-figure, #detail-figure, #progress-figure { width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
#guide canvas, #report-figure canvas, #detail-figure canvas, #progress-figure canvas, #avatar canvas { display: block; width: 100%; height: 100%; }
.stage-badge { position: absolute; top: 14px; left: 14px; margin: 0; padding: 6px 12px; background: rgba(15, 18, 20, .72); border-radius: 999px; color: #e8ecee; font-size: 12px; font-weight: 600; letter-spacing: .04em; pointer-events: none; }
.stage-controls { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px; }
.stage-controls .pill { min-height: 40px; padding: 0 14px; background: rgba(15, 18, 20, .78); color: #fff; font-size: 13px; }
.worked { display: flex; align-items: center; gap: 6px; margin: 0 0 0 auto; padding: 9px 12px; background: rgba(15, 18, 20, .78); border-radius: 999px; color: #fff; font-size: 13px; font-weight: 600; }
main:focus { outline: none; }
@media (max-width: 340px) { .stage-controls .pill { padding: 0 10px; } .worked { padding: 9px 8px; } }
.worked span { width: 9px; height: 9px; background: #ff5a14; border-radius: 50%; }
.guide-body { margin-top: 20px; }
.kicker { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.intro { margin: 12px 0 0; color: #c6cfca; }
.stats { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; }
.stat { padding: 12px 14px; border-top: 1px solid var(--line); }
.stat:nth-child(1) { grid-column: 1 / -1; border-top: 0; }
.stat:nth-child(even) { border-right: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.stat strong { display: block; margin-top: 2px; font-size: 15px; }
h2.section { margin: 34px 0 6px; color: var(--text); font-size: 22px; line-height: 1.2; }
.section-note { margin: 0; color: var(--muted); font-size: 14px; }
.activations { margin: 12px 0 0; padding: 0; list-style: none; }
.activation { margin-top: 12px; }
.activation .muscle-label span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.activation.main .muscle-label span { color: #ff7a3d; }
.activation .bar i { background: linear-gradient(90deg, #ff5a14, #ff8a3d); }
.activation.support .bar i { background: #8f5a3c; }
.cue-cards { margin: 12px 0 0; padding: 0; list-style: none; }
.cue-card { margin-top: 12px; padding: 16px 18px; background: var(--surface); border-radius: 22px; }
.cue-card h3 { margin: 0; font-size: 18px; }
.cue-summary { margin: 4px 0 0; color: #c6cfca; }
.cue-part { margin-top: 12px; }
.cue-part span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.cue-part p { margin: 2px 0 0; font-size: 15px; }
.cue-part.mistake span { color: var(--bad); }
.cue-part.fix span { color: var(--good); }
@media (min-width: 860px) {
  #setup, #detail { max-width: 1040px; }
  .guide-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; align-items: start; }
  .guide-media { position: sticky; top: 24px; }
  .guide-body { margin-top: 0; }
  h1 { font-size: 36px; }
}
.steps { margin: 10px 0 0; padding-left: 22px; }
.steps li { margin-top: 8px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.tip { margin: 0; padding: 14px 16px; background: var(--surface); border-radius: 18px; }
#start { position: sticky; bottom: 16px; margin-top: 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.primary, .secondary { display: block; width: 100%; min-height: 54px; margin-top: 12px; border-radius: 999px; font-weight: 700; }
.primary { background: var(--accent); color: var(--on-accent); }
.secondary { background: var(--surface); }

.search { width: 100%; min-height: 48px; margin-top: 12px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; }
.places { display: flex; margin-top: 12px; padding: 4px; background: var(--surface); border-radius: 999px; }
.place { flex: 1; min-height: 42px; border-radius: 999px; color: var(--muted); font-size: 15px; font-weight: 700; }
.place[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.filters { display: flex; gap: 8px; margin: 12px -20px 0; padding: 0 20px 4px; overflow-x: auto; scrollbar-width: none; }
.filter { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600; }
.filter[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.selects { display: flex; gap: 8px; margin-top: 8px; }
.selects select { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.library-heading { margin: 22px 0 8px; font-size: 18px; }
.library-heading span { color: var(--muted); font-size: 14px; font-weight: 500; }
.library-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 2px; border-top: 1px solid var(--line); text-align: left; }
.library-row strong { display: block; font-size: 15px; font-weight: 600; }
.library-row span { color: var(--muted); font-size: 13px; }
.library-row em { flex: none; padding: 3px 9px; border-radius: 999px; background: rgba(62, 226, 143, .15); color: var(--accent); font-size: 12px; font-style: normal; font-weight: 700; }

.tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; padding: 6px 8px max(8px, env(safe-area-inset-bottom)); background: rgba(15, 20, 18, .96); border-top: 1px solid var(--line); }
.tabs button { flex: 1; min-height: 48px; border-radius: 14px; color: var(--muted); font-size: 13px; font-weight: 700; }
.tabs button[aria-current="page"] { background: var(--surface); color: var(--accent); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { flex: 1 1 auto; min-height: 48px; padding: 0 16px; border-radius: 999px; background: var(--surface); color: var(--muted); font-weight: 700; }
.choice[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.week { display: flex; justify-content: space-between; gap: 6px; margin: 20px 0 0; padding: 0; list-style: none; }
.week-day { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--text); font-size: 14px; font-weight: 700; }
.week-day.rest { color: var(--muted); border-style: dashed; }
.week-day.now { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.week-day.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.plan-items { margin: 20px 0 0; padding: 0; list-style: none; }
.plan-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 68px; margin-bottom: 10px; padding: 12px 18px; background: var(--surface); border-radius: 18px; text-align: left; }
.plan-item strong { display: block; font-size: 16px; }
.plan-item span { color: var(--muted); font-size: 13px; }
.plan-item em, .history-row em { flex: none; color: var(--accent); font-size: 13px; font-style: normal; font-weight: 700; }
.plan-item.done strong { color: var(--muted); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.tile { padding: 14px 16px; background: var(--surface); border-radius: 18px; }
.tile strong { display: block; font-size: 28px; line-height: 1.15; }
.tile span { color: var(--muted); font-size: 13px; }
#progress-skipped { margin-top: 12px; }
.history { margin: 10px 0 0; padding: 0; list-style: none; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.history-row strong { display: block; font-size: 15px; }
.history-row span { color: var(--muted); font-size: 13px; }
#report-figure, #progress-figure { touch-action: pan-y; }

.coach { position: fixed; inset: 0; overflow: hidden; background: #000; }
.coach video, .coach canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#avatar { display: none; position: absolute; inset: 0; touch-action: pan-y; }
.coach.figure-view { background: radial-gradient(circle at 50% 38%, #b9bec4, #7d8389 48%, #4c5157); }
.coach.figure-view #avatar { display: block; }
.coach.figure-view video, .coach.figure-view #overlay { visibility: hidden; }
.coach.mirrored video, .coach.mirrored canvas { transform: scaleX(-1); }
.frame { position: absolute; inset: 0; pointer-events: none; border: 8px solid transparent; transition: border-color .15s; }
.frame.good { border-color: var(--good); }
.frame.warn { border-color: var(--warn); }
.frame.bad { border-color: var(--bad); }
.top { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tools { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pill { min-height: 44px; padding: 0 16px; background: rgba(0, 0, 0, .62); border-radius: 999px; font-size: 14px; font-weight: 600; }
.counter { min-width: 88px; padding: 4px 16px 8px; background: rgba(0, 0, 0, .62); border-radius: 22px; text-align: center; }
.counter strong { display: block; font-size: 40px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.counter span { color: var(--muted); font-size: 13px; }
.bottom { position: absolute; left: 14px; right: 14px; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.live-muscles:empty { display: none; }
.live-muscles { margin: 0; padding: 7px 14px; background: rgba(255, 90, 20, .92); border-radius: 999px; color: #2a0d00; font-size: 14px; font-weight: 700; }
.cue { align-self: stretch; margin: 0; padding: 14px 18px; background: rgba(0, 0, 0, .72); border-radius: 22px; font-size: 22px; font-weight: 700; line-height: 1.25; text-align: center; }

.score { margin: 18px 0 0; color: var(--accent); font-size: 56px; font-weight: 800; line-height: 1.1; }
.stage-hint { position: absolute; top: 12px; left: 16px; margin: 0; color: #e8ecee; font-size: 13px; pointer-events: none; }
.report-stage { aspect-ratio: 1 / 0.95; }
#report .stage-controls { position: static; justify-content: center; margin-top: 10px; }
#report .stage-controls .pill { flex: 1; background: var(--surface); }
.legend { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.trained { background: var(--good); }
.dot.partly { margin-left: 10px; background: var(--warn); }
.dot.missed { margin-left: 10px; background: var(--bad); }
.muscles, .issues { margin: 12px 0 0; padding: 0; list-style: none; }
.muscle { margin-top: 12px; }
.muscle-label { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.muscle-label span { color: var(--muted); font-size: 13px; }
.bar { height: 8px; margin-top: 5px; overflow: hidden; background: var(--surface); border-radius: 999px; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--good); }
.muscle.partly .bar i { background: var(--warn); }
.muscle.missed .bar i { background: var(--bad); }
.issue { margin-top: 10px; padding: 14px 16px; background: var(--surface); border-radius: 18px; }
.issue strong { display: block; }
.issue p { margin: 4px 0 6px; }
.issue span { color: var(--muted); font-size: 13px; }

@media (prefers-reduced-motion: reduce) { .frame { transition: none; } }

a { color: var(--accent); }
.self-check { margin-top: 20px; }
.self-check p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.routines, .routine-rows, .record-list, .set-list { margin: 0; padding: 0; list-style: none; }
.routine { display: flex; align-items: center; gap: 8px; min-height: 64px; margin-bottom: 8px; padding: 6px 10px 6px 4px; background: var(--surface); border-radius: 18px; }
.routine-main { flex: 1; min-width: 0; min-height: 52px; padding: 4px 12px; text-align: left; }
.routine-main strong { display: block; }
.routine-main span { color: var(--muted); font-size: 14px; }
.routine .pill, .log-actions .pill, .summary-log .pill { min-height: 44px; padding: 0 14px; background: var(--line); border-radius: 999px; font-size: 14px; font-weight: 600; }
.log-card { margin-top: 14px; padding: 12px; background: var(--surface); border-radius: 18px; }
.log-name { display: block; width: 100%; min-height: 44px; font-size: 18px; font-weight: 700; text-align: left; }
.log-previous, .log-hint { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.log-hint { color: var(--accent); }
.set-row { display: grid; grid-template-columns: 40px 44px minmax(0, 1fr) 44px 64px 52px; align-items: center; gap: 5px; margin-top: 8px; padding: 2px; border-radius: 14px; }
.set-row.done { background: rgba(62, 226, 143, .14); }
.set-type { height: 48px; color: var(--muted); font-weight: 700; }
.set-step { min-width: 44px; height: 48px; background: var(--line); border-radius: 12px; font-size: 20px; font-weight: 700; }
.set-input { width: 100%; height: 48px; padding: 0 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; font-size: 18px; font-weight: 700; text-align: center; -moz-appearance: textfield; }
.set-input::-webkit-outer-spin-button, .set-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.set-check { height: 48px; background: var(--line); border-radius: 12px; font-size: 20px; font-weight: 700; }
.set-row.done .set-check { background: var(--accent); color: var(--on-accent); }
.log-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rest-bar { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 5; display: flex; align-items: center; gap: 6px; width: min(500px, calc(100% - 24px)); padding: 10px 12px; background: #24302b; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); transform: translateX(-50%); }
.rest-bar div { flex: 1; }
.rest-bar span { display: block; color: var(--muted); font-size: 12px; }
.rest-bar strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.rest-bar .pill { min-width: 48px; min-height: 48px; padding: 0 10px; background: var(--line); border-radius: 12px; font-weight: 700; }
#log { padding-bottom: 150px; }
.hurts-link { display: block; min-height: 48px; margin: 12px auto 0; color: var(--muted); text-decoration: underline; }
.sheet { width: min(500px, calc(100% - 24px)); max-height: 80vh; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); color: var(--text); }
.sheet::backdrop { background: rgba(0, 0, 0, .6); }
.sheet-title { margin: 0 0 8px; color: var(--text); font-size: 20px; }
.sheet-head { display: flex; gap: 8px; align-items: center; }
.sheet-head .search { margin: 0; }
.sheet-head .pill { min-height: 48px; padding: 0 12px; }
.picker-row { display: block; width: 100%; min-height: 48px; padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.picker-new { color: var(--accent); font-weight: 700; }
.routine-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 8px 10px; background: var(--surface); border-radius: 14px; }
.routine-row-name { flex: 1; min-width: 0; }
.routine-row-name strong { display: block; }
.routine-row-name span { color: var(--muted); font-size: 14px; }
.field-label { display: block; margin-top: 16px; color: var(--muted); font-size: 14px; }
.record-list li { padding: 10px 14px; margin-top: 6px; background: var(--surface); border-radius: 14px; }
.lift-choice { width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; }
.chart { display: block; width: 100%; margin-top: 10px; background: var(--surface); border-radius: 14px; }
.chart polyline { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart circle { fill: var(--accent); }
.calc { margin-top: 10px; }
.danger { display: block; width: 100%; min-height: 54px; margin-top: 24px; color: var(--bad); font-weight: 700; }
.summary-log { margin-top: 20px; }
.summary-log label { color: var(--muted); font-size: 14px; }
.summary-log-row { display: flex; gap: 8px; margin-top: 6px; }
@media (max-width: 340px) { .set-row { grid-template-columns: 24px 34px minmax(0, 1fr) 34px 46px 40px; gap: 3px; } .set-step { min-width: 34px; } .set-input { padding: 0; font-size: 15px; } .log-card { padding: 10px 8px; } }
.save-warning { margin: 0; padding: 10px 16px; background: var(--bad); color: #2a0606; font-weight: 600; }
