@font-face {
  font-family: "Archivo";
  src: url(/fonts/archivo.woff2) format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url(/fonts/plexmono-500.woff2) format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #14120f;
  --card: #1e1b17;
  --card2: #2a2621;
  --card3: #35302a;
  --bone: #f0ece3;
  --dim: rgba(240, 236, 227, 0.62);
  --sig: #ff5a2b;
  --sig-soft: rgba(255, 90, 43, 0.14);
  --ember: #a13d18;
  --r: 18px;
  --tabs-h: 72px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--bone); }
body {
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.splash {
  min-height: 100dvh; display: grid; place-items: center;
  font-weight: 900; font-stretch: 70%; font-size: 48px; letter-spacing: -0.01em;
}
.splash span { color: var(--sig); }

.app {
  max-width: 560px; margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + var(--tabs-h) + 28px);
}
.app.full { padding-bottom: calc(env(safe-area-inset-bottom) + 120px); }

/* ---------- type ---------- */
.h1, .h2, .h3, .big {
  margin: 0; text-transform: uppercase; font-stretch: 72%; letter-spacing: -0.005em;
}
.h1 { font-weight: 900; font-size: 46px; line-height: 0.9; }
.h2 { font-weight: 850; font-size: 30px; line-height: 0.92; }
.h3 { font-weight: 800; font-size: 21px; line-height: 1; font-stretch: 78%; }
.big { font-weight: 900; font-size: 64px; line-height: 0.85; font-stretch: 68%; }
.tag {
  font-family: "Plex Mono", ui-monospace, monospace; font-weight: 500;
  font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sig);
}
.tag.b { color: var(--bone); }
.tag.d { color: var(--dim); }
.dim { color: var(--dim); }
.sig { color: var(--sig); }
.small { font-size: 14px; }
.center { text-align: center; }
p { margin: 8px 0; }

