/* fyrvo — mobile-first dark fire theme */
:root {
    color-scheme: dark;
    /* Refined ember v2: neutrals lifted off pure-black and warmed so cards
       read as elevated; a hotter, more saturated ember; a cool slate-blue
       secondary so the UI isn't mono-orange; soft drop-shadows instead of
       hairline borders. v2 pushes the primary brighter and swaps the type
       pairing (Bebas Neue + Inter -> Unbounded + Manrope) for a louder,
       more contemporary voice — see mobile's June "Refined ember" pass. */
    --bg: #0e0e12;
    --bg-grad: radial-gradient(ellipse 90% 60% at 50% -8%, rgba(var(--primary-rgb), 0.10), transparent 62%), radial-gradient(ellipse 70% 50% at 100% 0%, rgba(91, 124, 255, 0.06), transparent 60%), #0e0e12;
    --surface: #17171e;
    --surface-soft: #1e1e26;
    --surface-elev: #24242e;
    --text: #f4f4f7;
    --text-strong: #ffffff;
    --muted: #8d8d98;
    --muted-strong: #b6b6c2;
    --border: #2a2a34;
    --border-strong: #3a3a46;
    /* Single source for the brand ember. Every alpha variant below derives
       from --primary-rgb via rgba(var(--primary-rgb), …) so the hue lives in
       exactly one place per theme. (Mobile mirrors this in
       mobile/lib/theme/fyrvo_colors.dart; manifest/JS hexes can't read CSS
       vars and stay in sync by hand.) */
    --primary-rgb: 255, 61, 20;
    --primary: rgb(var(--primary-rgb));
    --primary-hover: #ff7a4d;
    --primary-soft: #331b14;
    --primary-glow: rgba(var(--primary-rgb), 0.5);
    --gradient-flame: linear-gradient(135deg, #ff3d14, #ffb347 85%);
    --secondary: #6a86ff;
    --secondary-hover: #869cff;
    --secondary-soft: #1c2030;
    --accent: #ffb347;
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.32);
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --font-display: "Unbounded", "Manrope", sans-serif;
    --font-body: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --tab-h: 64px;
    --rest-h: 56px;
}

:root.light {
    color-scheme: light;
    --bg: #f4f4f6;
    --bg-grad: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(var(--primary-rgb), 0.06), transparent 60%), #f4f4f6;
    --surface: #ffffff;
    --surface-soft: #eeeef1;
    --surface-elev: #ffffff;
    --text: #15151a;
    --text-strong: #000000;
    --muted: #6b6b75;
    --muted-strong: #3f3f48;
    --border: #e4e4e8;
    --border-strong: #cfcfd6;
    --primary-rgb: 224, 48, 16;
    --primary: rgb(var(--primary-rgb));
    --primary-hover: #c23116;
    --primary-soft: rgba(var(--primary-rgb), 0.10);
    --primary-glow: rgba(var(--primary-rgb), 0.24);
    --gradient-flame: linear-gradient(135deg, #e03010, #e08a1e 85%);
    --accent: #e08a1e;
    --success-soft: rgba(16, 185, 129, 0.10);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10), 0 2px 8px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); }
::selection { background: var(--primary); color: white; }

.app-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: calc(20px + env(safe-area-inset-top)) 0 calc(40px + env(safe-area-inset-bottom));
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }

.brand-mark {
    display: block;
    width: 40px; height: 40px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 18px var(--primary-glow);
}

.brand-text strong {
    font-family: var(--font-display); font-size: 1.35rem; letter-spacing: 0.06em;
    line-height: 1; color: var(--text-strong);
}
.brand-text small {
    display: block; color: var(--muted); margin-top: 3px;
    font-size: 0.65rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.button, .icon-button {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    min-height: 42px;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; font-weight: 700; font-size: 0.92rem;
    transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}
.button { padding: 0 16px; }
.button:active { transform: scale(0.97); }

.button-primary {
    background: var(--gradient-flame); color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}
.button-primary:hover { box-shadow: 0 6px 20px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.2); transform: scale(1.015); }

.button-secondary {
    background: var(--surface); color: var(--text); border-color: var(--border);
}
.button-secondary:hover { background: var(--surface-soft); border-color: var(--border-strong); }

.button-ghost { background: transparent; color: var(--text); }
.button-ghost:hover { background: var(--surface-soft); }

.button-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.button-danger:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); }

.button-block { width: 100%; }

.icon-button {
    width: 42px; background: var(--surface); color: var(--text); border-color: var(--border);
}
.icon-button:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.install-button[hidden] { display: none; }

