/* Layout: one phone-first column (max ~720px), sticky tab bar, cards only for the coach and logged exercises. */
:root {
  --bg: #f3f4f2;
  --surface: #ffffff;
  --sunk: #e7e9e6;
  --fg: #16191c;
  --muted: #5d646b;
  --line: #d5d9d6;
  --accent: #1d5fc4;       /* competition-plate blue */
  --accent-ink: #ffffff;
  --accent-soft: #dce7f8;
  --good: #1f7a46;  --good-soft: #dcefe3;
  --warn: #9a6400;  --warn-soft: #f6ead0;
  --bad:  #b3261e;  --bad-soft: #f7dcda;
  --font-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111416; --surface: #1a1e21; --sunk: #23282c; --fg: #e9ecee; --muted: #9aa3aa; --line: #2e353a;
    --accent: #6fa3f2; --accent-ink: #0b1626; --accent-soft: #1c2c45;
    --good: #5cc98b; --good-soft: #17301f; --warn: #e2b04f; --warn-soft: #34290f; --bad: #f08a80; --bad-soft: #3a1a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111416; --surface: #1a1e21; --sunk: #23282c; --fg: #e9ecee; --muted: #9aa3aa; --line: #2e353a;
  --accent: #6fa3f2; --accent-ink: #0b1626; --accent-soft: #1c2c45;
  --good: #5cc98b; --good-soft: #17301f; --warn: #e2b04f; --warn-soft: #34290f; --bad: #f08a80; --bad-soft: #3a1a17;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 720px; margin: 0 auto; padding-inline: 16px; padding-block: 0 96px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: .01em; text-wrap: balance; margin: 0; line-height: 1.05; }
h1 { font-size: 30px; text-transform: uppercase; }
h2 { font-size: 22px; text-transform: uppercase; }
h3 { font-size: 17px; text-transform: uppercase; }
.num, .mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 18px 10px; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .mark { align-self: center; flex: none; border-radius: 7px; }
.brand .plate { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 5px var(--accent), inset 0 0 0 7px var(--surface); align-self: center; flex: none; }
.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.unit-toggle button { border: 0; background: transparent; padding: 4px 12px; font-family: var(--font-data); font-size: 13px; }
.unit-toggle button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

/* Tabs (bottom bar) */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom, 0px); }
nav.tabs .in { display: flex; width: 100%; max-width: 720px; }
nav.tabs button { flex: 1; border: 0; background: transparent; padding: 12px 4px 14px; font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: 16px; letter-spacing: .04em; color: var(--muted); border-top: 3px solid transparent; }
nav.tabs button[aria-selected="true"] { color: var(--fg); border-top-color: var(--accent); }

.banner { background: var(--warn-soft); color: var(--fg); border-radius: var(--r); padding: 10px 12px; font-size: 13px; margin-block: 4px 12px; }
.banner b { color: var(--warn); }

/* Day nav */
.daynav { display: flex; align-items: center; gap: 8px; margin-block: 6px 14px; }
.daynav .d { flex: 1; min-width: 0; }
.daynav .d .big { font-family: var(--font-display); font-weight: 800; font-size: 26px; text-transform: uppercase; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 18px; display: grid; place-items: center; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: var(--sunk); color: var(--muted); }

