/* ---- CSS Variables ---- */
:root {
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.12);
    --surface: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --bottom-nav-height: 64px;

    --muscle-chest:     #ef4444;
    --muscle-back:      #3b82f6;
    --muscle-shoulders: #f59e0b;
    --muscle-biceps:    #8b5cf6;
    --muscle-triceps:   #a78bfa;
    --muscle-legs:      #10b981;
    --muscle-core:      #f97316;
    --muscle-cardio:    #ec4899;
}

[data-theme="dark"] {
    --surface: #0f172a;
    --card-bg: #1e293b;
    --border: #334155;
    --muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
.container { max-width: 1100px; }
body { background: var(--surface); }

/* ---- Desktop Navigation ---- */
.desktop-header { display: block; }
.mobile-header  { display: none; }
.mobile-bottom-nav { display: none; }
.main-content { padding-bottom: 1rem; }

.logo-link { text-decoration: none; }
.logo-text  { font-size: 1.15rem; letter-spacing: -0.02em; }

nav [aria-current="page"] {
    color: var(--accent) !important;
    font-weight: 600;
}

.theme-btn, .logout-btn {
    padding: 0.35rem 0.6rem;
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
}

/* ---- Mobile Header ---- */
.mobile-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
}

.mobile-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ---- Mobile Bottom Nav ---- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.6rem 0.25rem;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.15s;
}

.bottom-nav-item svg { stroke: currentColor; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item:hover  { color: var(--accent); }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h2 {
    margin: 0;
    font-size: 1.75rem;
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--muted);
    margin: 0.2rem 0 0;
    font-size: 0.875rem;
}

.back-link {
    font-size: 0.8rem;
    color: var(--muted);
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
}
.back-link:hover { color: var(--accent); }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    letter-spacing: -0.03em;
}
.stat-value small { font-size: 1rem; font-weight: 600; }

.stat-label {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* ---- Welcome Card ---- */
.welcome-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    max-width: 620px;
    margin: 1.5rem auto;
}

.welcome-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.welcome-card h3 { margin-bottom: 0.5rem; font-size: 1.4rem; }
.welcome-card > p { color: var(--muted); margin-bottom: 1.25rem; }

.how-it-works {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
}

.how-step { display: flex; gap: 0.875rem; align-items: flex-start; }

.how-num {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    flex-shrink: 0; margin-top: 0.1rem;
}

/* ---- Dashboard Grid ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.section-header h3 { margin: 0; font-size: 1.05rem; }

.view-all-link { font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.view-all-link:hover { color: var(--accent); }

/* ---- Workout Cards ---- */
.workout-list { display: flex; flex-direction: column; gap: 0.5rem; }
.workout-card-link { text-decoration: none; color: inherit; }

.workout-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
}
.workout-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.workout-card-left { display: flex; align-items: center; gap: 0.75rem; }
.workout-icon { font-size: 1.2rem; }
.workout-name { font-weight: 600; font-size: 0.9rem; }
.workout-date { font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }
.workout-arrow { color: var(--muted); }

/* ---- PR Cards ---- */
.pr-list { display: flex; flex-direction: column; gap: 0.5rem; }

.pr-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
}