/* Material Symbols glyph utility — matches the mobile app's Icons.xxx_rounded look. */
.material-symbols-rounded {
    font-family: "Material Symbols Rounded";
    font-weight: normal; font-style: normal;
    font-size: 24px; line-height: 1;
    letter-spacing: normal; text-transform: none;
    display: inline-block; white-space: nowrap; word-wrap: normal;
    direction: ltr; font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
    font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* Hero — compact */
.hero {
    position: relative; overflow: hidden;
    padding: 22px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.10), rgba(255, 182, 39, 0.05) 60%, transparent 100%), var(--surface);
    box-shadow: var(--shadow);
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400; line-height: 0.95;
    margin: 6px 0 14px; text-transform: uppercase;
    color: var(--text-strong);
}
.hero-accent {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p { margin: 0 0 16px; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--primary); font-size: 0.7rem; font-weight: 800;
    letter-spacing: 0.12em; text-transform: uppercase; margin: 0;
}
.eyebrow-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Active session hero */
.session-hero {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 16px; margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-soft), transparent), var(--surface);
    box-shadow: var(--shadow-sm);
}
.session-hero-info { flex: 1; min-width: 0; }
.session-hero-info .name {
    font-family: var(--font-display); font-size: 1.4rem; line-height: 1;
    color: var(--text-strong); letter-spacing: 0.03em; text-transform: uppercase;
    border: 0; background: transparent; padding: 0; width: 100%;
}
.session-hero-info .name:focus { outline: none; color: var(--primary); }
.session-hero-info .meta {
    display: flex; gap: 10px; align-items: center;
    margin-top: 6px; font-size: 0.78rem; color: var(--muted);
}
.session-hero-info .meta .dot-live {
    width: 8px; height: 8px; border-radius: 50%; background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
    animation: pulse 1.5s ease-in-out infinite;
}
.session-hero-actions { display: flex; gap: 8px; }

h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 1rem; font-weight: 800; letter-spacing: 0.02em; margin-bottom: 8px; color: var(--text-strong); }
h3 { font-size: 0.95rem; font-weight: 800; margin-bottom: 6px; color: var(--text-strong); }
.subtle, .muted { color: var(--muted); font-size: 0.92rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px; margin-bottom: 18px;
}
.stat {
    position: relative; overflow: hidden;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.stat::after {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--primary), transparent); opacity: 0.6;
}
.stat-label { color: var(--muted); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; margin-top: 8px; color: var(--text-strong); }
.stat-hint { color: var(--muted); font-size: 0.74rem; margin-top: 4px; font-weight: 500; }

/* Tabs (desktop) */
.tabs {
    display: flex; gap: 4px; padding: 5px;
    margin-bottom: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.tab {
    color: var(--muted-strong);
    padding: 9px 16px;
    font-weight: 700; font-size: 0.88rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
    flex: 1;
}
.tab:hover { color: var(--text); background: var(--surface-soft); }
.tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px var(--primary-glow); }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

.panel {
    padding: 18px; margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Cards */
.template-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px;
    text-align: left;
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}
.template-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.template-card .workout-image {
    display: flex; align-items: center; justify-content: center;
    width: 100%; aspect-ratio: 16 / 10;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.18), transparent 65%),
        linear-gradient(160deg, #1f1f24 0%, #131316 100%);
    margin-bottom: 10px;
    overflow: hidden;
}
:root.light .template-card .workout-image {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.10), transparent 65%),
        linear-gradient(160deg, #ffffff 0%, #eeeef1 100%);
}
.template-card .workout-image .ex-photo { width: 100%; height: 100%; }

/* Library row click affordance */
.library-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-radius: var(--radius-sm);
}
.library-row:hover { background: var(--surface-soft); }
.library-row:active { background: var(--surface-soft); }
.library-chev { color: var(--muted); flex: 0 0 auto; margin-left: 4px; }

/* Exercise card head clickable area */
.exercise-head-clickable {
    display: flex; align-items: center; gap: 12px;
    flex: 1; min-width: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
    padding: 4px;
    margin: -4px;
}
.exercise-head-clickable:hover { background: var(--surface-soft); }

/* ---------- Exercise detail (in sheet) ---------- */
.detail-anim {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.25), transparent 65%),
        linear-gradient(160deg, #1f1f24 0%, #131316 100%);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
:root.light .detail-anim {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.14), transparent 65%),
        linear-gradient(160deg, #ffffff 0%, #eeeef1 100%);
}
.detail-anim .svg-icon, .detail-anim svg { width: 100%; height: 100%; }
.detail-anim .ex-photo, .detail-anim .detail-anim-media {
    width: 100%; height: 100%;
    display: block;
}
/* Bigger / slower animation for the detail view */
.detail-anim svg [class*="anim-"] { animation-duration: 2.4s !important; }

