:root {
  color-scheme: light dark;
  --bg: #fcfcfb;
  --card: #ffffff;
  --ink: #0b0b0b;
  --quiet: #52514e;
  --edge: #e2e1dc;
  --grid: #ecebe7;
  --accent: #2a78d6;
  --tint: rgba(42, 120, 214, 0.09);
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --z-rec: #c6d6eb;
  --z-z1: #86b0e4;
  --z-z2: #2a78d6;
  --z-z3: #eb6834;
  --z-z4: #d03b3b;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a19;
    --card: #232321;
    --ink: #f0efec;
    --quiet: #c3c2b7;
    --edge: #383733;
    --grid: #2e2e2b;
    --accent: #3987e5;
    --tint: rgba(57, 135, 229, 0.15);
    --z-rec: #3a4a60;
    --z-z1: #4f78ad;
    --z-z2: #3987e5;
    --z-z3: #d95926;
    --z-z4: #e66767;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
.wrap { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px 24px; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { margin: 0; }
h3 { font-size: 17px; margin: 4px 0 8px; text-align: center; }
p { margin: 6px 0; }
a { color: var(--accent); }
code { font: 0.88em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--grid); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--quiet); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--bad); }

header.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--edge); background: var(--card);
  color: var(--ink); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; min-height: 32px; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.status.warn .dot { background: var(--warn); }
.status.bad .dot { background: var(--bad); }
.status-why { margin: -2px 0 8px; }

.card { background: var(--card); border: 1px solid var(--edge); border-radius: 16px; padding: 16px; margin: 12px 0; }
.hero { background: var(--tint); border: 2px solid var(--accent); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--quiet); }
.eyebrow .link { text-transform: none; letter-spacing: 0; font-weight: 600; }
.session h2 { font-size: 24px; font-weight: 600; margin: 6px 0 2px; line-height: 1.2; }
.session + .session { border-top: 1px solid var(--edge); margin-top: 14px; padding-top: 10px; }
.session.done h2 { color: var(--quiet); }
.tick { color: var(--good); }
.sub { font-size: 15px; }
.hr { font-size: 16px; font-weight: 600; margin-top: 10px; }
.note-text { font-size: 13.5px; color: var(--quiet); }
.workline { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0 4px; }
.sq { width: 8px; height: 8px; background: var(--quiet); border-radius: 1px; flex: none; }
.actual { margin-top: 12px; font-size: 14px; }
.actual .lbl { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--quiet); margin-right: 4px; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1; }

.btn { appearance: none; -webkit-appearance: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--edge); background: var(--card); color: var(--ink); border-radius: 999px; padding: 10px 16px;
  font: inherit; font-weight: 500; min-height: 44px; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--quiet); }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13.5px; }
.btn.left { flex-direction: column; align-items: flex-start; text-align: left; border-radius: 14px; gap: 2px; }
.btn[disabled] { opacity: 0.6; }
.link { appearance: none; background: none; border: 0; padding: 0; color: inherit; font: inherit;
  text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.x { appearance: none; border: 0; background: none; color: var(--quiet); font-size: 22px; line-height: 1; min-width: 36px; min-height: 36px; cursor: pointer; }

.why { margin-top: 10px; }
.why summary { color: var(--quiet); font-size: 13px; cursor: pointer; }
.why ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--quiet); }
.why li { margin: 2px 0; }

