/* Flexibility & Mobility Coach — mobile-first, no dependencies */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --good: #22a15c;      /* score 3 */
  --limited: #eab308;   /* score 2 */
  --restricted: #f97316;/* score 1 */
  --pain: #dc2626;      /* score 0 */
  --none: #cbd5e1;      /* not assessed */
  --body-fill: #e8edf3;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { margin: 0 0 8px; font-size: 1.15rem; }
nav { display: flex; gap: 2px; overflow-x: auto; }
nav button {
  border: none; background: none; padding: 8px 12px 10px;
  font-size: .92rem; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
nav button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 860px; margin: 0 auto; padding: 16px; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 10px; font-size: 1.2rem; }
.card h3 { margin: 18px 0 6px; font-size: 1rem; }
.card h4 { margin: 0 0 6px; }
.card ol, .card ul { margin: 6px 0; padding-left: 22px; }
.card li { margin: 3px 0; }
.muted { color: var(--muted); font-size: .88rem; }
.small { font-size: .82rem; }
.note { color: var(--accent); font-size: .9rem; margin: 4px 0; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
a { color: var(--accent); }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .85em; }

.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; font-size: .92rem; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: none; }
.btn.danger { border-color: var(--pain); color: var(--pain); }
.btn.small { padding: 5px 10px; font-size: .85rem; margin-bottom: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Progress bar */
.progressbar {
  height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 14px;
}
.progressbar div { height: 100%; background: var(--accent); transition: width .3s; }

/* Test list */
.testlist { display: flex; flex-direction: column; gap: 6px; }
.testrow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit;
}
.testrow:hover { border-color: var(--accent); }
.testnum {
  flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--line);
  display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600;
}
.testname { flex: 1; font-weight: 600; font-size: .95rem; }
.testname small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.teststatus { display: flex; gap: 6px; align-items: center; font-size: .8rem; color: var(--muted); }

/* Badges & score colors */
.badge {
  display: inline-block; min-width: 24px; text-align: center;
  padding: 1px 7px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: #fff;
}
.badge.todo { background: var(--none); color: var(--ink); font-weight: 500; }
.badge.score-3, .cell.score-3 { background: var(--good); }
.badge.score-2, .cell.score-2 { background: var(--limited); color: #3b3000; }
.badge.score-1, .cell.score-1 { background: var(--restricted); }
.badge.score-0, .cell.score-0 { background: var(--pain); }
.badge.score-none { background: var(--none); color: var(--ink); }

/* Rubric table */
.rubric { border-collapse: collapse; width: 100%; }
.rubric td { border-top: 1px solid var(--line); padding: 6px 8px 6px 0; vertical-align: top; font-size: .92rem; }
.rubric td:first-child { width: 48px; }

/* Score input */
.scorebox {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin: 10px 0;
}
.scorepick { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.scoreopt {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--card);
}
.scoreopt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.2); }
.measure { display: block; margin: 8px 0; font-size: .92rem; }
.measure input[type="number"] { width: 90px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; margin-top: 4px;
}
.links { font-size: .88rem; }

/* Flags */
.flag {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: 8px; padding: 10px 12px; font-size: .92rem;
}

/* Body map */
.bodymap-wrap { max-width: 480px; margin: 0 auto; }
#bodymap-svg { width: 100%; height: auto; display: block; }
.bodypart { fill: var(--body-fill); stroke: #c7d2de; stroke-width: 1; }
.region { stroke: #ffffff; stroke-width: 1.5; cursor: pointer; transition: opacity .15s; }
.region:hover { opacity: .8; }
.region.selected { stroke: var(--ink); stroke-width: 2.5; }
.region.score-3 { fill: var(--good); }
.region.score-2 { fill: var(--limited); }
.region.score-1 { fill: var(--restricted); }
.region.score-0 { fill: var(--pain); }
.region.score-none { fill: var(--none); }
.sidelabel { font-size: 13px; fill: var(--muted); font-weight: 700; }
.figlabel { font-size: 14px; fill: var(--muted); text-anchor: middle; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: .85rem; margin: 10px 0; }
.legend .chip {
  display: inline-block; width: 13px; height: 13px; border-radius: 3px; margin-right: 4px; vertical-align: -1px;
}
.chip.score-3 { background: var(--good); }
.chip.score-2 { background: var(--limited); }
.chip.score-1 { background: var(--restricted); }
.chip.score-0 { background: var(--pain); }
.chip.score-none { background: var(--none); }

.region-panel {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-top: 10px;
}
.region-panel h3 { margin-top: 0; }

/* Plan */
.planlist { display: flex; flex-direction: column; gap: 10px; }
.planitem { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.planitem p { margin: 6px 0 0; font-size: .92rem; }

/* Progress table */
.tablewrap { overflow-x: auto; }
table.progress { border-collapse: collapse; width: 100%; font-size: .88rem; }
table.progress th, table.progress td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.progress .cell {
  display: inline-block; min-width: 22px; text-align: center; border-radius: 5px;
  font-weight: 700; color: #fff; padding: 0 4px;
}
.up { color: var(--good); font-weight: 700; }
.down { color: var(--pain); font-weight: 700; }

/* Modal */
.modal {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50;
  align-items: center; justify-content: center; padding: 16px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card); border-radius: var(--radius); max-width: 520px;
  padding: 22px; max-height: 85vh; overflow-y: auto;
}
.modal-box h2 { margin-top: 0; }

@media (max-width: 480px) {
  main { padding: 10px; }
  .card { padding: 14px; }
  nav button { padding: 8px 9px 10px; font-size: .85rem; }
}