.detail-meta {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 12px;
}
.detail-desc {
    font-size: 0.95rem; line-height: 1.5;
    color: var(--text);
    margin: 0 0 16px;
}
.detail-section { margin-bottom: 18px; }
.detail-section h3 {
    font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 10px;
}
.detail-steps {
    margin: 0; padding: 0; list-style: none;
    counter-reset: step;
    display: flex; flex-direction: column; gap: 8px;
}
.detail-steps li {
    counter-increment: step;
    position: relative;
    padding: 10px 12px 10px 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-size: 0.9rem; line-height: 1.45;
}
.detail-steps li::before {
    content: counter(step);
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #0a0a0b;
    font-family: var(--font-display); font-size: 0.95rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.detail-stats {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px; margin-bottom: 12px;
}
.detail-stat {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    text-align: center;
}
.detail-stat span {
    display: block; color: var(--muted);
    font-size: 0.65rem; font-weight: 800;
    letter-spacing: 0.08em; text-transform: uppercase;
}
.detail-stat strong {
    display: block; margin-top: 4px;
    font-family: var(--font-display); font-size: 1.2rem;
    color: var(--text-strong); letter-spacing: 0.02em;
}
.detail-chart {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
}
.detail-chart-head {
    display: flex; justify-content: space-between;
    font-size: 0.8rem; margin-bottom: 8px;
}
.detail-chart svg {
    width: 100%; height: 110px; display: block;
}
.template-card:hover .workout-image { border-color: var(--primary); }
.template-card h3 { margin-bottom: 4px; }

/* Exercise card */
.exercise-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}
.exercise-head {
    display: flex; align-items: center; gap: 12px;
    padding-bottom: 12px; margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.exercise-thumb {
    width: 56px; height: 56px; flex: 0 0 auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.18), transparent 65%),
        linear-gradient(160deg, #1f1f24 0%, #131316 100%);
    display: inline-flex; align-items: center; justify-content: center;
    overflow: hidden;
}
:root.light .exercise-thumb {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.10), transparent 65%),
        linear-gradient(160deg, #ffffff 0%, #eeeef1 100%);
}
.exercise-thumb svg { width: 100%; height: 100%; }
/* When the thumb is a photo flipbook, give it a white photo backdrop. */
.exercise-thumb.ex-photo,
.session-thumb.ex-photo,
.library-thumb.ex-photo,
.detail-anim-media.ex-photo {
    background: #fff;
}
.exercise-title { flex: 1; min-width: 0; }
.exercise-title h3 { margin-bottom: 2px; line-height: 1.2; }
.exercise-title p { margin: 0; font-size: 0.78rem; color: var(--muted); }
.exercise-menu { width: 36px; height: 36px; border-radius: var(--radius-sm); color: var(--muted-strong); }
.exercise-menu:hover { background: var(--surface-soft); color: var(--text); }
.exercise-menu svg { width: 20px; height: 20px; fill: currentColor; }

/* Sets */
.set-list { display: flex; flex-direction: column; gap: 8px; }

.set-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-soft);
    transition: background 0.18s ease, border-color 0.18s ease;
    position: relative;
}
.set-row.complete {
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, 0.35);
}
.set-row .set-num {
    text-align: center; color: var(--muted-strong);
    font-family: var(--font-display); font-size: 1.3rem;
}
.set-row.complete .set-num { color: var(--success); }

.set-prev {
    grid-column: 2 / span 2;
    display: flex; align-items: center; gap: 6px;
    font-size: 0.72rem; color: var(--muted);
    margin: -4px 0 -2px;
    cursor: pointer; user-select: none;
}
.set-prev:hover { color: var(--text); }
.set-prev .pill-mini {
    padding: 2px 8px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    font-weight: 700;
}

.set-target {
    grid-column: 2 / span 2;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 0.74rem; font-weight: 700; color: var(--primary);
    margin: -2px 0 0;
    padding: 6px 10px;
    border: 1px dashed var(--primary);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    cursor: pointer; user-select: none;
    transition: background 0.12s ease, border-style 0.12s ease;
}
.set-target:hover, .set-target:focus { background: var(--primary-glow); }
.set-target.is-target { border-style: solid; }
.set-target .muted-mini {
    margin-left: auto;
    font-size: 0.68rem; font-weight: 600; color: var(--muted);
}

