:root {
  --bg: #0f1216;
  --card: #1a1f26;
  --card-2: #232a33;
  --text: #eef1f4;
  --muted: #9aa5b1;
  --line: #2e3742;
  --accent: #3fb68b;
  --accent-text: #06130e;
  --warn: #e8b04a;
  --danger: #e5605a;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f7; --card: #ffffff; --card-2: #eef1f4; --text: #14181d; --muted: #5d6874;
    --line: #dde2e7; --accent: #1f9a6e; --accent-text: #ffffff; color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 12px 12px 24px; }
h1 { font-size: 1.6rem; margin: 0.2rem 0 0.4rem; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 0.2rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
p { margin: 0.4rem 0; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); }
.up { color: var(--accent); font-weight: 600; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.badge { display: inline-block; font-size: 0.7rem; padding: 2px 7px; border-radius: 999px; background: var(--warn); color: #1a1200; vertical-align: middle; font-weight: 700; text-transform: uppercase; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; }
.card.accent { outline: 2px solid var(--accent); }
.card.notice { border-left: 4px solid var(--warn); }

button, select, input, textarea {
  font: inherit; color: var(--text); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 10px;
}
button { padding: 10px 14px; min-height: 44px; cursor: pointer; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 700; }
button.danger { color: var(--danger); }
button.primary.danger { background: var(--danger); color: #fff; }
button.big { width: 100%; min-height: 60px; font-size: 1.2rem; margin-top: 12px; }
input, select, textarea { padding: 10px; width: 100%; }
label { display: block; margin: 12px 0; color: var(--muted); font-size: 0.9rem; }
label input, label select, label textarea { margin-top: 4px; }
label.toggle { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 1rem; }
label.toggle input { width: auto; margin: 0; transform: scale(1.3); }

.row { display: flex; gap: 8px; margin-top: 10px; }
.row > * { flex: 1; }
.col { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button small { display: block; color: var(--muted); font-size: 0.75rem; }
.chips button.on, .chip:has(input:checked) { background: var(--accent); color: var(--accent-text); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; margin: 0; color: var(--text); background: var(--card-2); }
.chip input { width: auto; margin: 0; }
.feel button, .rir button { flex: 1; font-size: 1.2rem; }
.scroll { max-height: 40vh; overflow-y: auto; }

#nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav[hidden] { display: none; }
#nav a { flex: 1; text-align: center; padding: 16px 0; color: var(--muted); text-decoration: none; font-weight: 600; }
#nav a.active { color: var(--accent); }

.preview, .list, .overview { list-style: none; padding: 0; margin: 8px 0; }
.preview li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.preview li:last-child { border: 0; }
.preview li > span:last-child { text-align: right; white-space: nowrap; }
.list li a { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.overview li button { width: 100%; display: flex; justify-content: space-between; margin-bottom: 6px; text-align: left; }
.overview li.complete button { opacity: 0.5; }
.sets { margin: 0; padding-left: 1.4rem; }
.note { background: var(--card-2); padding: 8px 10px; border-radius: 8px; }

.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; position: sticky; top: 0; background: var(--bg); padding: 4px 0; z-index: 2; }
.bar-title { flex: 1; display: flex; flex-direction: column; align-items: center; }
.bar button { min-width: 72px; }

.step h1 { font-size: 1.8rem; }
.target { font-size: 1.15rem; font-weight: 600; margin: 4px 0 8px; }
.cue { color: var(--muted); font-size: 0.95rem; }
.last { font-size: 0.95rem; }
button.setup { width: 100%; text-align: left; background: transparent; border-style: dashed; color: var(--muted); margin: 6px 0; }
button.setup strong { color: var(--text); }
.stepper-label { margin-top: 14px; color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }
button.unit { min-height: 32px; padding: 2px 12px; font-weight: 700; }
.stepper { display: flex; gap: 8px; margin-top: 6px; }
.stepper button { width: 72px; min-height: 64px; font-size: 1.8rem; }
.stepper input { flex: 1; text-align: center; font-size: 2rem; font-weight: 700; min-height: 64px; }
.fields { display: flex; gap: 10px; }
.fields label { flex: 1; }
.fields input { font-size: 1.5rem; text-align: center; }
.stopwatch { text-align: center; font-size: 3rem; font-weight: 800; margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.stopwatch small { display: block; font-size: 0.9rem; font-weight: 400; }

.rest {
  position: fixed; inset: 0; z-index: 5; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center; padding: 24px; text-align: center;
}
.rest-clock { font-size: 5.5rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 8px 0 16px; }
.rest .row { max-width: 420px; margin: 0 auto 16px; width: 100%; }
.rest .chips { justify-content: center; max-width: 420px; margin: 0 auto; width: 100%; }
.rest .rest-note { margin-top: 24px; }
.up-next { margin-top: 24px; font-size: 1.1rem; }

.stats { display: flex; gap: 8px; margin: 12px 0; }
.stats div { flex: 1; background: var(--card-2); border-radius: 10px; padding: 10px; text-align: center; }
.stats strong { display: block; font-size: 1.4rem; }
.stats span { color: var(--muted); font-size: 0.8rem; }

#modal { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; }
.sheet textarea, .sheet input { margin: 10px 0; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* Charts: palette slots validated (dataviz validator) against the card surfaces in both modes. */
:root { --s1: #2a78d6; --s2: #eb6834; --grid: #e6e9ec; }
@media (prefers-color-scheme: dark) { :root { --s1: #3987e5; --s2: #d95926; --grid: #2a323c; } }
.range { margin: 0 0 12px; }
.range button { flex: 1; }
.metric { margin: 10px 0 4px; }
.metric button { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.chart { position: relative; margin-top: 8px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .label { fill: var(--text); font-size: 11px; font-weight: 700; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--s1); } .chart .line.s2 { stroke: var(--s2); }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .dot.s1, .chart .bar.s1 { fill: var(--s1); } .chart .dot.s2, .chart .bar.s2 { fill: var(--s2); }
.chart .dot.pr { fill: none; stroke: var(--text); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: var(--text); fill-opacity: 0.06; }
.tip { position: absolute; top: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 0.85rem; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.tip-date { color: var(--muted); font-size: 0.75rem; }
.key { display: inline-block; width: 14px; height: 2px; margin: 0 6px 3px 4px; vertical-align: middle; background: var(--s1); border-radius: 1px; }
.key.s2 { background: var(--s2); }
.key.box { width: 10px; height: 10px; border-radius: 2px; margin-bottom: 1px; }
.key.dot { width: 8px; height: 8px; border-radius: 50%; margin-bottom: 1px; }
.legend { display: flex; gap: 14px; font-size: 0.85rem; color: var(--muted); }
.tiles { display: flex; gap: 8px; margin: 0 0 12px; }
.tile { flex: 1; background: var(--card); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; min-width: 0; }
.card .tile { background: var(--card-2); }
.tile strong { font-size: 1.6rem; line-height: 1.2; }
.tile-label { color: var(--muted); font-size: 0.8rem; }
.barlist { list-style: none; padding: 0; margin: 8px 0 0; }
.barlist li { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; font-size: 0.9rem; }
.bl-track { height: 12px; }
.bl-bar { display: block; height: 12px; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bl-value { text-align: right; font-variant-numeric: tabular-nums; }
.table-view { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
.table-view table, table.prs { width: 100%; border-collapse: collapse; margin-top: 6px; }
.table-view td, .table-view th, table.prs td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; color: var(--text); }
table.prs td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
table.cmp { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
table.cmp th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem; padding: 4px; }
table.cmp td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.cmp td + td, table.cmp th + th { text-align: right; white-space: nowrap; }
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; }
.cal-head button { min-height: 36px; width: 44px; padding: 0; font-size: 1.3rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin: 10px 0 8px; text-align: center; }
.cal-dow { font-size: 0.75rem; color: var(--muted); padding-bottom: 4px; }
.cal-day { position: relative; background: none; border: 0; min-height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.cal-day.out { opacity: 0.35; }
.cal-day.on { background: var(--card-2); }
.cal-num { width: 32px; height: 32px; line-height: 32px; border-radius: 50%; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.cal-num.gym { background: var(--s1); color: #fff; font-weight: 700; }
.cal-day.today .cal-num { box-shadow: 0 0 0 2px var(--text); }
.cal-home { position: absolute; bottom: 2px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--s2); box-shadow: 0 0 0 2px var(--card); }
.cal-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px 1px 0; vertical-align: middle; background: var(--s1); }
.cal-key.home { width: 8px; height: 8px; background: var(--s2); }
select { margin-top: 4px; }
button.set-edit { background: transparent; border: 0; padding: 4px 0; min-height: 32px; text-align: left; width: 100%; }
.btn-link { display: flex; align-items: center; justify-content: center; }
.sides { display: flex; gap: 10px; }
.sides > * { flex: 1; min-width: 0; }
.sides .stepper { gap: 4px; }
.sides .stepper button { width: 44px; font-size: 1.5rem; }
.sides .stepper input { min-width: 0; font-size: 1.6rem; }
.chips.round { margin: 6px 0 2px; gap: 6px; }
.chips.round button { min-height: 34px; padding: 4px 10px; font-size: 0.8rem; }
.chips.round button.done { opacity: 0.45; }
.rest .chips.round { justify-content: center; }
.chips button.suggested { border: 2px solid var(--accent); }
.prep { margin-top: 6px; }
.prep-load { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.auth { margin-top: 4vh; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.auth form { margin-top: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; margin-bottom: 12px; }
.brand img { border-radius: 10px; }
.msg { min-height: 1.2em; }
button.linkish { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
.admin-users li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin-users .col { margin: 0; flex-shrink: 0; }
.admin-users .col button { min-height: 36px; padding: 6px 10px; font-size: 0.85rem; }
.debrief, .changes { padding-left: 1.2rem; margin: 8px 0; }
.debrief li, .changes li { margin: 6px 0; }
.onboarding h1 { margin-bottom: 12px; }
.progress { height: 4px; background: var(--card-2); border-radius: 2px; margin: 8px 0 12px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.chips.pick { margin: 6px 0 14px; }
.chips.pick button { min-height: 44px; }
.yesno { padding: 8px 0; border-bottom: 1px solid var(--line); }
.yesno .chips { margin: 6px 0 0; }
.yesno .chips button { flex: 0 0 80px; }

/* Logged-out landing page */
main.landing { max-width: 1040px; padding: 0 16px 32px; position: relative; }
.landing::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 100vw; height: 640px; transform: translateX(-50%); z-index: -1; pointer-events: none;
  background: radial-gradient(55% 80% at 35% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
}
body:has(main.landing) { overflow-x: hidden; }
/* Phones: headline, then log in, then the preview. Wide: headline and preview left, log in right. */
.hero { display: grid; gap: 20px; padding: 28px 0 8px; align-items: start; grid-template-areas: "copy" "auth" "preview"; }
.hero-copy { grid-area: copy; }
.hero .auth { grid-area: auth; }
.preview-phone { grid-area: preview; }
.hero .auth { margin-top: 0; }
.display { font-size: clamp(2rem, 3.2vw + 1rem, 3.1rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.08; margin: 8px 0 12px; }
.lede { font-size: 1.12rem; color: var(--muted); margin: 0 0 20px; max-width: 34em; }
.preview-phone {
  max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px;
  box-shadow: 0 18px 50px color-mix(in srgb, var(--accent) 18%, transparent);
}
.pv-title { font-size: 1.35rem; font-weight: 800; margin: 2px 0; }
.pv-target { color: var(--muted); font-size: 0.9rem; }
.pv-load { font-size: 1rem; color: var(--muted); margin: 10px 0; }
.pv-load span { font-size: 2.2rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.pv-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pv-chip { font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); }
.pv-chip.on { opacity: 0.55; }
.pv-btn { background: var(--accent); color: var(--accent-text); font-weight: 700; text-align: center; padding: 12px; border-radius: 12px; }
.pv-rest { margin-top: 10px; font-size: 0.8rem; color: var(--muted); text-align: center; }
.pv-rest b { display: inline-block; min-width: 26px; padding: 2px 6px; margin-left: 2px; border-radius: 8px; background: var(--card-2); color: var(--text); font-weight: 600; }
.pv-rest b.on { background: var(--accent); color: var(--accent-text); }
.about { padding: 28px 0 8px; }
.about > h2 { text-align: center; font-size: 1.5rem; margin-bottom: 16px; }
.features { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.features li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.features strong { font-size: 1rem; }
.f-text { color: var(--muted); font-size: 0.92rem; }
.f-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.contact { max-width: 680px; margin: 20px auto 0; padding: 20px; }
.pair { display: grid; gap: 0 12px; }
.footer { margin-top: 20px; }
@media (min-width: 600px) {
  .features { grid-template-columns: 1fr 1fr; }
  .features li:last-child { grid-column: 1 / -1; }
  .pair { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 860px) {
  .hero { grid-template-columns: 1.15fr 0.85fr; grid-template-areas: "copy auth" "preview auth"; column-gap: 40px; row-gap: 4px; padding-top: 56px; }
  /* 3 across, then 2 wider below */
  .features { grid-template-columns: repeat(6, 1fr); }
  .features li { grid-column: span 2; }
  .features li:nth-child(n + 4) { grid-column: span 3; }
  .features li:last-child { grid-column: span 3; }
}
