:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #18202b; --sub: #5b6676; --line: #dde3ea;
  --brand: #11161f; --accent: #ff6b4a; --ref: #13b9a0; --ok: #2fa36b; --mild: #f0a020; --notable: #e5484d;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1117; --panel: #161c25; --ink: #e8edf3; --sub: #9aa6b5; --line: #2a3340; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1rem; margin: 1.2em 0 .4em; }
p { margin: .5em 0; }
button, .button { font: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; min-height: 52px;
  margin: 10px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); font-weight: 600; cursor: pointer; text-align: center; }
button small, .button small { font-weight: 400; font-size: .8rem; color: var(--sub); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary small { color: rgba(255,255,255,.85); }
button.big { min-height: 64px; font-size: 1.1rem; }
button.link { border: 0; background: none; color: var(--sub); text-decoration: underline; min-height: 44px; font-weight: 400; }
button.danger { color: var(--notable); border-color: var(--notable); background: none; }
button.icon { width: 44px; min-height: 44px; margin: 0; padding: 0; border: 0; background: none; color: #fff; font-size: 2rem; line-height: 1; }
button:focus-visible, .button:focus-within { outline: 3px solid var(--ref); outline-offset: 2px; }
.bar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: calc(4px + env(safe-area-inset-top)) 8px 4px; background: var(--brand); color: #fff; }
.bar h1 { text-align: center; font-size: 1.05rem; }
.home .brand { background: var(--brand); color: #fff; margin: -16px -16px 16px; padding: calc(40px + env(safe-area-inset-top)) 20px 28px; }
.home .brand h1 { font-size: 2rem; letter-spacing: .04em; }
.eyebrow { font-size: .75rem; letter-spacing: .2em; color: #2ee6c8; margin: 0 0 4px; }
.lead { color: #c9d3df; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .card { margin: 0; min-height: 86px; }
.card span { font-weight: 400; font-size: .85rem; color: var(--sub); }
.fine { font-size: .8rem; color: var(--sub); }
.ver { text-align: center; }
.hint { color: var(--sub); font-size: .9rem; }
.error { color: var(--notable); font-weight: 600; }
.warn { background: color-mix(in srgb, var(--mild) 15%, transparent); border-left: 4px solid var(--mild); padding: 8px 12px; border-radius: 6px; font-size: .9rem; }
.center { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.spinner { width: 48px; height: 48px; border: 5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.steps { display: flex; gap: 6px; margin: 4px 0 12px; }
.steps span { flex: 1; text-align: center; font-size: .8rem; padding: 6px 0; border-radius: 999px; background: var(--line); color: var(--sub); }
.steps .on { background: var(--accent); color: #fff; font-weight: 700; }
.steps .done { background: var(--ref); color: #fff; }
.pose-hint { display: flex; gap: 12px; align-items: center; margin: 0 0 8px; padding: 12px; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); }
.pose-hint ul { margin: 0; padding-left: 1.2em; font-size: .9rem; }
.figure-icon { flex: 0 0 56px; height: 110px; background: linear-gradient(var(--ref), var(--ref)) center/3px 100% no-repeat; position: relative; }
.figure-icon::before { content: ""; position: absolute; left: 50%; top: 4px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--sub); }
.figure-icon::after { content: ""; position: absolute; left: 50%; top: 30px; width: 30px; height: 76px; margin-left: -15px; border-radius: 10px 10px 4px 4px; background: var(--sub); opacity: .7; }
.figure-icon.side::after { width: 16px; margin-left: -6px; }
.figure-icon.side::before { margin-left: -6px; }
.stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage canvas, .stage video { display: block; width: 100%; max-height: 62vh; object-fit: contain; }
video.mirror { transform: scaleX(-1); }
.count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 6rem; font-weight: 800; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.count.rec::after { content: ""; position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; border-radius: 50%; background: var(--notable); }
.level { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .85rem; text-align: center; }
.level.good { background: rgba(47,163,107,.85); }
.level.bad { background: rgba(229,72,77,.8); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
select, input[type=number] { font: inherit; width: 100%; min-height: 52px; margin: 10px 0; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.slider { display: block; margin: 14px 0; }
.slider input { width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.check input { width: 22px; height: 22px; margin-top: 3px; }
.field { display: block; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin: 4px 0 12px; }
.tabs button { margin: 0; min-height: 44px; border-radius: 999px; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: #000; }
.photo img, .photo canvas { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.photo .tag { position: absolute; top: 8px; padding: 2px 10px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: .85rem; font-weight: 700; }
.tag.l { left: 8px; } .tag.r { right: 8px; }
.src { font-size: .85rem; color: var(--sub); }
.scale { display: grid; grid-template-columns: 1fr 1fr 1fr; font-size: .75rem; color: var(--sub); margin: 14px 0 2px; }
.scale span:nth-child(2) { text-align: center; } .scale span:last-child { text-align: right; }
.metrics { list-style: none; margin: 0; padding: 0; }
.metric { padding: 8px 0; border-top: 1px solid var(--line); }
.mhead { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
.mhead b { text-align: right; font-weight: 600; }
.mhead em { font-style: normal; font-size: .75rem; padding: 1px 6px; border-radius: 4px; color: #fff; background: var(--mild); margin-left: 4px; }
.metric.notable .mhead em { background: var(--notable); }
.cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.cells i { height: 8px; border-radius: 4px; background: var(--line); }
.cells i.mid { outline: 2px solid var(--ref); outline-offset: 1px; }
.cells i.on { background: var(--ok); }
.cells i.on.mild { background: var(--mild); }
.cells i.on.notable { background: var(--notable); }
.cells.off { opacity: .4; }
.metric.na .mhead b { color: var(--sub); font-weight: 400; font-size: .85rem; }
.spread { color: var(--sub); }
.spark { margin: 8px 0; }
.spark svg { width: 100%; height: 80px; background: var(--bg); border-radius: 8px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark .axis { stroke: var(--ref); stroke-dasharray: 4 4; }
.spark figcaption { font-size: .75rem; color: var(--sub); }
.find { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--mild); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.find.notable { border-left-color: var(--notable); }
.find h3 { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.find h3 span { flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .8rem; display: flex; align-items: center; justify-content: center; }
.find h3 em { margin-left: auto; font-style: normal; font-size: .75rem; color: #fff; background: var(--mild); padding: 1px 8px; border-radius: 4px; white-space: nowrap; }
.find.notable h3 em { background: var(--notable); }
.habits { margin: 4px 0; padding-left: 1.2em; color: var(--sub); font-size: .9rem; }
.ex { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; padding: 0 14px; }
.ex summary { list-style: none; cursor: pointer; padding: 12px 0; display: flex; flex-direction: column; }
.ex summary::-webkit-details-marker { display: none; }
.ex summary span { font-size: .85rem; color: var(--sub); }
.ex ol { padding-left: 1.3em; }
.caution { background: color-mix(in srgb, var(--notable) 10%, transparent); border-radius: 8px; padding: 8px 12px; font-size: .85rem; }
.actions { margin-top: 20px; }
.list { list-style: none; padding: 0; margin: 0; }
.hist { align-items: flex-start; text-align: left; }
.hist span { font-weight: 400; font-size: .85rem; color: var(--sub); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.doc ul { padding-left: 1.2em; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20; max-width: 600px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--brand); color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.toast.update { display: flex; align-items: center; gap: 12px; }
.toast.update button { width: auto; min-height: 40px; margin: 0 0 0 auto; padding: 6px 14px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* Overlay legend (colors match js/draw.js COLORS) */
.legend { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .25rem; font-size: .78rem; color: var(--sub); }
.legend li { display: flex; align-items: center; gap: .45rem; }
.legend i { width: .8rem; height: .8rem; border-radius: 50%; flex: none; border: 1px solid var(--line); }
.lg-joint { background: #ff6b4a; } .lg-derived { background: #ffffff; } .lg-pelvisLine { background: #a078ff; }
.lg-ref { background: #2ee6c8; } .lg-neck { background: #4fc3ff; } .lg-upper { background: #a078ff; }
.lg-lower { background: #ff5fa2; } .lg-seat { background: #ffb03a; }
.metric .ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--sub); margin-top: .15rem; }