.plate-link {
    align-self: center;
    margin-top: 4px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.7rem; font-weight: 600;
    cursor: pointer;
}
.plate-link:hover { color: var(--text); border-color: var(--border-strong); }

/* Plate calculator sheet */
.plate-calc { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 12px; }
.plate-calc-input {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface);
}
.plate-calc-input label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.plate-calc-input input {
    flex: 1;
    border: none; background: transparent; outline: none;
    font-size: 1.4rem; font-weight: 800; color: var(--text);
    text-align: right;
}
.plate-calc-meta {
    display: flex; gap: 12px; flex-wrap: wrap;
}
.plate-calc-meta > div {
    flex: 1 1 0; min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-soft);
    text-align: center;
}
.plate-calc-meta strong { display: block; font-size: 1.1rem; }
.plate-calc-meta span { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.plate-calc-meta .warn { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.plate-bar {
    display: flex; align-items: center; justify-content: center;
    padding: 16px 0 8px;
    overflow-x: auto;
}
.plate-bar-rod {
    width: 24px; height: 4px;
    background: linear-gradient(180deg, #999, #555);
    border-radius: 2px;
    flex-shrink: 0;
}
.plate-bar-grip {
    width: 80px; height: 8px;
    background: linear-gradient(180deg, #888, #444);
    border-radius: 4px;
    flex-shrink: 0;
}
.plate-bar-collar {
    width: 6px; height: 22px;
    background: linear-gradient(180deg, #aaa, #555);
    border-radius: 2px;
    flex-shrink: 0;
}
.plate-bar-side {
    display: flex; align-items: center;
    flex-shrink: 0;
}
.plate-bar-side.mirror { flex-direction: row-reverse; }
.plate-vis {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 28px;
    height: 56px;
    padding: 0 6px;
    margin: 0 1px;
    border-radius: 4px;
    color: #fff;
    font-weight: 800; font-size: 0.78rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    background: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.plate-vis small { font-size: 0.62rem; opacity: 0.85; font-weight: 600; }
.plate-vis.plate-25, .plate-vis.plate-45 { background: #c0392b; height: 64px; }
.plate-vis.plate-20, .plate-vis.plate-35 { background: #2980b9; height: 60px; }
.plate-vis.plate-15, .plate-vis.plate-25 { background: #f39c12; height: 56px; }
.plate-vis.plate-10 { background: #27ae60; height: 50px; }
.plate-vis.plate-5  { background: #ffffff; color: #1a1a1c; text-shadow: none; height: 44px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2); }
.plate-vis.plate-2-5 { background: #555; height: 36px; }
.plate-vis.plate-1-25 { background: #888; height: 32px; }
.plate-calc .small { font-size: 0.72rem; }

/* Training heatmap */
.heatmap-panel { padding: 14px 16px 18px; }
.heatmap-stats {
    display: flex; gap: 8px; margin-bottom: 14px;
}
.heatmap-stats > div {
    flex: 1 1 0; min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-soft);
    text-align: center;
}
.heatmap-stats strong { display: block; font-size: 1.2rem; line-height: 1.1; }
.heatmap-stats span { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap-months {
    display: grid;
    grid-template-columns: 32px repeat(26, 14px);
    gap: 3px;
    font-size: 0.65rem; color: var(--muted);
    margin-bottom: 4px;
    margin-left: 2px;
    height: 14px;
}
.heatmap-months span { white-space: nowrap; }
.heatmap-grid {
    display: grid;
    grid-template-columns: 32px repeat(26, 14px);
    grid-template-rows: repeat(7, 14px);
    grid-auto-flow: column;
    gap: 3px;
}
.heatmap-dow {
    grid-column: 1; font-size: 0.62rem; color: var(--muted);
    line-height: 14px; text-align: right; padding-right: 6px;
}
.heatmap-cell {
    width: 14px; height: 14px;
    border-radius: 3px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    box-sizing: border-box;
}
.heatmap-future { visibility: hidden; }
.heatmap-l0 { background: var(--surface-soft); }
.heatmap-l1 { background: rgba(var(--primary-rgb), 0.20); border-color: rgba(var(--primary-rgb), 0.30); }
.heatmap-l2 { background: rgba(var(--primary-rgb), 0.45); border-color: rgba(var(--primary-rgb), 0.55); }
.heatmap-l3 { background: rgba(var(--primary-rgb), 0.72); border-color: rgba(var(--primary-rgb), 0.80); }
.heatmap-l4 { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 6px rgba(var(--primary-rgb), 0.5); }
.heatmap-legend {
    display: flex; align-items: center; gap: 4px;
    margin-top: 10px;
    font-size: 0.66rem; color: var(--muted);
}
.heatmap-legend .heatmap-cell { width: 11px; height: 11px; border-radius: 2px; }

/* Per-exercise sparkline in library row */
.library-spark {
    width: 60px; height: 22px;
    flex-shrink: 0;
    color: var(--muted);
}
.library-spark-up { color: var(--primary); }
.library-spark-down { color: var(--muted); }
.library-spark-empty { display: inline-block; }

/* Full-screen PR celebration */
.pr-celebration {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at center, rgba(var(--primary-rgb), 0.25), rgba(0, 0, 0, 0.85));
    backdrop-filter: blur(8px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.pr-celebration.show { opacity: 1; pointer-events: auto; }
.pr-celeb-card {
    position: relative;
    max-width: 420px; width: 100%;
    padding: 32px 24px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    transform: scale(0.92) translateY(12px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 16px 64px rgba(var(--primary-rgb), 0.4), 0 0 0 1px rgba(var(--primary-rgb), 0.3);
}
.pr-celebration.show .pr-celeb-card { transform: scale(1) translateY(0); }
.pr-celeb-trophy {
    font-size: 4rem; line-height: 1;
    margin-bottom: 8px;
    animation: pr-bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
@keyframes pr-bounce {
    0% { transform: scale(0) rotate(-15deg); }
    100% { transform: scale(1) rotate(0deg); }
}
.pr-celeb-card h2 {
    font-family: var(--font-display, inherit);
    font-size: 1.6rem; margin: 4px 0 6px;
    color: var(--primary);
    letter-spacing: 0.02em;
}
.pr-celeb-sub { color: var(--muted); font-weight: 600; margin: 0 0 18px; }
.pr-celeb-list {
    list-style: none; padding: 0; margin: 0 0 18px;
    text-align: left;
}
.pr-celeb-list li {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    border: 1px solid var(--border);
}
.pr-celeb-type {
    font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--primary);
    padding: 3px 8px; border-radius: 999px;
    background: var(--primary-soft);
}
.pr-celeb-list li strong { font-size: 0.92rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-celeb-detail { font-weight: 700; color: var(--text); white-space: nowrap; font-size: 0.85rem; }
.pr-celeb-card .button { width: 100%; }

.pr-celeb-confetti {
    position: absolute; inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.pr-celeb-confetti span {
    position: absolute;
    top: 50%; left: 50%;
    width: 8px; height: 12px;
    background: var(--primary);
    opacity: 0;
    border-radius: 1px;
    animation: pr-confetti 1.4s ease-out forwards;
    animation-delay: calc(var(--i) * 22ms);
    transform-origin: center;
}
.pr-celeb-confetti span:nth-child(3n) { background: #f1c40f; }
.pr-celeb-confetti span:nth-child(3n+1) { background: #2ecc71; }
.pr-celeb-confetti span:nth-child(3n+2) { background: #3498db; }
@keyframes pr-confetti {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(0); }
    20% { opacity: 1; }
    100% {
        opacity: 0;
        transform:
            translate(calc(-50% + (var(--i) - 14) * 18px), calc(-50% + (var(--i) % 7) * -40px - 80px))
            rotate(calc(var(--i) * 47deg));
    }
}

/* Stepper input */
.stepper {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
    height: 48px;
}
.stepper button {
    color: var(--muted-strong);
    font-size: 1.3rem; font-weight: 700;
    transition: background 0.12s ease, color 0.12s ease;
}
.stepper button:hover, .stepper button:active { background: var(--surface-soft); color: var(--text); }
.stepper input {
    border: 0; background: transparent;
    text-align: center; font-weight: 800; font-size: 1rem;
    width: 100%; padding: 0 2px; color: var(--text-strong);
    -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--primary-soft); }
.stepper-label { font-size: 0.62rem; color: var(--muted); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 2px; padding-left: 2px; }
.stepper-cell { min-width: 0; }

.set-done {
    width: 44px; height: 48px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted-strong);
    font-size: 1.3rem; font-weight: 800;
    transition: all 0.15s ease;
}
.set-done:active { transform: scale(0.92); }
.set-row.complete .set-done {
    background: var(--success); border-color: var(--success); color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* Add set button */
.add-set-btn {
    width: 100%; min-height: 44px; margin-top: 8px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted-strong); font-weight: 700; font-size: 0.88rem;
    background: transparent;
    transition: all 0.15s ease;
}
.add-set-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

/* Add exercise CTA */
.add-exercise-cta {
    width: 100%; min-height: 56px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius);
    color: var(--primary); font-weight: 800; font-size: 0.95rem;
    background: var(--primary-soft);
    transition: all 0.15s ease;
}
.add-exercise-cta:hover { background: var(--primary); color: #fff; }
.add-exercise-cta svg { width: 20px; height: 20px; }

/* Inputs (general) */
.input, .select, .textarea {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft); color: var(--text);
    transition: border-color 0.15s ease, background-color 0.15s ease;
    font-size: 16px;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { min-height: 80px; padding: 12px; resize: vertical; font-family: inherit; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Session list / cards */
.session-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px;
    margin-bottom: 10px;
    transition: border-color 0.15s ease;
}
.session-card:hover { border-color: var(--border-strong); }
.session-row {
    display: flex; align-items: center; gap: 12px;
    cursor: pointer;
}
.session-thumb {
    width: 64px; height: 64px; flex: 0 0 auto;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.18), transparent 65%),
        linear-gradient(160deg, #1f1f24 0%, #131316 100%);
    display: inline-flex; align-items: center; justify-content: center;
    overflow: hidden;
}
:root.light .session-thumb {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.10), transparent 65%),
        linear-gradient(160deg, #ffffff 0%, #eeeef1 100%);
}
.session-thumb svg { width: 100%; height: 100%; }
.session-meta { flex: 1; min-width: 0; }
.session-meta h3 { margin-bottom: 2px; }
.session-meta p { margin: 0; font-size: 0.78rem; color: var(--muted); }
.session-volume { text-align: right; }
.session-volume strong {
    font-family: var(--font-display); font-size: 1.3rem; color: var(--text-strong);
    line-height: 1;
}
.session-volume small { display: block; color: var(--muted); font-size: 0.7rem; margin-top: 2px; }

.session-detail { display: none; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border); }
.session-card.expanded .session-detail { display: block; }
.session-detail .ex-line {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 6px 0; font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.session-detail .ex-line:last-of-type { border-bottom: 0; }
.session-detail .ex-line .ex-name { font-weight: 600; }
.session-detail .ex-line .ex-best { color: var(--muted); font-variant-numeric: tabular-nums; }

.pr-row {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 8px;
}
.pr-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #0a0a0b; font-weight: 800; font-size: 0.72rem;
    letter-spacing: 0.04em; text-transform: uppercase;
}

/* Library */
.library-group { margin-bottom: 14px; }
.library-group h3 {
    color: var(--muted); font-size: 0.7rem;
    letter-spacing: 0.1em; text-transform: uppercase;
    padding: 0 4px 8px;
    border-bottom: 1px solid var(--border);
}
.library-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 4px; min-height: 52px;
    border-bottom: 1px solid var(--border);
}
.library-row:last-child { border-bottom: 0; }
.library-row .name { flex: 1; min-width: 0; }
.library-row .name strong { display: block; font-weight: 600; }
.library-row .name small { color: var(--muted); font-size: 0.74rem; }
.library-thumb {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.18), transparent 65%),
        linear-gradient(160deg, #1f1f24 0%, #131316 100%);
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; overflow: hidden;
}
:root.light .library-thumb {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.10), transparent 65%),
        linear-gradient(160deg, #ffffff 0%, #eeeef1 100%);
}
.library-thumb svg { width: 100%; height: 100%; }

/* Empty state */
.empty-state {
    padding: 36px 20px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
}
.empty-state h2 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 8px; }

/* Pill */
.pill {
    display: inline-flex; align-items: center; min-height: 22px;
    padding: 2px 10px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
    font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}

/* Toast */
.toast {
    position: fixed; left: 50%; transform: translateX(-50%) translateY(8px);
    bottom: calc(20px + env(safe-area-inset-bottom));
    max-width: min(420px, calc(100vw - 40px));
    padding: 12px 18px;
    border-radius: var(--radius);
    background: var(--surface-elev); color: var(--text-strong);
    border: 1px solid var(--primary);
    box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none;
    transition: opacity 200ms, transform 200ms;
    font-weight: 600; font-size: 0.9rem;
    z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* FAB */
.fab {
    position: fixed; right: 16px;
    bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--primary); color: #fff;
    box-shadow: 0 8px 24px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.25);
    z-index: 80;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease;
}
.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fab:active { transform: scale(0.92); }
body.rest-active .fab { bottom: calc(var(--tab-h) + var(--rest-h) + 16px + env(safe-area-inset-bottom)); }

/* Mobile tab bar */
.mobile-tabbar {
    position: fixed; left: 0; right: 0;
    bottom: 0;
    z-index: 70;
    display: none;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(18px) saturate(1.5);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
}
.mobile-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 52px;
    color: var(--muted); font-size: 0.68rem; font-weight: 700;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease;
}
.mobile-tab svg {
    width: 22px; height: 22px;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}
.mobile-tab.active { color: var(--primary); }

/* Rest bar */
.rest-bar {
    position: fixed; left: 0; right: 0;
    bottom: var(--tab-h);
    height: var(--rest-h);
    background: var(--surface-elev);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.3);
    z-index: 65;
    overflow: hidden;
}
@media (min-width: 901px) {
    .rest-bar { bottom: 0; }
}
.rest-bar-fill {
    position: absolute; inset: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0.18;
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.5s linear;
}
.rest-bar-content {
    position: relative;
    height: 100%;
    display: flex; align-items: center; gap: 12px;
    padding: 0 14px;
}
.rest-bar-label {
    font-size: 0.65rem; font-weight: 800; letter-spacing: 0.12em;
    color: var(--primary);
}
.rest-bar-content strong {
    flex: 1;
    font-family: var(--font-display); font-size: 1.5rem;
    color: var(--text-strong); letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}
.rest-bar-btn {
    min-height: 36px; padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border);
    font-weight: 700; font-size: 0.82rem;
}
.rest-bar.done strong { color: var(--success); }
.rest-bar.done .rest-bar-fill { opacity: 0.35; }

/* Bottom Sheet */
.sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.sheet-backdrop.show { opacity: 1; }

.sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 100;
    max-height: 88vh;
    background: var(--surface);
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    border: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex; flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
}
.sheet.show { transform: translateY(0); }
@media (min-width: 901px) {
    .sheet {
        left: 50%; right: auto; bottom: 50%;
        transform: translate(-50%, calc(50% + 30px));
        opacity: 0; pointer-events: none;
        max-width: 540px; width: calc(100vw - 40px);
        max-height: 80vh;
        border-radius: var(--radius-lg);
        border-bottom: 1px solid var(--border);
    }
    .sheet.show { transform: translate(-50%, 50%); opacity: 1; pointer-events: auto; }
}
.sheet-handle {
    width: 40px; height: 4px;
    border-radius: 999px; background: var(--border-strong);
    margin: 8px auto 4px;
}
@media (min-width: 901px) { .sheet-handle { display: none; } }
.sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.sheet-header h2 { margin: 0; font-family: var(--font-display); font-size: 1.4rem; letter-spacing: 0.04em; text-transform: uppercase; }
.sheet-body { padding: 12px 16px 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

/* Picker (in sheet) */
.picker-search { position: sticky; top: 0; padding: 4px 0 10px; background: var(--surface); z-index: 2; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; padding: 7px 12px;
    border-radius: 999px;
    background: var(--surface-soft); color: var(--muted-strong);
    border: 1px solid var(--border);
    font-size: 0.78rem; font-weight: 700;
    white-space: nowrap;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.picker-list { display: flex; flex-direction: column; }
.picker-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 4px; min-height: 56px;
    border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
}
.picker-item:last-child { border-bottom: 0; }
.picker-item:active { background: var(--surface-soft); }
.picker-check {
    width: 22px; height: 22px; flex: 0 0 auto;
    border-radius: 50%; border: 2px solid var(--border-strong);
    display: inline-flex; align-items: center; justify-content: center;
    color: transparent; font-weight: 800;
}
.picker-item.selected .picker-check {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.picker-name { flex: 1; min-width: 0; }
.picker-name strong { display: block; }
.picker-name small { color: var(--muted); font-size: 0.74rem; }

.sheet-footer {
    position: sticky; bottom: 0;
    padding: 10px 0 4px;
    background: linear-gradient(to top, var(--surface) 80%, transparent);
}

/* Routine editor */
.routine-ex-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.routine-ex-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-soft);
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.routine-ex-row.dragging { opacity: 0.4; transform: scale(0.97); }
.routine-ex-row.drop-target { border-color: var(--primary); background: var(--primary-soft); }
.routine-ex-row .grip { color: var(--muted); cursor: grab; font-size: 1.1rem; user-select: none; touch-action: none; }
.routine-ex-row .grip:active { cursor: grabbing; }
.routine-ex-row .name { flex: 1; min-width: 0; font-weight: 600; }
.routine-ex-actions { display: flex; align-items: center; gap: 4px; }
.routine-ex-actions button {
    width: 28px; height: 28px;
    background: transparent; border: 1px solid transparent; border-radius: 6px;
    color: var(--muted-strong); cursor: pointer;
    font-size: 0.78rem; line-height: 1;
}
.routine-ex-actions button:hover:not(:disabled) { background: var(--surface); color: var(--text); border-color: var(--border); }
.routine-ex-actions button:disabled { opacity: 0.25; cursor: not-allowed; }
.routine-ex-row .remove { width: 30px; height: 30px; color: var(--muted-strong); border-radius: 6px; background: transparent; border: 1px solid transparent; }
.routine-ex-row .remove:hover { color: var(--danger); background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); }

.template-card-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    margin-bottom: 4px;
}
.template-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--muted-strong);
    font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
    flex-shrink: 0;
    align-self: center;
}
.template-card.is-template .template-badge {
    background: var(--primary-soft); color: var(--primary); border-color: rgba(var(--primary-rgb), 0.3);
}

.routine-template-hint {
    display: flex; flex-direction: column; gap: 4px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px dashed rgba(var(--primary-rgb), 0.4);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--text);
    font-size: 0.78rem; line-height: 1.4;
}
.routine-template-hint strong {
    font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary);
}
.routine-template-hint em { font-style: normal; font-weight: 700; color: var(--primary); }