/* Coach */
.coach { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; margin-bottom: 16px; }
.coach .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.msgs { display: grid; gap: 8px; }
.msg { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; font-size: 14px; }
.msg .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 800; font-family: var(--font-data); }
.msg.bad .ic { background: var(--bad-soft); color: var(--bad); }
.msg.warn .ic { background: var(--warn-soft); color: var(--warn); }
.msg.good .ic { background: var(--good-soft); color: var(--good); }
.msg.info .ic { background: var(--accent-soft); color: var(--accent); }
.msg b { font-weight: 700; }
.notecard { display: grid; gap: 6px; margin-bottom: 12px; }
.notecard textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); resize: vertical; font-size: 15px; line-height: 1.4; }
.issues { display: flex; flex-wrap: wrap; gap: 6px; }
.issues .pill { gap: 4px; padding-right: 4px; }
.chipx { border: 0; background: transparent; color: inherit; font-size: 13px; font-weight: 700; padding: 0 4px; border-radius: 999px; }
.chipx.ok { font-size: 11px; background: var(--good-soft); color: var(--good); padding: 1px 6px; }
.swaps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.swaps .chipbtn { padding: 3px 10px; font-size: 12px; background: var(--surface); }
.today-plan { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-block: 10px; display: grid; gap: 4px; }
.today-plan .label { display: flex; align-items: center; gap: 8px; }
.today-plan .pt { font-family: var(--font-display); font-weight: 800; font-size: 24px; text-transform: uppercase; line-height: 1.1; }
.today-plan .why { margin: 2px 0 4px; padding-left: 18px; font-size: 13px; color: var(--muted); }
.today-plan .suggest { margin-top: 4px; }
.adapt { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; }
.adapt ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; display: grid; gap: 2px; }
.eqmax { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ahead { display: grid; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.ahead .ad { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.ahead .ad b { width: 32px; flex: none; }
.ahead .ad span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.chipbtn:hover { border-color: var(--accent); }
.chipbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Readiness grid */
.ready { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
.ready .m { border-radius: 6px; padding: 5px 8px; font-size: 12px; display: flex; justify-content: space-between; gap: 4px; background: var(--sunk); }
.ready .m span:last-child { font-family: var(--font-data); }
.ready .m.fresh { background: var(--good-soft); color: var(--good); }
.ready .m.rec { background: var(--warn-soft); color: var(--warn); }
.ready .m.fat { background: var(--bad-soft); color: var(--bad); }
details.fold > summary { cursor: pointer; list-style: none; font-size: 13px; color: var(--muted); font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸ "; }
details.fold[open] > summary::before { content: "▾ "; }

/* Entries */
.entries { display: grid; gap: 10px; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 10px; }
.entry.complete { border-color: var(--good); }
.entry .eh { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.entry .eh .nm { font-weight: 700; font-size: 16px; }
.entry .eh .sub { font-size: 12px; color: var(--muted); }
.entry .x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px; }
.setrow { display: grid; grid-template-columns: 28px 1fr 1fr 44px; gap: 8px; align-items: center; }
.setrow .idx { font-family: var(--font-data); color: var(--muted); font-size: 13px; text-align: center; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); min-width: 0; }
.stepper button { border: 0; background: transparent; width: 32px; height: 38px; font-size: 18px; color: var(--muted); flex: none; }
.stepper input { border: 0; background: transparent; width: 100%; min-width: 0; text-align: center; font-family: var(--font-data); font-size: 15px; padding: 0; height: 38px; }
.stepper .u { font-size: 11px; color: var(--muted); padding-right: 6px; font-family: var(--font-data); }
.check { width: 44px; height: 38px; border-radius: 8px; border: 2px solid var(--line); background: transparent; font-size: 18px; color: transparent; }
.check[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: var(--surface); }
.entry .foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.effort { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.effort button { border: 0; background: transparent; padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.effort button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.linkbtn { border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 0; }
.hint { font-size: 12px; border-radius: 6px; padding: 6px 8px; }
.hint.warn { background: var(--warn-soft); color: var(--warn); }
.hint.bad { background: var(--bad-soft); color: var(--bad); }
.hint.info { background: var(--accent-soft); color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

.empty { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 20px 16px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }

/* Sheet */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 720px; max-height: 86%; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }
.sheet .sh { padding: 14px 16px 8px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.sheet .sb { overflow-y: auto; padding: 8px 16px 16px; }
.search { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.exrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; background: transparent; border-inline: 0; border-top: 0; text-align: left; }
.exrow .l { min-width: 0; }
.exrow .l div:first-child { font-weight: 600; }
.grouphdr { margin-top: 12px; }
.help { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-size: 12px; font-weight: 700; line-height: 1; padding: 0; display: inline-grid; place-items: center; vertical-align: 2px; flex: none; font-family: var(--font-body); }
.help:hover { background: var(--accent); color: var(--accent-ink); }
.exline { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.exline .exrow { border-bottom: 0; flex: 1; min-width: 0; }
.routine-items { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.routine-items span { display: inline-flex; align-items: center; gap: 4px; }
.routine-items .help { width: 18px; height: 18px; font-size: 11px; }
#help .sheet-bg { z-index: 25; }
.sheet.guide h3 { margin: 14px 0 6px; font-size: 15px; color: var(--accent); }
.sheet.guide ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; line-height: 1.5; max-width: 62ch; }
.sheet.guide ul.steps { list-style: decimal; }
.sheet.guide ul.mistakes li::marker { content: "✕  "; color: var(--bad); }
.sheet.guide ul.cues li::marker { content: "✓  "; color: var(--good); }
@media (min-width: 900px) { #help .sheet-bg { justify-content: flex-end; align-items: stretch; } #help .sheet { max-width: 440px; max-height: none; height: 100%; border-radius: 0; border-left: 1px solid var(--line); } }

/* Progress */
section.block { display: grid; gap: 10px; margin-block: 18px 26px; }
.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-width: 0; }
.stat .v { font-family: var(--font-data); font-size: 20px; font-weight: 500; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-family: var(--font-data); font-size: 10px; }
.tip { position: absolute; pointer-events: none; background: var(--fg); color: var(--bg); font-size: 12px; border-radius: 6px; padding: 4px 8px; white-space: nowrap; font-family: var(--font-data); transform: translate(-50%, -110%); }
select.sel { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); width: 100%; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 96px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; }
.bar .track { position: relative; height: 14px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.bar .band { position: absolute; top: 0; bottom: 0; background: var(--good-soft); border-inline: 1px dashed var(--good); }
.bar .fill { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.bar .fill.over { background: var(--bad); }
.bar .cfill { position: absolute; top: 3px; bottom: 3px; border-left: 2px solid var(--sunk); border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(135deg, var(--accent) 0 2px, var(--accent-soft) 2px 5px); }
.bar { grid-template-columns: 96px 1fr 64px; }
.bar .usual { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--fg); opacity: .6; border-radius: 1px; }
.bar .fill.warnf { background: var(--warn); }
.hot { color: var(--bad); font-weight: 700; }
.bar .v.hot { color: var(--bad); }
.sw.usual { width: 2px; height: 12px; background: var(--fg); opacity: .6; }
.bar .track { overflow: visible; }
.bar .cv { color: var(--muted); font-size: 11px; margin-left: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 8px; border-radius: 2px; }
.sw.lift { background: var(--accent); }
.sw.cardio { background: repeating-linear-gradient(135deg, var(--accent) 0 2px, var(--accent-soft) 2px 5px); }
.bar .v { font-family: var(--font-data); text-align: right; }
table.vt { border-collapse: collapse; width: 100%; font-size: 13px; }
table.vt th { text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.vt td { text-align: right; padding: 6px; border-bottom: 1px solid var(--line); font-family: var(--font-data); font-variant-numeric: tabular-nums; }
table.vt th:first-child, table.vt td:first-child { text-align: left; font-family: var(--font-body); }
.hist { display: grid; }
.hist button { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; width: 100%; }
.hist button .l { min-width: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; background: var(--surface); }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: 15px; letter-spacing: .04em; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.mw { display: grid; grid-template-columns: 88px repeat(8, minmax(0, 1fr)); gap: 3px; align-items: center; font-size: 12px; }
.mw .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw .h { font-family: var(--font-data); font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; }
.mw .c { font-family: var(--font-data); font-variant-numeric: tabular-nums; text-align: center; border-radius: 4px; padding: 3px 0; background: var(--sunk); color: var(--muted); }
.mw .c.ok { background: var(--good-soft); color: var(--good); }
.mw .c.lo { background: var(--warn-soft); color: var(--warn); }
.mw .c.hi { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.mw .c.opt { color: var(--fg); }
.mw .c.na { background: transparent; }
.sw.ok { background: var(--good-soft); box-shadow: inset 0 0 0 1px var(--good); }
.sw.lo { background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn); }
.sw.hi { background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
/* Exercise ↔ muscle map */
.bp { position: relative; display: grid; grid-template-columns: minmax(0, 1.3fr) 48px minmax(0, 1fr); align-items: start; }
.bp svg.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.bp .col { display: grid; gap: 3px; position: relative; z-index: 1; min-width: 0; }
.bp .col.exs { grid-column: 1; }
.bp .col.mus { grid-column: 3; position: sticky; top: 8px; }
.bp .node { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 12px; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 6px; min-width: 0; }
.bp .node span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp .node .k { font-family: var(--font-data); color: var(--muted); font-size: 11px; }
.bp .node.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bp .node.lit { border-color: var(--accent); }
.bp .node.dim { opacity: .4; }
.bp .exn { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bp .exn .node { flex: 1; }
.bp .exn .help { width: 18px; height: 18px; font-size: 11px; }
.bp .node .used { width: 6px; height: 6px; border-radius: 50%; background: var(--good); flex: none; }
.bp .glbl { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-top: 6px; }
.bpd { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 6px; }
.bpd .eh { display: flex; align-items: center; gap: 8px; }
.bpd .eh b { flex: 1; min-width: 0; }
.bpd .x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px; }

/* Library */
.list { display: grid; }
.list .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .row .l { min-width: 0; }
form.custom { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
form.custom input[type=text], form.custom select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.mgrid { display: flex; flex-wrap: wrap; gap: 6px; }
.mgrid button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.mgrid button[data-w="1"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mgrid button[data-w="0.5"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 30; }
@media (prefers-reduced-motion: no-preference) { .entry, .msg { transition: border-color .2s; } }
