:root {
  --bg: #f4f4f2; --card: #fff; --ink: #141414; --muted: #6b6b6b; --line: #e3e3df;
  --bar: #111; --blue: #1f5fd1; --blue-bg: #eaf1ff; --green: #1e9e55; --green-bg: #dcf5e6;
  --grey-bg: #f0f0ee; --warn: #b54708; --warn-bg: #fff4e5; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.small { font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: var(--bar); color: #fff; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.brand { font-weight: 800; letter-spacing: .08em; font-size: 13px; }
.who { flex: 1; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync { font-size: 12px; opacity: .9; }
.sync.err { color: #ffb4a8; opacity: 1; }

main { padding: 12px 12px 90px; max-width: 720px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { flex: 1; border: 0; background: none; padding: 12px 4px 14px; font-weight: 600; color: var(--muted); }
.tabs button.on { color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }

/* week header */
.weekbar { display: flex; align-items: center; gap: 8px; }
.weekbar .t { flex: 1; text-align: center; }
.weekbar .t b { display: block; font-size: 17px; }
.iconbtn { border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 42px; height: 42px; font-size: 20px; }
.iconbtn:disabled { opacity: .3; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--grey-bg); }
.pill.deload { background: var(--warn-bg); color: var(--warn); }
.pill.done { background: var(--green-bg); color: var(--green); }
.linkbtn { border: 0; background: none; color: var(--blue); padding: 6px 0; font-weight: 600; }

.days { display: flex; gap: 6px; overflow-x: auto; margin: 0 -12px 12px; padding: 0 12px; scrollbar-width: none; }
.days button { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; text-align: left; }
.days button small { display: block; color: var(--muted); font-size: 12px; }
.days button.on { background: var(--bar); color: #fff; border-color: var(--bar); }
.days button.on small { color: #ccc; }
.days button.isdone::after { content: " ✓"; color: var(--green); font-weight: 800; }

.sessionbar { background: var(--bar); color: #fff; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; font-weight: 800; letter-spacing: .04em; }

/* exercise */
.ex h3 { font-size: 16px; }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.cue { font-size: 13px; background: var(--grey-bg); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.hint { font-size: 13px; border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.hint.increase { background: var(--green-bg); color: #0f6b38; font-weight: 600; }
.hint.hold { background: var(--blue-bg); color: #1b4aa3; }
.hint.deload { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.altrow { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; }
.altrow select { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }

table.sets { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.sets th { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 2px; }
table.sets th.in { color: var(--blue); }
table.sets td { text-align: center; padding: 3px 2px; font-size: 14px; }
table.sets td.plan { background: var(--grey-bg); white-space: nowrap; font-size: 13px; padding: 3px 4px; }
table.sets td.last { font-size: 12px; color: var(--muted); white-space: nowrap; }
table.sets input { width: 100%; min-width: 0; max-width: 64px; padding: 9px 2px; text-align: center; border: 1px solid #c9d6f2;
  border-radius: 8px; background: var(--blue-bg); font-size: 16px; }
table.sets tr.beat input { background: var(--green-bg); border-color: #9ad8b3; }
table.sets tr.skip td { opacity: .45; }
table.sets input.invalid { border-color: #d33; background: #ffecec; }
.notes, .setup { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-height: 40px; resize: vertical; font-size: 14px; }
label.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }

.donebtn { width: 100%; border: 0; border-radius: var(--radius); padding: 16px; font-size: 16px; font-weight: 800;
  background: var(--bar); color: #fff; letter-spacing: .04em; }
.donebtn.isdone { background: var(--green); }

/* overview */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.grid th { font-size: 12px; color: var(--muted); }
table.grid tr.cur td { font-weight: 700; }
table.grid td.num, table.grid th.num { text-align: right; }

/* body */
.daypick { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 600; }
.backfill { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; margin-top: 8px; }
.field { display: grid; grid-template-columns: 1fr 110px 80px; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field input { width: 100%; padding: 10px 6px; text-align: center; border: 1px solid #c9d6f2; border-radius: 8px; background: var(--blue-bg); font-size: 16px; }
.field .saved { text-align: right; color: var(--muted); font-size: 13px; }
.field .saved b { color: var(--ink); }

/* progress */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--grey-bg); border-radius: 10px; padding: 10px; }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat b { font-size: 18px; }
svg.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.guide p, .guide li { font-size: 14px; }
.guide ul { padding-left: 18px; margin: 6px 0; }
.safety { background: var(--warn-bg); color: #7a2e00; }
.err-box { background: #ffecec; border: 1px solid #f3b6b6; border-radius: var(--radius); padding: 16px; }