/* ---------- layout ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.gap { height: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.card { background: var(--card); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.hero { padding: 0; overflow: hidden; }
.card.hero .body { padding: 16px; }
.card.sig { background: var(--sig); color: var(--bg); }
.card.sig .tag { color: var(--bg); }

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 0; border-radius: 14px; min-height: 54px; padding: 0 20px;
  font-weight: 850; font-stretch: 76%; text-transform: uppercase; font-size: 19px; letter-spacing: 0.01em;
  background: var(--sig); color: var(--bg); width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
}
.btn:active { transform: scale(0.985); }
.btn[disabled] { opacity: 0.45; }
.btn.sec { background: var(--card2); color: var(--bone); }
.btn.ghost { background: transparent; color: var(--bone); box-shadow: inset 0 0 0 1.5px var(--card3); }
.btn.sm { min-height: 40px; font-size: 15px; width: auto; padding: 0 14px; border-radius: 11px; }
.btn svg { width: 22px; height: 22px; }

.iconbtn {
  appearance: none; border: 0; background: var(--card); color: var(--bone);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none;
  text-decoration: none;
}
.iconbtn svg { width: 22px; height: 22px; }

.in {
  appearance: none; background: var(--card2); border: 0; border-radius: 12px; color: var(--bone);
  font: inherit; font-size: 18px; min-height: 50px; padding: 0 14px; width: 100%;
}
.in::placeholder { color: rgba(240, 236, 227, 0.38); }
.in:focus { outline: 2px solid var(--sig); outline-offset: 0; }
.in.num { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 20px; }
label.f { display: block; }
label.f .tag { display: block; margin-bottom: 6px; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; border: 0; flex: none; background: var(--card2); color: var(--bone);
  border-radius: 999px; padding: 9px 14px; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--sig); color: var(--bg); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card2); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--bone); border-radius: 10px; min-height: 40px;
  font-weight: 800; font-stretch: 80%; text-transform: uppercase; font-size: 14px; cursor: pointer;
}
.seg button.on { background: var(--sig); color: var(--bg); }

.bar { height: 10px; border-radius: 999px; background: var(--card3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--sig); border-radius: 999px; transition: width 0.3s; }
.bar.over > i { background: var(--ember); }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(20, 18, 15, 0.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; justify-content: space-around; padding: 8px 4px calc(env(safe-area-inset-bottom) + 6px);
}
.tabs a {
  flex: 1; text-align: center; color: var(--dim); text-decoration: none;
  font-family: "Plex Mono", monospace; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 0;
}
.tabs a svg { display: block; margin: 0 auto 4px; width: 25px; height: 25px; }
.tabs a.on { color: var(--sig); }

/* ---------- exercise imagery ---------- */
.exImg { position: relative; aspect-ratio: 3 / 2; border-radius: var(--r); overflow: hidden; background: #fff; }
.exImg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.exImg img + img { animation: flip 1.8s steps(1, end) infinite; }
@keyframes flip { 0% { opacity: 0; } 50% { opacity: 1; } }
.exImg .badge { position: absolute; left: 10px; top: 10px; background: var(--bg); color: var(--bone); border-radius: 8px; padding: 4px 8px; }
.thumb { width: 64px; height: 48px; border-radius: 10px; overflow: hidden; background: #fff; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumbs { display: flex; gap: 6px; overflow: hidden; }
.thumbs .thumb { width: 52px; height: 40px; border-radius: 8px; }

/* ---------- lists ---------- */
.list { margin: 8px 0; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; text-decoration: none; color: inherit;
  cursor: pointer; background: none; border: 0; width: 100%; text-align: left;
}
.item + .item { box-shadow: 0 -1px 0 rgba(240, 236, 227, 0.06); }
.item .nm { font-weight: 650; line-height: 1.2; }
.item .sub { font-size: 13.5px; color: var(--dim); margin-top: 2px; }
.item .val { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- workout ---------- */
.wbar {
  position: sticky; top: 0; z-index: 25; margin: calc(-1 * (env(safe-area-inset-top) + 14px)) -16px 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: rgba(20, 18, 15, 0.95);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.sets { margin-top: 12px; }
.set {
  display: grid; grid-template-columns: 30px 1fr 1fr 54px; gap: 8px; align-items: center;
  padding: 6px; border-radius: 14px; margin: 6px -6px;
}
.set.done { background: var(--sig-soft); }
.set .n { font-family: "Plex Mono", monospace; color: var(--dim); text-align: center; }
.set .in { min-height: 48px; }
.check {
  appearance: none; border: 0; height: 48px; border-radius: 12px; background: var(--card3); color: var(--bone);
  display: grid; place-items: center; cursor: pointer;
}
.check svg { width: 24px; height: 24px; }
.set.done .check { background: var(--sig); color: var(--bg); }
.sethead { display: grid; grid-template-columns: 30px 1fr 1fr 54px; gap: 8px; padding: 0 0; }
.sethead .tag { text-align: center; }

.exrow { display: flex; gap: 12px; align-items: center; padding: 10px 0; text-decoration: none; color: inherit; }
.exrow + .exrow { box-shadow: 0 -1px 0 rgba(240, 236, 227, 0.06); }
.exrow .dots { display: flex; gap: 4px; margin-top: 6px; }
.exrow .dots i { width: 14px; height: 6px; border-radius: 3px; background: var(--card3); }
.exrow .dots i.on { background: var(--sig); }

.rest {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--sig); color: var(--bg);
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px); display: flex; align-items: center; gap: 12px;
  animation: up 0.2s ease-out;
}
.rest .t { font-weight: 900; font-stretch: 68%; font-size: 52px; line-height: 0.9; font-variant-numeric: tabular-nums; }
.rest .btn.sm { background: var(--bg); color: var(--bone); }
@keyframes up { from { transform: translateY(100%); } }

.next {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, rgba(20, 18, 15, 0));
}
.next .inner { max-width: 528px; margin: 0 auto; display: flex; gap: 10px; }
.next .btn { min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- food ---------- */
.meal { margin: 18px 0 6px; }
.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + var(--tabs-h) + 14px); z-index: 31;
  width: 62px; height: 62px; border-radius: 50%; background: var(--sig); color: var(--bg); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); border: 0; cursor: pointer; text-decoration: none;
}
.fab svg { width: 30px; height: 30px; }
.macro { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.macro .num { font-weight: 900; font-stretch: 70%; font-size: 40px; line-height: 0.9; font-variant-numeric: tabular-nums; }
.photoPrev { width: 100%; border-radius: var(--r); aspect-ratio: 4 / 3; object-fit: cover; background: var(--card2); }
.scanbox { position: relative; border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; }
.scanbox .aim {
  position: absolute; left: 12%; right: 12%; top: 40%; height: 20%; border-radius: 14px;
  box-shadow: 0 0 0 2px var(--sig), 0 0 0 999px rgba(0, 0, 0, 0.35);
}

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 50; animation: fade 0.15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--card); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); max-height: 88dvh; overflow-y: auto; animation: up 0.2s ease-out;
}
.sheet .inner { max-width: 528px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--card3); margin: -6px auto 12px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- progress ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: "Plex Mono", monospace; font-size: 10px; fill: var(--dim); }
.stat .num { font-weight: 900; font-stretch: 70%; font-size: 32px; line-height: 0.95; font-variant-numeric: tabular-nums; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { font-family: "Plex Mono", monospace; font-size: 10.5px; color: var(--dim); text-transform: uppercase; }
.week .o {
  width: 34px; height: 34px; border-radius: 50%; margin: 6px auto 0; display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px var(--card3); font-weight: 800; font-size: 13px;
}
.week .o.plan { box-shadow: inset 0 0 0 2px var(--sig); }
.week .o.done { background: var(--sig); box-shadow: none; color: var(--bg); }
.week .o.today { outline: 2px solid var(--bone); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + var(--tabs-h) + 18px);
  background: var(--bone); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; z-index: 60;
  animation: fade 0.2s; max-width: calc(100% - 32px);
}
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--card3); border-top-color: var(--sig); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

ol.how { padding-left: 20px; margin: 8px 0; }
ol.how li { margin: 6px 0; color: var(--dim); }
hr.sp { border: 0; height: 1px; background: rgba(240, 236, 227, 0.06); margin: 16px 0; }