/* Footer */
.app-footer {
    margin-top: 30px; text-align: center;
    color: var(--muted); font-size: 0.74rem; font-weight: 500;
    letter-spacing: 0.04em;
}

/* Drag state */
.exercise-card.dragging { opacity: 0.5; }
.exercise-card.drag-over { box-shadow: 0 0 0 2px var(--primary) inset; }

/* Responsive */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .desktop-only { display: none !important; }
    .app-shell {
        width: calc(100vw - 20px);
        padding-top: calc(8px + env(safe-area-inset-top));
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
    body.rest-active .app-shell {
        padding-bottom: calc(140px + env(safe-area-inset-bottom));
    }
    /* Sticky glass topbar — full-bleed across the 10px shell gutters, with
       the shell's top padding folded into its own so nothing jumps. */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 60;
        margin: calc(-8px - env(safe-area-inset-top)) -10px 14px;
        padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
        background: color-mix(in srgb, var(--bg) 80%, transparent);
        backdrop-filter: blur(18px) saturate(1.5);
        -webkit-backdrop-filter: blur(18px) saturate(1.5);
        border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    }
    .brand-text small { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
    .stat { padding: 12px; }
    .stat-value { font-size: 1.4rem; }
    .grid-3 { grid-template-columns: 1fr; }
    .panel { padding: 14px; }
    .hero { padding: 18px; }
    .hero h1 { font-size: clamp(1.8rem, 9vw, 2.4rem); }
    .hero-actions .button { flex: 1; }

    .session-hero { flex-wrap: wrap; padding: 12px; }
    .session-hero-actions { width: 100%; }
    .session-hero-actions .button { flex: 1; }

    .mobile-tabbar { display: grid; }
    :root { --tab-h: calc(58px + env(safe-area-inset-bottom)); }

    .stepper { height: 52px; }
    .set-done { height: 52px; }

    .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
    body.rest-active .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
}

