:root {
  --bg: #eef1f2; --surface: #ffffff; --ink: #171b1e; --muted: #5d676e; --line: #d5dbdf;
  --accent: #1d5fa8; --accent-ink: #ffffff; --done: #2f7d4f; --done-soft: #dff0e5; --warn-soft: #f6ecd2; --error: #b3261e;
  --display: "Space Grotesk", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --surface: #1d2226; --ink: #eceff1; --muted: #9aa5ad; --line: #323a40;
    --accent: #6ea8e6; --accent-ink: #0d1318; --done: #6cc08a; --done-soft: #1f3327; --warn-soft: #3a3220; --error: #f2877f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); }
h1, h2, h3, p { margin: 0; }
h1 { font: 700 26px/1.2 var(--display); letter-spacing: -0.01em; }
h2 { font: 600 13px/1.3 var(--display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
h3 { font: 600 16px/1.3 var(--display); }
a { color: var(--accent); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); font-size: 13.5px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid, .grid.even { grid-template-columns: minmax(0, 1fr); } }

.bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding-top: 10px; padding-bottom: 10px; }
.brand { font: 700 17px var(--display); color: var(--ink); text-decoration: none; }
.bar nav { display: flex; gap: 4px; flex: 1; }
.bar nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.bar nav a.on { background: var(--bg); color: var(--ink); }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; }
.day-nav, .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }

.btn { display: inline-block; border: 1px solid var(--accent); border-radius: 8px; padding: 7px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn.ghost:hover { border-color: var(--accent); }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
input[type=text], input[type=email], input[type=password] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Today: one column, the same on phone and Mac */
.today { max-width: 640px; margin: 0 auto; }
.today.with-rest-bar { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
.session-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: -4px; }

/* Exercise card with Strong-style set rows */
.exercise { gap: 8px; }
.ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ex-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.exercise.complete h3 { color: var(--done); }
.dose { font: 600 15px var(--display); color: var(--accent); white-space: nowrap; }
.ex-count { font: 600 13px var(--display); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }
.exercise.complete .ex-count { color: var(--done); }
.note { color: var(--muted); font-size: 13.5px; }
.target { align-self: flex-start; font-size: 13.5px; background: var(--bg); border-radius: 8px; padding: 5px 10px; }
.target-up, .target-harder { background: var(--done-soft); color: var(--done); font-weight: 600; }
.target-first { color: var(--muted); }
.ex-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.ex-links:empty { display: none; }

.sets { width: 100%; border-collapse: separate; border-spacing: 0 4px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sets th { font: 600 11px var(--display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-align: left; padding: 0 6px 2px; }
.sets td { padding: 4px 6px; vertical-align: middle; background: transparent; }
.sets td:first-child { border-radius: 8px 0 0 8px; }
.sets td:last-child { border-radius: 0 8px 8px 0; }
.sets .c-set { width: 36px; text-align: center; font: 600 14px var(--display); color: var(--muted); }
.sets .c-prev { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.sets .c-prev .none { opacity: 0.6; }
.sets .c-in { width: 84px; }
.sets .c-tick { width: 52px; text-align: right; }
.sets input { width: 100%; min-width: 0; padding: 8px 8px; font-size: 16px; text-align: center; color: var(--ink); }
.sets input:disabled { background: transparent; border-color: transparent; color: var(--ink); opacity: 1; -webkit-text-fill-color: var(--ink); }
.sets tr.done td { background: var(--done-soft); }
.sets tr.done .c-set { color: var(--done); }
.tick { width: 44px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 18px; line-height: 1; }
.tick:hover { border-color: var(--done); color: var(--done); }
.tick[aria-pressed=true] { background: var(--done); border-color: var(--done); color: var(--surface); }
.sets tr.row-error td { background: transparent; color: var(--error); font-size: 13px; padding-top: 0; }
@media (max-width: 420px) {
  .sets .c-set { width: 28px; }
  .sets .c-in { width: 68px; }
  .sets .c-prev { font-size: 12.5px; }
}

.done-toggle { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 14px 8px 8px; font-weight: 600; }
.done-toggle .tick-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.done-toggle:hover { border-color: var(--done); }
.done-toggle.on { background: var(--done-soft); border-color: var(--done-soft); color: var(--done); }
.done-toggle.on .tick-mark { background: var(--done); border-color: var(--done); color: var(--surface); }

/* Rest timer bar, fixed to the bottom while a session is open today */
.rest-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / 0.06); padding-bottom: env(safe-area-inset-bottom, 0px); }
.rest-in { max-width: 640px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.rest-read { display: flex; align-items: baseline; gap: 10px; }
.rest-time { font: 700 32px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; min-width: 3.2ch; }
.rest-status { color: var(--muted); font-size: 13.5px; }
.rest-bar.running .rest-time { color: var(--accent); }
.rest-bar.go { background: var(--done-soft); }
.rest-bar.go .rest-time, .rest-bar.go .rest-status { color: var(--done); font-weight: 600; }
.rest-controls .actions { align-items: center; }

.set-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.set-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.set-form input { width: 96px; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }

.chips { display: flex; gap: 8px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed=true] { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Break snacks */
.count { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.hit { color: var(--done); font-weight: 600; }
/* Snack meter: four segments, the target after the second */
.snack-meter { display: flex; align-items: center; gap: 14px; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: 1 1 auto; min-width: 96px; max-width: 160px; }
.meter .seg { height: 10px; border-radius: 3px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.meter .seg.goal { position: relative; }
.meter .seg.goal::after { content: ""; position: absolute; right: -3px; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--muted); }
.meter .seg.filled { background: var(--accent); box-shadow: none; }
.snack-meter.hit .seg.filled { background: var(--done); }
.meter-label { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-label strong { color: var(--ink); font-weight: 600; }
.snack-meter.hit .meter-label strong { color: var(--done); }

/* This week, Monday to Friday */
.week-dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.wd-dot { display: block; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; }
.wd-some .wd-dot { border-color: var(--accent); background: linear-gradient(to top, var(--accent) 50%, transparent 50%); }
.wd-hit .wd-dot { border-color: var(--done); background: var(--done); }
.wd-future .wd-dot { border-style: dashed; }
.wd-name { font: 600 10px var(--display); color: var(--muted); line-height: 1; }
.wd.current .wd-name { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a.wd-dot:hover { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent); }

.snacks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.snacks li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.snacks li:first-child { border-top: 0; padding-top: 0; }
.snack-text { flex: 1; min-width: 0; }
.snack-text .name { display: block; font-weight: 500; }
.snack-text .how { display: block; color: var(--muted); font-size: 13.5px; }
.snack-text .how a, .ex-links a { white-space: nowrap; }
.snacks li.did .name { color: var(--done); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: transparent; font-size: 17px; line-height: 1; }
.stepper button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper .n { min-width: 18px; text-align: center; font: 600 15px var(--display); font-variant-numeric: tabular-nums; }

/* History calendar */
.scroll-x { overflow-x: auto; }
.cal { width: 100%; min-width: 620px; border-collapse: collapse; table-layout: fixed; }
.cal th { font: 600 12px var(--display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-align: left; padding: 0 6px 8px; }
.cal td { border: 1px solid var(--line); height: 92px; vertical-align: top; padding: 0; }
.cal td.out { opacity: 0.45; }
.cal td.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-link { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; height: 100%; min-height: 92px; padding: 6px; color: inherit; text-decoration: none; }
.cal-link:hover { background: var(--bg); }
.cal-day { font: 600 14px var(--display); font-variant-numeric: tabular-nums; }
td > .cal-day { display: block; padding: 6px; color: var(--muted); }
.tag { font-size: 12px; border-radius: 6px; padding: 1px 6px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag.session { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tag.snack { background: var(--warn-soft); color: var(--ink); }
.tag.snack.hit { background: var(--done-soft); color: var(--done); font-weight: 600; }

/* Progress */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.bar-n { font: 600 13px var(--display); font-variant-numeric: tabular-nums; }
.bar-fill { width: 100%; max-width: 44px; background: var(--line); border-radius: 4px 4px 0 0; }
.bar-fill.hit { background: var(--done); }
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.snackgrid { border-collapse: separate; border-spacing: 6px; }
.snackgrid th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; white-space: nowrap; }
.snackgrid thead th { text-align: center; }
.sq { display: grid; place-items: center; width: 40px; height: 32px; border-radius: 6px; background: var(--bg); color: var(--muted); font: 600 13px var(--display); text-decoration: none; }
.sq.some { background: var(--warn-soft); color: var(--ink); }
.sq.hit { background: var(--done); color: var(--surface); }
.sq.future { background: transparent; border: 1px dashed var(--line); }
.lift { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); }
.lift:first-of-type { border-top: 0; padding-top: 0; }
.lift-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.chart { width: 100%; min-width: 420px; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart .line { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .dot.last { fill: var(--accent); }
.chart .dot.reading { fill: var(--muted); stroke: none; opacity: 0.45; }
.trend-summary { color: var(--ink); font-weight: 600; }

/* Login */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 340px; gap: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-box input { color: var(--ink); font-size: 15px; }