.pr-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.pr-exercise { font-weight: 600; font-size: 0.875rem; }
.pr-details { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.pr-weight { font-size: 0.85rem; }

.pr-1rm {
    font-size: 0.72rem; font-weight: 700;
    color: #16a34a;
    background: rgba(34,197,94,0.12);
    padding: 0.15rem 0.45rem;
    border-radius: 0.25rem;
}

.pr-date { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }

/* ---- Charts ---- */
.chart-section { margin-top: 0.5rem; }

.chart-container {
    position: relative;
    height: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: var(--shadow);
}

.chart-container-large {
    position: relative;
    height: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
}

/* ---- Progress Page ---- */
.progress-controls {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.control-group { display: flex; flex-direction: column; gap: 0.3rem; }

.control-group label {
    font-size: 0.7rem; font-weight: 700;
    color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.07em;
}

.control-group select { min-width: 240px; }

.pill-toggle {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 0.2rem;
    gap: 0.2rem;
}

.pill-toggle button {
    border: none; background: transparent;
    border-radius: 0.4rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem; font-weight: 500;
    color: var(--muted);
    cursor: pointer; transition: all 0.15s; margin: 0;
}

.pill-toggle button.pill-active {
    background: var(--accent); color: #fff;
    box-shadow: 0 1px 4px rgba(99,102,241,0.35);
}

/* ---- Log Workout Page ---- */
.steps-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
}

.step { display: flex; align-items: center; gap: 0.5rem; opacity: 0.35; transition: opacity 0.2s; }
.step.active { opacity: 1; }

.step-num {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    background: var(--card-bg); color: var(--muted);
    transition: all 0.2s;
}

.step.active .step-num { background: var(--accent); border-color: var(--accent); color: white; }
.step-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.step.active .step-label { color: var(--accent); }

.step-divider {
    flex: 1; height: 2px;
    background: var(--border);
    margin: 0 0.6rem; max-width: 50px;
}

.log-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.log-section h3 { margin-top: 0; margin-bottom: 1rem; }

.setup-form-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.active-workout-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.active-badge {
    font-size: 0.68rem; font-weight: 700;
    color: var(--success);
    text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 0.2rem;
}

.finish-btn { white-space: nowrap; flex-shrink: 0; }

/* Add set form */
.add-set-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.set-form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 2fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.set-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.set-meta { display: flex; flex-direction: column; gap: 0.15rem; }
.live-orm { font-weight: 700; color: var(--accent); font-size: 0.95rem; min-height: 1.2em; }
.prev-best { font-size: 0.78rem; color: var(--muted); }
.prev-label { font-weight: 700; color: var(--accent); }
.add-set-btn { white-space: nowrap; margin-bottom: 0; }

.empty-sets {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1.25rem 1rem;
    color: var(--muted); font-size: 0.875rem;
    background: var(--surface);
    border-radius: 0.75rem;
    border: 1px dashed var(--border);
}
.empty-sets-icon { font-size: 1.4rem; }

.set-row-new { animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Exercise Groups ---- */
.exercise-group {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.875rem;
    box-shadow: var(--shadow);
    overflow-x: auto;   /* scroll on mobile */
}

.exercise-group-title {
    display: flex; align-items: center; gap: 0.5rem;
    margin-top: 0; margin-bottom: 0.625rem;
    font-size: 0.95rem;
}

.orm-cell { color: var(--accent); font-weight: 600; }

.small-btn {
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem; line-height: 1.5; margin-bottom: 0;
}

/* ---- Exercises Page ---- */
.muscle-filters {
    display: flex; flex-wrap: wrap;
    gap: 0.4rem; margin-bottom: 1.25rem;
}

.muscle-filters button {
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem; border-radius: 2rem; margin-bottom: 0;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex; gap: 0.4rem;
    margin-bottom: 1.25rem; flex-wrap: wrap;
}

.filter-bar a {
    padding: 0.25rem 0.7rem;
    font-size: 0.82rem; border-radius: 2rem;
}

/* ---- Muscle Badges ---- */
.muscle-badge {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 0.3rem;
    font-size: 0.67rem; font-weight: 700;
    color: white; letter-spacing: 0.02em; text-transform: uppercase;
}

.muscle-chest     { background: var(--muscle-chest); }
.muscle-back      { background: var(--muscle-back); }
.muscle-shoulders { background: var(--muscle-shoulders); }
.muscle-biceps    { background: var(--muscle-biceps); }
.muscle-triceps   { background: var(--muscle-triceps); }
.muscle-legs      { background: var(--muscle-legs); }
.muscle-core      { background: var(--muscle-core); }
.muscle-cardio    { background: var(--muscle-cardio); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.12rem 0.45rem; border-radius: 0.3rem;
    font-size: 0.7rem; font-weight: 700;
    background: var(--accent-light); color: var(--accent);
}

.custom-badge { background: rgba(245,158,11,0.15); color: #d97706; }

/* ---- Misc ---- */
.muted { color: var(--muted); }

.empty-state {
    color: var(--muted); text-align: center;
    padding: 1rem 0; font-size: 0.875rem;
}

.empty-state-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 1rem; padding: 2.5rem 1.5rem;
    text-align: center; color: var(--muted); box-shadow: var(--shadow);
}

.empty-state-card .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state-card h3 { color: inherit; margin-bottom: 0.5rem; }
.empty-state-card p { max-width: 360px; margin: 0 auto 1.25rem; font-size: 0.875rem; }

.error-msg {
    background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
    border-radius: 0.5rem; color: var(--danger);
    padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.875rem;
}

/* ---- Login Page ---- */
.login-container {
    display: flex; justify-content: center; align-items: center;
    min-height: 80vh;
}

.login-card {
    width: 100%; max-width: 400px;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 1rem; padding: 2rem;
    box-shadow: var(--shadow-md);
}

.login-card hgroup { text-align: center; margin-bottom: 1.5rem; }
.login-card h1 { margin-bottom: 0.25rem; font-size: 1.75rem; }

/* ---- Tables ---- */
.workout-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Scroll tables inside exercise groups ---- */
.exercise-group table { min-width: 360px; }

/* ================================================================
   MOBILE BREAKPOINT  ≤ 768px
   ================================================================ */
@media (max-width: 768px) {
    /* Nav swap */
    .desktop-header    { display: none; }
    .mobile-header     { display: flex; }
    .mobile-bottom-nav { display: flex; }

    /* Main content clears bottom nav */
    .main-content {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 1rem);
    }

    /* Container padding */
    .container { padding-left: 1rem; padding-right: 1rem; }

    /* Page header */
    .page-header { margin-bottom: 1.25rem; }
    .page-header h2 { font-size: 1.4rem; }

    /* Stats: 3 equal columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .stat-card { padding: 0.75rem 0.5rem; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.62rem; }

    /* Dashboard: stack columns */
    .dashboard-grid { grid-template-columns: 1fr; gap: 1rem; }

    /* Charts shorter on mobile */
    .chart-container { height: 180px; }
    .chart-container-large { height: 240px; }

    /* Progress controls: stack */
    .progress-controls { flex-direction: column; align-items: stretch; }
    .control-group select { min-width: 0; width: 100%; }
    .pill-toggle { justify-content: center; }

    /* Log: setup form stacks */
    .setup-form-grid { grid-template-columns: 1fr; gap: 0.75rem; }

    /* Log: set form becomes 2-col grid */
    .set-form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
    .exercise-select-wrap { grid-column: 1 / -1; }
    .notes-wrap { grid-column: 1 / -1; }

    /* Larger touch targets for inputs */
    input[type="number"],
    input[type="text"],
    input[type="date"],
    select {
        font-size: 16px !important; /* prevents iOS zoom */
        min-height: 44px;
    }

    /* Set footer: stack vertically */
    .set-form-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .add-set-btn { width: 100%; text-align: center; }

    /* Active workout header: keep on one row, compact finish btn */
    .active-workout-header { align-items: center; flex-wrap: nowrap; }
    .finish-btn {
        font-size: 0.82rem;
        padding: 0.4rem 0.75rem;
        width: auto;
    }

    /* Tables: horizontal scroll */
    .workout-table-wrap { margin: 0 -1rem; padding: 0 1rem; }

    /* Exercise group table scroll */
    .exercise-group { padding: 0.75rem; }

    /* Exercises filter pills: smaller */
    .muscle-filters button { font-size: 0.75rem; padding: 0.2rem 0.6rem; }

    /* Steps indicator: smaller */
    .step-label { display: none; } /* save space on mobile */

    /* Welcome card */
    .welcome-card { padding: 1.5rem 1rem; margin: 0.75rem 0; }
    .welcome-card h3 { font-size: 1.2rem; }

    /* Login */
    .login-container { align-items: flex-start; padding-top: 2rem; min-height: 0; }
    .login-card { padding: 1.5rem; }

    /* PRs: tighter */
    .pr-card { padding: 0.625rem 0.875rem; }

    /* Toast: slide in from top on mobile */
    .toast-container {
        bottom: auto;
        top: 1rem;
        left: 1rem;
        right: 1rem;
        align-items: stretch;
    }
    .toast {
        max-width: 100%;
        transform: translateY(-150%);
    }
    .toast.toast-show { transform: translateY(0); }

    /* Rest timer: centered above bottom nav */
    .rest-timer-pill {
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 0.75rem);
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
    }

    /* Picker sheet: taller on mobile */
    .picker-sheet { max-height: 85vh; }

    /* Num buttons: slightly narrower on mobile */
    .num-btn { width: 34px; }
}