/* Hide elements when desktop and mobile tab-bar is hidden — show full topbar */
@media (min-width: 641px) {
    .mobile-tabbar { display: none !important; }
    .fab { display: none !important; }
}

/* 2-frame exercise photo (start/end of a rep). Frame 1 fades in/out on top of frame 0. */
.ex-photo {
    position: relative;
    display: inline-block;
    overflow: hidden;
    line-height: 0;
    pointer-events: none;
    background: #ffffff;
}
.ex-photo-frame {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.ex-photo-frame-0 { z-index: 1; }
.ex-photo-frame-1 {
    z-index: 2;
    animation: ex-flip 1.4s steps(2, end) infinite;
}
@keyframes ex-flip {
    0%, 49.99% { opacity: 0; }
    50%, 100% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .ex-photo-frame-1 { animation: none; opacity: 0.5; }
}

/* Inline-SVG icon container — color via currentColor */
.svg-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    color: var(--primary);
    pointer-events: none;
}
.svg-icon svg { width: 100%; height: 100%; display: block; pointer-events: none; }

/* Subtle Hevy-style rep animations on category icons */
/* Obsolete rep-* keyframe animations (anim-press / anim-pull / anim-squat /
   anim-lateral-* / anim-curl-* / anim-crunch / anim-deadlift / anim-bell) were
   removed when the muscle-group SVGs were replaced with photo flipbooks
   sourced from yuhonas/free-exercise-db. Card flip is now driven by .ex-photo
   keyframe ex-flip earlier in this file. */