.block { margin: 18px 0; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { border: 1px solid var(--grid); border-radius: 8px; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 12px; }
.day.today { border: 2px solid var(--accent); background: var(--tint); font-weight: 600; }
.mk { display: inline-block; width: 8px; height: 8px; vertical-align: middle; }
.mk.done { border-radius: 50%; background: var(--accent); }
.mk.open { border-radius: 50%; border: 1.5px solid var(--accent); }
.mk.work { border-radius: 1px; background: var(--quiet); }
.mk.rest { width: 10px; height: 0; border-top: 1.5px solid var(--quiet); }
.legend { margin-top: 8px; }
.legend .mk { margin: 0 4px 0 10px; }
.legend .mk:first-child { margin-left: 0; }
.bar { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.note { background: var(--card); border: 1px solid var(--edge); border-left: 3px solid var(--accent); border-radius: 12px;
  padding: 10px 6px 10px 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin: 10px 0; font-size: 14px; }
.note.warn { border-left-color: var(--warn); }
.flash { background: var(--tint); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; margin: 4px 0 10px; font-size: 14px; }

.chips, .choice { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips form, .choice form { margin: 0; }
.chip { appearance: none; border: 1px solid var(--edge); background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 6px 14px; min-height: 36px; font: inherit; font-size: 14px; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--tint); }
.ask { border-color: var(--accent); }

.weightline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.foot { margin-top: 18px; text-align: center; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: var(--bg); border-top: 1px solid var(--edge); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.tabs a { color: var(--quiet); text-decoration: none; font-size: 13px; padding: 10px 14px; min-height: 44px; }
.tabs a.on { color: var(--ink); font-weight: 600; }

.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-panel { background: var(--card); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; max-height: 88vh; overflow: auto;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); animation: up 0.18s ease-out; }
.sheet-panel p { font-size: 14px; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--edge); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet-panel { animation: none; } }
.big { text-align: center; font-size: 56px; font-weight: 600; line-height: 1.1; margin-top: 10px; font-variant-numeric: tabular-nums; }
.big .unit { font-size: 16px; font-weight: 400; color: var(--quiet); margin-left: 6px; }
.pm { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 4px; }
.pm .btn { padding: 8px 4px; }
.opt { margin: 8px 0 0; }

.gym { margin-top: 12px; }
.gym-head { margin-bottom: 4px; }
.ex { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--edge); }
.ex-name { display: flex; flex-direction: column; min-width: 0; }
.ex-ctl { display: flex; align-items: center; gap: 8px; flex: none; }
.stepper { display: flex; align-items: center; border: 1px solid var(--edge); border-radius: 999px; background: var(--card); }
.stepper button { appearance: none; width: 34px; height: 34px; border: 0; background: none; color: var(--ink); font-size: 18px; cursor: pointer; }
.stepper input { width: 50px; border: 0; background: transparent; color: var(--ink); text-align: center; font: inherit; font-size: 14px; padding: 0; }
.upto { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.upto input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--quiet); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--edge); border-radius: 10px; }
.field input, .field select, textarea { padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field, .field input, .field select { min-width: 0; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.h2-small { font-size: 17px; font-weight: 600; margin: 4px 0 8px; }
.card .h2-small ~ .h2-small { margin-top: 18px; }
.zones, .list { list-style: none; padding: 0; margin: 8px 0; }
.zones li, .list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--grid); font-size: 14px; }
.list form { margin: 0; }
.row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row-form select, .row-form input { padding: 6px 8px; min-height: 36px; font-size: 14px; }
.paste-result { margin-top: 10px; font-size: 14px; }
.paste-result input[type=time] { padding: 4px 6px; min-height: 32px; }
.steps { padding-left: 18px; }
.steps li { margin: 6px 0; }
.log { list-style: none; padding: 0; font-size: 12.5px; }
.log li { padding: 3px 0; border-top: 1px solid var(--grid); color: var(--quiet); }
.log li.error { color: var(--bad); }

.week-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.week-head .right { text-align: right; white-space: nowrap; }
.days { list-style: none; padding: 0; margin: 10px 0 0; }
.days li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--grid); }
.days li.today { background: var(--tint); margin: 0 -16px; padding: 10px 16px; }
.days li.past { opacity: 0.72; }
.d-label { font-size: 13px; color: var(--quiet); padding-top: 1px; }
.d-t { font-weight: 500; }
.d-body .why { margin-top: 4px; }
.days .workline { margin: 0 0 2px; font-weight: 400; }

.chart { width: 100%; height: auto; display: block; margin: 4px 0; font-family: var(--font); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--quiet); font-size: 10px; }
.chart .bar { fill: var(--accent); }
.chart .bar.current { fill-opacity: 0.5; }
.chart .mark:hover .bar { fill-opacity: 0.8; }
.chart .target { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.chart .hit { fill: transparent; }
.chart .dot { fill: var(--quiet); fill-opacity: 0.5; stroke: var(--card); stroke-width: 2; }
.chart .trend { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .label { fill: var(--ink); font-size: 11px; font-weight: 600; }
.legend-inline .sw { display: inline-block; vertical-align: middle; margin: 0 4px 0 10px; }
.sw.bar { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.sw.target { width: 12px; height: 0; border-top: 2px solid var(--ink); }
.sw.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--quiet); opacity: 0.5; }
.sw.line { width: 14px; height: 0; border-top: 2px solid var(--accent); }

.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { appearance: none; border: 1px solid var(--edge); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 10px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; font: inherit; cursor: pointer; }
.stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.acts { list-style: none; padding: 0; margin: 4px 0 0; }
.acts li { padding: 10px 0; border-top: 1px solid var(--grid); }
.acts li.ignored { opacity: 0.5; }
.a-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.zbar { display: flex; gap: 2px; height: 6px; margin: 7px 0 2px; }
.zbar span { display: block; height: 100%; border-radius: 2px; }
.z-rec { background: var(--z-rec); }
.z-z1 { background: var(--z-z1); }
.z-z2 { background: var(--z-z2); }
.z-z3 { background: var(--z-z3); }
.z-z4 { background: var(--z-z4); }
.zlegend span { display: inline-block; width: 10px; height: 6px; border-radius: 2px; margin: 0 4px 0 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--grid); }
.tbl th { color: var(--quiet); font-weight: 500; }
.glossary dt { font-weight: 600; margin-top: 14px; }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 4px 0 0; color: var(--quiet); font-size: 14px; }
.login { max-width: 360px; margin: 14vh auto 0; }
.login h1 { font-size: 30px; margin-bottom: 16px; }
