:root {
  --bg: #000;
  --surface: #0e0e0e;
  --surface-2: #171717;
  --line: #262626;
  --line-strong: #3a3a3a;
  --text: #fff;
  --muted: #8a8a8a;
  --faint: #555;
  --invert-bg: #fff;
  --invert-text: #000;
  --good: #fff;
  --radius: 14px;
  --gutter: 16px;
  --tabbar: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --display: "Archivo", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 12px) var(--gutter) calc(var(--tabbar) + var(--safe-b) + 32px);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-stretch: 118%; text-transform: uppercase; letter-spacing: -0.01em; line-height: 0.95; }
h1 { font-size: clamp(40px, 12vw, 64px); font-weight: 900; }
h2 { font-size: 26px; font-weight: 900; }
h3 { font-size: 18px; font-weight: 800; }
p { margin: 0 0 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 28px; }
.section > .eyebrow { display: block; margin-bottom: 10px; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 18px; }
.wordmark { font-weight: 900; font-stretch: 125%; font-size: 20px; letter-spacing: -0.02em; text-transform: uppercase; }
.wordmark b { background: var(--invert-bg); color: var(--invert-text); padding: 0 6px; margin-left: 4px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.iconbtn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 20px; width: 100%;
  border-radius: 999px; border: 2px solid var(--text);
  background: var(--invert-bg); color: var(--invert-text);
  font-weight: 900; font-stretch: 115%; text-transform: uppercase; letter-spacing: 0.02em; font-size: 16px;
  cursor: pointer; text-decoration: none; transition: transform .08s ease;
}
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.small { min-height: 40px; font-size: 13px; padding: 0 14px; width: auto; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.card.invert { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.card.invert .muted, .card.invert .eyebrow { color: #555; }

/* Hero */
.hero { padding: 22px 18px; }
.hero h1 { margin: 8px 0 12px; }
.hero .chips { margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 9px; border-radius: 999px; border: 1px solid currentColor; opacity: .85;
}

/* Mode switch (segmented) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.seg button {
  border: 0; background: transparent; padding: 10px 6px; border-radius: 999px; cursor: pointer;
  font-weight: 800; font-size: 13px; text-transform: uppercase; color: var(--muted); font-stretch: 110%;
}
.seg button[aria-pressed="true"] { background: var(--invert-bg); color: var(--invert-text); }

/* Day list */
.daylist { display: grid; gap: 8px; }
.dayrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; cursor: pointer;
}
.dayrow h3 { font-size: 20px; }
.dayrow .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.dayrow .arrow { font-size: 22px; font-weight: 900; }
.dayrow.next { border-color: var(--text); }

/* Week strip */
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekstrip .d { text-align: center; }
.weekstrip .d span { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.weekstrip .d i {
  display: block; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line-strong);
}
.weekstrip .d.done i { background: var(--invert-bg); border-color: var(--invert-bg); }
.weekstrip .d.today i { border: 2px solid var(--text); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .v { font-family: var(--mono); font-weight: 700; font-size: 24px; line-height: 1.1; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }

.banner {
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
}
.banner strong { text-transform: uppercase; font-stretch: 115%; }

/* Workout */
.wo-head { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 80%, transparent); padding: calc(var(--safe-t) + 8px) 0 14px; margin-top: calc(-1 * (var(--safe-t) + 12px)); }
.wo-head h2 { font-size: 30px; }
.progressbar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 12px; }
.progressbar i { display: block; height: 100%; background: var(--invert-bg); transition: width .3s ease; }

.ex { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-top: 10px; overflow: hidden; }
.ex.active { border-color: var(--text); }
.ex.done { opacity: .9; }
.ex-sum { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
.ex-sum .num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 13px;
}
.ex.done .ex-sum .num { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.ex-sum .t { flex: 1; min-width: 0; }
.ex-sum h3 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-sum .s { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 3px; }
.ex-body { padding: 0 14px 16px; }

.media {
  position: relative; border-radius: 10px; overflow: hidden; background: #fff; aspect-ratio: 16 / 10;
  margin-bottom: 12px;
}
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: grayscale(1) contrast(1.05); transition: opacity .35s ease; }
.media img.b { opacity: 0; }
.media.flip img.b { opacity: 1; }
.media .tag {
  position: absolute; left: 8px; bottom: 8px; background: #000; color: #fff; font-family: var(--mono);
  font-size: 10px; padding: 3px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: .08em;
}
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.links a {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border-radius: 10px;
  border: 1px solid var(--line-strong); text-decoration: none; font-size: 13px; font-weight: 700;
}
.links svg { width: 16px; height: 16px; fill: currentColor; }
details.cues { margin-bottom: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
details.cues summary { cursor: pointer; padding: 10px 0; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: .04em; list-style: none; display: flex; justify-content: space-between; }
details.cues summary::after { content: "+"; font-family: var(--mono); }
details.cues[open] summary::after { content: "−"; }
details.cues ul { margin: 0 0 12px; padding-left: 18px; color: #cfcfcf; font-size: 14px; }
details.cues li + li { margin-top: 4px; }

.target { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.target > div { border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.target .k { font-size: 10px; font-family: var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.target .v { font-family: var(--mono); font-weight: 700; font-size: 17px; margin-top: 2px; }
.target .goal { background: var(--invert-bg); color: var(--invert-text); }
.target .goal .k { color: #555; }
.target .why { grid-column: 1 / -1; font-size: 13px; color: var(--muted); background: none; padding: 0 2px; }

.warmups { margin-bottom: 14px; }
.wu { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.wu:last-child { border-bottom: 0; }
.wu input { appearance: none; width: 24px; height: 24px; border: 1.5px solid var(--line-strong); border-radius: 6px; margin: 0; flex: none; display: grid; place-items: center; }
.wu input:checked { background: var(--invert-bg); border-color: var(--invert-bg); }
.wu input:checked::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid #000; border-bottom: 2.5px solid #000; transform: rotate(-45deg) translate(1px, -1px); }
.wu .lbl { flex: 1; font-size: 14px; }
.wu .lbl b { font-family: var(--mono); }
.wu .pct { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.working-label { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 8px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stepper { background: var(--surface-2); border-radius: 12px; padding: 8px; text-align: center; }
.stepper .k { font-size: 10px; font-family: var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.stepper input {
  width: 100%; background: transparent; border: 0; color: var(--text); text-align: center;
  font-family: var(--mono); font-weight: 700; font-size: 38px; padding: 2px 0; outline: none;
}
.stepper input:focus { text-decoration: underline; text-underline-offset: 6px; }
.stepper .pm { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stepper .pm button {
  min-height: 48px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg);
  font-size: 24px; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.stepper .pm button:active { background: var(--invert-bg); color: var(--invert-text); }

.optgroup { margin-top: 12px; }
.optgroup .eyebrow { display: block; margin-bottom: 6px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button {
  border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 9px 14px; cursor: pointer;
  font-size: 13px; font-weight: 700;
}
.pills button[aria-pressed="true"] { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
textarea, input.text {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  font: inherit; font-size: 15px; padding: 10px 12px; resize: vertical; outline: none;
}
textarea:focus, input.text:focus { border-color: var(--text); }

.ex-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 14px; }

/* Rest timer */
.rest {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 16px); z-index: 30;
  width: min(608px, calc(100% - 32px)); background: var(--invert-bg); color: var(--invert-text); border-radius: 999px;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 20px; box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
.rest .time { font-family: var(--mono); font-weight: 700; font-size: 22px; }
.rest .lbl { flex: 1; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.rest button { border: 0; border-radius: 999px; padding: 10px 14px; background: #000; color: #fff; font-weight: 800; font-size: 12px; cursor: pointer; }
.rest .bar { position: absolute; left: 20px; right: 20px; bottom: 4px; height: 2px; background: #ddd; border-radius: 2px; overflow: hidden; }
.rest .bar i { display: block; height: 100%; background: #000; }

/* Tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(0,0,0,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); height: calc(var(--tabbar) + var(--safe-b));
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--faint); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.tabs a.on { color: var(--text); }
.tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

/* Progress */
.select {
  width: 100%; appearance: none; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23fff' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 14px; font: inherit; font-weight: 800; text-transform: uppercase; font-stretch: 110%;
}
.chartbox { position: relative; height: 260px; margin-top: 12px; }
.chartbox.sm { height: 170px; }
.liftlist { display: grid; gap: 0; border-top: 1px solid var(--line); }
.lift { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.lift .n { font-weight: 800; font-size: 14px; }
.lift .g { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.lift .w { font-family: var(--mono); font-weight: 700; }
.lift .delta { font-family: var(--mono); font-size: 12px; min-width: 56px; text-align: right; color: var(--muted); }
.lift .delta.up { color: var(--text); }
.spark { width: 64px; height: 22px; }
.spark path { fill: none; stroke: var(--text); stroke-width: 1.6; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.table td.r, .table th.r { text-align: right; font-family: var(--mono); }
.pr { display: inline-block; font-family: var(--mono); font-size: 9px; font-weight: 700; background: var(--invert-bg); color: var(--invert-text); padding: 2px 5px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }

/* History */
.hist { display: block; padding: 14px 16px; text-decoration: none; }
.hist + .hist { margin-top: 8px; }
.hist .d { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.hist .x { font-size: 13px; color: #bbb; margin-top: 6px; }

/* Guide */
.prose h3 { margin: 26px 0 10px; }
.prose p, .prose li { color: #d6d6d6; font-size: 15px; }
.prose ul, .prose ol { padding-left: 20px; margin: 0 0 12px; }
.prose li + li { margin-top: 6px; }
.prose strong { color: #fff; }
.rule { border-left: 3px solid var(--text); padding: 2px 0 2px 14px; margin: 14px 0; }
.rule b { display: block; text-transform: uppercase; font-stretch: 115%; font-size: 15px; margin-bottom: 2px; }
.rule span { color: #cfcfcf; font-size: 14px; }

/* Login */
.login { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; }
.login h1 { margin-bottom: 18px; }
.login input { font-family: var(--mono); font-size: 24px; text-align: center; letter-spacing: .3em; padding: 16px; margin-bottom: 12px; }

.toast {
  position: fixed; top: calc(var(--safe-t) + 12px); left: 50%; transform: translate(-50%, -150%); z-index: 50;
  background: var(--invert-bg); color: var(--invert-text); padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 14px;
  transition: transform .25s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.sync { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sync.warn { color: var(--text); }

.summary-list { margin-top: 14px; }
.summary-list .item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.summary-list .item span:last-child { font-family: var(--mono); }

@media (min-width: 700px) {
  .tabs { left: 50%; transform: translateX(-50%); max-width: 640px; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
