/* ==========================================================================
   IRONCLAD PLANS — app styles
   Black canvas, charcoal tiles, one orange accent taken from the logo, steel
   silver as the secondary tone. Photo-led cards, big accent numbers, pill tabs.

   Fonts (SIL OFL, self-hosted): Plus Jakarta Sans (UI), Russo One (posters).
   Icons: Lucide (ISC). Photos: CC0, see /img/CREDITS.md.
   Dark is the default; js/theme.js sets data-theme="light" when chosen.
   ========================================================================== */

@font-face { font-family: "Jakarta"; src: url(/fonts/plus-jakarta-sans.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Russo One"; src: url(/fonts/russo-one.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1d1f;
  --surface-2: #2a2b2e;
  --surface-3: #37383c;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #9c9ea3;
  --accent: #f36f21;          /* logo orange: numbers, rings, icons */
  --accent-fill: #ec6417;     /* buttons and selected pills (white text) */
  --accent-text: #ff8a45;     /* orange as small text on dark */
  --accent-soft: rgba(243, 111, 33, 0.16);
  --steel: linear-gradient(135deg, #eceef0 0%, #a7abb0 45%, #8b8f95 55%, #d3d6d9 100%);
  --chart: #f26a21;
  --grid: rgba(255, 255, 255, 0.08);
  --warn: #ffc857;
  --warn-soft: rgba(255, 200, 87, 0.14);
  --danger: #ff6b6b;
  --chrome: #000000;
  --shadow: none;

  --radius: 14px;
  --radius-sm: 10px;
  --tab-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Jakarta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Russo One", "Jakarta", Impact, sans-serif;
  font-family: var(--font);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f4;
  --surface: #ffffff;
  --surface-2: #ececef;
  --surface-3: #dfdfe3;
  --line: #e4e4e8;
  --line-strong: #cfcfd5;
  --text: #121214;
  --muted: #64656b;
  --accent: #e4610f;
  --accent-fill: #d9560a;
  --accent-text: #b8470a;
  --accent-soft: rgba(228, 97, 15, 0.1);
  --chart: #c2410c;
  --grid: #e8e8ec;
  --warn: #8a5a00;
  --chrome: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 20px -14px rgba(0,0,0,.25);
}

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
svg[aria-hidden="true"] { width: 20px; height: 20px; flex: none; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: var(--accent-text); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0.4em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tnum { font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.eyebrow.ember { color: var(--accent-text); }

/* ---- Chrome ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
  min-height: calc(60px + var(--safe-t));
  padding: var(--safe-t) 10px 0;
  background: var(--chrome);
}
.topbar .left { justify-self: start; }
.topbar .right { justify-self: end; display: flex; align-items: center; }
.topbar .title { text-align: center; min-width: 0; font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-weight: 500; font-size: 0.75rem; color: var(--muted); }
.topbar .logo { display: block; height: 34px; width: auto; margin: 0 auto; }
:root[data-theme="light"] .topbar .logo { content: url(/img/logo-dark.svg); }
.round-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.round-btn svg { width: 18px; height: 18px; }

.view {
  max-width: 640px; margin: 0 auto;
  padding: 8px 14px calc(var(--tab-h) + var(--safe-b) + 96px);
  outline: none;
  animation: rise .28s cubic-bezier(.2, .7, .2, 1);
}
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 8px 10px calc(8px + var(--safe-b));
  background: var(--chrome);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; color: var(--muted); font-size: 0.68rem; font-weight: 600;
}
.tabbar a svg { width: 21px; height: 21px; stroke-width: 1.9; }
.tabbar a[aria-current="page"] { background: var(--accent-fill); color: #fff; }

/* ---- Tiles & photo cards ------------------------------------------------------ */
.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text);
}
.photo {
  position: relative; isolation: isolate; overflow: hidden;
  background: #111 var(--photo, url(/img/ex/gym.webp)) center / cover no-repeat;
  color: #fff;
}
.photo::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,.05) 30%, rgba(0,0,0,.78) 100%); }

