/* ==========================================================================
   Forge design system — dark-first, mobile-first.
   Rule of thumb for motion: animate only transform + opacity.
   ========================================================================== */

@font-face {
    font-family: "Space Grotesk";
    src: url("../fonts/space-grotesk-latin-wght.woff2") format("woff2");
    font-weight: 300 700;
    font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
    color-scheme: dark;

    --bg: #05070c;
    --bg-elev: #0b0f17;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-2: rgba(255, 255, 255, 0.075);
    --surface-3: rgba(255, 255, 255, 0.11);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text: #f3f6fb;
    --text-2: #a7b0c0;
    --text-3: #687286;

    --lime: #c8ff3e;
    --cyan: #2ee8d8;
    --magenta: #ff3d9a;
    --orange: #ff8a3d;
    --amber: #ffbe4d;
    --red: #ff4d61;
    --indigo: #7083ff;
    --violet: #a46bff;

    --grad-primary: linear-gradient(135deg, #d6ff3e 0%, #2ee8d8 100%);
    --grad-hot: linear-gradient(135deg, #ff3d9a 0%, #ff8a3d 100%);
    --grad-cool: linear-gradient(135deg, #7083ff 0%, #2ee8d8 100%);
    --grad-gold: linear-gradient(135deg, #ffe17a 0%, #ff9f3d 100%);

    --r-xl: 28px;
    --r-lg: 22px;
    --r-md: 16px;
    --r-sm: 12px;
    --r-pill: 999px;

    --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-h: 68px;
    --gutter: 16px;

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --shadow-card: 0 12px 32px -12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }

/* ---------- App shell ---------- */
.app {
    position: relative;
    min-height: 100dvh;
    isolation: isolate;
}

/* Ambient glow lives on a fixed layer so it never repaints with scroll. */
.app::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(70vmax 45vmax at 95% -12%, rgba(46, 232, 216, 0.13), transparent 60%),
        radial-gradient(60vmax 40vmax at -15% 8%, rgba(200, 255, 62, 0.08), transparent 60%),
        radial-gradient(50vmax 40vmax at 50% 115%, rgba(164, 107, 255, 0.10), transparent 60%);
}

.page {
    max-width: 560px;
    margin: 0 auto;
    padding: calc(var(--safe-top) + 14px) var(--gutter) calc(var(--nav-h) + var(--safe-bottom) + 28px);
    animation: page-in 0.42s var(--ease-out) backwards;
}

.page.focus { padding-bottom: calc(var(--safe-bottom) + 120px); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* ---------- Typography ---------- */
.display, .num, h1, h2, h3 { font-family: var(--font-display); }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }

.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.strong { font-weight: 650; }

.text-grad {
    background: var(--grad-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.text-hot { background: var(--grad-hot); -webkit-background-clip: text; background-clip: text; color: transparent; }
.text-gold { background: var(--grad-gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
.c-lime { color: var(--lime); }
.c-cyan { color: var(--cyan); }
.c-magenta { color: var(--magenta); }
.c-amber { color: var(--amber); }

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 6px 2px -2px;
}
.section-title h2 { font-size: 18px; }
.section-title a, .section-title button { font-size: 14px; color: var(--cyan); background: none; border: 0; padding: 0; }

/* ---------- Cards ---------- */
.card {
    position: relative;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.022));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card.hero { border-radius: var(--r-xl); padding: 18px 16px 16px; }
.card.tap { transition: transform 0.18s var(--ease-out); }
.card.tap:active { transform: scale(0.98); }

.card.glow-lime { border-color: rgba(200, 255, 62, 0.28); box-shadow: var(--shadow-card), 0 0 40px -18px rgba(200, 255, 62, 0.6); }
.card.glow-hot { border-color: rgba(255, 61, 154, 0.3); box-shadow: var(--shadow-card), 0 0 40px -16px rgba(255, 61, 154, 0.55); }
.card.glow-gold { border-color: rgba(255, 190, 77, 0.32); box-shadow: var(--shadow-card), 0 0 40px -16px rgba(255, 190, 77, 0.55); }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 20px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    font-weight: 650;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.16s var(--ease-out), opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.lg { min-height: 60px; font-size: 18px; border-radius: 20px; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }

.btn.primary {
    border: 0;
    color: #061008;
    background: var(--grad-primary);
    box-shadow: 0 14px 34px -12px rgba(200, 255, 62, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.hot { border: 0; color: #fff; background: var(--grad-hot); box-shadow: 0 14px 34px -12px rgba(255, 61, 154, 0.6); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.outline { background: transparent; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: transform 0.16s var(--ease-out);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.round { border-radius: 50%; }

/* ---------- Chips & segmented ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter); }
.chips.scroll::-webkit-scrollbar { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.16s var(--ease-out), background 0.2s, border-color 0.2s, color 0.2s;
}
.chip:active { transform: scale(0.95); }
.chip.on { background: rgba(200, 255, 62, 0.13); border-color: rgba(200, 255, 62, 0.6); color: var(--lime); }
.chip.off { text-decoration: line-through; opacity: 0.55; }
.chip.big { min-height: 54px; padding: 0 18px; font-size: 17px; }

.seg {
    --n: 3;
    --i: 0;
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--n), 1fr);
    padding: 4px;
    border-radius: var(--r-pill);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
}
.seg::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / var(--n));
    border-radius: var(--r-pill);
    background: var(--surface-3);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.35);
    transform: translateX(calc(var(--i) * 100%));
    transition: transform 0.35s var(--ease-out);
}
.seg button {
    position: relative;
    z-index: 1;
    min-height: 36px;
    border: 0;
    background: none;
    color: var(--text-3);
    font-weight: 650;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.25s;
}
.seg button.on { color: var(--text); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: 12px;
    font-weight: 650;
    background: var(--surface-2);
    color: var(--text-2);
}
.badge.lime { background: rgba(200, 255, 62, 0.14); color: var(--lime); }
.badge.cyan { background: rgba(46, 232, 216, 0.14); color: var(--cyan); }
.badge.hot { background: rgba(255, 61, 154, 0.15); color: var(--magenta); }
.badge.amber { background: rgba(255, 190, 77, 0.15); color: var(--amber); }

/* ---------- Bottom navigation ---------- */
.nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding: 0 8px var(--safe-bottom);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(8, 11, 18, 0.78);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    border-top: 1px solid var(--border);
}
.nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 52px;
    justify-content: center;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    transition: color 0.2s;
}
.nav a.active { color: var(--lime); }
.nav a.active svg { filter: drop-shadow(0 0 8px rgba(200, 255, 62, 0.55)); }
.nav .fab {
    justify-self: center;
    width: 62px;
    height: 62px;
    margin-top: -26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #061008;
    background: var(--grad-primary);
    box-shadow: 0 10px 30px -6px rgba(200, 255, 62, 0.7), 0 0 0 6px var(--bg);
    transition: transform 0.2s var(--ease-spring);
}
.nav .fab:active { transform: scale(0.9); }
.nav .fab.active svg { filter: none; }

/* ---------- Header ---------- */
.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.top .greet { font-size: 14px; color: var(--text-2); }
.top h1 { font-size: 26px; margin-top: 2px; }

.avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    background: radial-gradient(circle at 30% 25%, #2a3346, #121722);
    border: 2px solid transparent;
    background-clip: padding-box;
}
.avatar::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    padding: 2px;
    background: var(--grad-primary);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}
.avatar .lvl {
    position: absolute;
    bottom: -6px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 11px;
    background: var(--lime);
    color: #061008;
    font-size: 11px;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 3px var(--bg);
}

.streak-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px 0 10px;
    border-radius: var(--r-pill);
    background: rgba(255, 138, 61, 0.12);
    border: 1px solid rgba(255, 138, 61, 0.35);
    color: #ffb27a;
    font-family: var(--font-display);
    font-weight: 700;
}
.streak-pill svg { color: var(--orange); filter: drop-shadow(0 0 6px rgba(255, 138, 61, 0.7)); }

/* ---------- Muscle map ---------- */
.mm {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px 6px 0;
}
.mm-view { position: relative; }
.mm-view .mm-label {
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-top: 2px;
}
.mm-svg { width: 100%; height: auto; overflow: visible; }
.mm-slot { aspect-ratio: 638 / 1300; display: grid; place-items: center; }
.mm-skeleton {
    width: 70%;
    height: 92%;
    border-radius: 40% 40% 20% 20%;
    background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.07), rgba(255,255,255,.03));
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

.mm-body path { fill: #161c29; }
.mm-m path {
    fill: #222a3b;
    stroke: #070a10;
    stroke-width: 2.5;
    transition: fill 0.7s var(--ease-out), opacity 0.4s;
    cursor: pointer;
}
.mm-m.hot path { filter: url(#mm-glow); }
.mm-m.sel path { stroke: #ffffff; stroke-width: 5; }
.mm-m.pulse path { animation: mm-pulse 1.5s var(--ease-out) 3; }
.mm.dim .mm-m:not(.sel) path { opacity: 0.55; }

.mm-intro .mm-view { animation: mm-rise 0.8s var(--ease-out) backwards; }
.mm-intro .mm-view:nth-child(2) { animation-delay: 0.08s; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend-bar { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-2); justify-content: center; }
.legend-bar span.bar { width: 140px; height: 8px; border-radius: 4px; }
.mm-caption { font-size: 11px; color: var(--text-3); text-align: center; line-height: 1.35; }

/* ---------- Rings, meters, bars ---------- */
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: rgba(255, 255, 255, 0.07); }
.ring .value {
    transition: stroke-dashoffset 1.2s var(--ease-out);
}
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }

.meter { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.meter > span {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: var(--grad-primary);
    transform-origin: left center;
    transform: scaleX(var(--v, 0));
    animation: meter-in 1.1s var(--ease-out) backwards;
}
.meter.hot > span { background: var(--grad-hot); }
.meter.cool > span { background: var(--grad-cool); }
.meter.gold > span { background: var(--grad-gold); }

.week-dots { display: flex; justify-content: space-between; gap: 6px; }
.week-dots .d { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.week-dots .d i {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
}
.week-dots .d.done i { background: var(--grad-primary); border: 0; color: #061008; box-shadow: 0 6px 16px -6px rgba(200, 255, 62, 0.7); }
.week-dots .d.today i { border-color: var(--cyan); }

/* ---------- Stat tiles ---------- */
.tile {
    padding: 14px;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px solid var(--border);
}
.tile .label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.tile .value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; line-height: 1; }
.tile .value small { font-size: 14px; font-weight: 600; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.tile .delta { margin-top: 6px; font-size: 12px; font-weight: 600; }
.delta.up { color: var(--lime); }
.delta.down { color: var(--red); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}
.list-item:last-child { border-bottom: 0; }
.ico {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--text-2);
}
.ico.lime { background: rgba(200, 255, 62, 0.12); color: var(--lime); }
.ico.cyan { background: rgba(46, 232, 216, 0.12); color: var(--cyan); }
.ico.hot { background: rgba(255, 61, 154, 0.13); color: var(--magenta); }
.ico.amber { background: rgba(255, 190, 77, 0.13); color: var(--amber); }
.ico.violet { background: rgba(164, 107, 255, 0.14); color: var(--violet); }
.ico.gold { background: var(--grad-gold); color: #2a1600; }
.ico.grad { background: var(--grad-primary); color: #061008; }

/* ---------- Workout: plan + active ---------- */
.ex-card {
    border-radius: var(--r-lg);
    background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
    border: 1px solid var(--border);
    overflow: hidden;
    transition: border-color 0.3s, background 0.3s;
}
.ex-card.done { border-color: rgba(200, 255, 62, 0.35); background: linear-gradient(180deg, rgba(200,255,62,.07), rgba(200,255,62,.015)); }
.ex-card.skipped { opacity: 0.5; }
.ex-head { display: flex; align-items: center; gap: 12px; padding: 14px; }
.ex-num {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-2);
    background: var(--surface-2);
}
.ex-title { font-weight: 650; font-size: 16px; line-height: 1.25; }
.ex-meta { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.ex-meta .num { color: var(--text); font-weight: 600; }

.check {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 2px solid var(--border-strong);
    background: transparent;
    color: transparent;
    cursor: pointer;
    transition: transform 0.25s var(--ease-spring), background 0.25s, border-color 0.25s, color 0.2s;
}
.check:active { transform: scale(0.88); }
.check.on { background: var(--grad-primary); border-color: transparent; color: #061008; box-shadow: 0 8px 20px -8px rgba(200, 255, 62, 0.8); }
.check.sm { width: 36px; height: 36px; }

.ex-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.ex-actions { display: flex; gap: 8px; padding-top: 4px; }

.set-row {
    position: relative;
    display: grid;
    grid-template-columns: 28px 1fr 1fr 40px;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.25);
    touch-action: pan-y;
    overflow: hidden;
    transition: background 0.25s;
}
.set-row .sn { font-family: var(--font-display); color: var(--text-3); font-weight: 700; text-align: center; }
.set-row.done { background: rgba(200, 255, 62, 0.09); }
.set-row .swipe-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding-left: 16px;
    gap: 8px;
    color: #061008;
    font-weight: 700;
    background: var(--grad-primary);
    opacity: 0;
    pointer-events: none;
}
.set-row .swipe-content { display: contents; }

.stepper {
    display: grid;
    grid-template-columns: 34px 1fr 34px;
    align-items: center;
    height: 40px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.stepper button {
    height: 100%;
    border: 0;
    background: none;
    color: var(--text-2);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.stepper button:active { color: var(--lime); }
.stepper .v { text-align: center; font-family: var(--font-display); font-weight: 650; font-size: 16px; line-height: 1; }
.stepper .v small { display: block; font-size: 10px; font-weight: 500; color: var(--text-3); margin-top: 2px; font-family: var(--font-body); }

.workout-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 14px var(--gutter) calc(var(--safe-bottom) + 14px);
    background: linear-gradient(180deg, rgba(5, 7, 12, 0), rgba(5, 7, 12, 0.97) 24%);
}
.workout-bar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }

.timer-big { font-family: var(--font-display); font-size: 40px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.rest-pill {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + 96px);
    z-index: 45;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 10px 18px;
    border-radius: var(--r-pill);
    background: rgba(14, 19, 30, 0.92);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(46, 232, 216, 0.4);
    box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8), 0 0 30px -10px rgba(46, 232, 216, 0.6);
    animation: pop-in 0.4s var(--ease-spring) backwards;
}
.rest-pill .t { font-family: var(--font-display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--cyan); min-width: 64px; }

.generating { display: grid; place-items: center; gap: 18px; padding: 40px 0; text-align: center; }
.orb {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #c8ff3e, #2ee8d8, #a46bff, #ff3d9a, #c8ff3e);
    filter: blur(1px);
    animation: spin 1.6s linear infinite;
    position: relative;
}
.orb::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--bg); }
.orb-wrap { position: relative; display: grid; place-items: center; }
.orb-wrap svg { position: absolute; color: var(--lime); animation: breathe 1.6s ease-in-out infinite; }

/* ---------- Sheet ---------- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 81;
    max-width: 560px;
    margin: 0 auto;
    max-height: 88dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px var(--gutter) calc(var(--safe-bottom) + 20px);
    border-radius: 28px 28px 0 0;
    background: #0e131d;
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(105%);
    transition: transform 0.42s var(--ease-out);
    will-change: transform;
}
.sheet.open { transform: translateY(0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 4px auto 14px; }
.sheet h2 { margin-bottom: 4px; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s var(--ease-out) forwards; }
.chart .area { opacity: 0; animation: fade-in 0.8s 0.5s var(--ease-out) forwards; }
.chart .grid line { stroke: rgba(255, 255, 255, 0.06); }
.chart .axis text { fill: var(--text-3); font-size: 10px; font-family: var(--font-body); }
.chart .cursor { opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.chart.scrubbing .cursor { opacity: 1; }
.chart .tip {
    position: absolute;
    top: -6px;
    transform: translateX(-50%);
    padding: 5px 9px;
    border-radius: 9px;
    background: #1a2131;
    border: 1px solid var(--border-strong);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.chart.scrubbing .tip { opacity: 1; }
.bars rect { transform-box: fill-box; transform-origin: bottom; animation: bar-in 0.9s var(--ease-out) backwards; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: rgba(255, 255, 255, 0.05); animation: fade-in 0.5s var(--ease-out) backwards; }
.heat i.l1 { background: rgba(46, 232, 216, 0.28); }
.heat i.l2 { background: rgba(46, 232, 216, 0.55); }
.heat i.l3 { background: rgba(140, 245, 120, 0.8); }
.heat i.l4 { background: var(--lime); box-shadow: 0 0 10px -2px rgba(200, 255, 62, 0.7); }

/* ---------- Celebration / badges ---------- */
.hero-num { font-family: var(--font-display); font-size: 64px; font-weight: 700; letter-spacing: -0.04em; line-height: 0.95; }
.trophy-burst {
    width: 92px;
    height: 92px;
    margin: 0 auto;
    border-radius: 28px;
    display: grid;
    place-items: center;
    background: var(--grad-gold);
    color: #2a1600;
    box-shadow: 0 20px 50px -12px rgba(255, 159, 61, 0.7);
    animation: pop-in 0.7s 0.2s var(--ease-spring) backwards;
}
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.medal { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 11px; color: var(--text-2); }
.medal .m {
    width: 60px;
    height: 60px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: var(--grad-primary);
    color: #061008;
    box-shadow: 0 10px 24px -10px rgba(200, 255, 62, 0.7);
}
.medal.locked .m { background: var(--surface-2); color: var(--text-3); box-shadow: none; }
.medal.gold .m { background: var(--grad-gold); color: #2a1600; box-shadow: 0 10px 24px -10px rgba(255, 159, 61, 0.7); }
.medal.hot .m { background: var(--grad-hot); color: #fff; box-shadow: 0 10px 24px -10px rgba(255, 61, 154, 0.7); }
.medal.cool .m { background: var(--grad-cool); color: #050816; box-shadow: 0 10px 24px -10px rgba(112, 131, 255, 0.7); }

.stagger > * { animation: rise-in 0.55s var(--ease-out) backwards; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.07s; }
.stagger > *:nth-child(3) { animation-delay: 0.12s; }
.stagger > *:nth-child(4) { animation-delay: 0.17s; }
.stagger > *:nth-child(5) { animation-delay: 0.22s; }
.stagger > *:nth-child(6) { animation-delay: 0.27s; }
.stagger > *:nth-child(7) { animation-delay: 0.32s; }
.stagger > *:nth-child(n+8) { animation-delay: 0.37s; }

.notice {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: rgba(255, 190, 77, 0.08);
    border: 1px solid rgba(255, 190, 77, 0.3);
    color: #ffd897;
    font-size: 13px;
}
.notice svg { flex: none; color: var(--amber); margin-top: 1px; }

.toggle {
    position: relative;
    width: 52px;
    height: 32px;
    flex: none;
    border-radius: 16px;
    border: 0;
    background: var(--surface-3);
    cursor: pointer;
    transition: background 0.25s;
}
.toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.3s var(--ease-spring);
}
.toggle.on { background: var(--lime); }
.toggle.on::after { transform: translateX(20px); background: #061008; }

/* ---------- Keyframes ---------- */
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateX(var(--tx, 0)) scale(0.6); } to { opacity: 1; transform: translateX(var(--tx, 0)) scale(1); } }
@keyframes mm-rise { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes mm-pulse { 0% { opacity: 1; } 30% { opacity: 0.35; } 100% { opacity: 1; } }
@keyframes meter-in { from { transform: scaleX(0); } }
@keyframes bar-in { from { transform: scaleY(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: scale(0.9); opacity: 0.8; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.rest-pill { --tx: -50%; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--safe-bottom) + 12px);
    z-index: 1000;
    display: none;
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: #2a1018;
    border: 1px solid rgba(255, 77, 97, 0.5);
    color: #ffd0d6;
}
#blazor-error-ui .reload { color: var(--lime); font-weight: 650; margin-left: 8px; }
#blazor-error-ui .dismiss { position: absolute; right: 14px; top: 12px; cursor: pointer; }

/* ---------- Page-level helpers ---------- */
.mm-slot > svg { width: 100%; height: 100%; }
.mt-map { margin-top: 10px; }
.rot180 { transform: rotate(180deg); }
.icon-btn svg { transition: transform 0.3s var(--ease-out); }
.inline-ico { display: inline-block; vertical-align: -2px; color: var(--lime); }
.seg.seg-sm button { min-height: 30px; padding: 0 10px; font-size: 12px; }

.search {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 44px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 16px; /* 16px stops iOS zooming on focus */
    outline: none;
}
.search:focus { border-color: rgba(46, 232, 216, 0.6); }
.search::placeholder { color: var(--text-3); }
.search-ico { position: absolute; left: 14px; top: 15px; color: var(--text-3); pointer-events: none; }

.hk { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: rgba(255,255,255,.05); vertical-align: -1px; margin: 0 1px; }
.hk.l2 { background: rgba(46, 232, 216, 0.55); }
.hk.l4 { background: var(--lime); }

/* Closed sheets are fully hidden (no shadow peeking at the screen edge). */
.sheet { visibility: hidden; transition: transform 0.42s var(--ease-out), visibility 0s linear 0.42s; }
.sheet.open { visibility: visible; transition: transform 0.42s var(--ease-out), visibility 0s; }

/* Equipment chips: neutral when available, struck-through when skipped today. */
.chip.eq.on { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.chip.eq.on svg { color: var(--lime); }

/* Declines are informational, never alarming. */
.delta.down { color: var(--text-3); }

/* Action bar on pages that also show the tab bar. */
.workout-bar.above-nav { bottom: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: 12px; }
.page.has-bar { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 110px); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field input, .field select, .field textarea {
    height: 52px;
    padding: 0 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 16px; /* 16px prevents iOS zoom on focus */
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.field input:focus { border-color: rgba(46, 232, 216, 0.6); background: var(--surface-2); }
.field input::placeholder { color: var(--text-3); }
.field input[type="date"] { color-scheme: dark; }

.consent { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--text-2); cursor: pointer; }
.consent input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--lime); }

.notice.error { background: rgba(255, 77, 97, 0.08); border-color: rgba(255, 77, 97, 0.35); color: #ffc2ca; }
.notice.error svg { color: var(--red); }
a.notice.tap, .notice.tap { transition: transform 0.16s var(--ease-out); }
.notice.tap:active { transform: scale(0.98); }

.spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid rgba(6, 16, 8, 0.25);
    border-top-color: #061008;
    animation: spin 0.8s linear infinite;
}

/* ---------- Choice cards (onboarding, pickers) ---------- */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 16px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: transform 0.16s var(--ease-out), border-color 0.2s, background 0.2s;
}
.choice:active { transform: scale(0.97); }
.choice svg { color: var(--text-2); }
.choice.on { border-color: rgba(200, 255, 62, 0.65); background: rgba(200, 255, 62, 0.09); box-shadow: 0 0 30px -16px rgba(200, 255, 62, 0.8); }
.choice.on svg { color: var(--lime); }
.choice.wide { width: 100%; }
.choice .mm { width: 100%; padding: 0; }
.choice-map { pointer-events: none; }

/* ---------- Buttons that look like list rows / links ---------- */
.as-button { width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.list-item.as-button:last-child { border-bottom: 0; }
.section-title.as-button { border: 0; padding: 0; cursor: pointer; }
.link-btn { background: none; border: 0; color: var(--cyan); padding: 0; cursor: pointer; font-weight: 600; }

.steps { margin: 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 8px; font-size: 15px; }

details.excluded summary { list-style: none; cursor: pointer; }
details.excluded summary::-webkit-details-marker { display: none; }

.gym-card { width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }

.set-row.timed { grid-template-columns: 28px 1fr 40px; }

/* ---------- Offline / sync banner ---------- */
.offline-banner {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: calc(var(--safe-top) + 6px) 16px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #bff7f1;
    background: rgba(8, 40, 44, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(46, 232, 216, 0.25);
}

/* ---------- Splash (Blazor-rendered twin of the index.html splash) ---------- */
.splash-blazor { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 26px; }
.splash-mark-b {
    width: 92px; height: 92px; border-radius: 28px; display: grid; place-items: center;
    background: var(--grad-primary); color: #061008; box-shadow: 0 20px 60px -12px rgba(200, 255, 62, 0.65);
    animation: breathe 1.6s ease-in-out infinite;
}
.splash-word-b { font-weight: 800; letter-spacing: 0.32em; font-size: 15px; color: var(--text-2); padding-left: 0.32em; }

/* ---------- Welcome ---------- */
.welcome-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--grad-primary); color: #061008; margin: 4px auto 0; }
.welcome-hero { margin: 4px auto 18px; max-width: 320px; }
.welcome-map { pointer-events: none; }
.page.welcome { padding-bottom: calc(var(--safe-bottom) + 170px); }

/* An exercise with no logged weight yet nudges the user to set one. */
.needs-weight .stepper { border-color: rgba(255, 190, 77, 0.55); background: rgba(255, 190, 77, 0.07); }
.needs-weight .stepper .v small { color: var(--amber); }

/* ---------- Generating screen: never an empty wait ---------- */
.gen { min-height: 72dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 10px 0; }
.gen-progress { width: min(260px, 80%); height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.gen-progress > span {
    display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--grad-primary);
    transform-origin: left center; animation: gen-fill 14s cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}
.gen-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); }
.gen-steps li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-3); transition: color 0.3s; }
.gen-steps li.done { color: var(--text-2); }
.gen-steps li.active { color: var(--text); font-weight: 600; }
.gen-dot {
    width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center;
    border: 2px solid var(--border-strong); color: #061008; transition: background 0.3s, border-color 0.3s;
}
.gen-steps li.done .gen-dot { background: var(--grad-primary); border-color: transparent; animation: pop-in 0.35s var(--ease-spring) backwards; }
.gen-steps li.active .gen-dot { border-color: var(--cyan); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.gen-card { width: 100%; display: flex; gap: 14px; align-items: flex-start; min-height: 104px; animation: gen-card-in 0.5s var(--ease-out) backwards; }
.gen-card p { margin-top: 4px; font-size: 16px; line-height: 1.45; }
.gen-pager { display: flex; gap: 6px; }
.gen-pager i { width: 6px; height: 6px; border-radius: 3px; background: var(--surface-3); transition: width 0.3s var(--ease-out), background 0.3s; }
.gen-pager i.on { width: 18px; background: var(--lime); }
@keyframes gen-fill { from { transform: scaleX(0.04); } to { transform: scaleX(0.92); } }
@keyframes gen-card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Include-cardio switch card */
.cardio-toggle { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; color: inherit; font: inherit; cursor: pointer; transition: border-color 0.25s, box-shadow 0.25s, transform 0.16s var(--ease-out); }
.cardio-toggle:active { transform: scale(0.98); }
.cardio-toggle.on { border-color: rgba(255, 61, 154, 0.45); box-shadow: var(--shadow-card), 0 0 34px -18px rgba(255, 61, 154, 0.75); }
span.toggle { display: inline-block; pointer-events: none; }
.tile.cardio-tile { grid-column: 1 / -1; }
.tile.cardio-tile .label svg { color: var(--magenta); }

/* ---------- Exercise demonstration photos ---------- */
.demo { position: relative; aspect-ratio: 3 / 2; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.demo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.demo .finish { opacity: 0; } /* hidden unless animating or picked by hand */
.demo.animated, .demo.manual { cursor: pointer; }
.demo.animated .finish { animation: demo-swap 2.8s ease-in-out infinite; }
.demo.manual .finish { opacity: 0; transition: opacity 0.35s var(--ease-out); }
.demo.manual.frame-1 .finish { opacity: 1; }
.demo.empty { display: grid; place-items: center; color: var(--text-3); }

/* Start / Finish pills: animated highlight in auto-play, tappable to pick a frame. */
.demo-pills {
    position: absolute; left: 10px; bottom: 10px; display: flex; gap: 2px; padding: 3px; border-radius: var(--r-pill);
    background: rgba(5, 7, 12, 0.75); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.demo-pills button {
    min-height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-2);
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
.demo-pills .p0.on { background: var(--lime); color: #061008; }
.demo-pills .p1.on { background: var(--cyan); color: #061008; }
.demo.animated .demo-pills .p0 { animation: pill-start 2.8s ease-in-out infinite; }
.demo.animated .demo-pills .p1 { animation: pill-finish 2.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
    .demo.animated .demo-pills .p0 { background: var(--lime); color: #061008; }
}
@keyframes demo-swap { 0%, 30% { opacity: 0; } 45%, 80% { opacity: 1; } 95%, 100% { opacity: 0; } }
@keyframes pill-start {
    0%, 30% { background: var(--lime); color: #061008; }
    45%, 80% { background: transparent; color: var(--text-2); }
    95%, 100% { background: var(--lime); color: #061008; }
}
@keyframes pill-finish {
    0%, 30% { background: transparent; color: var(--text-2); }
    45%, 80% { background: var(--cyan); color: #061008; }
    95%, 100% { background: transparent; color: var(--text-2); }
}

/* Thumbnail with the exercise number in the corner (plan list, swap list). */
.ex-thumb { position: relative; width: 58px; height: 58px; flex: none; }
.ex-thumb .demo { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 14px; }
.ex-thumb-n {
    position: absolute; right: -6px; bottom: -6px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
    display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 12px;
    background: var(--bg-elev); border: 1px solid var(--border-strong); color: var(--text);
}
.ex-body .demo { margin-bottom: 4px; max-height: 210px; width: 100%; }
.sheet .demo { margin: 14px 0 6px; }
