:root {
  --bg: #f6f7f4; --card: #ffffff; --ink: #1d2320; --muted: #5d6762; --line: #d9ddd8;
  --accent: #2f6b4f; --accent-ink: #ffffff; --done: #2f6b4f; --done-bg: #e3f0e8; --warn: #9a3d22;
  --s1: #1a7f50; --s2: #b0731a;   /* chart series, checked with the dataviz validator (#623) */
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --card: #1b201d; --ink: #e8ece9; --muted: #a2aca6; --line: #2e3531;
    --accent: #6cc196; --accent-ink: #0d1a13; --done: #8fd6af; --done-bg: #1f3529; --warn: #f0a084;
    --s1: #45a877; --s2: #c4822a;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --card: #1b201d; --ink: #e8ece9; --muted: #a2aca6; --line: #2e3531;
  --accent: #6cc196; --accent-ink: #0d1a13; --done: #8fd6af; --done-bg: #1f3529; --warn: #f0a084;
  --s1: #45a877; --s2: #c4822a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* author display rules (nav { display: flex }) would beat the attribute */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.bar { position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 16px 0; }
.bar h1 { margin: 0 0 8px; font-size: 1.15rem; letter-spacing: .01em; }
nav { display: flex; gap: 4px; overflow-x: auto; }
.tab { flex: 1 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 8px 10px 9px; font: inherit; font-weight: 600; cursor: pointer; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 96px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: .92rem; }
.run { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.run .big { font-size: 1.6rem; font-weight: 700; }
.item { display: flex; align-items: center; gap: 12px; }
.item .name { flex: 1; min-width: 0; }
.item .name strong { display: block; overflow-wrap: anywhere; }
.item.met { background: var(--done-bg); border-color: var(--done); }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.check { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--accent); font-size: 1.3rem; cursor: pointer; flex: none; }
.check[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.slots { display: flex; gap: 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 44px; width: 100%; }
input.num { width: 96px; text-align: right; }
label { display: block; font-weight: 600; margin: 10px 0 4px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.inline input { width: auto; min-height: 0; }
.btn { display: inline-block; font: inherit; font-weight: 600; min-height: 44px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; border-color: var(--warn); color: var(--warn); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#devices .row input { flex: 1 1 160px; width: auto; }
[data-workout] .name { flex: 1 1 160px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.err { color: var(--warn); }
#toast { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 560px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; }
.code { font-family: ui-monospace, monospace; font-size: .85rem; overflow-wrap: anywhere; background: var(--bg); padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
details summary .badge { margin-left: 0; white-space: nowrap; }
@media (min-width: 720px) {
  main { padding-top: 24px; }
  .bar { padding-left: max(16px, calc(50% - 304px)); padding-right: max(16px, calc(50% - 304px)); }
  nav { overflow: visible; }
  .tab { flex: 0 0 auto; }
}
textarea { resize: vertical; min-height: 96px; }
.spread { justify-content: space-between; }
.spread h2 { margin: 12px 0 4px; }
.nudge { border-color: var(--accent); }
.nudge .name { flex: 1 1 180px; }
[data-confirm] .row { padding: 6px 0; border-bottom: 1px solid var(--line); }
[data-confirm] .row .name { flex: 1 1 160px; }
[data-confirm] > .btn { margin-top: 10px; }
[data-open-workout] .name { flex: 1 1 160px; }
.btn.wide { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* S8 #423: the crew feed */
button.card.item { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
[data-feed-day] > p { margin: 0 0 4px; }
.feed { padding: 4px 0; }
.feed .name { flex: 1 1 200px; overflow-wrap: anywhere; }
/* #433: the lift log */
.lift-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lift-row .ex { flex: 1 1 100%; }
.lift-row .n { width: 56px; text-align: right; padding: 9px 6px; }
.lift-row select { width: auto; }
.lift-row .btn { min-width: 44px; padding: 9px 0; }
[data-lift-confirm] > .btn { margin-top: 10px; }
.lift-hist { margin: 6px 0 0; padding-left: 18px; }
.lift-hist li { overflow-wrap: anywhere; }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 8px; }
/* #422: voice notes */
[data-voice] audio { width: 100%; margin: 4px 0 8px; }
[data-voice] textarea { min-height: 72px; }
[data-voice] select { margin-top: 8px; }
[data-voice] .row { margin-top: 10px; }
[data-voice] p { margin: 0 0 6px; }
[data-voice-prompt] p, [data-voice-new] p { margin: 0 0 8px; }
[data-voice-prompt] > .btn { margin-top: 8px; }
.btn.pick { position: relative; margin: 0; }
.btn.rec { background: var(--warn); border-color: var(--warn); }
/* S9-1 #424: history */
#histitem { margin: 0 0 10px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { text-align: center; font-size: .8rem; color: var(--muted); font-weight: 600; }
.cal .day { min-height: 44px; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; padding: 0; position: relative; }
.cal .day:disabled { cursor: default; color: var(--muted); background: transparent; border-style: dashed; }
.cal .day.future { border-color: transparent; }
.cal .day.complete, .cal .day.met { background: var(--done); border-color: var(--done); color: var(--accent-ink); }
.cal .day.partial { background: color-mix(in srgb, #c08a1e 30%, var(--card)); border-color: #c08a1e; }
.cal .day.missed, .cal .day.not_met { background: color-mix(in srgb, var(--warn) 22%, var(--card)); border-color: var(--warn); }
.cal .day.not_reviewed { background: var(--card); border-style: dotted; border-color: var(--muted); }
.cal .day.inrun::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: 4px; height: 3px; border-radius: 2px; background: var(--accent); }
.cal .day.complete.inrun::after, .cal .day.met.inrun::after { background: var(--accent-ink); }
.cal .day.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.swatch.complete, .swatch.met { background: var(--done); border-color: var(--done); }
.swatch.partial { background: color-mix(in srgb, #c08a1e 30%, var(--card)); border-color: #c08a1e; }
.swatch.missed, .swatch.not_met { background: color-mix(in srgb, var(--warn) 22%, var(--card)); border-color: var(--warn); }
.swatch.not_reviewed { border-style: dotted; border-color: var(--muted); }
.swatch.off { border-style: dashed; }
.swatch.inrun { height: 3px; border: 0; background: var(--accent); }
.streaks { gap: 20px; flex-wrap: nowrap; }
p.entries { margin: -4px 4px 10px; }
/* S9-2 #622: the check-in */
.hint { margin: 0 0 6px; }
.rate { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 4px 0; }
.rate .rname { flex: 1 1 96px; font-weight: 600; }
.seg { display: flex; gap: 4px; }
.pip { width: 40px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.pip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: .92rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.static { cursor: default; min-height: 0; padding: 2px 10px; }
.tags { margin: 10px 0 4px; gap: 6px; }
.addtag { margin: 6px 0; flex-wrap: nowrap; }
.addtag input { flex: 1 1 auto; width: auto; min-width: 0; }
.addtag .btn { white-space: nowrap; }
.why { gap: 6px; margin: -4px 0 12px; }
.why > .muted { flex: 1 0 100%; }
@media (max-width: 420px) {   /* seven tabs fit at 390 px (#424) */
  .bar { padding-left: 8px; padding-right: 8px; }
  nav { gap: 0; }
  .tab { padding: 8px 3px 9px; font-size: .84rem; }
}
/* S9-3 #623: trends */
.seg-range { gap: 6px; margin: 0 0 6px; }
.trend-item .rate-n { font-weight: 600; white-space: nowrap; }
.trend-item .name .muted { display: block; }
.tr-chart { margin: 4px 0 8px; }
.tr-chart svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.tr-chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.tr-chart .grid { stroke: var(--line); stroke-width: 1; }
.tr-chart .axis { fill: var(--muted); font-size: 10px; }
.tr-chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tr-chart .ln.ref { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1.5; }
.tr-chart .s1 { stroke: var(--s1); } .tr-chart .s2 { stroke: var(--s2); }
.tr-chart .dot { stroke: var(--card); stroke-width: 2; } .tr-chart .dot.s1 { fill: var(--s1); } .tr-chart .dot.s2 { fill: var(--s2); }
.tr-chart .bar.s1 { fill: var(--s1); stroke: none; }
.tr-chart .cross { stroke: var(--ink); stroke-width: 1; opacity: .5; }
.tr-chart .hit { fill: transparent; cursor: pointer; }
.tr-chart .readout { margin: 2px 0 0; min-height: 1.4em; }
.tr-chart .legend { margin: 0 0 4px; }
.key { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.key.s1 { border-color: var(--s1); } .key.s2 { border-color: var(--s2); }
.key.round { width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--s2); }
.key.ref { border-top: 2px dashed var(--muted); }
.nums { margin: 4px 0 0; padding-left: 18px; font-size: .92rem; }
/* S9-4 #624: the weekly card (top of History) and its line on Review */
.week h2 { margin-top: 0; }
.week p { margin: 4px 0; }
.week .big { font-size: 1.25rem; font-weight: 700; }
.week .noticed { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.btn.week-line { text-align: left; margin: 0 0 10px; }