.home-top { display: grid; grid-template-columns: 1fr 92px; gap: 10px; }
.home-top .prog-card { min-height: 230px; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: var(--radius); }
.home-top .prog-card .name { font-family: var(--display); font-size: 1.5rem; line-height: 1.02; text-transform: uppercase; text-shadow: 0 2px 14px rgba(0,0,0,.5); margin-bottom: 10px; }
.stat-col { display: grid; gap: 10px; }
.stat-tile { padding: 14px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.stat-tile b { font-size: 1.9rem; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: 0.7rem; color: var(--muted); margin-top: 4px; line-height: 1.25; }

.home-mid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.next-card { display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface); }
.next-card .pic { height: 108px; position: relative; }
.next-card .pic .tag { position: absolute; top: 8px; left: 8px; }
.next-card .pic .play { position: absolute; inset: 0; display: grid; place-items: center; }
.next-card .pic .play span { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; display: grid; place-items: center; background: rgba(0,0,0,.25); }
.next-card .pic .play svg { width: 18px; height: 18px; fill: #fff; stroke: none; margin-left: 2px; }
.next-card .body { padding: 10px 10px 12px; }
.next-card .body b { display: block; font-size: 0.92rem; margin-bottom: 8px; }
.ring-tile { padding: 14px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-tile h3 { font-size: 1.05rem; line-height: 1.15; }
.ring { position: relative; width: 112px; height: 112px; margin-top: 10px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.ring .arc { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .9s cubic-bezier(.2, .7, .2, 1); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: var(--accent); }

.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 7px; background: var(--accent-fill); color: #fff; font-size: 0.72rem; font-weight: 700; }

.cta-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 16px; border-radius: var(--radius);
  background: var(--accent-fill); color: #fff;
}
.cta-banner b { font-size: 1.25rem; font-weight: 800; }
.cta-banner span { padding: 6px 10px; border-radius: 9px; background: rgba(255,255,255,.2); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }

/* ---- Section header, pills, rows ------------------------------------------------ */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 1.2rem; }
.section-title a { font-size: 0.85rem; font-weight: 600; }

.pills { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px 12px; padding: 0 14px; }
.pills::-webkit-scrollbar { display: none; }
.pills button {
  flex: none; padding: 8px 14px; border: 0; border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.pills button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; }
.pills button.done:not([aria-pressed="true"]) { color: var(--accent-text); }

.day-list { display: grid; gap: 8px; }
.day-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 8px; border-radius: 12px; background: var(--surface);
  color: var(--text); box-shadow: var(--shadow);
}
.day-row .thumb { width: 52px; height: 52px; border-radius: 8px; flex: none; background: #111 var(--photo) center / cover; }
.day-row b { display: block; font-size: 0.95rem; font-weight: 700; }
.day-row.next b { color: var(--accent-text); }
.day-row .sub { font-size: 0.8rem; color: var(--muted); }
.day-row .chev { color: var(--accent); width: 20px; height: 20px; }
.day-row.done .thumb { position: relative; }
.day-row.done .thumb::after { content: ""; position: absolute; inset: 0; border-radius: 8px; background: rgba(236,100,23,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 24px no-repeat; }
.rest-line { display: flex; align-items: center; gap: 10px; padding: 2px 14px; color: var(--muted); font-size: 0.8rem; }
.rest-line::before, .rest-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- Cards, lists, chips (shared) -------------------------------------------------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 60px; color: inherit; }
.list-item b { font-weight: 700; }
.list-item .chev { color: var(--accent); width: 18px; height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.photo .chip { background: rgba(40, 40, 44, 0.85); color: #fff; }
.chip.muted { color: var(--muted); }
.chip.accent, .chip.done { background: var(--accent-fill); color: #fff; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.light { background: #fff; color: #111; }
.chip svg { width: 13px; height: 13px; }

.banner { display: flex; gap: 10px; border-radius: var(--radius-sm); padding: 12px 14px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 0.88rem; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.7rem; font-weight: 800; line-height: 1.05; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat b small { font-size: 0.9rem !important; color: var(--muted); }
.stat span { display: block; margin-top: 3px; font-size: 0.75rem; color: var(--muted); }

/* ---- Plans -------------------------------------------------------------------------- */
.poster-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.poster {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 250px; padding: 12px; border-radius: var(--radius);
}
.poster .ttl { font-family: var(--display); font-size: 1.45rem; line-height: 1; text-transform: uppercase; text-shadow: 0 2px 16px rgba(0,0,0,.6); }
.poster.wide { grid-column: 1 / -1; min-height: 220px; }
.poster.wide .ttl { font-size: 2rem; }

.plan-top { display: grid; grid-template-columns: 1fr 96px; gap: 10px; }
.plan-top .poster { min-height: 300px; justify-content: flex-start; }
.plan-top .poster .ttl { font-size: 2rem; }
.desc-card { overflow: hidden; padding: 0; }
.desc-card .head { padding: 12px 16px; background: var(--accent-fill); color: #fff; font-weight: 800; font-size: 1.05rem; }
.desc-card .bodyx { padding: 16px; }
.desc-card .bodyx h3 { margin-bottom: 4px; }

/* ---- Workout ------------------------------------------------------------------------ */
.w-hero { min-height: 190px; padding: 14px; border-radius: var(--radius); display: flex; flex-direction: column; justify-content: flex-end; }
.w-hero .eyebrow { color: rgba(255,255,255,.8); }
.w-hero h1 { font-size: 1.6rem; margin: 2px 0 8px; }
.ex-list { display: grid; gap: 8px; }
.ex-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.ex-row .thumb { position: relative; width: 64px; height: 64px; border-radius: 9px; flex: none; background: #111 var(--photo) center / cover; }
.ex-row .thumb .n { position: absolute; left: 4px; top: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; }
.ex-row b { display: block; font-size: 0.92rem; line-height: 1.25; margin-bottom: 6px; }
.ex-row .chips { gap: 4px; }
.ex-row .chip { font-size: 0.7rem; padding: 3px 7px; border-radius: 6px; }
.ex-row .chev { color: var(--accent); }
.ex-row.complete b::after { content: " ✓"; color: var(--accent); }

.dock {
  position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); z-index: 12;
  display: flex; gap: 8px; margin-top: 16px;
}
.dock .btn { flex: 1; padding: 0 12px; white-space: nowrap; font-size: 0.95rem; }
.dock .sq { flex: none; width: 54px; padding: 0; }

/* Exercise focus */
.ex-media { height: 230px; border-radius: var(--radius) var(--radius) 0 0; display: grid; place-items: center; }
.ex-media .playbtn { width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.88); display: grid; place-items: center; color: #111; }
.ex-media .playbtn svg { width: 22px; height: 22px; fill: #111; stroke: none; margin-left: 3px; }
.ex-media .demo-label { position: absolute; bottom: 8px; right: 10px; font-size: 0.7rem; color: rgba(255,255,255,.8); }
.ex-panel { background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); padding: 12px 14px 14px; }
.ex-title { display: flex; align-items: flex-start; gap: 10px; }
.ex-title .grow small { display: block; font-size: 0.72rem; color: var(--muted); }
.ex-title h2 { font-size: 1.2rem; line-height: 1.2; }
.mini-btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 50px; height: 46px; border: 0; border-radius: 9px; background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 0.62rem; font-weight: 600; cursor: pointer;
}
.mini-btn svg { width: 17px; height: 17px; }

.ex-card { padding: 14px; }
.sets-head { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 2px 6px; }
.sets-head h3 { font-size: 1.05rem; }
.sets-head .pb { font-size: 0.78rem; color: var(--muted); }
.sets-head .pb b { color: var(--text); }
.ex-meta { margin: 10px 0 0; }
.technique { margin-top: 10px; font-size: 0.85rem; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.technique svg { width: 15px; height: 15px; color: var(--accent); }
.technique b { color: var(--text); }
.last-time { font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; display: flex; gap: 6px; align-items: center; }
.last-time svg { width: 14px; height: 14px; }
.swap { display: none; }
.superset-tag { font-size: 0.7rem; font-weight: 700; color: var(--accent-text); letter-spacing: .1em; text-transform: uppercase; }

.sets { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.sets th { font-size: 0.7rem; font-weight: 600; color: var(--muted); text-align: center; padding: 0 3px; }
.sets th:first-child { text-align: left; }
.sets td { padding: 0 3px; vertical-align: middle; }
.sets tr td:first-child { border-radius: 10px 0 0 10px; }
.sets td.n { width: 52px; font-size: 0.85rem; font-weight: 600; color: var(--muted); padding-left: 2px; }
.sets td.n small { display: block; font-size: 0.62rem; font-weight: 700; color: var(--accent-text); text-transform: uppercase; letter-spacing: .06em; }
.sets td.chk { width: 54px; text-align: right; }
.sets input { text-align: center; padding: 8px 4px; min-height: 46px; font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; background: var(--surface-2); border-color: transparent; border-radius: 10px; }
.sets input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); font-weight: 500; }
.sets tr.done input { background: var(--accent-soft); color: var(--text); }
.tick {
  width: 46px; height: 46px; border-radius: 10px; border: 0;
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation;
  transition: transform .12s, background .2s;
}
.tick svg { width: 22px; height: 22px; stroke-width: 2.8; }
.tick:active { transform: scale(.92); }
.tick[aria-pressed="true"] { background: var(--accent-fill); color: #fff; }

details.more { margin-top: 6px; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; font-weight: 600; padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 6px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
details.more[open] > summary::after { transform: rotate(225deg) translateY(-1px); }
details.more .body { font-size: 0.9rem; padding: 4px 0 6px; }

/* Session summary */
.summary { min-height: 62vh; border-radius: var(--radius); padding: 22px 16px; display: flex; flex-direction: column; justify-content: flex-end; text-align: center; }
.summary .eyebrow { color: rgba(255,255,255,.8); }
.summary h1 { font-size: 2rem; margin: 4px 0 18px; }
.sum-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sum-stats b { display: block; font-size: 1.35rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.sum-stats span { font-size: 0.68rem; color: rgba(255,255,255,.8); }

/* ---- Buttons & forms -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px;
  border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 0.98rem; font-weight: 700;
  cursor: pointer; touch-action: manipulation; transition: transform .1s, filter .15s;
}
.btn svg { width: 19px; height: 19px; stroke-width: 2.2; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent-fill); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.done-state { background: var(--surface-3); color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; }
.btn.ghost { background: transparent; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }

label.field { display: block; }
label.field > span { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: 12px;
  padding: 12px 14px; min-height: 50px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; border: 0; border-radius: 10px; background: var(--surface-2);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.segmented button svg { width: 16px; height: 16px; }
.segmented button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; }

/* ---- Auth --------------------------------------------------------------------------- */
.auth {
  position: relative; isolation: isolate;
  margin: -8px -14px 0; min-height: 100vh; min-height: 100dvh;
  padding: calc(40px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  display: flex; flex-direction: column; color: #fff;
  background: #000 url(/img/photo-deadlift.webp) center 20% / cover no-repeat;
}
.auth::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,.7) 0%, rgba(0,0,0,.2) 30%, rgba(0,0,0,.85) 58%, #000 78%); }
.auth .brand img { display: block; width: min(300px, 80%); margin: 0 auto; }
.auth .pitch { margin-top: auto; padding-top: 110px; text-align: center; }
.auth .pitch h1 { font-size: 2.1rem; line-height: 1.08; }
.auth .pitch h1 span { color: var(--accent); }
.auth .pitch p { color: rgba(255,255,255,.75); margin: 10px auto 0; max-width: 32ch; }
.auth-form { margin-top: 22px; }
.auth-form label.field > span { color: rgba(255,255,255,.7); }
.auth-form input { background: rgba(255,255,255,.1); color: #fff; }
.auth .switch { text-align: center; color: rgba(255,255,255,.7); margin-top: 16px; }
.auth .switch a { color: #fff; font-weight: 700; }

/* ---- Sheet ---------------------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); animation: up .22s cubic-bezier(.2, .7, .2, 1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
.option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 12px; min-height: 58px; margin-top: 8px; border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option[aria-pressed="true"] > svg { color: var(--accent); }
.option .grow small { display: block; color: var(--muted); font-size: 0.8rem; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }

/* ---- Rest timer -------------------------------------------------------------------- */
.timer {
  position: fixed; z-index: 40;
  left: 10px; right: 10px; bottom: calc(var(--tab-h) + var(--safe-b) + 10px);
  max-width: 620px; margin: 0 auto; overflow: hidden;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 10px 16px; border-radius: 16px;
  background: var(--accent-fill); color: #fff;
  box-shadow: 0 14px 36px -10px rgba(236, 100, 23, 0.55);
}
.timer .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.9); transition: width .25s linear; }
.timer .t { font-size: 2.1rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; flex: 1; }
.timer .t small { display: block; font-size: 0.72rem; font-weight: 600; opacity: .85; margin-bottom: 2px; }
.timer button { min-width: 48px; height: 44px; border: 0; border-radius: 11px; background: rgba(0,0,0,.16); color: inherit; cursor: pointer; font: inherit; font-weight: 700; }
.timer.finished { animation: glow 1.1s ease-in-out 3; }
.timer.finished .bar { display: none; }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(236, 100, 23, 0.3); } }

/* ---- Toast -------------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; top: calc(70px + var(--safe-t)); z-index: 60;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  padding: 11px 16px; border-radius: 12px; max-width: calc(100% - 32px);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 0.9rem;
  border-left: 4px solid var(--accent); box-shadow: 0 12px 30px rgba(0,0,0,.4);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-left-color: var(--danger); }
.save-state { font-size: 0.75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.save-state.pending { color: var(--warn); }

/* ---- Chart ----------------------------------------------------------------------- */
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart:focus:not(:focus-visible) { outline: none; }
.chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart); opacity: 0.1; }
.chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; top: 0; pointer-events: none; padding: 6px 10px; border-radius: 9px; background: var(--text); color: var(--bg); font-size: 0.8rem; font-weight: 600; white-space: nowrap; transform: translateX(-50%); }
.chart-tip b { font-variant-numeric: tabular-nums; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 0.72rem; font-weight: 600; color: var(--muted); border-top: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

.prose ul { padding-left: 1.1em; margin: 0.5em 0; }
.prose li { margin: 0.5em 0; }
.prose li::marker { color: var(--accent); }
.prose h2 { margin-bottom: 6px; }
.empty { text-align: center; padding: 30px 20px; }
.empty .brand-mark { width: 54px; height: auto; margin: 0 auto 12px; display: block; }
.footer-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 30px; color: var(--muted); font-size: 0.78rem; }
.footer-brand img { width: 150px; opacity: .7; }
:root[data-theme="light"] .footer-brand img { content: url(/img/logo-dark.svg); }

@media (min-width: 700px) {
  .view { padding-top: 16px; }
  .auth { margin: 0; border-radius: 0 0 var(--radius) var(--radius); min-height: 92vh; }
  .home-top { grid-template-columns: 1fr 140px; }
  .home-top .prog-card { min-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Progressive overload: "Last → aim" per set ---------------------------------- */
.sets td.n { width: 40px; font-size: 0.8rem; }
.sets td.prev { width: 76px; }
.sets th.prev-h { text-align: left; white-space: nowrap; }
.sets input { min-width: 0; padding: 8px 2px; }
.prev-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  padding: 4px 2px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font: inherit; text-align: left; white-space: nowrap; line-height: 1.2;
}
.prev-btn:active { background: var(--surface-2); }
.prev-btn .was { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.prev-btn .aim { color: var(--accent-text); font-size: 0.78rem; font-weight: 800; }
.prev-btn .beaten { display: none; color: var(--accent-text); font-size: 0.74rem; font-weight: 800; }
.sets tr.beat .prev-btn .aim { display: none; }
.sets tr.beat .prev-btn .beaten { display: block; }
.sets .first { font-size: 0.72rem; color: var(--muted); }
.last-line { font-size: 0.74rem; color: var(--muted); margin: -3px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overload-hint { display: flex; gap: 8px; align-items: flex-start; margin: 8px 2px 0; font-size: 0.78rem; line-height: 1.4; color: var(--muted); }
.overload-hint svg { width: 14px; height: 14px; margin-top: 2px; color: var(--accent); }

/* ---- Exercise tools: weight jump, plate calculator ---------------------------------- */
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; }
.tool {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 0; border-radius: 10px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.tool svg { width: 15px; height: 15px; color: var(--accent); }
.tool b { color: var(--accent-text); }

/* ---- Warm-up calculator --------------------------------------------------------------- */
.warm-card { padding: 8px 12px 12px; }
.warm-list { list-style: none; margin: 0; padding: 0; }
.warm-list li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.warm-list li + li { border-top: 1px solid var(--line); }
.warm-list .wn { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.warm-list b { font-weight: 800; }
.warm-list em { font-style: normal; font-size: 0.7rem; color: var(--muted); margin-left: 6px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); }

/* ---- Plate calculator sheet -------------------------------------------------------- */
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; }
.stepper button { border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.stepper input { text-align: center; font-size: 1.3rem; font-weight: 800; }
.plate-viz { display: flex; align-items: center; justify-content: flex-start; gap: 3px; min-height: 110px; margin: 16px 0 4px; padding-left: 4px; overflow-x: auto; }
.plate-viz .sleeve { width: 44px; height: 12px; border-radius: 3px; background: linear-gradient(180deg, #e9ebee, #8b8f95); flex: none; }
.plate-viz .disc { flex: none; width: 22px; border-radius: 4px; display: grid; place-items: center; color: #fff; font-size: 0.62rem; font-weight: 800; writing-mode: vertical-rl; transform: rotate(180deg); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.plate-viz .collar { width: 10px; height: 26px; border-radius: 3px; background: #8b8f95; flex: none; }
.plate-sum { font-size: 0.95rem; margin: 6px 0 0; }
.warn-text { color: var(--warn); font-size: 0.85rem; }

/* ---- Effort (RPE) per set --------------------------------------------------------------- */
.rpe-btn {
  display: block; margin-top: 4px; padding: 2px 5px; min-height: 22px; border: 0; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font: inherit; font-size: 0.62rem; font-weight: 700;
  letter-spacing: .02em; cursor: pointer; white-space: nowrap;
}
.rpe-btn.set { background: var(--accent-soft); color: var(--accent-text); font-size: 0.72rem; }
.rpe-grid .option { min-height: 50px; padding: 10px 12px; margin-top: 6px; }
.rpe-num { width: 34px; flex: none; text-align: center; font-size: 1.2rem; font-weight: 800; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.rpe-note { color: var(--muted); font-size: 0.78em; margin-left: 1px; }

/* ---- Deload targets ------------------------------------------------------------------------ */
.prev-btn .aim.hold { color: var(--muted); }

/* ---- Personal records ------------------------------------------------------------------------ */
.prev-btn .prtag { display: none; align-items: center; gap: 3px; color: var(--accent-text); font-size: 0.74rem; font-weight: 800; }
.prev-btn .prtag svg { width: 12px; height: 12px; }
.sets tr.pr .prev-btn .aim, .sets tr.pr .prev-btn .beaten { display: none; }
.sets tr.pr .prev-btn .prtag { display: inline-flex; }
.pr-card { padding: 14px 16px 6px; }
.pr-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pr-head svg { width: 20px; height: 20px; color: var(--accent); }
.pr-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.pr-row + .pr-row { border-top: 1px solid var(--line); }
.pr-val, .rec-val { font-weight: 800; white-space: nowrap; }
.rec-val small { font-size: 0.72em; font-weight: 600; color: var(--muted); margin-left: 1px; }
.rec-icon { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.rec-icon svg { width: 18px; height: 18px; }

/* ---- Training calendar ------------------------------------------------------------------------ */
.cal-card { padding: 16px; }
.cal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; text-align: center; }
.cal-stats b { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.05; color: var(--accent); font-variant-numeric: tabular-nums; }
.cal-stats span { font-size: 0.72rem; color: var(--muted); }
.cal { display: grid; grid-template-columns: 14px 1fr; grid-template-rows: auto auto; column-gap: 6px; row-gap: 4px; }
.cal-months { grid-column: 2; display: grid; grid-template-columns: repeat(16, 1fr); font-size: 0.64rem; color: var(--muted); white-space: nowrap; }
.cal-days { grid-row: 2; display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; font-size: 0.58rem; color: var(--muted); align-items: center; }
.cal-grid { grid-row: 2; grid-column: 2; display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.cal-cell { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); cursor: pointer; }
.cal-cell.on { background: var(--accent); }
.cal-cell.future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); cursor: default; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal-cell.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.cal-key { display: inline-flex; align-items: center; gap: 5px; font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.cal-key .cal-cell { width: 10px; cursor: default; }
.cal-key .cal-cell.on { margin-left: 6px; }
.sheet:focus { outline: none; }

/* ---- Supersets on one screen --------------------------------------------------------- */
.ss-banner { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 0.86rem; line-height: 1.4; }
.ss-banner svg { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 1px; }
.ss-then { display: flex; align-items: center; gap: 10px; margin: 26px 2px 10px; color: var(--accent-text); font-size: 0.74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.ss-then::before, .ss-then::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.ex-panel.partner { border-radius: var(--radius); }

/* ---- Stall detection ------------------------------------------------------------------------ */
.stall-card { margin-top: 12px; padding: 14px 16px; border-left: 3px solid var(--warn); }
.stall-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stall-head svg { width: 18px; height: 18px; color: var(--warn); }
.stall-card p { margin: 0; }
.stall-card .tool { background: var(--surface-2); }

/* ---- Sets per muscle ------------------------------------------------------------------------ */
.vol-card { padding: 14px 16px; }
.vol-list { list-style: none; margin: 0; padding: 0; }
.vol-row { display: grid; grid-template-columns: 96px 1fr 30px; align-items: center; gap: 10px; padding: 5px 0; }
.vol-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol-track { position: relative; height: 14px; }
.vol-bar { position: absolute; left: 0; top: 0; bottom: 0; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--chart); }
.vol-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.vol-val { text-align: right; font-weight: 800; font-size: 0.9rem; }
.vol-key { display: flex; gap: 16px; margin-top: 10px; font-size: 0.72rem; color: var(--muted); }
.vol-key span { display: inline-flex; align-items: center; gap: 6px; }
.vol-key-bar { display: inline-block; width: 14px; height: 10px; border-radius: 0 3px 3px 0; background: var(--chart); }
.vol-key-tick { display: inline-block; width: 2px; height: 14px; border-radius: 1px; background: var(--text); }

/* ---- Bodyweight ------------------------------------------------------------------------------ */
.bw-now { font-size: 1.9rem; font-weight: 800; line-height: 1.1; color: var(--accent); }
.bw-now small { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.bw-card .btn.small svg { width: 16px; height: 16px; }

/* ---- Admin: members ----------------------------------------------------------------------- */
.round-btn { position: relative; }
.badge-dot { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--chrome); }
.count-badge { min-width: 26px; height: 26px; padding: 0 7px; flex: none; border-radius: 13px; display: grid; place-items: center; background: var(--accent-fill); color: #fff; font-size: 0.8rem; font-weight: 800; }
.admin-link { padding: 12px 16px; }
.member { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 14px 16px; }
.member + .member { border-top: 1px solid var(--line); }
.member .grow { min-width: 160px; }
.member .chip { vertical-align: 2px; margin-left: 4px; }
.member-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.member-actions .btn svg { width: 15px; height: 15px; }
