:root { --ink:#000; --bg:#fff; --mute:#666; --line:#e2e2e2; --soft:#f3f3f3; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
button { font: inherit; }

.top {
  position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid #000;
  display: flex; justify-content: space-between; align-items: center;
  height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: .01em; }
.top-link { font-size: 15px; color: var(--mute); text-decoration: none; padding: 12px 0; }
main { max-width: 640px; margin: 0 auto; padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; background: #fff; border-top: 1px solid #000;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.nav a { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--mute); font-size: 15px; border-top: 3px solid transparent; margin-top: -1px; }
.nav a.on { color: #000; border-top-color: #000; font-weight: 600; }
body.noauth .nav, body.noauth .top-link { display: none; }

h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 28px 0 12px; font-weight: 700; }
h2:first-child { margin-top: 0; }
p { margin: 8px 0; }
.mute { color: var(--mute); }
.small { font-size: 15px; }
.eyebrow { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin-bottom: 6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.btn {
  -webkit-appearance: none; appearance: none; font-weight: 600; background: #000; color: #fff;
  border: 1px solid #000; border-radius: 2px; min-height: 52px; padding: 0 20px; width: 100%; cursor: pointer;
}
.btn.ghost { background: #fff; color: #000; }
.btn.sm { min-height: 40px; width: auto; padding: 0 14px; font-size: 15px; }
.btn.link { background: none; border: 0; color: var(--mute); text-decoration: underline; min-height: 40px; width: auto; padding: 0; font-weight: 400; font-size: 15px; }
.btn:disabled { background: #fff; color: #999; border-color: #ccc; cursor: default; }
.btn.link:disabled { border: 0; }

input, textarea { font: inherit; color: #000; background: #fff; border: 1px solid #000; border-radius: 2px; padding: 12px; width: 100%; min-height: 52px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.4; }
label { display: block; font-size: 15px; margin: 16px 0 6px; }
.err { border: 1px solid #000; padding: 10px 12px; margin: 14px 0; font-size: 15px; }
.note { border-left: 2px solid #000; padding: 4px 0 4px 14px; margin: 16px 0; font-size: 15px; }

.bar { height: 4px; background: var(--line); margin: 10px 0; }
.bar i { display: block; height: 100%; background: #000; }

.limits summary { cursor: pointer; font-size: 15px; padding: 10px 0; list-style: none; }
.limits summary::-webkit-details-marker { display: none; }
.limits summary::before { content: "+ "; font-weight: 700; }
.limits[open] summary::before { content: "– "; }
.limits ul { margin: 0 0 8px; padding-left: 20px; font-size: 15px; }
.limits li { margin: 4px 0; }

.block { border: 1px solid #000; margin-top: 12px; }
.block.locked { border-color: #ccc; color: #777; }
.block-h {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center;
  padding: 14px; width: 100%; text-align: left; background: none; border: 0; color: inherit; cursor: pointer;
}
.block-n { width: 32px; height: 32px; border: 1px solid currentColor; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.block.done .block-n { background: #000; color: #fff; border-color: #000; }
.block-name { font-weight: 600; }
.block-meta { font-size: 14px; color: var(--mute); }
.block.locked .block-meta { color: #999; }
.block-status { font-size: 14px; color: var(--mute); text-align: right; white-space: nowrap; }
.block-body { border-top: 1px solid var(--line); padding: 2px 14px 14px; }
.block-foot { margin-top: 14px; display: grid; gap: 10px; }

.ex { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: start; }
.ex:last-of-type { border-bottom: 0; }
.ex-name { font-weight: 600; }
.ex-cue { font-size: 15px; color: #555; margin-top: 2px; }
.block.locked .ex-cue { color: #999; }
.ex-target { font-size: 15px; margin-top: 6px; }
.flag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border: 1px solid currentColor; padding: 1px 6px; margin-left: 8px; vertical-align: 2px; }

.sq {
  -webkit-appearance: none; appearance: none; width: 44px; height: 44px; border: 2px solid #000; background: #fff; color: #000;
  font-weight: 600; font-size: 15px; border-radius: 2px; padding: 0; cursor: pointer; display: grid; place-items: center;
}
.sq.on { background: #000; color: #fff; }
.sq:disabled { border-color: #ccc; color: #aaa; cursor: default; }
.sq.on:disabled { background: #888; border-color: #888; color: #fff; }
.sets { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 164px; }

.mins { display: flex; align-items: center; gap: 12px; }
.mins .sq { width: 52px; height: 52px; font-size: 26px; font-weight: 400; }
.mins b { font-size: 34px; min-width: 2.4ch; text-align: center; line-height: 1; }
.mins span { font-size: 15px; color: var(--mute); }

.pain { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pain .sq { width: auto; height: 48px; font-size: 17px; }
.pain-l { display: flex; justify-content: space-between; font-size: 13px; color: var(--mute); margin-top: 6px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { font-size: 13px; color: var(--mute); text-align: center; padding: 6px 0; }
.cell { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-decoration: none; color: #000; font-size: 15px; }
.cell.out { color: #c4c4c4; border-color: #f0f0f0; }
.cell.prog { border-color: #000; }
.cell.future { border-style: dashed; border-color: #999; color: #666; }
.cell.today { font-weight: 700; }
.cell.today::after { content: ""; position: absolute; }
.cell .d { line-height: 1; }
.cell .n { font-size: 11px; color: var(--mute); line-height: 1; }
.mark { width: 10px; height: 10px; border: 1px solid #000; border-radius: 1px; }
.mark.full { background: #000; }
.mark.part { background: #999; border-color: #999; }
.mark.none { border-color: #000; }
.mark.future { border-style: dashed; border-color: #999; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--mute); margin: 14px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.list a, .list div { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: #000; }
.list .n { font-weight: 700; }
.list .s { font-size: 15px; color: var(--mute); text-align: right; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: #000; border: 1px solid #000; }
.stat { background: #fff; padding: 14px; }
.stat b { display: block; font-size: 30px; line-height: 1.1; font-weight: 700; }
.stat b small { font-size: 16px; font-weight: 400; color: var(--mute); }
.stat span { font-size: 14px; color: var(--mute); }
.chart { margin: 10px 0 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; fill: #666; }

.goal { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.goal .t { font-weight: 600; }
.goal .t.done { color: var(--mute); text-decoration: line-through; }
.goal .p { font-size: 15px; color: var(--mute); }
.goal .bar { margin: 6px 0 0; }
.goal-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }
.goal-add .btn { width: auto; padding: 0 18px; }

.login { max-width: 400px; margin: 40px auto 0; }
.login .btn { margin-top: 20px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 3; max-width: 608px; margin: 0 auto; background: #000; color: #fff; padding: 12px 14px; font-size: 15px; display: none; }
.toast.show { display: block; }

@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: no-preference) { .bar i { transition: width .25s; } }
:focus-visible { outline: 2px solid #000; outline-offset: 2px; }
input:focus, textarea:focus { outline: 2px solid #000; outline-offset: 0; }
.daynav { margin-top: 24px; font-size: 15px; }
.daynav a { color: var(--mute); text-decoration: none; padding: 10px 0; }
.btn.link.del { font-size: 22px; text-decoration: none; padding: 0 8px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.choice { -webkit-appearance: none; appearance: none; min-height: 48px; border: 2px solid #000; background: #fff; color: #000; font-weight: 600; font-size: 16px; border-radius: 2px; cursor: pointer; }
.choice.on { background: #000; color: #fff; }
.choice:disabled { border-color: #ccc; color: #aaa; cursor: default; }
.choice.on:disabled { background: #888; border-color: #888; color: #fff; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 12px 0 0; }
.check input { width: 26px; height: 26px; min-height: 0; margin: 0; accent-color: #000; }
.btn.link.del.armed { font-size: 15px; font-weight: 600; color: #000; text-decoration: underline; }