/* ── Toast Notifications ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    border-radius: 0.75rem;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    transform: translateX(-110%);
    transition: transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
    max-width: 280px;
    pointer-events: auto;
}

.toast.toast-show { transform: translateX(0); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-pr {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, var(--card-bg), rgba(245,158,11,0.06));
}

/* ── Quick start date ────────────────────────────────────────────────── */
.quick-start-date {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.quick-start-date strong { color: inherit; }

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.82rem;
    text-decoration: underline;
    margin: 0;
    line-height: 1;
}

/* ── Exercise Picker Button ──────────────────────────────────────────── */
.exercise-picker-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    color: var(--muted);
    margin: 0;
    font-size: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 44px;
}

.exercise-picker-btn:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-light);
}

.exercise-picker-btn:hover { border-color: var(--accent); }

.exercise-picker-btn span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
}

/* When an exercise is selected, text goes back to normal color */
.exercise-picker-btn span[style] { color: inherit; }

/* ── Number Input Group (+/-) ────────────────────────────────────────── */
.num-input-group {
    display: flex;
    align-items: stretch;
}

.num-input-group input[type="number"] {
    flex: 1;
    min-width: 0;
    text-align: center;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    margin: 0;
}

.num-btn {
    flex-shrink: 0;
    width: 38px;
    padding: 0;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-btn:first-child { border-radius: 0.5rem 0 0 0.5rem; }
.num-btn:last-child  { border-radius: 0 0.5rem 0.5rem 0; }
.num-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.num-btn:active { background: var(--accent); color: white; }

/* ── PR Badge ────────────────────────────────────────────────────────── */
.pr-badge {
    display: inline-block;
    font-size: 0.58rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    animation: prPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-left: 0.2rem;
}

@keyframes prPop {
    from { transform: scale(0) rotate(-10deg); opacity: 0; }
    to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

/* ── Rest Timer Pill ─────────────────────────────────────────────────── */
.rest-timer-pill {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    background: var(--accent);
    color: white;
    border-radius: 2rem;
    padding: 0.6rem 1rem 0.6rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    font-weight: 700;
    font-size: 1.05rem;
    animation: pillSlideIn 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes pillSlideIn {
    from { transform: translateY(2rem); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.rest-timer-icon { font-size: 1rem; }

.rest-skip-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 1rem;
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    margin: 0;
    transition: background 0.15s;
    white-space: nowrap;
    min-height: 0;
}

.rest-skip-btn:hover { background: rgba(255,255,255,0.35); }

/* ── Exercise Picker Overlay ─────────────────────────────────────────── */
.picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.picker-sheet {
    background: var(--card-bg);
    border-radius: 1rem 1rem 0 0;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sheetSlideUp 0.28s cubic-bezier(0.34, 1.1, 0.64, 1);
}

@keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.picker-close-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin: 0;
    border-radius: 0.5rem;
    line-height: 1;
    min-height: 0;
}

.picker-close-btn:hover { color: var(--danger); background: rgba(239,68,68,0.08); }

.picker-search-wrap {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.picker-search-wrap input {
    margin: 0;
    font-size: 16px !important; /* prevent iOS zoom */
}

.picker-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.picker-group { padding: 0.5rem 0; }

.picker-group-label {
    padding: 0.35rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 1;
}

.picker-item {
    padding: 0.7rem 1.25rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 0.5rem;
    margin: 0 0.25rem;
}

.picker-item:hover { background: var(--accent-light); color: var(--accent); }
.picker-item-selected { color: var(--accent); font-weight: 600; }
.picker-item-selected::after { content: ' ✓'; font-size: 0.8rem; }

.picker-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.875rem;
}

/* Prevent body scroll when picker is open */
body.picker-open { overflow: hidden; }

/* ── Delete set button (larger touch target) ─────────────────────────── */
.delete-set-btn {
    min-width: 44px !important;
    min-height: 36px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Inline workout name editing ────────────────────────────────────── */
.workout-name-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.icon-edit-btn {
    background: none;
    border: none;
    padding: 0.2rem 0.35rem;
    margin: 0;
    color: var(--muted);
    cursor: pointer;
    border-radius: 0.4rem;
    display: flex;
    align-items: center;
    min-height: 0;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.icon-edit-btn:hover { opacity: 1; color: var(--accent); }

/* ── Repeat Last Workout Card ────────────────────────────────────────── */
.repeat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.repeat-card-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.repeat-card-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.repeat-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repeat-card-date {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.repeat-card-btn {
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0;
    padding: 0.4rem 0.875rem;
    font-size: 0.875rem;
}

/* ── Session Summary Overlay ─────────────────────────────────────────── */
.summary-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: overlayFadeIn 0.3s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.summary-overlay.summary-fade-out {
    animation: overlayFadeIn 0.35s ease reverse forwards;
}

.summary-card {
    background: var(--card-bg);
    border-radius: 1.25rem;
    padding: 2rem 1.75rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: summarySlideUp 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes summarySlideUp {
    from { transform: translateY(1.5rem) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1);         opacity: 1; }
}

.summary-icon { font-size: 2.75rem; margin-bottom: 0.75rem; }
.summary-title { margin: 0 0 0.2rem; font-size: 1.6rem; letter-spacing: -0.03em; }
.summary-subtitle { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.9rem; }

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.summary-stat {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 0.75rem 0.5rem;
}

.summary-stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.03em;
    line-height: 1;
}

.summary-stat-value small { font-size: 0.85rem; font-weight: 600; }

.summary-stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Desktop: exercise picker as centered modal */
@media (min-width: 769px) {
    .picker-overlay { align-items: center; }
    .picker-sheet {
        border-radius: 1rem;
        max-height: 70vh;
        animation: none;
        box-shadow: var(--shadow-md);
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
    .stat-value { font-size: 1.3rem; }
    .bottom-nav-item span { display: none; }  /* icon only */
    .bottom-nav-item { padding: 0.75rem 0; }
}
